@bufbuild/protoplugin 1.9.0 → 2.0.0-alpha.2

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.
Files changed (77) hide show
  1. package/dist/cjs/create-es-plugin.d.ts +7 -11
  2. package/dist/cjs/create-es-plugin.js +15 -13
  3. package/dist/cjs/ecmascript/file-preamble.js +11 -7
  4. package/dist/cjs/ecmascript/generated-file.d.ts +19 -20
  5. package/dist/cjs/ecmascript/generated-file.js +95 -108
  6. package/dist/cjs/ecmascript/import-path.d.ts +0 -6
  7. package/dist/cjs/ecmascript/import-path.js +1 -22
  8. package/dist/cjs/ecmascript/import-symbol.d.ts +1 -3
  9. package/dist/cjs/ecmascript/import-symbol.js +3 -5
  10. package/dist/cjs/ecmascript/index.d.ts +3 -16
  11. package/dist/cjs/ecmascript/index.js +3 -29
  12. package/dist/cjs/ecmascript/jsdoc.d.ts +2 -13
  13. package/dist/cjs/ecmascript/jsdoc.js +39 -35
  14. package/dist/cjs/ecmascript/names.d.ts +4 -0
  15. package/dist/cjs/ecmascript/names.js +119 -0
  16. package/dist/cjs/ecmascript/parameter.d.ts +1 -1
  17. package/dist/cjs/ecmascript/parameter.js +3 -3
  18. package/dist/cjs/ecmascript/printable.d.ts +36 -0
  19. package/dist/cjs/ecmascript/runtime-imports.d.ts +12 -23
  20. package/dist/cjs/ecmascript/runtime-imports.js +28 -29
  21. package/dist/cjs/ecmascript/safe-identifier.d.ts +6 -0
  22. package/dist/cjs/ecmascript/safe-identifier.js +90 -0
  23. package/dist/cjs/ecmascript/schema.d.ts +9 -8
  24. package/dist/cjs/ecmascript/schema.js +72 -20
  25. package/dist/cjs/index.d.ts +1 -5
  26. package/dist/cjs/index.js +6 -1
  27. package/dist/cjs/plugin.d.ts +1 -1
  28. package/dist/cjs/run-node.js +4 -3
  29. package/dist/cjs/source-code-info.d.ts +23 -0
  30. package/dist/cjs/source-code-info.js +286 -0
  31. package/dist/esm/create-es-plugin.d.ts +7 -11
  32. package/dist/esm/create-es-plugin.js +15 -13
  33. package/dist/esm/ecmascript/file-preamble.js +8 -4
  34. package/dist/esm/ecmascript/generated-file.d.ts +19 -20
  35. package/dist/esm/ecmascript/generated-file.js +97 -110
  36. package/dist/esm/ecmascript/import-path.d.ts +0 -6
  37. package/dist/esm/ecmascript/import-path.js +0 -20
  38. package/dist/esm/ecmascript/import-symbol.d.ts +1 -3
  39. package/dist/esm/ecmascript/import-symbol.js +3 -5
  40. package/dist/esm/ecmascript/index.d.ts +3 -16
  41. package/dist/esm/ecmascript/index.js +1 -18
  42. package/dist/esm/ecmascript/jsdoc.d.ts +2 -13
  43. package/dist/esm/ecmascript/jsdoc.js +36 -33
  44. package/dist/esm/ecmascript/names.d.ts +4 -0
  45. package/dist/esm/ecmascript/names.js +113 -0
  46. package/dist/esm/ecmascript/parameter.d.ts +1 -1
  47. package/dist/esm/ecmascript/parameter.js +3 -3
  48. package/dist/esm/ecmascript/printable.d.ts +36 -0
  49. package/dist/esm/ecmascript/{opaque-printables.js → printable.js} +1 -1
  50. package/dist/esm/ecmascript/runtime-imports.d.ts +12 -23
  51. package/dist/esm/ecmascript/runtime-imports.js +28 -29
  52. package/dist/esm/ecmascript/safe-identifier.d.ts +6 -0
  53. package/dist/esm/ecmascript/safe-identifier.js +86 -0
  54. package/dist/esm/ecmascript/schema.d.ts +9 -8
  55. package/dist/esm/ecmascript/schema.js +74 -22
  56. package/dist/esm/index.d.ts +1 -5
  57. package/dist/esm/index.js +1 -0
  58. package/dist/esm/plugin.d.ts +1 -1
  59. package/dist/esm/run-node.js +4 -3
  60. package/dist/esm/source-code-info.d.ts +23 -0
  61. package/dist/esm/source-code-info.js +278 -0
  62. package/package.json +2 -2
  63. package/dist/cjs/ecmascript/legacy-custom-options.d.ts +0 -40
  64. package/dist/cjs/ecmascript/legacy-custom-options.js +0 -121
  65. package/dist/cjs/ecmascript/legacy-gencommon.d.ts +0 -25
  66. package/dist/cjs/ecmascript/legacy-gencommon.js +0 -237
  67. package/dist/cjs/ecmascript/opaque-printables.d.ts +0 -27
  68. package/dist/cjs/ecmascript/reify-wkt.d.ts +0 -100
  69. package/dist/cjs/ecmascript/reify-wkt.js +0 -170
  70. package/dist/esm/ecmascript/legacy-custom-options.d.ts +0 -40
  71. package/dist/esm/ecmascript/legacy-custom-options.js +0 -115
  72. package/dist/esm/ecmascript/legacy-gencommon.d.ts +0 -25
  73. package/dist/esm/ecmascript/legacy-gencommon.js +0 -230
  74. package/dist/esm/ecmascript/opaque-printables.d.ts +0 -27
  75. package/dist/esm/ecmascript/reify-wkt.d.ts +0 -100
  76. package/dist/esm/ecmascript/reify-wkt.js +0 -166
  77. /package/dist/cjs/ecmascript/{opaque-printables.js → printable.js} +0 -0
