@bufbuild/protobuf 2.12.1 → 2.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/README.md +2 -2
  2. package/dist/commonjs/codegenv1/symbols.d.ts +5 -0
  3. package/dist/commonjs/codegenv2/enum.d.ts +15 -4
  4. package/dist/commonjs/codegenv2/enum.js +18 -0
  5. package/dist/commonjs/codegenv2/symbols.d.ts +10 -0
  6. package/dist/commonjs/codegenv2/symbols.js +2 -0
  7. package/dist/commonjs/create.js +3 -3
  8. package/dist/commonjs/descriptors.d.ts +2 -2
  9. package/dist/commonjs/index.d.ts +1 -0
  10. package/dist/commonjs/index.js +1 -0
  11. package/dist/commonjs/reflect/reflect.js +3 -2
  12. package/dist/commonjs/reflect/unsafe.js +1 -1
  13. package/dist/commonjs/registry.js +19 -19
  14. package/dist/commonjs/to-binary.js +1 -1
  15. package/dist/commonjs/to-json.js +2 -2
  16. package/dist/commonjs/txtpb/from-text.d.ts +35 -0
  17. package/dist/commonjs/txtpb/from-text.js +684 -0
  18. package/dist/commonjs/txtpb/index.d.ts +4 -0
  19. package/dist/commonjs/txtpb/index.js +21 -0
  20. package/dist/commonjs/txtpb/is-group-like.d.ts +19 -0
  21. package/dist/commonjs/txtpb/is-group-like.js +47 -0
  22. package/dist/commonjs/txtpb/reader.d.ts +91 -0
  23. package/dist/commonjs/txtpb/reader.js +481 -0
  24. package/dist/commonjs/txtpb/to-text.d.ts +34 -0
  25. package/dist/commonjs/txtpb/to-text.js +358 -0
  26. package/dist/commonjs/txtpb/writer.d.ts +76 -0
  27. package/dist/commonjs/txtpb/writer.js +220 -0
  28. package/dist/commonjs/types.d.ts +7 -0
  29. package/dist/commonjs/unknown-enum.d.ts +10 -0
  30. package/dist/commonjs/unknown-enum.js +26 -0
  31. package/dist/commonjs/wire/size-delimited.d.ts +19 -1
  32. package/dist/commonjs/wire/size-delimited.js +54 -16
  33. package/dist/esm/codegenv1/symbols.d.ts +5 -0
  34. package/dist/esm/codegenv2/enum.d.ts +15 -4
  35. package/dist/esm/codegenv2/enum.js +17 -0
  36. package/dist/esm/codegenv2/symbols.d.ts +10 -0
  37. package/dist/esm/codegenv2/symbols.js +2 -0
  38. package/dist/esm/create.js +3 -3
  39. package/dist/esm/descriptors.d.ts +2 -2
  40. package/dist/esm/index.d.ts +1 -0
  41. package/dist/esm/index.js +1 -0
  42. package/dist/esm/reflect/reflect.js +3 -2
  43. package/dist/esm/reflect/unsafe.js +1 -1
  44. package/dist/esm/registry.js +19 -19
  45. package/dist/esm/to-binary.js +1 -1
  46. package/dist/esm/to-json.js +2 -2
  47. package/dist/esm/txtpb/from-text.d.ts +35 -0
  48. package/dist/esm/txtpb/from-text.js +680 -0
  49. package/dist/esm/txtpb/index.d.ts +4 -0
  50. package/dist/esm/txtpb/index.js +15 -0
  51. package/dist/esm/txtpb/is-group-like.d.ts +19 -0
  52. package/dist/esm/txtpb/is-group-like.js +44 -0
  53. package/dist/esm/txtpb/reader.d.ts +91 -0
  54. package/dist/esm/txtpb/reader.js +477 -0
  55. package/dist/esm/txtpb/to-text.d.ts +34 -0
  56. package/dist/esm/txtpb/to-text.js +355 -0
  57. package/dist/esm/txtpb/writer.d.ts +76 -0
  58. package/dist/esm/txtpb/writer.js +214 -0
  59. package/dist/esm/types.d.ts +7 -0
  60. package/dist/esm/unknown-enum.d.ts +10 -0
  61. package/dist/esm/unknown-enum.js +23 -0
  62. package/dist/esm/wire/size-delimited.d.ts +19 -1
  63. package/dist/esm/wire/size-delimited.js +54 -16
  64. package/package.json +16 -3
