@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/cjs/registry.js
CHANGED
|
@@ -65,7 +65,6 @@ function createFileRegistry(...args) {
|
|
|
65
65
|
const input = args[0];
|
|
66
66
|
const resolve = args[1];
|
|
67
67
|
const seen = new Set();
|
|
68
|
-
// eslint-disable-next-line no-inner-declarations
|
|
69
68
|
function recurseDeps(file) {
|
|
70
69
|
const deps = [];
|
|
71
70
|
for (const protoFileName of file.dependency) {
|
|
@@ -121,13 +120,11 @@ function createBaseRegistry() {
|
|
|
121
120
|
},
|
|
122
121
|
addFile(file, skipTypes, withDeps) {
|
|
123
122
|
files.set(file.proto.name, file);
|
|
124
|
-
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
125
123
|
if (!skipTypes) {
|
|
126
124
|
for (const type of (0, nested_types_js_1.nestedTypes)(file)) {
|
|
127
125
|
this.add(type);
|
|
128
126
|
}
|
|
129
127
|
}
|
|
130
|
-
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
131
128
|
if (withDeps) {
|
|
132
129
|
for (const f of file.dependencies) {
|
|
133
130
|
this.addFile(f, skipTypes, withDeps);
|
|
@@ -138,7 +135,9 @@ function createBaseRegistry() {
|
|
|
138
135
|
if (desc.kind == "extension") {
|
|
139
136
|
let numberToExt = extendees.get(desc.extendee.typeName);
|
|
140
137
|
if (!numberToExt) {
|
|
141
|
-
extendees.set(desc.extendee.typeName,
|
|
138
|
+
extendees.set(desc.extendee.typeName,
|
|
139
|
+
// biome-ignore lint/suspicious/noAssignInExpressions: no
|
|
140
|
+
(numberToExt = new Map()));
|
|
142
141
|
}
|
|
143
142
|
numberToExt.set(desc.number, desc);
|
|
144
143
|
}
|
|
@@ -228,7 +227,7 @@ const PACKED = 1;
|
|
|
228
227
|
const DELIMITED = 2;
|
|
229
228
|
// bootstrap-inject google.protobuf.FeatureSet.EnumType.OPEN: const $name: FeatureSet_EnumType.$localName = $number;
|
|
230
229
|
const OPEN = 1;
|
|
231
|
-
//
|
|
230
|
+
// biome-ignore format: want this to read well
|
|
232
231
|
// bootstrap-inject defaults: EDITION_PROTO2 to EDITION_2023: export const minimumEdition: SupportedEdition = $minimumEdition, maximumEdition: SupportedEdition = $maximumEdition;
|
|
233
232
|
// generated from protoc v30.0
|
|
234
233
|
exports.minimumEdition = 998, exports.maximumEdition = 1000;
|
|
@@ -377,7 +376,7 @@ function addFields(message, reg, mapEntries) {
|
|
|
377
376
|
* parent type, if any.
|
|
378
377
|
*/
|
|
379
378
|
function addEnum(proto, file, parent, reg) {
|
|
380
|
-
var _a, _b, _c;
|
|
379
|
+
var _a, _b, _c, _d, _e;
|
|
381
380
|
const sharedPrefix = findEnumSharedPrefix(proto.name, proto.value);
|
|
382
381
|
const desc = {
|
|
383
382
|
kind: "enum",
|
|
@@ -397,25 +396,26 @@ function addEnum(proto, file, parent, reg) {
|
|
|
397
396
|
};
|
|
398
397
|
desc.open = isEnumOpen(desc);
|
|
399
398
|
reg.add(desc);
|
|
400
|
-
proto.value
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
399
|
+
for (const p of proto.value) {
|
|
400
|
+
const name = p.name;
|
|
401
|
+
desc.values.push(
|
|
402
|
+
// biome-ignore lint/suspicious/noAssignInExpressions: no
|
|
403
|
+
(desc.value[p.number] = {
|
|
404
404
|
kind: "enum_value",
|
|
405
|
-
proto,
|
|
406
|
-
deprecated: (
|
|
405
|
+
proto: p,
|
|
406
|
+
deprecated: (_d = (_c = p.options) === null || _c === void 0 ? void 0 : _c.deprecated) !== null && _d !== void 0 ? _d : false,
|
|
407
407
|
parent: desc,
|
|
408
408
|
name,
|
|
409
409
|
localName: (0, names_js_1.safeObjectProperty)(sharedPrefix == undefined
|
|
410
410
|
? name
|
|
411
411
|
: name.substring(sharedPrefix.length)),
|
|
412
|
-
number:
|
|
412
|
+
number: p.number,
|
|
413
413
|
toString() {
|
|
414
414
|
return `enum value ${desc.typeName}.${name}`;
|
|
415
415
|
},
|
|
416
416
|
}));
|
|
417
|
-
}
|
|
418
|
-
((
|
|
417
|
+
}
|
|
418
|
+
((_e = parent === null || parent === void 0 ? void 0 : parent.nestedEnums) !== null && _e !== void 0 ? _e : file.enums).push(desc);
|
|
419
419
|
}
|
|
420
420
|
/**
|
|
421
421
|
* Create a descriptor for a message, including nested types, and add it to our
|
|
@@ -617,14 +617,12 @@ function newField(proto, parentOrFile, reg, oneof, mapEntries) {
|
|
|
617
617
|
case TYPE_GROUP:
|
|
618
618
|
field.listKind = "message";
|
|
619
619
|
field.message = reg.getMessage(trimLeadingDot(proto.typeName));
|
|
620
|
-
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
621
620
|
assert(field.message);
|
|
622
621
|
field.delimitedEncoding = isDelimitedEncoding(proto, parentOrFile);
|
|
623
622
|
break;
|
|
624
623
|
case TYPE_ENUM:
|
|
625
624
|
field.listKind = "enum";
|
|
626
625
|
field.enum = reg.getEnum(trimLeadingDot(proto.typeName));
|
|
627
|
-
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
628
626
|
assert(field.enum);
|
|
629
627
|
break;
|
|
630
628
|
default:
|
|
@@ -642,9 +640,7 @@ function newField(proto, parentOrFile, reg, oneof, mapEntries) {
|
|
|
642
640
|
case TYPE_GROUP:
|
|
643
641
|
field.fieldKind = "message";
|
|
644
642
|
field.message = reg.getMessage(trimLeadingDot(proto.typeName));
|
|
645
|
-
assert(
|
|
646
|
-
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
647
|
-
field.message, `invalid FieldDescriptorProto: type_name ${proto.typeName} not found`);
|
|
643
|
+
assert(field.message, `invalid FieldDescriptorProto: type_name ${proto.typeName} not found`);
|
|
648
644
|
field.delimitedEncoding = isDelimitedEncoding(proto, parentOrFile);
|
|
649
645
|
field.getDefaultValue = () => undefined;
|
|
650
646
|
break;
|
|
@@ -781,9 +777,7 @@ function findOneof(proto, allOneofs) {
|
|
|
781
777
|
return undefined;
|
|
782
778
|
}
|
|
783
779
|
const oneof = allOneofs[proto.oneofIndex];
|
|
784
|
-
assert(
|
|
785
|
-
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
786
|
-
oneof, `invalid FieldDescriptorProto: oneof #${proto.oneofIndex} for field #${proto.number} not found`);
|
|
780
|
+
assert(oneof, `invalid FieldDescriptorProto: oneof #${proto.oneofIndex} for field #${proto.number} not found`);
|
|
787
781
|
return oneof;
|
|
788
782
|
}
|
|
789
783
|
/**
|
|
@@ -803,15 +797,17 @@ function getFieldPresence(proto, oneof, isExtension, parent) {
|
|
|
803
797
|
// oneof is always explicit
|
|
804
798
|
return EXPLICIT;
|
|
805
799
|
}
|
|
806
|
-
if (proto.type == TYPE_MESSAGE) {
|
|
807
|
-
// singular message field cannot be implicit
|
|
808
|
-
return EXPLICIT;
|
|
809
|
-
}
|
|
810
800
|
if (isExtension) {
|
|
811
801
|
// extensions always track presence
|
|
812
802
|
return EXPLICIT;
|
|
813
803
|
}
|
|
814
|
-
|
|
804
|
+
const resolved = resolveFeature("fieldPresence", { proto, parent });
|
|
805
|
+
if (resolved == IMPLICIT &&
|
|
806
|
+
(proto.type == TYPE_MESSAGE || proto.type == TYPE_GROUP)) {
|
|
807
|
+
// singular message field cannot be implicit
|
|
808
|
+
return EXPLICIT;
|
|
809
|
+
}
|
|
810
|
+
return resolved;
|
|
815
811
|
}
|
|
816
812
|
/**
|
|
817
813
|
* Pack this repeated field?
|
|
@@ -820,7 +816,6 @@ function isPackedField(proto, parent) {
|
|
|
820
816
|
if (proto.label != LABEL_REPEATED) {
|
|
821
817
|
return false;
|
|
822
818
|
}
|
|
823
|
-
// eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check
|
|
824
819
|
switch (proto.type) {
|
|
825
820
|
case TYPE_STRING:
|
|
826
821
|
case TYPE_BYTES:
|
|
@@ -907,7 +902,6 @@ function resolveFeature(name, ref) {
|
|
|
907
902
|
* Assert that condition is truthy or throw error (with message)
|
|
908
903
|
*/
|
|
909
904
|
function assert(condition, msg) {
|
|
910
|
-
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions -- we want the implicit conversion to boolean
|
|
911
905
|
if (!condition) {
|
|
912
906
|
throw new Error(msg);
|
|
913
907
|
}
|
package/dist/cjs/to-binary.js
CHANGED
|
@@ -35,7 +35,7 @@ function writeFields(writer, opts, msg) {
|
|
|
35
35
|
for (const f of msg.sortedFields) {
|
|
36
36
|
if (!msg.isSet(f)) {
|
|
37
37
|
if (f.presence == LEGACY_REQUIRED) {
|
|
38
|
-
throw new Error(`cannot encode
|
|
38
|
+
throw new Error(`cannot encode ${f} to binary: required field not set`);
|
|
39
39
|
}
|
|
40
40
|
continue;
|
|
41
41
|
}
|
package/dist/cjs/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/cjs/to-json.js
CHANGED
|
@@ -24,7 +24,6 @@ const wrappers_js_1 = require("./wkt/wrappers.js");
|
|
|
24
24
|
const index_js_2 = require("./wire/index.js");
|
|
25
25
|
const extensions_js_1 = require("./extensions.js");
|
|
26
26
|
const reflect_check_js_1 = require("./reflect/reflect-check.js");
|
|
27
|
-
/* eslint-disable @typescript-eslint/restrict-template-expressions */
|
|
28
27
|
// bootstrap-inject google.protobuf.FeatureSet.FieldPresence.LEGACY_REQUIRED: const $name: FeatureSet_FieldPresence.$localName = $number;
|
|
29
28
|
const LEGACY_REQUIRED = 3;
|
|
30
29
|
// bootstrap-inject google.protobuf.FeatureSet.FieldPresence.IMPLICIT: const $name: FeatureSet_FieldPresence.$localName = $number;
|
|
@@ -63,7 +62,7 @@ function enumToJson(descEnum, value) {
|
|
|
63
62
|
}
|
|
64
63
|
const name = (_a = descEnum.value[value]) === null || _a === void 0 ? void 0 : _a.name;
|
|
65
64
|
if (name === undefined) {
|
|
66
|
-
throw new Error(`${
|
|
65
|
+
throw new Error(`${value} is not a value in ${descEnum}`);
|
|
67
66
|
}
|
|
68
67
|
return name;
|
|
69
68
|
}
|
|
@@ -76,7 +75,7 @@ function reflectToJson(msg, opts) {
|
|
|
76
75
|
for (const f of msg.sortedFields) {
|
|
77
76
|
if (!msg.isSet(f)) {
|
|
78
77
|
if (f.presence == LEGACY_REQUIRED) {
|
|
79
|
-
throw new Error(`cannot encode
|
|
78
|
+
throw new Error(`cannot encode ${f} to JSON: required field not set`);
|
|
80
79
|
}
|
|
81
80
|
if (!opts.alwaysEmitImplicit || f.presence !== IMPLICIT) {
|
|
82
81
|
// Fields with implicit presence omit zero values (e.g. empty string) by default
|
|
@@ -90,21 +89,21 @@ function reflectToJson(msg, opts) {
|
|
|
90
89
|
}
|
|
91
90
|
if (opts.registry) {
|
|
92
91
|
const tagSeen = new Set();
|
|
93
|
-
for (const
|
|
92
|
+
for (const { no } of (_a = msg.getUnknown()) !== null && _a !== void 0 ? _a : []) {
|
|
94
93
|
// Same tag can appear multiple times, so we
|
|
95
94
|
// keep track and skip identical ones.
|
|
96
|
-
if (tagSeen.has(
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
95
|
+
if (!tagSeen.has(no)) {
|
|
96
|
+
tagSeen.add(no);
|
|
97
|
+
const extension = opts.registry.getExtensionFor(msg.desc, no);
|
|
98
|
+
if (!extension) {
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
const value = (0, extensions_js_1.getExtension)(msg.message, extension);
|
|
102
|
+
const [container, field] = (0, extensions_js_1.createExtensionContainer)(extension, value);
|
|
103
|
+
const jsonValue = fieldToJson(field, container.get(field), opts);
|
|
104
|
+
if (jsonValue !== undefined) {
|
|
105
|
+
json[extension.jsonName] = jsonValue;
|
|
106
|
+
}
|
|
108
107
|
}
|
|
109
108
|
}
|
|
110
109
|
}
|
|
@@ -202,7 +201,7 @@ function scalarToJson(field, value) {
|
|
|
202
201
|
if (typeof value != "number") {
|
|
203
202
|
throw new Error(`cannot encode ${field} to JSON: ${(_b = (0, reflect_check_js_1.checkField)(field, value)) === null || _b === void 0 ? void 0 : _b.message}`);
|
|
204
203
|
}
|
|
205
|
-
if (isNaN(value))
|
|
204
|
+
if (Number.isNaN(value))
|
|
206
205
|
return "NaN";
|
|
207
206
|
if (value === Number.POSITIVE_INFINITY)
|
|
208
207
|
return "Infinity";
|
|
@@ -322,7 +321,6 @@ function durationToJson(val) {
|
|
|
322
321
|
function fieldMaskToJson(val) {
|
|
323
322
|
return val.paths
|
|
324
323
|
.map((p) => {
|
|
325
|
-
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
|
326
324
|
if (p.match(/_[0-9]?_/g) || p.match(/[A-Z]/g)) {
|
|
327
325
|
throw new Error(`cannot encode message ${val.$typeName} to JSON: lowerCamelCase of path name "` +
|
|
328
326
|
p +
|
|
@@ -15,7 +15,6 @@
|
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
16
|
exports.base64Decode = base64Decode;
|
|
17
17
|
exports.base64Encode = base64Encode;
|
|
18
|
-
/* eslint-disable @typescript-eslint/ban-ts-comment, @typescript-eslint/no-unnecessary-condition, prefer-const */
|
|
19
18
|
/**
|
|
20
19
|
* Decodes a base64 string to a byte array.
|
|
21
20
|
*
|
|
@@ -46,7 +45,6 @@ function base64Decode(base64Str) {
|
|
|
46
45
|
// @ts-expect-error TS7029: Fallthrough case in switch
|
|
47
46
|
case "=":
|
|
48
47
|
groupPos = 0; // reset state when padding found
|
|
49
|
-
// eslint-disable-next-line no-fallthrough
|
|
50
48
|
case "\n":
|
|
51
49
|
case "\r":
|
|
52
50
|
case "\t":
|
|
@@ -139,7 +137,10 @@ function getEncodeTable(encoding) {
|
|
|
139
137
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");
|
|
140
138
|
encodeTableUrl = encodeTableStd.slice(0, -2).concat("-", "_");
|
|
141
139
|
}
|
|
142
|
-
return encoding == "url"
|
|
140
|
+
return encoding == "url"
|
|
141
|
+
? // biome-ignore lint/style/noNonNullAssertion: TS fails to narrow down
|
|
142
|
+
encodeTableUrl
|
|
143
|
+
: encodeTableStd;
|
|
143
144
|
}
|
|
144
145
|
function getDecodeTable() {
|
|
145
146
|
if (!decodeTable) {
|
|
@@ -17,7 +17,6 @@ exports.BinaryReader = exports.BinaryWriter = exports.INT32_MIN = exports.INT32_
|
|
|
17
17
|
const varint_js_1 = require("./varint.js");
|
|
18
18
|
const proto_int64_js_1 = require("../proto-int64.js");
|
|
19
19
|
const text_encoding_js_1 = require("./text-encoding.js");
|
|
20
|
-
/* eslint-disable prefer-const,no-case-declarations,@typescript-eslint/restrict-plus-operands */
|
|
21
20
|
/**
|
|
22
21
|
* Protobuf binary format wire types.
|
|
23
22
|
*
|
|
@@ -278,7 +277,7 @@ class BinaryWriter {
|
|
|
278
277
|
* Write a `sint64` value, a signed, zig-zag-encoded 64-bit varint.
|
|
279
278
|
*/
|
|
280
279
|
sint64(value) {
|
|
281
|
-
|
|
280
|
+
const tc = proto_int64_js_1.protoInt64.enc(value),
|
|
282
281
|
// zigzag encode
|
|
283
282
|
sign = tc.hi >> 31, lo = (tc.lo << 1) ^ sign, hi = ((tc.hi << 1) | (tc.lo >>> 31)) ^ sign;
|
|
284
283
|
(0, varint_js_1.varint64write)(lo, hi, this.buf);
|
|
@@ -288,7 +287,7 @@ class BinaryWriter {
|
|
|
288
287
|
* Write a `uint64` value, an unsigned 64-bit varint.
|
|
289
288
|
*/
|
|
290
289
|
uint64(value) {
|
|
291
|
-
|
|
290
|
+
const tc = proto_int64_js_1.protoInt64.uEnc(value);
|
|
292
291
|
(0, varint_js_1.varint64write)(tc.lo, tc.hi, this.buf);
|
|
293
292
|
return this;
|
|
294
293
|
}
|
|
@@ -330,11 +329,9 @@ class BinaryReader {
|
|
|
330
329
|
// ignore
|
|
331
330
|
}
|
|
332
331
|
break;
|
|
333
|
-
// eslint-disable-next-line
|
|
334
332
|
// @ts-expect-error TS7029: Fallthrough case in switch
|
|
335
333
|
case WireType.Bit64:
|
|
336
334
|
this.pos += 4;
|
|
337
|
-
// eslint-disable-next-line no-fallthrough
|
|
338
335
|
case WireType.Bit32:
|
|
339
336
|
this.pos += 4;
|
|
340
337
|
break;
|
|
@@ -415,12 +412,14 @@ class BinaryReader {
|
|
|
415
412
|
* Read a `fixed32` field, an unsigned, fixed-length 32-bit integer.
|
|
416
413
|
*/
|
|
417
414
|
fixed32() {
|
|
415
|
+
// biome-ignore lint/suspicious/noAssignInExpressions: no
|
|
418
416
|
return this.view.getUint32((this.pos += 4) - 4, true);
|
|
419
417
|
}
|
|
420
418
|
/**
|
|
421
419
|
* Read a `sfixed32` field, a signed, fixed-length 32-bit integer.
|
|
422
420
|
*/
|
|
423
421
|
sfixed32() {
|
|
422
|
+
// biome-ignore lint/suspicious/noAssignInExpressions: no
|
|
424
423
|
return this.view.getInt32((this.pos += 4) - 4, true);
|
|
425
424
|
}
|
|
426
425
|
/**
|
|
@@ -439,12 +438,14 @@ class BinaryReader {
|
|
|
439
438
|
* Read a `float` field, 32-bit floating point number.
|
|
440
439
|
*/
|
|
441
440
|
float() {
|
|
441
|
+
// biome-ignore lint/suspicious/noAssignInExpressions: no
|
|
442
442
|
return this.view.getFloat32((this.pos += 4) - 4, true);
|
|
443
443
|
}
|
|
444
444
|
/**
|
|
445
445
|
* Read a `double` field, a 64-bit floating point number.
|
|
446
446
|
*/
|
|
447
447
|
double() {
|
|
448
|
+
// biome-ignore lint/suspicious/noAssignInExpressions: no
|
|
448
449
|
return this.view.getFloat64((this.pos += 8) - 8, true);
|
|
449
450
|
}
|
|
450
451
|
/**
|
|
@@ -501,7 +502,7 @@ function assertFloat32(arg) {
|
|
|
501
502
|
if (typeof arg == "string") {
|
|
502
503
|
const o = arg;
|
|
503
504
|
arg = Number(arg);
|
|
504
|
-
if (isNaN(arg) && o !== "NaN") {
|
|
505
|
+
if (Number.isNaN(arg) && o !== "NaN") {
|
|
505
506
|
throw new Error("invalid float32: " + o);
|
|
506
507
|
}
|
|
507
508
|
}
|
|
@@ -17,7 +17,6 @@ exports.parseTextFormatEnumValue = parseTextFormatEnumValue;
|
|
|
17
17
|
exports.parseTextFormatScalarValue = parseTextFormatScalarValue;
|
|
18
18
|
const descriptors_js_1 = require("../descriptors.js");
|
|
19
19
|
const proto_int64_js_1 = require("../proto-int64.js");
|
|
20
|
-
/* eslint-disable @typescript-eslint/restrict-template-expressions */
|
|
21
20
|
/**
|
|
22
21
|
* Parse an enum value from the Protobuf text format.
|
|
23
22
|
*
|
|
@@ -140,7 +139,7 @@ function unescapeBytesDefaultValue(str) {
|
|
|
140
139
|
return false;
|
|
141
140
|
}
|
|
142
141
|
const n = parseInt(s + t, 8);
|
|
143
|
-
if (isNaN(n)) {
|
|
142
|
+
if (Number.isNaN(n)) {
|
|
144
143
|
return false;
|
|
145
144
|
}
|
|
146
145
|
b.push(n);
|
|
@@ -153,7 +152,7 @@ function unescapeBytesDefaultValue(str) {
|
|
|
153
152
|
return false;
|
|
154
153
|
}
|
|
155
154
|
const n = parseInt(s + t, 16);
|
|
156
|
-
if (isNaN(n)) {
|
|
155
|
+
if (Number.isNaN(n)) {
|
|
157
156
|
return false;
|
|
158
157
|
}
|
|
159
158
|
b.push(n);
|
|
@@ -166,7 +165,7 @@ function unescapeBytesDefaultValue(str) {
|
|
|
166
165
|
return false;
|
|
167
166
|
}
|
|
168
167
|
const n = parseInt(s + t, 16);
|
|
169
|
-
if (isNaN(n)) {
|
|
168
|
+
if (Number.isNaN(n)) {
|
|
170
169
|
return false;
|
|
171
170
|
}
|
|
172
171
|
const chunk = new Uint8Array(4);
|
package/dist/cjs/wire/varint.js
CHANGED
|
@@ -39,7 +39,6 @@ exports.int64ToString = int64ToString;
|
|
|
39
39
|
exports.uInt64ToString = uInt64ToString;
|
|
40
40
|
exports.varint32write = varint32write;
|
|
41
41
|
exports.varint32read = varint32read;
|
|
42
|
-
/* eslint-disable prefer-const,@typescript-eslint/restrict-plus-operands */
|
|
43
42
|
/**
|
|
44
43
|
* Read a 64 bit varint as two JS numbers.
|
|
45
44
|
*
|
|
@@ -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,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright 2021-2025 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.cpp = exports.CppFeatures_StringTypeSchema = exports.CppFeatures_StringType = exports.CppFeaturesSchema = exports.file_google_protobuf_cpp_features = void 0;
|
|
17
|
+
const file_js_1 = require("../../../../codegenv1/file.js");
|
|
18
|
+
const descriptor_pb_js_1 = require("./descriptor_pb.js");
|
|
19
|
+
const message_js_1 = require("../../../../codegenv1/message.js");
|
|
20
|
+
const enum_js_1 = require("../../../../codegenv1/enum.js");
|
|
21
|
+
const extension_js_1 = require("../../../../codegenv1/extension.js");
|
|
22
|
+
/**
|
|
23
|
+
* Describes the file google/protobuf/cpp_features.proto.
|
|
24
|
+
*/
|
|
25
|
+
exports.file_google_protobuf_cpp_features = (0, file_js_1.fileDesc)("CiJnb29nbGUvcHJvdG9idWYvY3BwX2ZlYXR1cmVzLnByb3RvEgJwYiL8AwoLQ3BwRmVhdHVyZXMS+wEKEmxlZ2FjeV9jbG9zZWRfZW51bRgBIAEoCELeAYgBAZgBBJgBAaIBCRIEdHJ1ZRiEB6IBChIFZmFsc2UY5weyAbgBCOgHEOgHGq8BVGhlIGxlZ2FjeSBjbG9zZWQgZW51bSBiZWhhdmlvciBpbiBDKysgaXMgZGVwcmVjYXRlZCBhbmQgaXMgc2NoZWR1bGVkIHRvIGJlIHJlbW92ZWQgaW4gZWRpdGlvbiAyMDI1LiAgU2VlIGh0dHA6Ly9wcm90b2J1Zi5kZXYvcHJvZ3JhbW1pbmctZ3VpZGVzL2VudW0vI2NwcCBmb3IgbW9yZSBpbmZvcm1hdGlvbhJaCgtzdHJpbmdfdHlwZRgCIAEoDjIaLnBiLkNwcEZlYXR1cmVzLlN0cmluZ1R5cGVCKYgBAZgBBJgBAaIBCxIGU1RSSU5HGIQHogEJEgRWSUVXGOkHsgEDCOgHEkwKGmVudW1fbmFtZV91c2VzX3N0cmluZ192aWV3GAMgASgIQiiIAQKYAQaYAQGiAQoSBWZhbHNlGIQHogEJEgR0cnVlGOkHsgEDCOkHIkUKClN0cmluZ1R5cGUSFwoTU1RSSU5HX1RZUEVfVU5LTk9XThAAEggKBFZJRVcQARIICgRDT1JEEAISCgoGU1RSSU5HEAM6PwoDY3BwEhsuZ29vZ2xlLnByb3RvYnVmLkZlYXR1cmVTZXQY6AcgASgLMg8ucGIuQ3BwRmVhdHVyZXNSA2NwcA", [descriptor_pb_js_1.file_google_protobuf_descriptor]);
|
|
26
|
+
/**
|
|
27
|
+
* Describes the message pb.CppFeatures.
|
|
28
|
+
* Use `create(CppFeaturesSchema)` to create a new message.
|
|
29
|
+
*/
|
|
30
|
+
exports.CppFeaturesSchema = (0, message_js_1.messageDesc)(exports.file_google_protobuf_cpp_features, 0);
|
|
31
|
+
/**
|
|
32
|
+
* @generated from enum pb.CppFeatures.StringType
|
|
33
|
+
*/
|
|
34
|
+
var CppFeatures_StringType;
|
|
35
|
+
(function (CppFeatures_StringType) {
|
|
36
|
+
/**
|
|
37
|
+
* @generated from enum value: STRING_TYPE_UNKNOWN = 0;
|
|
38
|
+
*/
|
|
39
|
+
CppFeatures_StringType[CppFeatures_StringType["STRING_TYPE_UNKNOWN"] = 0] = "STRING_TYPE_UNKNOWN";
|
|
40
|
+
/**
|
|
41
|
+
* @generated from enum value: VIEW = 1;
|
|
42
|
+
*/
|
|
43
|
+
CppFeatures_StringType[CppFeatures_StringType["VIEW"] = 1] = "VIEW";
|
|
44
|
+
/**
|
|
45
|
+
* @generated from enum value: CORD = 2;
|
|
46
|
+
*/
|
|
47
|
+
CppFeatures_StringType[CppFeatures_StringType["CORD"] = 2] = "CORD";
|
|
48
|
+
/**
|
|
49
|
+
* @generated from enum value: STRING = 3;
|
|
50
|
+
*/
|
|
51
|
+
CppFeatures_StringType[CppFeatures_StringType["STRING"] = 3] = "STRING";
|
|
52
|
+
})(CppFeatures_StringType || (exports.CppFeatures_StringType = CppFeatures_StringType = {}));
|
|
53
|
+
/**
|
|
54
|
+
* Describes the enum pb.CppFeatures.StringType.
|
|
55
|
+
*/
|
|
56
|
+
exports.CppFeatures_StringTypeSchema = (0, enum_js_1.enumDesc)(exports.file_google_protobuf_cpp_features, 0, 0);
|
|
57
|
+
/**
|
|
58
|
+
* @generated from extension: optional pb.CppFeatures cpp = 1000;
|
|
59
|
+
*/
|
|
60
|
+
exports.cpp = (0, extension_js_1.extDesc)(exports.file_google_protobuf_cpp_features, 0);
|