@bufbuild/protobuf 2.2.5 → 2.4.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/dist/cjs/clone.js +4 -6
- package/dist/cjs/codegenv1/boot.js +1 -1
- package/dist/cjs/codegenv1/embed.js +0 -1
- package/dist/cjs/codegenv1/file.js +1 -1
- package/dist/cjs/codegenv1/symbols.js +4 -1
- package/dist/cjs/create.js +0 -1
- package/dist/cjs/equals.js +2 -1
- package/dist/cjs/extensions.js +1 -1
- package/dist/cjs/from-binary.js +5 -3
- package/dist/cjs/from-json.js +8 -10
- package/dist/cjs/proto-int64.js +4 -1
- package/dist/cjs/reflect/guard.js +2 -1
- package/dist/cjs/reflect/index.d.ts +1 -0
- package/dist/cjs/reflect/index.js +1 -0
- package/dist/cjs/reflect/names.d.ts +8 -0
- package/dist/cjs/reflect/names.js +28 -0
- package/dist/cjs/reflect/nested-types.d.ts +23 -0
- package/dist/cjs/reflect/nested-types.js +40 -0
- package/dist/cjs/reflect/path.d.ts +107 -0
- package/dist/cjs/reflect/path.js +376 -0
- package/dist/cjs/reflect/reflect-check.js +3 -3
- package/dist/cjs/reflect/reflect-types.d.ts +1 -1
- package/dist/cjs/reflect/reflect.js +9 -7
- package/dist/cjs/reflect/scalar.js +4 -5
- package/dist/cjs/reflect/unsafe.d.ts +3 -6
- package/dist/cjs/reflect/unsafe.js +11 -10
- package/dist/cjs/registry.js +24 -30
- package/dist/cjs/to-binary.js +1 -1
- package/dist/cjs/to-json.d.ts +6 -0
- package/dist/cjs/to-json.js +16 -18
- package/dist/cjs/wire/base64-encoding.js +4 -3
- package/dist/cjs/wire/binary-encoding.js +7 -6
- package/dist/cjs/wire/text-encoding.js +1 -1
- package/dist/cjs/wire/text-format.js +3 -4
- package/dist/cjs/wire/varint.js +0 -1
- package/dist/cjs/wkt/gen/google/protobuf/cpp_features_pb.d.ts +89 -0
- package/dist/cjs/wkt/gen/google/protobuf/cpp_features_pb.js +60 -0
- package/dist/cjs/wkt/gen/google/protobuf/go_features_pb.d.ts +122 -0
- package/dist/cjs/wkt/gen/google/protobuf/go_features_pb.js +90 -0
- package/dist/cjs/wkt/gen/google/protobuf/java_features_pb.d.ts +113 -0
- package/dist/cjs/wkt/gen/google/protobuf/java_features_pb.js +67 -0
- package/dist/cjs/wkt/index.d.ts +4 -1
- package/dist/cjs/wkt/index.js +4 -1
- package/dist/esm/clone.js +4 -6
- package/dist/esm/codegenv1/boot.js +1 -1
- package/dist/esm/codegenv1/embed.js +0 -1
- package/dist/esm/codegenv1/file.js +1 -1
- package/dist/esm/codegenv1/symbols.js +4 -1
- package/dist/esm/create.js +0 -2
- package/dist/esm/equals.js +2 -1
- package/dist/esm/extensions.js +1 -1
- package/dist/esm/from-binary.js +5 -3
- package/dist/esm/from-json.js +8 -10
- package/dist/esm/proto-int64.js +4 -1
- package/dist/esm/reflect/guard.js +2 -1
- package/dist/esm/reflect/index.d.ts +1 -0
- package/dist/esm/reflect/index.js +1 -0
- package/dist/esm/reflect/names.d.ts +8 -0
- package/dist/esm/reflect/names.js +27 -0
- package/dist/esm/reflect/nested-types.d.ts +23 -0
- package/dist/esm/reflect/nested-types.js +39 -0
- package/dist/esm/reflect/path.d.ts +107 -0
- package/dist/esm/reflect/path.js +369 -0
- package/dist/esm/reflect/reflect-check.js +3 -3
- package/dist/esm/reflect/reflect-types.d.ts +1 -1
- package/dist/esm/reflect/reflect-types.js +0 -1
- package/dist/esm/reflect/reflect.js +9 -7
- package/dist/esm/reflect/scalar.js +4 -5
- package/dist/esm/reflect/unsafe.d.ts +3 -6
- package/dist/esm/reflect/unsafe.js +11 -10
- package/dist/esm/registry.js +24 -30
- package/dist/esm/to-binary.js +1 -1
- package/dist/esm/to-json.d.ts +6 -0
- package/dist/esm/to-json.js +16 -18
- package/dist/esm/wire/base64-encoding.js +4 -3
- package/dist/esm/wire/binary-encoding.js +7 -6
- package/dist/esm/wire/text-encoding.js +1 -1
- package/dist/esm/wire/text-format.js +3 -4
- package/dist/esm/wire/varint.js +0 -1
- package/dist/esm/wkt/gen/google/protobuf/cpp_features_pb.d.ts +89 -0
- package/dist/esm/wkt/gen/google/protobuf/cpp_features_pb.js +57 -0
- package/dist/esm/wkt/gen/google/protobuf/go_features_pb.d.ts +122 -0
- package/dist/esm/wkt/gen/google/protobuf/go_features_pb.js +87 -0
- package/dist/esm/wkt/gen/google/protobuf/java_features_pb.d.ts +113 -0
- package/dist/esm/wkt/gen/google/protobuf/java_features_pb.js +64 -0
- package/dist/esm/wkt/index.d.ts +4 -1
- package/dist/esm/wkt/index.js +4 -1
- package/package.json +9 -24
package/dist/esm/registry.js
CHANGED
|
@@ -59,7 +59,6 @@ export function createFileRegistry(...args) {
|
|
|
59
59
|
const input = args[0];
|
|
60
60
|
const resolve = args[1];
|
|
61
61
|
const seen = new Set();
|
|
62
|
-
// eslint-disable-next-line no-inner-declarations
|
|
63
62
|
function recurseDeps(file) {
|
|
64
63
|
const deps = [];
|
|
65
64
|
for (const protoFileName of file.dependency) {
|
|
@@ -115,13 +114,11 @@ function createBaseRegistry() {
|
|
|
115
114
|
},
|
|
116
115
|
addFile(file, skipTypes, withDeps) {
|
|
117
116
|
files.set(file.proto.name, file);
|
|
118
|
-
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
119
117
|
if (!skipTypes) {
|
|
120
118
|
for (const type of nestedTypes(file)) {
|
|
121
119
|
this.add(type);
|
|
122
120
|
}
|
|
123
121
|
}
|
|
124
|
-
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
125
122
|
if (withDeps) {
|
|
126
123
|
for (const f of file.dependencies) {
|
|
127
124
|
this.addFile(f, skipTypes, withDeps);
|
|
@@ -132,7 +129,9 @@ function createBaseRegistry() {
|
|
|
132
129
|
if (desc.kind == "extension") {
|
|
133
130
|
let numberToExt = extendees.get(desc.extendee.typeName);
|
|
134
131
|
if (!numberToExt) {
|
|
135
|
-
extendees.set(desc.extendee.typeName,
|
|
132
|
+
extendees.set(desc.extendee.typeName,
|
|
133
|
+
// biome-ignore lint/suspicious/noAssignInExpressions: no
|
|
134
|
+
(numberToExt = new Map()));
|
|
136
135
|
}
|
|
137
136
|
numberToExt.set(desc.number, desc);
|
|
138
137
|
}
|
|
@@ -222,7 +221,7 @@ const PACKED = 1;
|
|
|
222
221
|
const DELIMITED = 2;
|
|
223
222
|
// bootstrap-inject google.protobuf.FeatureSet.EnumType.OPEN: const $name: FeatureSet_EnumType.$localName = $number;
|
|
224
223
|
const OPEN = 1;
|
|
225
|
-
//
|
|
224
|
+
// biome-ignore format: want this to read well
|
|
226
225
|
// bootstrap-inject defaults: EDITION_PROTO2 to EDITION_2023: export const minimumEdition: SupportedEdition = $minimumEdition, maximumEdition: SupportedEdition = $maximumEdition;
|
|
227
226
|
// generated from protoc v30.0
|
|
228
227
|
export const minimumEdition = 998, maximumEdition = 1000;
|
|
@@ -371,7 +370,7 @@ function addFields(message, reg, mapEntries) {
|
|
|
371
370
|
* parent type, if any.
|
|
372
371
|
*/
|
|
373
372
|
function addEnum(proto, file, parent, reg) {
|
|
374
|
-
var _a, _b, _c;
|
|
373
|
+
var _a, _b, _c, _d, _e;
|
|
375
374
|
const sharedPrefix = findEnumSharedPrefix(proto.name, proto.value);
|
|
376
375
|
const desc = {
|
|
377
376
|
kind: "enum",
|
|
@@ -391,25 +390,26 @@ function addEnum(proto, file, parent, reg) {
|
|
|
391
390
|
};
|
|
392
391
|
desc.open = isEnumOpen(desc);
|
|
393
392
|
reg.add(desc);
|
|
394
|
-
proto.value
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
393
|
+
for (const p of proto.value) {
|
|
394
|
+
const name = p.name;
|
|
395
|
+
desc.values.push(
|
|
396
|
+
// biome-ignore lint/suspicious/noAssignInExpressions: no
|
|
397
|
+
(desc.value[p.number] = {
|
|
398
398
|
kind: "enum_value",
|
|
399
|
-
proto,
|
|
400
|
-
deprecated: (
|
|
399
|
+
proto: p,
|
|
400
|
+
deprecated: (_d = (_c = p.options) === null || _c === void 0 ? void 0 : _c.deprecated) !== null && _d !== void 0 ? _d : false,
|
|
401
401
|
parent: desc,
|
|
402
402
|
name,
|
|
403
403
|
localName: safeObjectProperty(sharedPrefix == undefined
|
|
404
404
|
? name
|
|
405
405
|
: name.substring(sharedPrefix.length)),
|
|
406
|
-
number:
|
|
406
|
+
number: p.number,
|
|
407
407
|
toString() {
|
|
408
408
|
return `enum value ${desc.typeName}.${name}`;
|
|
409
409
|
},
|
|
410
410
|
}));
|
|
411
|
-
}
|
|
412
|
-
((
|
|
411
|
+
}
|
|
412
|
+
((_e = parent === null || parent === void 0 ? void 0 : parent.nestedEnums) !== null && _e !== void 0 ? _e : file.enums).push(desc);
|
|
413
413
|
}
|
|
414
414
|
/**
|
|
415
415
|
* Create a descriptor for a message, including nested types, and add it to our
|
|
@@ -611,14 +611,12 @@ function newField(proto, parentOrFile, reg, oneof, mapEntries) {
|
|
|
611
611
|
case TYPE_GROUP:
|
|
612
612
|
field.listKind = "message";
|
|
613
613
|
field.message = reg.getMessage(trimLeadingDot(proto.typeName));
|
|
614
|
-
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
615
614
|
assert(field.message);
|
|
616
615
|
field.delimitedEncoding = isDelimitedEncoding(proto, parentOrFile);
|
|
617
616
|
break;
|
|
618
617
|
case TYPE_ENUM:
|
|
619
618
|
field.listKind = "enum";
|
|
620
619
|
field.enum = reg.getEnum(trimLeadingDot(proto.typeName));
|
|
621
|
-
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
622
620
|
assert(field.enum);
|
|
623
621
|
break;
|
|
624
622
|
default:
|
|
@@ -636,9 +634,7 @@ function newField(proto, parentOrFile, reg, oneof, mapEntries) {
|
|
|
636
634
|
case TYPE_GROUP:
|
|
637
635
|
field.fieldKind = "message";
|
|
638
636
|
field.message = reg.getMessage(trimLeadingDot(proto.typeName));
|
|
639
|
-
assert(
|
|
640
|
-
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
641
|
-
field.message, `invalid FieldDescriptorProto: type_name ${proto.typeName} not found`);
|
|
637
|
+
assert(field.message, `invalid FieldDescriptorProto: type_name ${proto.typeName} not found`);
|
|
642
638
|
field.delimitedEncoding = isDelimitedEncoding(proto, parentOrFile);
|
|
643
639
|
field.getDefaultValue = () => undefined;
|
|
644
640
|
break;
|
|
@@ -775,9 +771,7 @@ function findOneof(proto, allOneofs) {
|
|
|
775
771
|
return undefined;
|
|
776
772
|
}
|
|
777
773
|
const oneof = allOneofs[proto.oneofIndex];
|
|
778
|
-
assert(
|
|
779
|
-
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
780
|
-
oneof, `invalid FieldDescriptorProto: oneof #${proto.oneofIndex} for field #${proto.number} not found`);
|
|
774
|
+
assert(oneof, `invalid FieldDescriptorProto: oneof #${proto.oneofIndex} for field #${proto.number} not found`);
|
|
781
775
|
return oneof;
|
|
782
776
|
}
|
|
783
777
|
/**
|
|
@@ -797,15 +791,17 @@ function getFieldPresence(proto, oneof, isExtension, parent) {
|
|
|
797
791
|
// oneof is always explicit
|
|
798
792
|
return EXPLICIT;
|
|
799
793
|
}
|
|
800
|
-
if (proto.type == TYPE_MESSAGE) {
|
|
801
|
-
// singular message field cannot be implicit
|
|
802
|
-
return EXPLICIT;
|
|
803
|
-
}
|
|
804
794
|
if (isExtension) {
|
|
805
795
|
// extensions always track presence
|
|
806
796
|
return EXPLICIT;
|
|
807
797
|
}
|
|
808
|
-
|
|
798
|
+
const resolved = resolveFeature("fieldPresence", { proto, parent });
|
|
799
|
+
if (resolved == IMPLICIT &&
|
|
800
|
+
(proto.type == TYPE_MESSAGE || proto.type == TYPE_GROUP)) {
|
|
801
|
+
// singular message field cannot be implicit
|
|
802
|
+
return EXPLICIT;
|
|
803
|
+
}
|
|
804
|
+
return resolved;
|
|
809
805
|
}
|
|
810
806
|
/**
|
|
811
807
|
* Pack this repeated field?
|
|
@@ -814,7 +810,6 @@ function isPackedField(proto, parent) {
|
|
|
814
810
|
if (proto.label != LABEL_REPEATED) {
|
|
815
811
|
return false;
|
|
816
812
|
}
|
|
817
|
-
// eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check
|
|
818
813
|
switch (proto.type) {
|
|
819
814
|
case TYPE_STRING:
|
|
820
815
|
case TYPE_BYTES:
|
|
@@ -901,7 +896,6 @@ function resolveFeature(name, ref) {
|
|
|
901
896
|
* Assert that condition is truthy or throw error (with message)
|
|
902
897
|
*/
|
|
903
898
|
function assert(condition, msg) {
|
|
904
|
-
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions -- we want the implicit conversion to boolean
|
|
905
899
|
if (!condition) {
|
|
906
900
|
throw new Error(msg);
|
|
907
901
|
}
|
package/dist/esm/to-binary.js
CHANGED
|
@@ -31,7 +31,7 @@ function writeFields(writer, opts, msg) {
|
|
|
31
31
|
for (const f of msg.sortedFields) {
|
|
32
32
|
if (!msg.isSet(f)) {
|
|
33
33
|
if (f.presence == LEGACY_REQUIRED) {
|
|
34
|
-
throw new Error(`cannot encode
|
|
34
|
+
throw new Error(`cannot encode ${f} to binary: required field not set`);
|
|
35
35
|
}
|
|
36
36
|
continue;
|
|
37
37
|
}
|
package/dist/esm/to-json.d.ts
CHANGED
|
@@ -38,6 +38,12 @@ export interface JsonWriteOptions {
|
|
|
38
38
|
* Options for serializing to JSON.
|
|
39
39
|
*/
|
|
40
40
|
export interface JsonWriteStringOptions extends JsonWriteOptions {
|
|
41
|
+
/**
|
|
42
|
+
* Format JSON with indentation. Indicates the number of space characters to
|
|
43
|
+
* be used as indentation.
|
|
44
|
+
*
|
|
45
|
+
* This option is passed to JSON.stringify as `space`.
|
|
46
|
+
*/
|
|
41
47
|
prettySpaces: number;
|
|
42
48
|
}
|
|
43
49
|
/**
|
package/dist/esm/to-json.js
CHANGED
|
@@ -19,7 +19,6 @@ import { isWrapperDesc } from "./wkt/wrappers.js";
|
|
|
19
19
|
import { base64Encode } from "./wire/index.js";
|
|
20
20
|
import { createExtensionContainer, getExtension } from "./extensions.js";
|
|
21
21
|
import { checkField, formatVal } from "./reflect/reflect-check.js";
|
|
22
|
-
/* eslint-disable @typescript-eslint/restrict-template-expressions */
|
|
23
22
|
// bootstrap-inject google.protobuf.FeatureSet.FieldPresence.LEGACY_REQUIRED: const $name: FeatureSet_FieldPresence.$localName = $number;
|
|
24
23
|
const LEGACY_REQUIRED = 3;
|
|
25
24
|
// bootstrap-inject google.protobuf.FeatureSet.FieldPresence.IMPLICIT: const $name: FeatureSet_FieldPresence.$localName = $number;
|
|
@@ -58,7 +57,7 @@ export function enumToJson(descEnum, value) {
|
|
|
58
57
|
}
|
|
59
58
|
const name = (_a = descEnum.value[value]) === null || _a === void 0 ? void 0 : _a.name;
|
|
60
59
|
if (name === undefined) {
|
|
61
|
-
throw new Error(`${
|
|
60
|
+
throw new Error(`${value} is not a value in ${descEnum}`);
|
|
62
61
|
}
|
|
63
62
|
return name;
|
|
64
63
|
}
|
|
@@ -71,7 +70,7 @@ function reflectToJson(msg, opts) {
|
|
|
71
70
|
for (const f of msg.sortedFields) {
|
|
72
71
|
if (!msg.isSet(f)) {
|
|
73
72
|
if (f.presence == LEGACY_REQUIRED) {
|
|
74
|
-
throw new Error(`cannot encode
|
|
73
|
+
throw new Error(`cannot encode ${f} to JSON: required field not set`);
|
|
75
74
|
}
|
|
76
75
|
if (!opts.alwaysEmitImplicit || f.presence !== IMPLICIT) {
|
|
77
76
|
// Fields with implicit presence omit zero values (e.g. empty string) by default
|
|
@@ -85,21 +84,21 @@ function reflectToJson(msg, opts) {
|
|
|
85
84
|
}
|
|
86
85
|
if (opts.registry) {
|
|
87
86
|
const tagSeen = new Set();
|
|
88
|
-
for (const
|
|
87
|
+
for (const { no } of (_a = msg.getUnknown()) !== null && _a !== void 0 ? _a : []) {
|
|
89
88
|
// Same tag can appear multiple times, so we
|
|
90
89
|
// keep track and skip identical ones.
|
|
91
|
-
if (tagSeen.has(
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
90
|
+
if (!tagSeen.has(no)) {
|
|
91
|
+
tagSeen.add(no);
|
|
92
|
+
const extension = opts.registry.getExtensionFor(msg.desc, no);
|
|
93
|
+
if (!extension) {
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
const value = getExtension(msg.message, extension);
|
|
97
|
+
const [container, field] = createExtensionContainer(extension, value);
|
|
98
|
+
const jsonValue = fieldToJson(field, container.get(field), opts);
|
|
99
|
+
if (jsonValue !== undefined) {
|
|
100
|
+
json[extension.jsonName] = jsonValue;
|
|
101
|
+
}
|
|
103
102
|
}
|
|
104
103
|
}
|
|
105
104
|
}
|
|
@@ -197,7 +196,7 @@ function scalarToJson(field, value) {
|
|
|
197
196
|
if (typeof value != "number") {
|
|
198
197
|
throw new Error(`cannot encode ${field} to JSON: ${(_b = checkField(field, value)) === null || _b === void 0 ? void 0 : _b.message}`);
|
|
199
198
|
}
|
|
200
|
-
if (isNaN(value))
|
|
199
|
+
if (Number.isNaN(value))
|
|
201
200
|
return "NaN";
|
|
202
201
|
if (value === Number.POSITIVE_INFINITY)
|
|
203
202
|
return "Infinity";
|
|
@@ -317,7 +316,6 @@ function durationToJson(val) {
|
|
|
317
316
|
function fieldMaskToJson(val) {
|
|
318
317
|
return val.paths
|
|
319
318
|
.map((p) => {
|
|
320
|
-
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
|
321
319
|
if (p.match(/_[0-9]?_/g) || p.match(/[A-Z]/g)) {
|
|
322
320
|
throw new Error(`cannot encode message ${val.$typeName} to JSON: lowerCamelCase of path name "` +
|
|
323
321
|
p +
|
|
@@ -11,7 +11,6 @@
|
|
|
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
|
-
/* eslint-disable @typescript-eslint/ban-ts-comment, @typescript-eslint/no-unnecessary-condition, prefer-const */
|
|
15
14
|
/**
|
|
16
15
|
* Decodes a base64 string to a byte array.
|
|
17
16
|
*
|
|
@@ -42,7 +41,6 @@ export function base64Decode(base64Str) {
|
|
|
42
41
|
// @ts-expect-error TS7029: Fallthrough case in switch
|
|
43
42
|
case "=":
|
|
44
43
|
groupPos = 0; // reset state when padding found
|
|
45
|
-
// eslint-disable-next-line no-fallthrough
|
|
46
44
|
case "\n":
|
|
47
45
|
case "\r":
|
|
48
46
|
case "\t":
|
|
@@ -135,7 +133,10 @@ function getEncodeTable(encoding) {
|
|
|
135
133
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");
|
|
136
134
|
encodeTableUrl = encodeTableStd.slice(0, -2).concat("-", "_");
|
|
137
135
|
}
|
|
138
|
-
return encoding == "url"
|
|
136
|
+
return encoding == "url"
|
|
137
|
+
? // biome-ignore lint/style/noNonNullAssertion: TS fails to narrow down
|
|
138
|
+
encodeTableUrl
|
|
139
|
+
: encodeTableStd;
|
|
139
140
|
}
|
|
140
141
|
function getDecodeTable() {
|
|
141
142
|
if (!decodeTable) {
|
|
@@ -14,7 +14,6 @@
|
|
|
14
14
|
import { varint32read, varint32write, varint64read, varint64write, } from "./varint.js";
|
|
15
15
|
import { protoInt64 } from "../proto-int64.js";
|
|
16
16
|
import { getTextEncoding } from "./text-encoding.js";
|
|
17
|
-
/* eslint-disable prefer-const,no-case-declarations,@typescript-eslint/restrict-plus-operands */
|
|
18
17
|
/**
|
|
19
18
|
* Protobuf binary format wire types.
|
|
20
19
|
*
|
|
@@ -275,7 +274,7 @@ export class BinaryWriter {
|
|
|
275
274
|
* Write a `sint64` value, a signed, zig-zag-encoded 64-bit varint.
|
|
276
275
|
*/
|
|
277
276
|
sint64(value) {
|
|
278
|
-
|
|
277
|
+
const tc = protoInt64.enc(value),
|
|
279
278
|
// zigzag encode
|
|
280
279
|
sign = tc.hi >> 31, lo = (tc.lo << 1) ^ sign, hi = ((tc.hi << 1) | (tc.lo >>> 31)) ^ sign;
|
|
281
280
|
varint64write(lo, hi, this.buf);
|
|
@@ -285,7 +284,7 @@ export class BinaryWriter {
|
|
|
285
284
|
* Write a `uint64` value, an unsigned 64-bit varint.
|
|
286
285
|
*/
|
|
287
286
|
uint64(value) {
|
|
288
|
-
|
|
287
|
+
const tc = protoInt64.uEnc(value);
|
|
289
288
|
varint64write(tc.lo, tc.hi, this.buf);
|
|
290
289
|
return this;
|
|
291
290
|
}
|
|
@@ -326,11 +325,9 @@ export class BinaryReader {
|
|
|
326
325
|
// ignore
|
|
327
326
|
}
|
|
328
327
|
break;
|
|
329
|
-
// eslint-disable-next-line
|
|
330
328
|
// @ts-expect-error TS7029: Fallthrough case in switch
|
|
331
329
|
case WireType.Bit64:
|
|
332
330
|
this.pos += 4;
|
|
333
|
-
// eslint-disable-next-line no-fallthrough
|
|
334
331
|
case WireType.Bit32:
|
|
335
332
|
this.pos += 4;
|
|
336
333
|
break;
|
|
@@ -411,12 +408,14 @@ export class BinaryReader {
|
|
|
411
408
|
* Read a `fixed32` field, an unsigned, fixed-length 32-bit integer.
|
|
412
409
|
*/
|
|
413
410
|
fixed32() {
|
|
411
|
+
// biome-ignore lint/suspicious/noAssignInExpressions: no
|
|
414
412
|
return this.view.getUint32((this.pos += 4) - 4, true);
|
|
415
413
|
}
|
|
416
414
|
/**
|
|
417
415
|
* Read a `sfixed32` field, a signed, fixed-length 32-bit integer.
|
|
418
416
|
*/
|
|
419
417
|
sfixed32() {
|
|
418
|
+
// biome-ignore lint/suspicious/noAssignInExpressions: no
|
|
420
419
|
return this.view.getInt32((this.pos += 4) - 4, true);
|
|
421
420
|
}
|
|
422
421
|
/**
|
|
@@ -435,12 +434,14 @@ export class BinaryReader {
|
|
|
435
434
|
* Read a `float` field, 32-bit floating point number.
|
|
436
435
|
*/
|
|
437
436
|
float() {
|
|
437
|
+
// biome-ignore lint/suspicious/noAssignInExpressions: no
|
|
438
438
|
return this.view.getFloat32((this.pos += 4) - 4, true);
|
|
439
439
|
}
|
|
440
440
|
/**
|
|
441
441
|
* Read a `double` field, a 64-bit floating point number.
|
|
442
442
|
*/
|
|
443
443
|
double() {
|
|
444
|
+
// biome-ignore lint/suspicious/noAssignInExpressions: no
|
|
444
445
|
return this.view.getFloat64((this.pos += 8) - 8, true);
|
|
445
446
|
}
|
|
446
447
|
/**
|
|
@@ -496,7 +497,7 @@ function assertFloat32(arg) {
|
|
|
496
497
|
if (typeof arg == "string") {
|
|
497
498
|
const o = arg;
|
|
498
499
|
arg = Number(arg);
|
|
499
|
-
if (isNaN(arg) && o !== "NaN") {
|
|
500
|
+
if (Number.isNaN(arg) && o !== "NaN") {
|
|
500
501
|
throw new Error("invalid float32: " + o);
|
|
501
502
|
}
|
|
502
503
|
}
|
|
@@ -13,7 +13,6 @@
|
|
|
13
13
|
// limitations under the License.
|
|
14
14
|
import { ScalarType } from "../descriptors.js";
|
|
15
15
|
import { protoInt64 } from "../proto-int64.js";
|
|
16
|
-
/* eslint-disable @typescript-eslint/restrict-template-expressions */
|
|
17
16
|
/**
|
|
18
17
|
* Parse an enum value from the Protobuf text format.
|
|
19
18
|
*
|
|
@@ -136,7 +135,7 @@ function unescapeBytesDefaultValue(str) {
|
|
|
136
135
|
return false;
|
|
137
136
|
}
|
|
138
137
|
const n = parseInt(s + t, 8);
|
|
139
|
-
if (isNaN(n)) {
|
|
138
|
+
if (Number.isNaN(n)) {
|
|
140
139
|
return false;
|
|
141
140
|
}
|
|
142
141
|
b.push(n);
|
|
@@ -149,7 +148,7 @@ function unescapeBytesDefaultValue(str) {
|
|
|
149
148
|
return false;
|
|
150
149
|
}
|
|
151
150
|
const n = parseInt(s + t, 16);
|
|
152
|
-
if (isNaN(n)) {
|
|
151
|
+
if (Number.isNaN(n)) {
|
|
153
152
|
return false;
|
|
154
153
|
}
|
|
155
154
|
b.push(n);
|
|
@@ -162,7 +161,7 @@ function unescapeBytesDefaultValue(str) {
|
|
|
162
161
|
return false;
|
|
163
162
|
}
|
|
164
163
|
const n = parseInt(s + t, 16);
|
|
165
|
-
if (isNaN(n)) {
|
|
164
|
+
if (Number.isNaN(n)) {
|
|
166
165
|
return false;
|
|
167
166
|
}
|
|
168
167
|
const chunk = new Uint8Array(4);
|
package/dist/esm/wire/varint.js
CHANGED
|
@@ -30,7 +30,6 @@
|
|
|
30
30
|
// of the input file used when generating it. This code is not
|
|
31
31
|
// standalone and requires a support library to be linked with it. This
|
|
32
32
|
// support library is itself covered by the above license.
|
|
33
|
-
/* eslint-disable prefer-const,@typescript-eslint/restrict-plus-operands */
|
|
34
33
|
/**
|
|
35
34
|
* Read a 64 bit varint as two JS numbers.
|
|
36
35
|
*
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import type { GenEnum, GenExtension, GenFile, GenMessage } from "../../../../codegenv1/types.js";
|
|
2
|
+
import type { FeatureSet } from "./descriptor_pb.js";
|
|
3
|
+
import type { Message } from "../../../../types.js";
|
|
4
|
+
/**
|
|
5
|
+
* Describes the file google/protobuf/cpp_features.proto.
|
|
6
|
+
*/
|
|
7
|
+
export declare const file_google_protobuf_cpp_features: GenFile;
|
|
8
|
+
/**
|
|
9
|
+
* @generated from message pb.CppFeatures
|
|
10
|
+
*/
|
|
11
|
+
export type CppFeatures = Message<"pb.CppFeatures"> & {
|
|
12
|
+
/**
|
|
13
|
+
* Whether or not to treat an enum field as closed. This option is only
|
|
14
|
+
* applicable to enum fields, and will be removed in the future. It is
|
|
15
|
+
* consistent with the legacy behavior of using proto3 enum types for proto2
|
|
16
|
+
* fields.
|
|
17
|
+
*
|
|
18
|
+
* @generated from field: optional bool legacy_closed_enum = 1;
|
|
19
|
+
*/
|
|
20
|
+
legacyClosedEnum: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* @generated from field: optional pb.CppFeatures.StringType string_type = 2;
|
|
23
|
+
*/
|
|
24
|
+
stringType: CppFeatures_StringType;
|
|
25
|
+
/**
|
|
26
|
+
* @generated from field: optional bool enum_name_uses_string_view = 3;
|
|
27
|
+
*/
|
|
28
|
+
enumNameUsesStringView: boolean;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* @generated from message pb.CppFeatures
|
|
32
|
+
*/
|
|
33
|
+
export type CppFeaturesJson = {
|
|
34
|
+
/**
|
|
35
|
+
* Whether or not to treat an enum field as closed. This option is only
|
|
36
|
+
* applicable to enum fields, and will be removed in the future. It is
|
|
37
|
+
* consistent with the legacy behavior of using proto3 enum types for proto2
|
|
38
|
+
* fields.
|
|
39
|
+
*
|
|
40
|
+
* @generated from field: optional bool legacy_closed_enum = 1;
|
|
41
|
+
*/
|
|
42
|
+
legacyClosedEnum?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* @generated from field: optional pb.CppFeatures.StringType string_type = 2;
|
|
45
|
+
*/
|
|
46
|
+
stringType?: CppFeatures_StringTypeJson;
|
|
47
|
+
/**
|
|
48
|
+
* @generated from field: optional bool enum_name_uses_string_view = 3;
|
|
49
|
+
*/
|
|
50
|
+
enumNameUsesStringView?: boolean;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Describes the message pb.CppFeatures.
|
|
54
|
+
* Use `create(CppFeaturesSchema)` to create a new message.
|
|
55
|
+
*/
|
|
56
|
+
export declare const CppFeaturesSchema: GenMessage<CppFeatures, CppFeaturesJson>;
|
|
57
|
+
/**
|
|
58
|
+
* @generated from enum pb.CppFeatures.StringType
|
|
59
|
+
*/
|
|
60
|
+
export declare enum CppFeatures_StringType {
|
|
61
|
+
/**
|
|
62
|
+
* @generated from enum value: STRING_TYPE_UNKNOWN = 0;
|
|
63
|
+
*/
|
|
64
|
+
STRING_TYPE_UNKNOWN = 0,
|
|
65
|
+
/**
|
|
66
|
+
* @generated from enum value: VIEW = 1;
|
|
67
|
+
*/
|
|
68
|
+
VIEW = 1,
|
|
69
|
+
/**
|
|
70
|
+
* @generated from enum value: CORD = 2;
|
|
71
|
+
*/
|
|
72
|
+
CORD = 2,
|
|
73
|
+
/**
|
|
74
|
+
* @generated from enum value: STRING = 3;
|
|
75
|
+
*/
|
|
76
|
+
STRING = 3
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* @generated from enum pb.CppFeatures.StringType
|
|
80
|
+
*/
|
|
81
|
+
export type CppFeatures_StringTypeJson = "STRING_TYPE_UNKNOWN" | "VIEW" | "CORD" | "STRING";
|
|
82
|
+
/**
|
|
83
|
+
* Describes the enum pb.CppFeatures.StringType.
|
|
84
|
+
*/
|
|
85
|
+
export declare const CppFeatures_StringTypeSchema: GenEnum<CppFeatures_StringType, CppFeatures_StringTypeJson>;
|
|
86
|
+
/**
|
|
87
|
+
* @generated from extension: optional pb.CppFeatures cpp = 1000;
|
|
88
|
+
*/
|
|
89
|
+
export declare const cpp: GenExtension<FeatureSet, CppFeatures>;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// Copyright 2021-2025 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
|
+
import { fileDesc } from "../../../../codegenv1/file.js";
|
|
15
|
+
import { file_google_protobuf_descriptor } from "./descriptor_pb.js";
|
|
16
|
+
import { messageDesc } from "../../../../codegenv1/message.js";
|
|
17
|
+
import { enumDesc } from "../../../../codegenv1/enum.js";
|
|
18
|
+
import { extDesc } from "../../../../codegenv1/extension.js";
|
|
19
|
+
/**
|
|
20
|
+
* Describes the file google/protobuf/cpp_features.proto.
|
|
21
|
+
*/
|
|
22
|
+
export const file_google_protobuf_cpp_features = /*@__PURE__*/ fileDesc("CiJnb29nbGUvcHJvdG9idWYvY3BwX2ZlYXR1cmVzLnByb3RvEgJwYiL8AwoLQ3BwRmVhdHVyZXMS+wEKEmxlZ2FjeV9jbG9zZWRfZW51bRgBIAEoCELeAYgBAZgBBJgBAaIBCRIEdHJ1ZRiEB6IBChIFZmFsc2UY5weyAbgBCOgHEOgHGq8BVGhlIGxlZ2FjeSBjbG9zZWQgZW51bSBiZWhhdmlvciBpbiBDKysgaXMgZGVwcmVjYXRlZCBhbmQgaXMgc2NoZWR1bGVkIHRvIGJlIHJlbW92ZWQgaW4gZWRpdGlvbiAyMDI1LiAgU2VlIGh0dHA6Ly9wcm90b2J1Zi5kZXYvcHJvZ3JhbW1pbmctZ3VpZGVzL2VudW0vI2NwcCBmb3IgbW9yZSBpbmZvcm1hdGlvbhJaCgtzdHJpbmdfdHlwZRgCIAEoDjIaLnBiLkNwcEZlYXR1cmVzLlN0cmluZ1R5cGVCKYgBAZgBBJgBAaIBCxIGU1RSSU5HGIQHogEJEgRWSUVXGOkHsgEDCOgHEkwKGmVudW1fbmFtZV91c2VzX3N0cmluZ192aWV3GAMgASgIQiiIAQKYAQaYAQGiAQoSBWZhbHNlGIQHogEJEgR0cnVlGOkHsgEDCOkHIkUKClN0cmluZ1R5cGUSFwoTU1RSSU5HX1RZUEVfVU5LTk9XThAAEggKBFZJRVcQARIICgRDT1JEEAISCgoGU1RSSU5HEAM6PwoDY3BwEhsuZ29vZ2xlLnByb3RvYnVmLkZlYXR1cmVTZXQY6AcgASgLMg8ucGIuQ3BwRmVhdHVyZXNSA2NwcA", [file_google_protobuf_descriptor]);
|
|
23
|
+
/**
|
|
24
|
+
* Describes the message pb.CppFeatures.
|
|
25
|
+
* Use `create(CppFeaturesSchema)` to create a new message.
|
|
26
|
+
*/
|
|
27
|
+
export const CppFeaturesSchema = /*@__PURE__*/ messageDesc(file_google_protobuf_cpp_features, 0);
|
|
28
|
+
/**
|
|
29
|
+
* @generated from enum pb.CppFeatures.StringType
|
|
30
|
+
*/
|
|
31
|
+
export var CppFeatures_StringType;
|
|
32
|
+
(function (CppFeatures_StringType) {
|
|
33
|
+
/**
|
|
34
|
+
* @generated from enum value: STRING_TYPE_UNKNOWN = 0;
|
|
35
|
+
*/
|
|
36
|
+
CppFeatures_StringType[CppFeatures_StringType["STRING_TYPE_UNKNOWN"] = 0] = "STRING_TYPE_UNKNOWN";
|
|
37
|
+
/**
|
|
38
|
+
* @generated from enum value: VIEW = 1;
|
|
39
|
+
*/
|
|
40
|
+
CppFeatures_StringType[CppFeatures_StringType["VIEW"] = 1] = "VIEW";
|
|
41
|
+
/**
|
|
42
|
+
* @generated from enum value: CORD = 2;
|
|
43
|
+
*/
|
|
44
|
+
CppFeatures_StringType[CppFeatures_StringType["CORD"] = 2] = "CORD";
|
|
45
|
+
/**
|
|
46
|
+
* @generated from enum value: STRING = 3;
|
|
47
|
+
*/
|
|
48
|
+
CppFeatures_StringType[CppFeatures_StringType["STRING"] = 3] = "STRING";
|
|
49
|
+
})(CppFeatures_StringType || (CppFeatures_StringType = {}));
|
|
50
|
+
/**
|
|
51
|
+
* Describes the enum pb.CppFeatures.StringType.
|
|
52
|
+
*/
|
|
53
|
+
export const CppFeatures_StringTypeSchema = /*@__PURE__*/ enumDesc(file_google_protobuf_cpp_features, 0, 0);
|
|
54
|
+
/**
|
|
55
|
+
* @generated from extension: optional pb.CppFeatures cpp = 1000;
|
|
56
|
+
*/
|
|
57
|
+
export const cpp = /*@__PURE__*/ extDesc(file_google_protobuf_cpp_features, 0);
|