package/README.md CHANGED
@@ -6,7 +6,7 @@ code generator plugin.
6
6
  ## Protocol Buffers for ECMAScript
7
7
 
8
8
  A complete implementation of [Protocol Buffers](https://protobuf.dev/) in TypeScript,
9
- suitable for web browsers, Node.js, and Deno, created by [Buf](https://buf.build).
9
+ suitable for web browsers, Node.js, Deno, and Bun, created by [Buf](https://buf.build).
10
10
 
11
11
  **Protobuf-ES** is a solid, modern alternative to existing Protobuf implementations for the JavaScript ecosystem. It's
12
12
  the first project in this space to provide a comprehensive plugin framework and decouple the base types from RPC
@@ -19,7 +19,7 @@ Some additional features that set it apart from the others:
19
19
  - Generation of idiomatic JavaScript and TypeScript code
20
20
  - Generation of [much smaller bundles](https://github.com/bufbuild/protobuf-es/tree/main/packages/bundle-size/)
21
21
  - Implementation of all proto3 features, including the [canonical JSON format](https://protobuf.dev/programming-guides/proto3/#json)
22
- - Implementation of all proto2 features, except for extensions and the text format
22
+ - Implementation of all proto2 features, including extensions and the text format
23
23
  - Usage of standard JavaScript APIs instead of the [Closure Library](http://googlecode.blogspot.com/2009/11/introducing-closure-tools.html)
24
24
  - Compatibility is covered by the Protocol Buffers [conformance tests](https://github.com/bufbuild/protobuf-es/tree/main/packages/protobuf-conformance/)
25
25
  - Descriptor and reflection support
@@ -132,4 +132,9 @@ export declare const symbols: {
132
132
  readonly bootstrapWktFrom: "../../json-value.js";
133
133
  readonly from: "@bufbuild/protobuf";
134
134
  };
135
+ readonly UnknownEnum: {
136
+ readonly typeOnly: true;
137
+ readonly bootstrapWktFrom: "../../types.js";
138
+ readonly from: "@bufbuild/protobuf";
139
+ };
135
140
  };
@@ -9,10 +9,21 @@ import type { JsonValue } from "../json-value.js";
9
9
  export declare function enumDesc<Shape extends number, JsonType extends JsonValue = JsonValue>(file: DescFile, path: number, ...paths: number[]): GenEnum<Shape, JsonType>;
10
10
  /**
11
11
  * Construct a TypeScript enum object at runtime from a descriptor.
12
+ *
13
+ * The returned object is identical to a transpiled TS enum and includes the
14
+ * reverse mapping, see https://www.typescriptlang.org/docs/handbook/enums.html#reverse-mappings
12
15
  */
13
- export declare function tsEnum(desc: DescEnum): enumObject;
14
- type enumObject = {
16
+ export declare function tsEnum(desc: DescEnum): {
15
17
  [key: number]: string;
16
- [k: string]: number | string;
18
+ [k: string]: string | number;
19
+ };
20
+ /**
21
+ * Construct an object enum at runtime from a descriptor.
22
+ *
23
+ * The returned object is a record of enum value name to integer value. It's
24
+ * a subset of transpiled TS enums - it does not include the reverse mapping,
25
+ * and only supports lookup by value name.
26
+ */
27
+ export declare function objEnum(desc: DescEnum): {
28
+ [key: string]: number;
17
29
  };
18
- export {};
@@ -15,6 +15,7 @@
15
15
  Object.defineProperty(exports, "__esModule", { value: true });
16
16
  exports.enumDesc = enumDesc;
17
17
  exports.tsEnum = tsEnum;
18
+ exports.objEnum = objEnum;
18
19
  /**
19
20
  * Hydrate an enum descriptor.
20
21
  *
@@ -29,6 +30,9 @@ function enumDesc(file, path, ...paths) {
29
30
  }
30
31
  /**
31
32
  * Construct a TypeScript enum object at runtime from a descriptor.
33
+ *
34
+ * The returned object is identical to a transpiled TS enum and includes the
35
+ * reverse mapping, see https://www.typescriptlang.org/docs/handbook/enums.html#reverse-mappings
32
36
  */
33
37
  function tsEnum(desc) {
34
38
  const enumObject = {};
@@ -38,3 +42,17 @@ function tsEnum(desc) {
38
42
  }
39
43
  return enumObject;
40
44
  }
45
+ /**
46
+ * Construct an object enum at runtime from a descriptor.
47
+ *
48
+ * The returned object is a record of enum value name to integer value. It's
49
+ * a subset of transpiled TS enums - it does not include the reverse mapping,
50
+ * and only supports lookup by value name.
51
+ */
52
+ function objEnum(desc) {
53
+ const enumObject = {};
54
+ for (const value of desc.values) {
55
+ enumObject[value.localName] = value.number;
56
+ }
57
+ return enumObject;
58
+ }
@@ -70,6 +70,11 @@ export declare const symbols: {
70
70
  readonly bootstrapWktFrom: "../../json-value.js";
71
71
  readonly from: "@bufbuild/protobuf";
72
72
  };
73
+ readonly UnknownEnum: {
74
+ readonly typeOnly: true;
75
+ readonly bootstrapWktFrom: "../../types.js";
76
+ readonly from: "@bufbuild/protobuf";
77
+ };
73
78
  readonly codegen: {
74
79
  readonly boot: {
75
80
  readonly typeOnly: false;
@@ -106,6 +111,11 @@ export declare const symbols: {
106
111
  readonly bootstrapWktFrom: "../../codegenv2/enum.js";
107
112
  readonly from: string;
108
113
  };
114
+ readonly objEnum: {
115
+ readonly typeOnly: false;
116
+ readonly bootstrapWktFrom: "../../codegenv2/enum.js";
117
+ readonly from: string;
118
+ };
109
119
  readonly GenFile: {
110
120
  readonly typeOnly: true;
111
121
  readonly bootstrapWktFrom: "../../codegenv2/types.js";
@@ -55,6 +55,7 @@ exports.symbols = {
55
55
  protoInt64: { typeOnly: false, bootstrapWktFrom: "../../proto-int64.js", from: exports.packageName },
56
56
  JsonValue: { typeOnly: true, bootstrapWktFrom: "../../json-value.js", from: exports.packageName },
57
57
  JsonObject: { typeOnly: true, bootstrapWktFrom: "../../json-value.js", from: exports.packageName },
58
+ UnknownEnum: { typeOnly: true, bootstrapWktFrom: "../../types.js", from: exports.packageName },
58
59
  codegen: {
59
60
  boot: { typeOnly: false, bootstrapWktFrom: "../../codegenv2/boot.js", from: exports.packageName + "/codegenv2" },
60
61
  fileDesc: { typeOnly: false, bootstrapWktFrom: "../../codegenv2/file.js", from: exports.packageName + "/codegenv2" },
@@ -63,6 +64,7 @@ exports.symbols = {
63
64
  messageDesc: { typeOnly: false, bootstrapWktFrom: "../../codegenv2/message.js", from: exports.packageName + "/codegenv2" },
64
65
  serviceDesc: { typeOnly: false, bootstrapWktFrom: "../../codegenv2/service.js", from: exports.packageName + "/codegenv2" },
65
66
  tsEnum: { typeOnly: false, bootstrapWktFrom: "../../codegenv2/enum.js", from: exports.packageName + "/codegenv2" },
67
+ objEnum: { typeOnly: false, bootstrapWktFrom: "../../codegenv2/enum.js", from: exports.packageName + "/codegenv2" },
66
68
  GenFile: { typeOnly: true, bootstrapWktFrom: "../../codegenv2/types.js", from: exports.packageName + "/codegenv2" },
67
69
  GenEnum: { typeOnly: true, bootstrapWktFrom: "../../codegenv2/types.js", from: exports.packageName + "/codegenv2" },
68
70
  GenExtension: { typeOnly: true, bootstrapWktFrom: "../../codegenv2/types.js", from: exports.packageName + "/codegenv2" },
@@ -20,11 +20,11 @@ const scalar_js_1 = require("./reflect/scalar.js");
20
20
  const guard_js_1 = require("./reflect/guard.js");
21
21
  const unsafe_js_1 = require("./reflect/unsafe.js");
22
22
  const wrappers_js_1 = require("./wkt/wrappers.js");
23
- // bootstrap-inject google.protobuf.Edition.EDITION_PROTO3: const $name: Edition.$localName = $number;
23
+ // bootstrap-inject google.protobuf.Edition.EDITION_PROTO3: const $name = $number;
24
24
  const EDITION_PROTO3 = 999;
25
- // bootstrap-inject google.protobuf.Edition.EDITION_PROTO2: const $name: Edition.$localName = $number;
25
+ // bootstrap-inject google.protobuf.Edition.EDITION_PROTO2: const $name = $number;
26
26
  const EDITION_PROTO2 = 998;
27
- // bootstrap-inject google.protobuf.FeatureSet.FieldPresence.IMPLICIT: const $name: FeatureSet_FieldPresence.$localName = $number;
27
+ // bootstrap-inject google.protobuf.FeatureSet.FieldPresence.IMPLICIT: const $name = $number;
28
28
  const IMPLICIT = 2;
29
29
  /**
30
30
  * Create a new message instance.
@@ -1,7 +1,7 @@
1
1
  import type { DescriptorProto, Edition, EnumDescriptorProto, EnumValueDescriptorProto, FeatureSet_FieldPresence, FieldDescriptorProto, FileDescriptorProto, MethodDescriptorProto, MethodOptions_IdempotencyLevel, OneofDescriptorProto, ServiceDescriptorProto } from "./wkt/gen/google/protobuf/descriptor_pb.js";
2
2
  import type { ScalarValue } from "./reflect/scalar.js";
3
- export type SupportedEdition = Extract<Edition, Edition.EDITION_PROTO2 | Edition.EDITION_PROTO3 | Edition.EDITION_2023 | Edition.EDITION_2024>;
4
- type SupportedFieldPresence = Extract<FeatureSet_FieldPresence, FeatureSet_FieldPresence.EXPLICIT | FeatureSet_FieldPresence.IMPLICIT | FeatureSet_FieldPresence.LEGACY_REQUIRED>;
3
+ export type SupportedEdition = Extract<Edition, typeof Edition.EDITION_PROTO2 | typeof Edition.EDITION_PROTO3 | typeof Edition.EDITION_2023 | typeof Edition.EDITION_2024>;
4
+ type SupportedFieldPresence = Extract<FeatureSet_FieldPresence, typeof FeatureSet_FieldPresence.EXPLICIT | typeof FeatureSet_FieldPresence.IMPLICIT | typeof FeatureSet_FieldPresence.LEGACY_REQUIRED>;
5
5
  /**
6
6
  * Scalar value types. This is a subset of field types declared by protobuf
7
7
  * enum google.protobuf.FieldDescriptorProto.Type The types GROUP and MESSAGE
@@ -16,3 +16,4 @@ export * from "./from-json.js";
16
16
  export * from "./merge.js";
17
17
  export { hasExtension, getExtension, setExtension, clearExtension, hasOption, getOption, } from "./extensions.js";
18
18
  export * from "./proto-int64.js";
19
+ export * from "./unknown-enum.js";
@@ -52,3 +52,4 @@ Object.defineProperty(exports, "clearExtension", { enumerable: true, get: functi
52
52
  Object.defineProperty(exports, "hasOption", { enumerable: true, get: function () { return extensions_js_1.hasOption; } });
53
53
  Object.defineProperty(exports, "getOption", { enumerable: true, get: function () { return extensions_js_1.getOption; } });
54
54
  __exportStar(require("./proto-int64.js"), exports);
55
+ __exportStar(require("./unknown-enum.js"), exports);
@@ -25,6 +25,8 @@ const wrappers_js_1 = require("../wkt/wrappers.js");
25
25
  const scalar_js_1 = require("./scalar.js");
26
26
  const proto_int64_js_1 = require("../proto-int64.js");
27
27
  const guard_js_1 = require("./guard.js");
28
+ // google.protobuf.NullValue.NULL_VALUE;
29
+ const NULL_VALUE = 0;
28
30
  /**
29
31
  * Create a ReflectMessage.
30
32
  */
@@ -515,8 +517,7 @@ function wktValueToReflect(json) {
515
517
  break;
516
518
  case "object":
517
519
  if (json === null) {
518
- const nullValue = 0;
519
- value.kind = { case: "nullValue", value: nullValue };
520
+ value.kind = { case: "nullValue", value: NULL_VALUE };
520
521
  }
521
522
  else if (Array.isArray(json)) {
522
523
  const listValue = {
@@ -21,7 +21,7 @@ exports.unsafeGet = unsafeGet;
21
21
  exports.unsafeSet = unsafeSet;
22
22
  exports.unsafeClear = unsafeClear;
23
23
  const scalar_js_1 = require("./scalar.js");
24
- // bootstrap-inject google.protobuf.FeatureSet.FieldPresence.IMPLICIT: const $name: FeatureSet_FieldPresence.$localName = $number;
24
+ // bootstrap-inject google.protobuf.FeatureSet.FieldPresence.IMPLICIT: const $name = $number;
25
25
  const IMPLICIT = 2;
26
26
  exports.unsafeLocal = Symbol.for("reflect unsafe local");
27
27
  /**
@@ -193,43 +193,43 @@ function initBaseRegistry(inputs) {
193
193
  }
194
194
  return registry;
195
195
  }
196
- // bootstrap-inject google.protobuf.Edition.EDITION_PROTO2: const $name: Edition.$localName = $number;
196
+ // bootstrap-inject google.protobuf.Edition.EDITION_PROTO2: const $name = $number;
197
197
  const EDITION_PROTO2 = 998;
198
- // bootstrap-inject google.protobuf.Edition.EDITION_PROTO3: const $name: Edition.$localName = $number;
198
+ // bootstrap-inject google.protobuf.Edition.EDITION_PROTO3: const $name = $number;
199
199
  const EDITION_PROTO3 = 999;
200
- // bootstrap-inject google.protobuf.Edition.EDITION_UNSTABLE: const $name: Edition.$localName = $number;
200
+ // bootstrap-inject google.protobuf.Edition.EDITION_UNSTABLE: const $name = $number;
201
201
  const EDITION_UNSTABLE = 9999;
202
- // bootstrap-inject google.protobuf.FieldDescriptorProto.Type.TYPE_STRING: const $name: FieldDescriptorProto_Type.$localName = $number;
202
+ // bootstrap-inject google.protobuf.FieldDescriptorProto.Type.TYPE_STRING: const $name = $number;
203
203
  const TYPE_STRING = 9;
204
- // bootstrap-inject google.protobuf.FieldDescriptorProto.Type.TYPE_GROUP: const $name: FieldDescriptorProto_Type.$localName = $number;
204
+ // bootstrap-inject google.protobuf.FieldDescriptorProto.Type.TYPE_GROUP: const $name = $number;
205
205
  const TYPE_GROUP = 10;
206
- // bootstrap-inject google.protobuf.FieldDescriptorProto.Type.TYPE_MESSAGE: const $name: FieldDescriptorProto_Type.$localName = $number;
206
+ // bootstrap-inject google.protobuf.FieldDescriptorProto.Type.TYPE_MESSAGE: const $name = $number;
207
207
  const TYPE_MESSAGE = 11;
208
- // bootstrap-inject google.protobuf.FieldDescriptorProto.Type.TYPE_BYTES: const $name: FieldDescriptorProto_Type.$localName = $number;
208
+ // bootstrap-inject google.protobuf.FieldDescriptorProto.Type.TYPE_BYTES: const $name = $number;
209
209
  const TYPE_BYTES = 12;
210
- // bootstrap-inject google.protobuf.FieldDescriptorProto.Type.TYPE_ENUM: const $name: FieldDescriptorProto_Type.$localName = $number;
210
+ // bootstrap-inject google.protobuf.FieldDescriptorProto.Type.TYPE_ENUM: const $name = $number;
211
211
  const TYPE_ENUM = 14;
212
- // bootstrap-inject google.protobuf.FieldDescriptorProto.Label.LABEL_REPEATED: const $name: FieldDescriptorProto_Label.$localName = $number;
212
+ // bootstrap-inject google.protobuf.FieldDescriptorProto.Label.LABEL_REPEATED: const $name = $number;
213
213
  const LABEL_REPEATED = 3;
214
- // bootstrap-inject google.protobuf.FieldDescriptorProto.Label.LABEL_REQUIRED: const $name: FieldDescriptorProto_Label.$localName = $number;
214
+ // bootstrap-inject google.protobuf.FieldDescriptorProto.Label.LABEL_REQUIRED: const $name = $number;
215
215
  const LABEL_REQUIRED = 2;
216
- // bootstrap-inject google.protobuf.FieldOptions.JSType.JS_STRING: const $name: FieldOptions_JSType.$localName = $number;
216
+ // bootstrap-inject google.protobuf.FieldOptions.JSType.JS_STRING: const $name = $number;
217
217
  const JS_STRING = 1;
218
- // bootstrap-inject google.protobuf.MethodOptions.IdempotencyLevel.IDEMPOTENCY_UNKNOWN: const $name: MethodOptions_IdempotencyLevel.$localName = $number;
218
+ // bootstrap-inject google.protobuf.MethodOptions.IdempotencyLevel.IDEMPOTENCY_UNKNOWN: const $name = $number;
219
219
  const IDEMPOTENCY_UNKNOWN = 0;
220
- // bootstrap-inject google.protobuf.FeatureSet.FieldPresence.EXPLICIT: const $name: FeatureSet_FieldPresence.$localName = $number;
220
+ // bootstrap-inject google.protobuf.FeatureSet.FieldPresence.EXPLICIT: const $name = $number;
221
221
  const EXPLICIT = 1;
222
- // bootstrap-inject google.protobuf.FeatureSet.FieldPresence.IMPLICIT: const $name: FeatureSet_FieldPresence.$localName = $number;
222
+ // bootstrap-inject google.protobuf.FeatureSet.FieldPresence.IMPLICIT: const $name = $number;
223
223
  const IMPLICIT = 2;
224
- // bootstrap-inject google.protobuf.FeatureSet.FieldPresence.LEGACY_REQUIRED: const $name: FeatureSet_FieldPresence.$localName = $number;
224
+ // bootstrap-inject google.protobuf.FeatureSet.FieldPresence.LEGACY_REQUIRED: const $name = $number;
225
225
  const LEGACY_REQUIRED = 3;
226
- // bootstrap-inject google.protobuf.FeatureSet.RepeatedFieldEncoding.PACKED: const $name: FeatureSet_RepeatedFieldEncoding.$localName = $number;
226
+ // bootstrap-inject google.protobuf.FeatureSet.RepeatedFieldEncoding.PACKED: const $name = $number;
227
227
  const PACKED = 1;
228
- // bootstrap-inject google.protobuf.FeatureSet.MessageEncoding.DELIMITED: const $name: FeatureSet_MessageEncoding.$localName = $number;
228
+ // bootstrap-inject google.protobuf.FeatureSet.MessageEncoding.DELIMITED: const $name = $number;
229
229
  const DELIMITED = 2;
230
- // bootstrap-inject google.protobuf.FeatureSet.EnumType.OPEN: const $name: FeatureSet_EnumType.$localName = $number;
230
+ // bootstrap-inject google.protobuf.FeatureSet.EnumType.OPEN: const $name = $number;
231
231
  const OPEN = 1;
232
- // bootstrap-inject google.protobuf.FeatureSet.Utf8Validation.VERIFY: const $name: FeatureSet_Utf8Validation.$localName = $number;
232
+ // bootstrap-inject google.protobuf.FeatureSet.Utf8Validation.VERIFY: const $name = $number;
233
233
  const VERIFY = 2;
234
234
  // biome-ignore format: want this to read well
235
235
  // bootstrap-inject defaults: EDITION_PROTO2 to EDITION_2024: export const minimumEdition: SupportedEdition = $minimumEdition, maximumEdition: SupportedEdition = $maximumEdition;
@@ -18,7 +18,7 @@ exports.writeField = writeField;
18
18
  const reflect_js_1 = require("./reflect/reflect.js");
19
19
  const binary_encoding_js_1 = require("./wire/binary-encoding.js");
20
20
  const descriptors_js_1 = require("./descriptors.js");
21
- // bootstrap-inject google.protobuf.FeatureSet.FieldPresence.LEGACY_REQUIRED: const $name: FeatureSet_FieldPresence.$localName = $number;
21
+ // bootstrap-inject google.protobuf.FeatureSet.FieldPresence.LEGACY_REQUIRED: const $name = $number;
22
22
  const LEGACY_REQUIRED = 3;
23
23
  // Default options for serializing binary data.
24
24
  const writeDefaults = {
@@ -24,9 +24,9 @@ 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
- // bootstrap-inject google.protobuf.FeatureSet.FieldPresence.LEGACY_REQUIRED: const $name: FeatureSet_FieldPresence.$localName = $number;
27
+ // bootstrap-inject google.protobuf.FeatureSet.FieldPresence.LEGACY_REQUIRED: const $name = $number;
28
28
  const LEGACY_REQUIRED = 3;
29
- // bootstrap-inject google.protobuf.FeatureSet.FieldPresence.IMPLICIT: const $name: FeatureSet_FieldPresence.$localName = $number;
29
+ // bootstrap-inject google.protobuf.FeatureSet.FieldPresence.IMPLICIT: const $name = $number;
30
30
  const IMPLICIT = 2;
31
31
  // Default options for serializing to JSON.
32
32
  const jsonWriteDefaults = {
@@ -0,0 +1,35 @@
1
+ import { type DescMessage } from "../descriptors.js";
2
+ import type { Registry } from "../registry.js";
3
+ import type { MessageShape } from "../types.js";
4
+ /**
5
+ * Options for parsing the protobuf text format.
6
+ */
7
+ export interface TextReadOptions {
8
+ /**
9
+ * The registry to resolve `google.protobuf.Any` and extensions. Parsing an
10
+ * Any in its expanded form, or an extension field, requires it.
11
+ */
12
+ registry?: Registry | undefined;
13
+ /**
14
+ * The maximum depth of nested messages to parse. A message nesting deeper
15
+ * than this fails with an error instead of exhausting the call stack.
16
+ * Defaults to 100.
17
+ */
18
+ recursionLimit: number;
19
+ }
20
+ /**
21
+ * Parse a message from the protobuf text format.
22
+ *
23
+ * Requires BigInt: throws immediately if the environment does not support it.
24
+ */
25
+ export declare function fromText<Desc extends DescMessage>(schema: Desc, text: string, options?: Partial<TextReadOptions>): MessageShape<Desc>;
26
+ /**
27
+ * Parse a message from the protobuf text format, merging into the target.
28
+ *
29
+ * Repeated fields are appended, singular fields are overwritten (last wins),
30
+ * message fields are merged, and map entries are added (overwriting an existing
31
+ * key).
32
+ *
33
+ * Requires BigInt: throws immediately if the environment does not support it.
34
+ */
35
+ export declare function mergeFromText<Desc extends DescMessage>(schema: Desc, target: MessageShape<Desc>, text: string, options?: Partial<TextReadOptions>): MessageShape<Desc>;