@@ -0,0 +1,278 @@
1
+ // Copyright 2021-2024 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 { isFieldSet, } from "@bufbuild/protobuf";
15
+ import { protoCamelCase, reflect, ScalarType, } from "@bufbuild/protobuf/reflect";
16
+ import { Edition, FieldDescriptorProto_Label, FieldDescriptorProto_Type, FieldDescriptorProtoDesc, FieldOptions_JSType, FieldOptionsDesc, FeatureSetDesc, SourceCodeInfo_LocationDesc, FileDescriptorProtoDesc, DescriptorProtoDesc, EnumDescriptorProtoDesc, ServiceDescriptorProtoDesc, } from "@bufbuild/protobuf/wkt";
17
+ /**
18
+ * Get comments on the package element in the protobuf source.
19
+ */
20
+ export function getPackageComments(desc) {
21
+ return findComments(desc.proto.sourceCodeInfo, [
22
+ FileDescriptorProtoDesc.field.package.number,
23
+ ]);
24
+ }
25
+ /**
26
+ * Get comments on the syntax element in the protobuf source.
27
+ */
28
+ export function getSyntaxComments(desc) {
29
+ return findComments(desc.proto.sourceCodeInfo, [
30
+ FileDescriptorProtoDesc.field.syntax.number,
31
+ ]);
32
+ }
33
+ /**
34
+ * Get comments on the element in the protobuf source.
35
+ */
36
+ export function getComments(desc) {
37
+ let path = [];
38
+ let file;
39
+ switch (desc.kind) {
40
+ case "enum":
41
+ path = desc.parent
42
+ ? [
43
+ ...getComments(desc.parent).sourcePath,
44
+ DescriptorProtoDesc.field.enumType.number,
45
+ desc.parent.proto.enumType.indexOf(desc.proto),
46
+ ]
47
+ : [
48
+ FileDescriptorProtoDesc.field.enumType.number,
49
+ desc.file.proto.enumType.indexOf(desc.proto),
50
+ ];
51
+ file = desc.file;
52
+ break;
53
+ case "oneof":
54
+ path = [
55
+ ...getComments(desc.parent).sourcePath,
56
+ DescriptorProtoDesc.field.oneofDecl.number,
57
+ desc.parent.proto.oneofDecl.indexOf(desc.proto),
58
+ ];
59
+ file = desc.parent.file;
60
+ break;
61
+ case "message":
62
+ path = desc.parent
63
+ ? [
64
+ ...getComments(desc.parent).sourcePath,
65
+ DescriptorProtoDesc.field.nestedType.number,
66
+ desc.parent.proto.nestedType.indexOf(desc.proto),
67
+ ]
68
+ : [
69
+ FileDescriptorProtoDesc.field.messageType.number,
70
+ desc.file.proto.messageType.indexOf(desc.proto),
71
+ ];
72
+ file = desc.file;
73
+ break;
74
+ case "enum_value":
75
+ path = [
76
+ ...getComments(desc.parent).sourcePath,
77
+ EnumDescriptorProtoDesc.field.value.number,
78
+ desc.parent.proto.value.indexOf(desc.proto),
79
+ ];
80
+ file = desc.parent.file;
81
+ break;
82
+ case "field":
83
+ path = [
84
+ ...getComments(desc.parent).sourcePath,
85
+ DescriptorProtoDesc.field.field.number,
86
+ desc.parent.proto.field.indexOf(desc.proto),
87
+ ];
88
+ file = desc.parent.file;
89
+ break;
90
+ case "extension":
91
+ path = desc.parent
92
+ ? [
93
+ ...getComments(desc.parent).sourcePath,
94
+ DescriptorProtoDesc.field.extension.number,
95
+ desc.parent.proto.extension.indexOf(desc.proto),
96
+ ]
97
+ : [
98
+ FileDescriptorProtoDesc.field.extension.number,
99
+ desc.file.proto.extension.indexOf(desc.proto),
100
+ ];
101
+ file = desc.file;
102
+ break;
103
+ case "service":
104
+ path = [
105
+ FileDescriptorProtoDesc.field.service.number,
106
+ desc.file.proto.service.indexOf(desc.proto),
107
+ ];
108
+ file = desc.file;
109
+ break;
110
+ case "rpc":
111
+ path = [
112
+ ...getComments(desc.parent).sourcePath,
113
+ ServiceDescriptorProtoDesc.field.method.number,
114
+ desc.parent.proto.method.indexOf(desc.proto),
115
+ ];
116
+ file = desc.parent.file;
117
+ break;
118
+ }
119
+ return findComments(file.proto.sourceCodeInfo, path);
120
+ }
121
+ /**
122
+ * Get feature options set on the element in the protobuf source. This returns
123
+ * compact (e.g. fields) or regular options (e.g. files) as an array of strings.
124
+ */
125
+ export function getFeatureOptionStrings(desc) {
126
+ var _a, _b;
127
+ const strings = [];
128
+ const features = (_a = desc.proto.options) === null || _a === void 0 ? void 0 : _a.features;
129
+ if (features !== undefined) {
130
+ const r = reflect(FeatureSetDesc, features);
131
+ for (const f of r.fields) {
132
+ if (f.fieldKind != "enum" || !r.isSet(f)) {
133
+ continue;
134
+ }
135
+ const val = r.get(f);
136
+ const name = (_b = f.enum.values.find((v) => v.number == val)) === null || _b === void 0 ? void 0 : _b.name;
137
+ if (name !== undefined) {
138
+ strings.push(`features.${f.name} = ${name}`);
139
+ }
140
+ }
141
+ }
142
+ return strings;
143
+ }
144
+ /**
145
+ * Return a string that matches the definition of a field in the protobuf
146
+ * source. Does not take custom options into account.
147
+ */
148
+ export function getDeclarationString(desc) {
149
+ var _a;
150
+ if (desc.kind === "enum_value") {
151
+ let str = `${desc.name} = ${desc.number}`;
152
+ if (((_a = desc.proto.options) === null || _a === void 0 ? void 0 : _a.deprecated) === true) {
153
+ str += " [deprecated = true]";
154
+ }
155
+ return str;
156
+ }
157
+ const parts = [];
158
+ function typeName(f) {
159
+ if (f.message) {
160
+ return f.message.typeName;
161
+ }
162
+ if (f.enum) {
163
+ return f.enum.typeName;
164
+ }
165
+ return ScalarType[f.scalar].toLowerCase();
166
+ }
167
+ switch (desc.fieldKind) {
168
+ case "scalar":
169
+ case "enum":
170
+ case "message":
171
+ if (fieldHasRequiredKeyword(desc)) {
172
+ parts.push("required");
173
+ }
174
+ if (fieldHasOptionalKeyword(desc)) {
175
+ parts.push("optional");
176
+ }
177
+ parts.push(typeName(desc));
178
+ break;
179
+ case "list":
180
+ parts.push("repeated", typeName(desc));
181
+ break;
182
+ case "map": {
183
+ const k = ScalarType[desc.mapKey].toLowerCase();
184
+ const v = typeName(desc);
185
+ parts.push(`map<${k}, ${v}>`);
186
+ break;
187
+ }
188
+ }
189
+ parts.push(desc.name, "=", desc.number.toString());
190
+ const options = [];
191
+ const protoOptions = desc.proto.options;
192
+ if (protoOptions !== undefined &&
193
+ isFieldSet(protoOptions, FieldOptionsDesc.field.packed)) {
194
+ options.push(`packed = ${protoOptions.packed.toString()}`);
195
+ }
196
+ if (isFieldSet(desc.proto, FieldDescriptorProtoDesc.field.defaultValue)) {
197
+ let defaultValue = desc.proto.defaultValue;
198
+ if (desc.proto.type == FieldDescriptorProto_Type.BYTES ||
199
+ desc.proto.type == FieldDescriptorProto_Type.STRING) {
200
+ defaultValue = '"' + defaultValue.replace('"', '\\"') + '"';
201
+ }
202
+ options.push(`default = ${defaultValue}`);
203
+ }
204
+ if (desc.kind == "field" && desc.jsonName !== protoCamelCase(desc.name)) {
205
+ options.push(`json_name = "${desc.jsonName}"`);
206
+ }
207
+ if (protoOptions !== undefined &&
208
+ isFieldSet(protoOptions, FieldOptionsDesc.field.jstype)) {
209
+ options.push(`jstype = ${FieldOptions_JSType[protoOptions.jstype]}`);
210
+ }
211
+ if (protoOptions !== undefined &&
212
+ isFieldSet(protoOptions, FieldOptionsDesc.field.deprecated)) {
213
+ options.push(`deprecated = true`);
214
+ }
215
+ options.push(...getFeatureOptionStrings(desc));
216
+ if (options.length > 0) {
217
+ parts.push("[" + options.join(", ") + "]");
218
+ }
219
+ return parts.join(" ");
220
+ }
221
+ /**
222
+ * Whether this field was declared with `required` in the protobuf source.
223
+ */
224
+ function fieldHasRequiredKeyword(field) {
225
+ const edition = (field.kind == "extension" ? field.file : field.parent.file)
226
+ .edition;
227
+ return (edition == Edition.EDITION_PROTO2 &&
228
+ field.proto.label == FieldDescriptorProto_Label.REQUIRED);
229
+ }
230
+ /**
231
+ * Whether this field was declared with `optional` in the protobuf source.
232
+ * Note that message fields are always optional. It is impossible to determine
233
+ * whether the keyword was used.
234
+ */
235
+ function fieldHasOptionalKeyword(field) {
236
+ const edition = (field.kind == "extension" ? field.file : field.parent.file)
237
+ .edition;
238
+ if (edition == Edition.EDITION_PROTO2) {
239
+ return (!field.oneof && field.proto.label == FieldDescriptorProto_Label.OPTIONAL);
240
+ }
241
+ if (edition == Edition.EDITION_PROTO3) {
242
+ return field.proto.proto3Optional;
243
+ }
244
+ return false;
245
+ }
246
+ /**
247
+ * Find comments.
248
+ */
249
+ function findComments(sourceCodeInfo, sourcePath) {
250
+ if (!sourceCodeInfo) {
251
+ return {
252
+ leadingDetached: [],
253
+ sourcePath,
254
+ };
255
+ }
256
+ for (const location of sourceCodeInfo.location) {
257
+ if (location.path.length !== sourcePath.length) {
258
+ continue;
259
+ }
260
+ if (location.path.some((value, index) => sourcePath[index] !== value)) {
261
+ continue;
262
+ }
263
+ return {
264
+ leadingDetached: location.leadingDetachedComments,
265
+ leading: isFieldSet(location, SourceCodeInfo_LocationDesc.field.leadingComments)
266
+ ? location.leadingComments
267
+ : undefined,
268
+ trailing: isFieldSet(location, SourceCodeInfo_LocationDesc.field.trailingComments)
269
+ ? location.trailingComments
270
+ : undefined,
271
+ sourcePath,
272
+ };
273
+ }
274
+ return {
275
+ leadingDetached: [],
276
+ sourcePath,
277
+ };
278
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bufbuild/protoplugin",
3
- "version": "1.9.0",
3
+ "version": "2.0.0-alpha.2",
4
4
  "license": "(Apache-2.0 AND BSD-3-Clause)",
5
5
  "description": "Helps to create your own Protocol Buffers code generators.",
6
6
  "repository": {
@@ -36,7 +36,7 @@
36
36
  }
37
37
  },
