@bufbuild/protobuf 0.0.1-alpha.1 → 0.0.1
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 +21 -1
- package/dist/cjs/binary-encoding.js +402 -410
- package/dist/cjs/descriptor-registry.js +407 -449
- package/dist/cjs/descriptor-set.js +416 -513
- package/dist/cjs/field.js +30 -30
- package/dist/cjs/google/protobuf/any_pb.js +122 -140
- package/dist/cjs/google/protobuf/api_pb.js +177 -224
- package/dist/cjs/google/protobuf/compiler/plugin_pb.js +125 -227
- package/dist/cjs/google/protobuf/descriptor_pb.js +1029 -1888
- package/dist/cjs/google/protobuf/duration_pb.js +72 -88
- package/dist/cjs/google/protobuf/empty_pb.js +17 -17
- package/dist/cjs/google/protobuf/field_mask_pb.js +77 -94
- package/dist/cjs/google/protobuf/source_context_pb.js +25 -25
- package/dist/cjs/google/protobuf/struct_pb.js +144 -181
- package/dist/cjs/google/protobuf/timestamp_pb.js +86 -123
- package/dist/cjs/google/protobuf/type_pb.js +406 -462
- package/dist/cjs/google/protobuf/wrappers_pb.js +407 -470
- package/dist/cjs/index.js +24 -122
- package/dist/cjs/message.js +81 -89
- package/dist/cjs/private/assert.js +20 -26
- package/dist/cjs/private/base64.js +79 -78
- package/dist/cjs/private/binary-format-common.js +195 -208
- package/dist/cjs/private/binary-format-proto2.js +75 -109
- package/dist/cjs/private/binary-format-proto3.js +57 -90
- package/dist/cjs/private/enum.js +38 -43
- package/dist/cjs/private/field-list.js +51 -50
- package/dist/cjs/private/field-wrapper.js +8 -10
- package/dist/cjs/private/field.js +22 -25
- package/dist/cjs/private/goog-varint.js +275 -0
- package/dist/cjs/private/json-format-common.js +414 -440
- package/dist/cjs/private/json-format-proto2.js +78 -89
- package/dist/cjs/private/json-format-proto3.js +69 -93
- package/dist/cjs/private/message-type.js +26 -27
- package/dist/cjs/private/names.js +58 -62
- package/dist/cjs/private/proto-runtime.js +11 -16
- package/dist/cjs/private/scalars.js +100 -103
- package/dist/cjs/private/util-common.js +180 -210
- package/dist/cjs/proto-int64.js +111 -112
- package/dist/cjs/proto2.js +50 -63
- package/dist/cjs/proto3.js +61 -74
- package/dist/cjs/service-type.js +14 -17
- package/dist/cjs/type-registry.js +33 -31
- package/dist/esm/binary-encoding.js +401 -414
- package/dist/esm/descriptor-registry.js +409 -458
- package/dist/esm/descriptor-set.js +417 -478
- package/dist/esm/field.js +29 -29
- package/dist/esm/google/protobuf/any_pb.js +122 -140
- package/dist/esm/google/protobuf/api_pb.js +177 -197
- package/dist/esm/google/protobuf/compiler/plugin_pb.js +123 -216
- package/dist/esm/google/protobuf/descriptor_pb.js +1013 -1804
- package/dist/esm/google/protobuf/duration_pb.js +72 -88
- package/dist/esm/google/protobuf/empty_pb.js +17 -17
- package/dist/esm/google/protobuf/field_mask_pb.js +77 -94
- package/dist/esm/google/protobuf/source_context_pb.js +25 -25
- package/dist/esm/google/protobuf/struct_pb.js +143 -180
- package/dist/esm/google/protobuf/timestamp_pb.js +86 -123
- package/dist/esm/google/protobuf/type_pb.js +401 -421
- package/dist/esm/google/protobuf/wrappers_pb.js +406 -397
- package/dist/esm/index.js +1 -1
- package/dist/esm/message.js +81 -89
- package/dist/esm/private/assert.js +19 -21
- package/dist/esm/private/base64.js +79 -78
- package/dist/esm/private/binary-format-common.js +196 -207
- package/dist/esm/private/binary-format-proto2.js +76 -81
- package/dist/esm/private/binary-format-proto3.js +58 -67
- package/dist/esm/private/enum.js +38 -43
- package/dist/esm/private/field-list.js +51 -50
- package/dist/esm/private/field-wrapper.js +8 -10
- package/dist/esm/private/field.js +22 -22
- package/dist/esm/private/goog-varint.js +266 -0
- package/dist/esm/private/json-format-common.js +414 -435
- package/dist/esm/private/json-format-proto2.js +76 -81
- package/dist/esm/private/json-format-proto3.js +66 -80
- package/dist/esm/private/message-type.js +27 -28
- package/dist/esm/private/names.js +57 -57
- package/dist/esm/private/proto-runtime.js +11 -11
- package/dist/esm/private/scalars.js +99 -99
- package/dist/esm/private/util-common.js +180 -192
- package/dist/esm/proto-int64.js +111 -112
- package/dist/esm/proto2.js +50 -57
- package/dist/esm/proto3.js +61 -68
- package/dist/esm/service-type.js +12 -12
- package/dist/esm/type-registry.js +33 -31
- package/dist/types/binary-encoding.d.ts +398 -398
- package/dist/types/binary-format.d.ts +69 -91
- package/dist/types/descriptor-registry.d.ts +23 -29
- package/dist/types/descriptor-set.d.ts +107 -128
- package/dist/types/enum.d.ts +21 -21
- package/dist/types/field-list.d.ts +21 -21
- package/dist/types/field.d.ts +191 -231
- package/dist/types/google/protobuf/any_pb.d.ts +56 -77
- package/dist/types/google/protobuf/api_pb.d.ts +144 -187
- package/dist/types/google/protobuf/compiler/plugin_pb.d.ts +195 -257
- package/dist/types/google/protobuf/descriptor_pb.d.ts +1360 -1737
- package/dist/types/google/protobuf/duration_pb.d.ts +30 -50
- package/dist/types/google/protobuf/empty_pb.d.ts +9 -28
- package/dist/types/google/protobuf/field_mask_pb.d.ts +17 -37
- package/dist/types/google/protobuf/source_context_pb.d.ts +16 -35
- package/dist/types/google/protobuf/struct_pb.d.ts +64 -115
- package/dist/types/google/protobuf/timestamp_pb.d.ts +31 -51
- package/dist/types/google/protobuf/type_pb.d.ts +355 -422
- package/dist/types/google/protobuf/wrappers_pb.d.ts +181 -297
- package/dist/types/index.d.ts +4 -27
- package/dist/types/json-format.d.ts +70 -89
- package/dist/types/message-type.d.ts +38 -46
- package/dist/types/message.d.ts +73 -99
- package/dist/types/private/assert.d.ts +1 -4
- package/dist/types/private/binary-format-common.d.ts +6 -32
- package/dist/types/private/enum.d.ts +4 -11
- package/dist/types/private/field-list.d.ts +14 -21
- package/dist/types/private/field-wrapper.d.ts +5 -11
- package/dist/types/private/field.d.ts +12 -12
- package/dist/types/{google/varint.d.ts → private/goog-varint.d.ts} +6 -13
- package/dist/types/private/json-format-common.d.ts +5 -27
- package/dist/types/private/message-type.d.ts +3 -8
- package/dist/types/private/names.d.ts +1 -4
- package/dist/types/private/options-map.d.ts +1 -1
- package/dist/types/private/proto-runtime.d.ts +29 -42
- package/dist/types/private/scalars.d.ts +5 -12
- package/dist/types/private/util-common.d.ts +1 -4
- package/dist/types/private/util.d.ts +29 -41
- package/dist/types/proto-int64.d.ts +42 -42
- package/dist/types/service-type.d.ts +37 -57
- package/dist/types/type-registry.d.ts +13 -15
- package/package.json +2 -2
- package/dist/cjs/google/varint.js +0 -280
- package/dist/esm/google/varint.js +0 -265
|
@@ -5,98 +5,65 @@ const field_js_1 = require("../field.js");
|
|
|
5
5
|
const binary_format_common_js_1 = require("./binary-format-common.js");
|
|
6
6
|
/* eslint-disable @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unnecessary-condition, @typescript-eslint/strict-boolean-expressions, prefer-const, no-case-declarations */
|
|
7
7
|
function makeBinaryFormatProto3() {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
8
|
+
return {
|
|
9
|
+
...(0, binary_format_common_js_1.makeBinaryFormatCommon)(),
|
|
10
|
+
writeMessage(message, writer, options) {
|
|
11
|
+
const type = message.getType();
|
|
12
|
+
for (const field of type.fields.byNumber()) {
|
|
13
|
+
let value, // this will be our field value, whether it is member of a oneof or regular field
|
|
14
|
+
repeated = field.repeated, localName = field.localName;
|
|
15
|
+
if (field.oneof) {
|
|
16
|
+
const oneof = message[field.oneof.localName];
|
|
17
|
+
if (oneof.case !== localName) {
|
|
18
|
+
continue; // field is not selected, skip
|
|
19
|
+
}
|
|
20
|
+
value = oneof.value;
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
value = message[localName];
|
|
24
|
+
}
|
|
25
|
+
switch (field.kind) {
|
|
26
|
+
case "scalar":
|
|
27
|
+
case "enum":
|
|
28
|
+
let scalarType = field.kind == "enum" ? field_js_1.ScalarType.INT32 : field.T;
|
|
29
|
+
if (repeated) {
|
|
30
|
+
if (field.packed) {
|
|
31
|
+
(0, binary_format_common_js_1.writePacked)(writer, scalarType, field.no, value);
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
for (const item of value) {
|
|
35
|
+
(0, binary_format_common_js_1.writeScalar)(writer, scalarType, field.no, item, true);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
if (value !== undefined) {
|
|
41
|
+
(0, binary_format_common_js_1.writeScalar)(writer, scalarType, field.no, value, !!field.oneof || field.opt);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
break;
|
|
45
|
+
case "message":
|
|
46
|
+
if (repeated) {
|
|
47
|
+
for (const item of value) {
|
|
48
|
+
(0, binary_format_common_js_1.writeMessageField)(writer, options, field.T, field.no, item);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
(0, binary_format_common_js_1.writeMessageField)(writer, options, field.T, field.no, value);
|
|
53
|
+
}
|
|
54
|
+
break;
|
|
55
|
+
case "map":
|
|
56
|
+
for (const [key, val] of Object.entries(value)) {
|
|
57
|
+
(0, binary_format_common_js_1.writeMapEntry)(writer, options, field, key, val);
|
|
58
|
+
}
|
|
59
|
+
break;
|
|
47
60
|
}
|
|
48
|
-
}
|
|
49
|
-
} else {
|
|
50
|
-
if (value !== undefined) {
|
|
51
|
-
(0, binary_format_common_js_1.writeScalar)(
|
|
52
|
-
writer,
|
|
53
|
-
scalarType,
|
|
54
|
-
field.no,
|
|
55
|
-
value,
|
|
56
|
-
!!field.oneof || field.opt
|
|
57
|
-
);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
break;
|
|
61
|
-
case "message":
|
|
62
|
-
if (repeated) {
|
|
63
|
-
for (const item of value) {
|
|
64
|
-
(0, binary_format_common_js_1.writeMessageField)(
|
|
65
|
-
writer,
|
|
66
|
-
options,
|
|
67
|
-
field.T,
|
|
68
|
-
field.no,
|
|
69
|
-
item
|
|
70
|
-
);
|
|
71
|
-
}
|
|
72
|
-
} else {
|
|
73
|
-
(0, binary_format_common_js_1.writeMessageField)(
|
|
74
|
-
writer,
|
|
75
|
-
options,
|
|
76
|
-
field.T,
|
|
77
|
-
field.no,
|
|
78
|
-
value
|
|
79
|
-
);
|
|
80
61
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
for (const [key, val] of Object.entries(value)) {
|
|
84
|
-
(0, binary_format_common_js_1.writeMapEntry)(
|
|
85
|
-
writer,
|
|
86
|
-
options,
|
|
87
|
-
field,
|
|
88
|
-
key,
|
|
89
|
-
val
|
|
90
|
-
);
|
|
62
|
+
if (options.writeUnknownFields) {
|
|
63
|
+
this.writeUnknownFields(message, writer);
|
|
91
64
|
}
|
|
92
|
-
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
if (options.writeUnknownFields) {
|
|
96
|
-
this.writeUnknownFields(message, writer);
|
|
97
|
-
}
|
|
98
|
-
return writer;
|
|
99
|
-
},
|
|
100
|
-
};
|
|
65
|
+
return writer;
|
|
66
|
+
},
|
|
67
|
+
};
|
|
101
68
|
}
|
|
102
69
|
exports.makeBinaryFormatProto3 = makeBinaryFormatProto3;
|
package/dist/cjs/private/enum.js
CHANGED
|
@@ -9,26 +9,23 @@ const enumTypeSymbol = Symbol("@bufbuild/protobuf/enum-type");
|
|
|
9
9
|
* enum, it raises an error.
|
|
10
10
|
*/
|
|
11
11
|
function getEnumType(enumObject) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-explicit-any
|
|
13
|
+
const t = enumObject[enumTypeSymbol];
|
|
14
|
+
(0, assert_js_1.assert)(t, "missing enum type on enum object");
|
|
15
|
+
return t; // eslint-disable-line @typescript-eslint/no-unsafe-return
|
|
16
16
|
}
|
|
17
17
|
exports.getEnumType = getEnumType;
|
|
18
18
|
/**
|
|
19
19
|
* Sets reflection information on a generated enum.
|
|
20
20
|
*/
|
|
21
|
-
function setEnumType(
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
// opt?: {
|
|
27
|
-
// options?: { readonly [extensionName: string]: JsonValue };
|
|
28
|
-
// },
|
|
21
|
+
function setEnumType(enumObject, typeName, values
|
|
22
|
+
// We do not surface options at this time
|
|
23
|
+
// opt?: {
|
|
24
|
+
// options?: { readonly [extensionName: string]: JsonValue };
|
|
25
|
+
// },
|
|
29
26
|
) {
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any
|
|
28
|
+
enumObject[enumTypeSymbol] = makeEnumType(typeName, values);
|
|
32
29
|
}
|
|
33
30
|
exports.setEnumType = setEnumType;
|
|
34
31
|
// We do not surface options at this time
|
|
@@ -36,35 +33,33 @@ exports.setEnumType = setEnumType;
|
|
|
36
33
|
/**
|
|
37
34
|
* Create a new EnumType with the given values.
|
|
38
35
|
*/
|
|
39
|
-
function makeEnumType(
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
// options?: { readonly [extensionName: string]: JsonValue };
|
|
45
|
-
// },
|
|
36
|
+
function makeEnumType(typeName, values
|
|
37
|
+
// We do not surface options at this time
|
|
38
|
+
// opt?: {
|
|
39
|
+
// options?: { readonly [extensionName: string]: JsonValue };
|
|
40
|
+
// },
|
|
46
41
|
) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
42
|
+
const names = Object.create(null);
|
|
43
|
+
const numbers = Object.create(null);
|
|
44
|
+
const normalValues = [];
|
|
45
|
+
for (const value of values) {
|
|
46
|
+
// We do not surface options at this time
|
|
47
|
+
// const value: EnumValueInfo = {...v, options: v.options ?? emptyReadonlyObject};
|
|
48
|
+
normalValues.push(value);
|
|
49
|
+
names[value.name] = value;
|
|
50
|
+
numbers[value.no] = value;
|
|
51
|
+
}
|
|
52
|
+
return {
|
|
53
|
+
typeName,
|
|
54
|
+
values: normalValues,
|
|
55
|
+
// We do not surface options at this time
|
|
56
|
+
// options: opt?.options ?? Object.create(null),
|
|
57
|
+
findName(name) {
|
|
58
|
+
return names[name];
|
|
59
|
+
},
|
|
60
|
+
findNumber(no) {
|
|
61
|
+
return numbers[no];
|
|
62
|
+
},
|
|
63
|
+
};
|
|
69
64
|
}
|
|
70
65
|
exports.makeEnumType = makeEnumType;
|
|
@@ -2,61 +2,62 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.InternalFieldList = void 0;
|
|
4
4
|
class InternalFieldList {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
findJsonName(jsonName) {
|
|
10
|
-
if (!this.jsonNames) {
|
|
11
|
-
const t = {};
|
|
12
|
-
for (const f of this.list()) {
|
|
13
|
-
t[f.jsonName] = t[f.name] = f;
|
|
14
|
-
}
|
|
15
|
-
this.jsonNames = t;
|
|
5
|
+
constructor(fields, normalizer) {
|
|
6
|
+
this._fields = fields;
|
|
7
|
+
this._normalizer = normalizer;
|
|
16
8
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
9
|
+
findJsonName(jsonName) {
|
|
10
|
+
if (!this.jsonNames) {
|
|
11
|
+
const t = {};
|
|
12
|
+
for (const f of this.list()) {
|
|
13
|
+
t[f.jsonName] = t[f.name] = f;
|
|
14
|
+
}
|
|
15
|
+
this.jsonNames = t;
|
|
16
|
+
}
|
|
17
|
+
return this.jsonNames[jsonName];
|
|
26
18
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
19
|
+
find(fieldNo) {
|
|
20
|
+
if (!this.numbers) {
|
|
21
|
+
const t = {};
|
|
22
|
+
for (const f of this.list()) {
|
|
23
|
+
t[f.no] = f;
|
|
24
|
+
}
|
|
25
|
+
this.numbers = t;
|
|
26
|
+
}
|
|
27
|
+
return this.numbers[fieldNo];
|
|
32
28
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
29
|
+
list() {
|
|
30
|
+
if (!this.all) {
|
|
31
|
+
this.all = this._normalizer(this._fields);
|
|
32
|
+
}
|
|
33
|
+
return this.all;
|
|
34
|
+
}
|
|
35
|
+
byNumber() {
|
|
36
|
+
if (!this.numbersAsc) {
|
|
37
|
+
this.numbersAsc = this.list()
|
|
38
|
+
.concat()
|
|
39
|
+
.sort((a, b) => a.no - b.no);
|
|
40
|
+
}
|
|
41
|
+
return this.numbersAsc;
|
|
40
42
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
43
|
+
byMember() {
|
|
44
|
+
if (!this.members) {
|
|
45
|
+
this.members = [];
|
|
46
|
+
const a = this.members;
|
|
47
|
+
let o;
|
|
48
|
+
for (const f of this.list()) {
|
|
49
|
+
if (f.oneof) {
|
|
50
|
+
if (f.oneof !== o) {
|
|
51
|
+
o = f.oneof;
|
|
52
|
+
a.push(o);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
a.push(f);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
56
59
|
}
|
|
57
|
-
|
|
60
|
+
return this.members;
|
|
58
61
|
}
|
|
59
|
-
return this.members;
|
|
60
|
-
}
|
|
61
62
|
}
|
|
62
63
|
exports.InternalFieldList = InternalFieldList;
|
|
@@ -5,21 +5,19 @@ exports.unwrapField = exports.wrapField = void 0;
|
|
|
5
5
|
* Wrap field values whose message type has a wrapper.
|
|
6
6
|
*/
|
|
7
7
|
function wrapField(type, value) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
`cannot unwrap field value, ${type.typeName} does not define a field wrapper`
|
|
16
|
-
);
|
|
8
|
+
if (value instanceof type) {
|
|
9
|
+
return value;
|
|
10
|
+
}
|
|
11
|
+
if (type.fieldWrapper) {
|
|
12
|
+
return type.fieldWrapper.wrapField(value);
|
|
13
|
+
}
|
|
14
|
+
throw new Error(`cannot unwrap field value, ${type.typeName} does not define a field wrapper`);
|
|
17
15
|
}
|
|
18
16
|
exports.wrapField = wrapField;
|
|
19
17
|
/**
|
|
20
18
|
* Unwrap field values whose message type has a wrapper.
|
|
21
19
|
*/
|
|
22
20
|
function unwrapField(type, value) {
|
|
23
|
-
|
|
21
|
+
return type.fieldWrapper ? type.fieldWrapper.unwrapField(value) : value;
|
|
24
22
|
}
|
|
25
23
|
exports.unwrapField = unwrapField;
|
|
@@ -4,31 +4,28 @@ exports.InternalOneofInfo = void 0;
|
|
|
4
4
|
const names_js_1 = require("./names.js");
|
|
5
5
|
const assert_js_1 = require("./assert.js");
|
|
6
6
|
class InternalOneofInfo {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
)
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
this._lookup[
|
|
29
|
-
}
|
|
7
|
+
constructor(name) {
|
|
8
|
+
this.kind = "oneof";
|
|
9
|
+
this.repeated = false;
|
|
10
|
+
this.packed = false;
|
|
11
|
+
this.opt = false;
|
|
12
|
+
this.default = undefined;
|
|
13
|
+
this.fields = [];
|
|
14
|
+
this.name = name;
|
|
15
|
+
this.localName = (0, names_js_1.makeOneofName)(name);
|
|
16
|
+
}
|
|
17
|
+
addField(field) {
|
|
18
|
+
(0, assert_js_1.assert)(field.oneof === this, `field ${field.name} not one of ${this.name}`);
|
|
19
|
+
this.fields.push(field);
|
|
20
|
+
}
|
|
21
|
+
findField(localName) {
|
|
22
|
+
if (!this._lookup) {
|
|
23
|
+
this._lookup = Object.create(null);
|
|
24
|
+
for (let i = 0; i < this.fields.length; i++) {
|
|
25
|
+
this._lookup[this.fields[i].localName] = this.fields[i];
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return this._lookup[localName];
|
|
30
29
|
}
|
|
31
|
-
return this._lookup[localName];
|
|
32
|
-
}
|
|
33
30
|
}
|
|
34
31
|
exports.InternalOneofInfo = InternalOneofInfo;
|