38
38
  "dependencies": {
39
- "@bufbuild/protobuf": "1.9.0",
39
+ "@bufbuild/protobuf": "2.0.0-alpha.2",
40
40
  "@typescript/vfs": "^1.4.0",
41
41
  "typescript": "4.5.2"
42
42
  },
@@ -1,40 +0,0 @@
1
- import type { AnyDesc, MessageType } from "@bufbuild/protobuf";
2
- import { Message, ScalarType } from "@bufbuild/protobuf";
3
- /**
4
- * @deprecated Please use extensions instead.
5
- *
6
- * Returns the value of a custom option with a scalar type.
7
- *
8
- * If no option is found, returns undefined.
9
- */
10
- export declare function findCustomScalarOption<T extends ScalarType>(desc: AnyDesc, extensionNumber: number, scalarType: T): ScalarValue<T> | undefined;
11
- /**
12
- * @deprecated Please use extensions instead.
13
- *
14
- * Returns the value of a custom message option for the given descriptor and
15
- * extension number.
16
- * The msgType param is then used to deserialize the message for returning to
17
- * the caller.
18
- *
19
- * If no options are found, returns undefined.
20
- *
21
- * If the message option is unable to be read or deserialized, an error will
22
- * be thrown.
23
- */
24
- export declare function findCustomMessageOption<T extends Message<T>>(desc: AnyDesc, extensionNumber: number, msgType: MessageType<T>): T | undefined;
25
- /**
26
- * @deprecated Please use extensions instead.
27
- *
28
- * Returns the value of a custom enum option for the given descriptor and
29
- * extension number.
30
- *
31
- * If no options are found, returns undefined.
32
- */
33
- export declare function findCustomEnumOption(desc: AnyDesc, extensionNumber: number): number | undefined;
34
- /**
35
- * @deprecated Please use extensions instead.
36
- *
37
- * ScalarValue is a conditional type that pairs a ScalarType value with its concrete type.
38
- */
39
- type ScalarValue<T> = T extends ScalarType.STRING ? string : T extends ScalarType.INT32 ? number : T extends ScalarType.UINT32 ? number : T extends ScalarType.UINT32 ? number : T extends ScalarType.SINT32 ? number : T extends ScalarType.FIXED32 ? number : T extends ScalarType.SFIXED32 ? number : T extends ScalarType.FLOAT ? number : T extends ScalarType.DOUBLE ? number : T extends ScalarType.INT64 ? bigint | string : T extends ScalarType.SINT64 ? bigint | string : T extends ScalarType.SFIXED64 ? bigint | string : T extends ScalarType.UINT64 ? bigint | string : T extends ScalarType.FIXED64 ? bigint | string : T extends ScalarType.BOOL ? boolean : T extends ScalarType.BYTES ? Uint8Array : never;
40
- export {};
@@ -1,121 +0,0 @@
1
- "use strict";
2
- // Copyright 2021-2024 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.findCustomEnumOption = exports.findCustomMessageOption = exports.findCustomScalarOption = void 0;
17
- const protobuf_1 = require("@bufbuild/protobuf");
18
- /**
19
- * @deprecated Please use extensions instead.
20
- *
21
- * Returns the value of a custom option with a scalar type.
22
- *
23
- * If no option is found, returns undefined.
24
- */
25
- function findCustomScalarOption(desc, extensionNumber, scalarType) {
26
- const reader = createBinaryReader(desc, extensionNumber);
27
- if (reader) {
28
- switch (scalarType) {
29
- case protobuf_1.ScalarType.INT32:
30
- return reader.int32();
31
- case protobuf_1.ScalarType.UINT32:
32
- return reader.uint32();
33
- case protobuf_1.ScalarType.SINT32:
34
- return reader.sint32();
35
- case protobuf_1.ScalarType.FIXED32:
36
- return reader.fixed32();
37
- case protobuf_1.ScalarType.SFIXED32:
38
- return reader.sfixed32();
39
- case protobuf_1.ScalarType.FLOAT:
40
- return reader.float();
41
- case protobuf_1.ScalarType.DOUBLE:
42
- return reader.double();
43
- case protobuf_1.ScalarType.INT64:
44
- return reader.int64();
45
- case protobuf_1.ScalarType.SINT64:
46
- return reader.sint64();
47
- case protobuf_1.ScalarType.SFIXED64:
48
- return reader.sfixed64();
49
- case protobuf_1.ScalarType.UINT64:
50
- return reader.uint64();
51
- case protobuf_1.ScalarType.FIXED64:
52
- return reader.fixed64();
53
- case protobuf_1.ScalarType.BOOL:
54
- return reader.bool();
55
- case protobuf_1.ScalarType.BYTES:
56
- return reader.bytes();
57
- case protobuf_1.ScalarType.STRING:
58
- return reader.string();
59
- default: {
60
- break;
61
- }
62
- }
63
- }
64
- return undefined;
65
- }
66
- exports.findCustomScalarOption = findCustomScalarOption;
67
- /**
68
- * @deprecated Please use extensions instead.
69
- *
70
- * Returns the value of a custom message option for the given descriptor and
71
- * extension number.
72
- * The msgType param is then used to deserialize the message for returning to
73
- * the caller.
74
- *
75
- * If no options are found, returns undefined.
76
- *
77
- * If the message option is unable to be read or deserialized, an error will
78
- * be thrown.
79
- */
80
- function findCustomMessageOption(desc, extensionNumber, msgType) {
81
- const reader = createBinaryReader(desc, extensionNumber);
82
- if (reader) {
83
- try {
84
- const data = reader.bytes();
85
- return msgType.fromBinary(data);
86
- }
87
- catch (e) {
88
- const innerMessage = e instanceof Error ? e.message : String(e);
89
- throw new Error(`failed to access message option: ${innerMessage}`);
90
- }
91
- }
92
- return undefined;
93
- }
94
- exports.findCustomMessageOption = findCustomMessageOption;
95
- /**
96
- * @deprecated Please use extensions instead.
97
- *
98
- * Returns the value of a custom enum option for the given descriptor and
99
- * extension number.
100
- *
101
- * If no options are found, returns undefined.
102
- */
103
- function findCustomEnumOption(desc, extensionNumber) {
104
- return findCustomScalarOption(desc, extensionNumber, protobuf_1.ScalarType.INT32);
105
- }
106
- exports.findCustomEnumOption = findCustomEnumOption;
107
- /**
108
- * Returns a binary reader for the given descriptor and extension number.
109
- */
110
- function createBinaryReader(desc, extensionNumber) {
111
- const opt = desc.proto.options;
112
- let reader = undefined;
113
- if (opt !== undefined) {
114
- const unknownFields = protobuf_1.proto3.bin.listUnknownFields(opt);
115
- const field = unknownFields.find((f) => f.no === extensionNumber);
116
- if (field) {
117
- reader = new protobuf_1.BinaryReader(field.data);
118
- }
119
- }
120
- return reader;
121
- }
@@ -1,25 +0,0 @@
1
- import type { DescExtension, DescField } from "@bufbuild/protobuf";
2
- import type { GeneratedFile, Printable } from "./generated-file.js";
3
- import type { ImportSymbol } from "./import-symbol.js";
4
- /**
5
- * @deprecated Please use GeneratedFile.string() instead
6
- */
7
- export declare function literalString(value: string): string;
8
- /**
9
- * @deprecated
10
- */
11
- export declare function getFieldTyping(field: DescField | DescExtension, file: GeneratedFile): {
12
- typing: Printable;
13
- optional: boolean;
14
- };
15
- /**
16
- * @deprecated
17
- */
18
- export declare function getFieldExplicitDefaultValue(field: DescField | DescExtension, protoInt64Symbol: ImportSymbol): Printable | undefined;
19
- /**
20
- * @deprecated
21
- */
22
- export declare function getFieldIntrinsicDefaultValue(field: DescField): {
23
- defaultValue: Printable | undefined;
24
- typingInferrable: boolean;
25
- };