@bufbuild/protobuf 1.2.0 → 1.3.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 (53) hide show
  1. package/dist/cjs/binary-encoding.js +1 -1
  2. package/dist/cjs/codegen-info.js +1 -0
  3. package/dist/cjs/field.js +1 -1
  4. package/dist/cjs/google/protobuf/any_pb.js +3 -3
  5. package/dist/cjs/google/protobuf/api_pb.js +1 -1
  6. package/dist/cjs/google/protobuf/compiler/plugin_pb.js +1 -1
  7. package/dist/cjs/google/protobuf/descriptor_pb.js +88 -10
  8. package/dist/cjs/google/protobuf/field_mask_pb.js +1 -1
  9. package/dist/cjs/google/protobuf/struct_pb.js +3 -3
  10. package/dist/cjs/google/protobuf/timestamp_pb.js +1 -1
  11. package/dist/cjs/google/protobuf/type_pb.js +25 -4
  12. package/dist/cjs/index.js +5 -4
  13. package/dist/cjs/private/binary-format-common.js +44 -6
  14. package/dist/cjs/proto-base64.js +2 -10
  15. package/dist/cjs/proto-delimited.js +14 -19
  16. package/dist/cjs/proto-double.js +29 -0
  17. package/dist/cjs/proto-int64.js +1 -1
  18. package/dist/cjs/service-type.js +2 -2
  19. package/dist/cjs/to-plain-message.js +67 -0
  20. package/dist/esm/codegen-info.js +1 -0
  21. package/dist/esm/create-descriptor-set.js +1 -1
  22. package/dist/esm/google/protobuf/any_pb.js +3 -3
  23. package/dist/esm/google/protobuf/api_pb.js +1 -1
  24. package/dist/esm/google/protobuf/descriptor_pb.js +77 -0
  25. package/dist/esm/google/protobuf/field_mask_pb.js +1 -1
  26. package/dist/esm/google/protobuf/struct_pb.js +2 -2
  27. package/dist/esm/google/protobuf/timestamp_pb.js +1 -1
  28. package/dist/esm/google/protobuf/type_pb.js +22 -1
  29. package/dist/esm/index.js +3 -4
  30. package/dist/esm/private/binary-format-common.js +45 -7
  31. package/dist/esm/private/message-type.js +1 -1
  32. package/dist/esm/private/util-common.js +1 -1
  33. package/dist/esm/proto-base64.js +2 -10
  34. package/dist/esm/proto-delimited.js +14 -19
  35. package/dist/esm/proto-double.js +26 -0
  36. package/dist/esm/proto-int64.js +1 -1
  37. package/dist/esm/to-plain-message.js +63 -0
  38. package/dist/types/codegen-info.d.ts +1 -1
  39. package/dist/types/google/protobuf/any_pb.d.ts +3 -3
  40. package/dist/types/google/protobuf/api_pb.d.ts +1 -1
  41. package/dist/types/google/protobuf/descriptor_pb.d.ts +107 -3
  42. package/dist/types/google/protobuf/struct_pb.d.ts +1 -1
  43. package/dist/types/google/protobuf/timestamp_pb.d.ts +1 -1
  44. package/dist/types/google/protobuf/type_pb.d.ts +19 -1
  45. package/dist/types/index.d.ts +7 -4
  46. package/dist/types/private/binary-format-common.d.ts +3 -2
  47. package/dist/types/private/json-format-common.d.ts +2 -1
  48. package/dist/types/private/message-type.d.ts +2 -1
  49. package/dist/types/private/scalars.d.ts +2 -1
  50. package/dist/types/proto-base64.d.ts +1 -9
  51. package/dist/types/proto-double.d.ts +5 -0
  52. package/dist/types/to-plain-message.d.ts +9 -0
  53. package/package.json +2 -2
@@ -60,7 +60,7 @@ var WireType;
60
60
  * Always 4 bytes with little-endian byte order.
61
61
  */
62
62
  WireType[WireType["Bit32"] = 5] = "Bit32";
63
- })(WireType = exports.WireType || (exports.WireType = {}));
63
+ })(WireType || (exports.WireType = WireType = {}));
64
64
  class BinaryWriter {
65
65
  constructor(textEncoder) {
66
66
  /**
@@ -42,6 +42,7 @@ exports.codegenInfo = {
42
42
  JsonWriteOptions: { typeOnly: true, privateImportPath: "./json-format.js", publicImportPath: packageName },
43
43
  JsonValue: { typeOnly: true, privateImportPath: "./json-format.js", publicImportPath: packageName },
44
44
  JsonObject: { typeOnly: true, privateImportPath: "./json-format.js", publicImportPath: packageName },
45
+ protoDouble: { typeOnly: false, privateImportPath: "./proto-double.js", publicImportPath: packageName },
45
46
  protoInt64: { typeOnly: false, privateImportPath: "./proto-int64.js", publicImportPath: packageName },
46
47
  ScalarType: { typeOnly: false, privateImportPath: "./field.js", publicImportPath: packageName },
47
48
  MethodKind: { typeOnly: false, privateImportPath: "./service-type.js", publicImportPath: packageName },
package/dist/cjs/field.js CHANGED
@@ -50,4 +50,4 @@ var ScalarType;
50
50
  ScalarType[ScalarType["SFIXED64"] = 16] = "SFIXED64";
51
51
  ScalarType[ScalarType["SINT32"] = 17] = "SINT32";
52
52
  ScalarType[ScalarType["SINT64"] = 18] = "SINT64";
53
- })(ScalarType = exports.ScalarType || (exports.ScalarType = {}));
53
+ })(ScalarType || (exports.ScalarType = ScalarType = {}));
@@ -46,7 +46,7 @@ const proto3_js_1 = require("../../proto3.js");
46
46
  * foo = any.unpack(Foo.getDefaultInstance());
47
47
  * }
48
48
  *
49
- * Example 3: Pack and unpack a message in Python.
49
+ * Example 3: Pack and unpack a message in Python.
50
50
  *
51
51
  * foo = Foo(...)
52
52
  * any = Any()
@@ -56,7 +56,7 @@ const proto3_js_1 = require("../../proto3.js");
56
56
  * any.Unpack(foo)
57
57
  * ...
58
58
  *
59
- * Example 4: Pack and unpack a message in Go
59
+ * Example 4: Pack and unpack a message in Go
60
60
  *
61
61
  * foo := &pb.Foo{...}
62
62
  * any, err := anypb.New(foo)
@@ -76,7 +76,7 @@ const proto3_js_1 = require("../../proto3.js");
76
76
  * name "y.z".
77
77
  *
78
78
  * JSON
79
- *
79
+ * ====
80
80
  * The JSON representation of an `Any` value uses the regular
81
81
  * representation of the deserialized, embedded message, with an
82
82
  * additional field `@type` which contains the type URL. Example:
@@ -242,7 +242,7 @@ Method.fields = proto3_js_1.proto3.util.newFieldList(() => [
242
242
  * The mixin construct implies that all methods in `AccessControl` are
243
243
  * also declared with same name and request/response types in
244
244
  * `Storage`. A documentation generator or annotation processor will
245
- * see the effective `Storage.GetAcl` method after inheriting
245
+ * see the effective `Storage.GetAcl` method after inherting
246
246
  * documentation and annotations as follows:
247
247
  *
248
248
  * service Storage {
@@ -158,7 +158,7 @@ var CodeGeneratorResponse_Feature;
158
158
  * @generated from enum value: FEATURE_PROTO3_OPTIONAL = 1;
159
159
  */
160
160
  CodeGeneratorResponse_Feature[CodeGeneratorResponse_Feature["PROTO3_OPTIONAL"] = 1] = "PROTO3_OPTIONAL";
161
- })(CodeGeneratorResponse_Feature = exports.CodeGeneratorResponse_Feature || (exports.CodeGeneratorResponse_Feature = {}));
161
+ })(CodeGeneratorResponse_Feature || (exports.CodeGeneratorResponse_Feature = CodeGeneratorResponse_Feature = {}));
162
162
  // Retrieve enum metadata with: proto2.getEnumType(CodeGeneratorResponse_Feature)
163
163
  proto2_js_1.proto2.util.setEnumType(CodeGeneratorResponse_Feature, "google.protobuf.compiler.CodeGeneratorResponse.Feature", [
164
164
  { no: 0, name: "FEATURE_NONE" },
@@ -13,7 +13,7 @@
13
13
  // See the License for the specific language governing permissions and
14
14
  // limitations under the License.
15
15
  Object.defineProperty(exports, "__esModule", { value: true });
16
- exports.GeneratedCodeInfo_Annotation_Semantic = exports.GeneratedCodeInfo_Annotation = exports.GeneratedCodeInfo = exports.SourceCodeInfo_Location = exports.SourceCodeInfo = exports.UninterpretedOption_NamePart = exports.UninterpretedOption = exports.MethodOptions_IdempotencyLevel = exports.MethodOptions = exports.ServiceOptions = exports.EnumValueOptions = exports.EnumOptions = exports.OneofOptions = exports.FieldOptions_OptionTargetType = exports.FieldOptions_OptionRetention = exports.FieldOptions_JSType = exports.FieldOptions_CType = exports.FieldOptions = exports.MessageOptions = exports.FileOptions_OptimizeMode = exports.FileOptions = exports.MethodDescriptorProto = exports.ServiceDescriptorProto = exports.EnumValueDescriptorProto = exports.EnumDescriptorProto_EnumReservedRange = exports.EnumDescriptorProto = exports.OneofDescriptorProto = exports.FieldDescriptorProto_Label = exports.FieldDescriptorProto_Type = exports.FieldDescriptorProto = exports.ExtensionRangeOptions = exports.DescriptorProto_ReservedRange = exports.DescriptorProto_ExtensionRange = exports.DescriptorProto = exports.FileDescriptorProto = exports.FileDescriptorSet = void 0;
16
+ exports.GeneratedCodeInfo_Annotation_Semantic = exports.GeneratedCodeInfo_Annotation = exports.GeneratedCodeInfo = exports.SourceCodeInfo_Location = exports.SourceCodeInfo = exports.UninterpretedOption_NamePart = exports.UninterpretedOption = exports.MethodOptions_IdempotencyLevel = exports.MethodOptions = exports.ServiceOptions = exports.EnumValueOptions = exports.EnumOptions = exports.OneofOptions = exports.FieldOptions_OptionTargetType = exports.FieldOptions_OptionRetention = exports.FieldOptions_JSType = exports.FieldOptions_CType = exports.FieldOptions = exports.MessageOptions = exports.FileOptions_OptimizeMode = exports.FileOptions = exports.MethodDescriptorProto = exports.ServiceDescriptorProto = exports.EnumValueDescriptorProto = exports.EnumDescriptorProto_EnumReservedRange = exports.EnumDescriptorProto = exports.OneofDescriptorProto = exports.FieldDescriptorProto_Label = exports.FieldDescriptorProto_Type = exports.FieldDescriptorProto = exports.ExtensionRangeOptions_Declaration = exports.ExtensionRangeOptions_VerificationState = exports.ExtensionRangeOptions = exports.DescriptorProto_ReservedRange = exports.DescriptorProto_ExtensionRange = exports.DescriptorProto = exports.FileDescriptorProto = exports.FileDescriptorSet = void 0;
17
17
  const message_js_1 = require("../../message.js");
18
18
  const proto2_js_1 = require("../../proto2.js");
19
19
  /**
@@ -274,6 +274,15 @@ class ExtensionRangeOptions extends message_js_1.Message {
274
274
  * @generated from field: repeated google.protobuf.UninterpretedOption uninterpreted_option = 999;
275
275
  */
276
276
  this.uninterpretedOption = [];
277
+ /**
278
+ * go/protobuf-stripping-extension-declarations
279
+ * Like Metadata, but we use a repeated field to hold all extension
280
+ * declarations. This should avoid the size increases of transforming a large
281
+ * extension range into small ranges in generated binaries.
282
+ *
283
+ * @generated from field: repeated google.protobuf.ExtensionRangeOptions.Declaration declaration = 2;
284
+ */
285
+ this.declaration = [];
277
286
  proto2_js_1.proto2.util.initPartial(data, this);
278
287
  }
279
288
  static fromBinary(bytes, options) {
@@ -294,6 +303,63 @@ ExtensionRangeOptions.runtime = proto2_js_1.proto2;
294
303
  ExtensionRangeOptions.typeName = "google.protobuf.ExtensionRangeOptions";
295
304
  ExtensionRangeOptions.fields = proto2_js_1.proto2.util.newFieldList(() => [
296
305
  { no: 999, name: "uninterpreted_option", kind: "message", T: UninterpretedOption, repeated: true },
306
+ { no: 2, name: "declaration", kind: "message", T: ExtensionRangeOptions_Declaration, repeated: true },
307
+ { no: 3, name: "verification", kind: "enum", T: proto2_js_1.proto2.getEnumType(ExtensionRangeOptions_VerificationState), opt: true, default: ExtensionRangeOptions_VerificationState.UNVERIFIED },
308
+ ]);
309
+ /**
310
+ * The verification state of the extension range.
311
+ *
312
+ * @generated from enum google.protobuf.ExtensionRangeOptions.VerificationState
313
+ */
314
+ var ExtensionRangeOptions_VerificationState;
315
+ (function (ExtensionRangeOptions_VerificationState) {
316
+ /**
317
+ * All the extensions of the range must be declared.
318
+ *
319
+ * @generated from enum value: DECLARATION = 0;
320
+ */
321
+ ExtensionRangeOptions_VerificationState[ExtensionRangeOptions_VerificationState["DECLARATION"] = 0] = "DECLARATION";
322
+ /**
323
+ * @generated from enum value: UNVERIFIED = 1;
324
+ */
325
+ ExtensionRangeOptions_VerificationState[ExtensionRangeOptions_VerificationState["UNVERIFIED"] = 1] = "UNVERIFIED";
326
+ })(ExtensionRangeOptions_VerificationState || (exports.ExtensionRangeOptions_VerificationState = ExtensionRangeOptions_VerificationState = {}));
327
+ // Retrieve enum metadata with: proto2.getEnumType(ExtensionRangeOptions_VerificationState)
328
+ proto2_js_1.proto2.util.setEnumType(ExtensionRangeOptions_VerificationState, "google.protobuf.ExtensionRangeOptions.VerificationState", [
329
+ { no: 0, name: "DECLARATION" },
330
+ { no: 1, name: "UNVERIFIED" },
331
+ ]);
332
+ /**
333
+ * @generated from message google.protobuf.ExtensionRangeOptions.Declaration
334
+ */
335
+ class ExtensionRangeOptions_Declaration extends message_js_1.Message {
336
+ constructor(data) {
337
+ super();
338
+ proto2_js_1.proto2.util.initPartial(data, this);
339
+ }
340
+ static fromBinary(bytes, options) {
341
+ return new ExtensionRangeOptions_Declaration().fromBinary(bytes, options);
342
+ }
343
+ static fromJson(jsonValue, options) {
344
+ return new ExtensionRangeOptions_Declaration().fromJson(jsonValue, options);
345
+ }
346
+ static fromJsonString(jsonString, options) {
347
+ return new ExtensionRangeOptions_Declaration().fromJsonString(jsonString, options);
348
+ }
349
+ static equals(a, b) {
350
+ return proto2_js_1.proto2.util.equals(ExtensionRangeOptions_Declaration, a, b);
351
+ }
352
+ }
353
+ exports.ExtensionRangeOptions_Declaration = ExtensionRangeOptions_Declaration;
354
+ ExtensionRangeOptions_Declaration.runtime = proto2_js_1.proto2;
355
+ ExtensionRangeOptions_Declaration.typeName = "google.protobuf.ExtensionRangeOptions.Declaration";
356
+ ExtensionRangeOptions_Declaration.fields = proto2_js_1.proto2.util.newFieldList(() => [
357
+ { no: 1, name: "number", kind: "scalar", T: 5 /* ScalarType.INT32 */, opt: true },
358
+ { no: 2, name: "full_name", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true },
359
+ { no: 3, name: "type", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true },
360
+ { no: 4, name: "is_repeated", kind: "scalar", T: 8 /* ScalarType.BOOL */, opt: true },
361
+ { no: 5, name: "reserved", kind: "scalar", T: 8 /* ScalarType.BOOL */, opt: true },
362
+ { no: 6, name: "repeated", kind: "scalar", T: 8 /* ScalarType.BOOL */, opt: true },
297
363
  ]);
298
364
  /**
299
365
  * Describes a field within a message.
@@ -433,7 +499,7 @@ var FieldDescriptorProto_Type;
433
499
  * @generated from enum value: TYPE_SINT64 = 18;
434
500
  */
435
501
  FieldDescriptorProto_Type[FieldDescriptorProto_Type["SINT64"] = 18] = "SINT64";
436
- })(FieldDescriptorProto_Type = exports.FieldDescriptorProto_Type || (exports.FieldDescriptorProto_Type = {}));
502
+ })(FieldDescriptorProto_Type || (exports.FieldDescriptorProto_Type = FieldDescriptorProto_Type = {}));
437
503
  // Retrieve enum metadata with: proto2.getEnumType(FieldDescriptorProto_Type)
438
504
  proto2_js_1.proto2.util.setEnumType(FieldDescriptorProto_Type, "google.protobuf.FieldDescriptorProto.Type", [
439
505
  { no: 1, name: "TYPE_DOUBLE" },
@@ -474,7 +540,7 @@ var FieldDescriptorProto_Label;
474
540
  * @generated from enum value: LABEL_REPEATED = 3;
475
541
  */
476
542
  FieldDescriptorProto_Label[FieldDescriptorProto_Label["REPEATED"] = 3] = "REPEATED";
477
- })(FieldDescriptorProto_Label = exports.FieldDescriptorProto_Label || (exports.FieldDescriptorProto_Label = {}));
543
+ })(FieldDescriptorProto_Label || (exports.FieldDescriptorProto_Label = FieldDescriptorProto_Label = {}));
478
544
  // Retrieve enum metadata with: proto2.getEnumType(FieldDescriptorProto_Label)
479
545
  proto2_js_1.proto2.util.setEnumType(FieldDescriptorProto_Label, "google.protobuf.FieldDescriptorProto.Label", [
480
546
  { no: 1, name: "LABEL_OPTIONAL" },
@@ -779,7 +845,7 @@ var FileOptions_OptimizeMode;
779
845
  * @generated from enum value: LITE_RUNTIME = 3;
780
846
  */
781
847
  FileOptions_OptimizeMode[FileOptions_OptimizeMode["LITE_RUNTIME"] = 3] = "LITE_RUNTIME";
782
- })(FileOptions_OptimizeMode = exports.FileOptions_OptimizeMode || (exports.FileOptions_OptimizeMode = {}));
848
+ })(FileOptions_OptimizeMode || (exports.FileOptions_OptimizeMode = FileOptions_OptimizeMode = {}));
783
849
  // Retrieve enum metadata with: proto2.getEnumType(FileOptions_OptimizeMode)
784
850
  proto2_js_1.proto2.util.setEnumType(FileOptions_OptimizeMode, "google.protobuf.FileOptions.OptimizeMode", [
785
851
  { no: 1, name: "SPEED" },
@@ -830,6 +896,10 @@ MessageOptions.fields = proto2_js_1.proto2.util.newFieldList(() => [
830
896
  class FieldOptions extends message_js_1.Message {
831
897
  constructor(data) {
832
898
  super();
899
+ /**
900
+ * @generated from field: repeated google.protobuf.FieldOptions.OptionTargetType targets = 19;
901
+ */
902
+ this.targets = [];
833
903
  /**
834
904
  * The parser stores options it doesn't recognize here. See above.
835
905
  *
@@ -865,6 +935,7 @@ FieldOptions.fields = proto2_js_1.proto2.util.newFieldList(() => [
865
935
  { no: 16, name: "debug_redact", kind: "scalar", T: 8 /* ScalarType.BOOL */, opt: true, default: false },
866
936
  { no: 17, name: "retention", kind: "enum", T: proto2_js_1.proto2.getEnumType(FieldOptions_OptionRetention), opt: true },
867
937
  { no: 18, name: "target", kind: "enum", T: proto2_js_1.proto2.getEnumType(FieldOptions_OptionTargetType), opt: true },
938
+ { no: 19, name: "targets", kind: "enum", T: proto2_js_1.proto2.getEnumType(FieldOptions_OptionTargetType), repeated: true },
868
939
  { no: 999, name: "uninterpreted_option", kind: "message", T: UninterpretedOption, repeated: true },
869
940
  ]);
870
941
  /**
@@ -879,6 +950,13 @@ var FieldOptions_CType;
879
950
  */
880
951
  FieldOptions_CType[FieldOptions_CType["STRING"] = 0] = "STRING";
881
952
  /**
953
+ * The option [ctype=CORD] may be applied to a non-repeated field of type
954
+ * "bytes". It indicates that in C++, the data should be stored in a Cord
955
+ * instead of a string. For very large strings, this may reduce memory
956
+ * fragmentation. It may also allow better performance when parsing from a
957
+ * Cord, or when parsing with aliasing enabled, as the parsed Cord may then
958
+ * alias the original buffer.
959
+ *
882
960
  * @generated from enum value: CORD = 1;
883
961
  */
884
962
  FieldOptions_CType[FieldOptions_CType["CORD"] = 1] = "CORD";
@@ -886,7 +964,7 @@ var FieldOptions_CType;
886
964
  * @generated from enum value: STRING_PIECE = 2;
887
965
  */
888
966
  FieldOptions_CType[FieldOptions_CType["STRING_PIECE"] = 2] = "STRING_PIECE";
889
- })(FieldOptions_CType = exports.FieldOptions_CType || (exports.FieldOptions_CType = {}));
967
+ })(FieldOptions_CType || (exports.FieldOptions_CType = FieldOptions_CType = {}));
890
968
  // Retrieve enum metadata with: proto2.getEnumType(FieldOptions_CType)
891
969
  proto2_js_1.proto2.util.setEnumType(FieldOptions_CType, "google.protobuf.FieldOptions.CType", [
892
970
  { no: 0, name: "STRING" },
@@ -916,7 +994,7 @@ var FieldOptions_JSType;
916
994
  * @generated from enum value: JS_NUMBER = 2;
917
995
  */
918
996
  FieldOptions_JSType[FieldOptions_JSType["JS_NUMBER"] = 2] = "JS_NUMBER";
919
- })(FieldOptions_JSType = exports.FieldOptions_JSType || (exports.FieldOptions_JSType = {}));
997
+ })(FieldOptions_JSType || (exports.FieldOptions_JSType = FieldOptions_JSType = {}));
920
998
  // Retrieve enum metadata with: proto2.getEnumType(FieldOptions_JSType)
921
999
  proto2_js_1.proto2.util.setEnumType(FieldOptions_JSType, "google.protobuf.FieldOptions.JSType", [
922
1000
  { no: 0, name: "JS_NORMAL" },
@@ -944,7 +1022,7 @@ var FieldOptions_OptionRetention;
944
1022
  * @generated from enum value: RETENTION_SOURCE = 2;
945
1023
  */
946
1024
  FieldOptions_OptionRetention[FieldOptions_OptionRetention["RETENTION_SOURCE"] = 2] = "RETENTION_SOURCE";
947
- })(FieldOptions_OptionRetention = exports.FieldOptions_OptionRetention || (exports.FieldOptions_OptionRetention = {}));
1025
+ })(FieldOptions_OptionRetention || (exports.FieldOptions_OptionRetention = FieldOptions_OptionRetention = {}));
948
1026
  // Retrieve enum metadata with: proto2.getEnumType(FieldOptions_OptionRetention)
949
1027
  proto2_js_1.proto2.util.setEnumType(FieldOptions_OptionRetention, "google.protobuf.FieldOptions.OptionRetention", [
950
1028
  { no: 0, name: "RETENTION_UNKNOWN" },
@@ -1001,7 +1079,7 @@ var FieldOptions_OptionTargetType;
1001
1079
  * @generated from enum value: TARGET_TYPE_METHOD = 9;
1002
1080
  */
1003
1081
  FieldOptions_OptionTargetType[FieldOptions_OptionTargetType["TARGET_TYPE_METHOD"] = 9] = "TARGET_TYPE_METHOD";
1004
- })(FieldOptions_OptionTargetType = exports.FieldOptions_OptionTargetType || (exports.FieldOptions_OptionTargetType = {}));
1082
+ })(FieldOptions_OptionTargetType || (exports.FieldOptions_OptionTargetType = FieldOptions_OptionTargetType = {}));
1005
1083
  // Retrieve enum metadata with: proto2.getEnumType(FieldOptions_OptionTargetType)
1006
1084
  proto2_js_1.proto2.util.setEnumType(FieldOptions_OptionTargetType, "google.protobuf.FieldOptions.OptionTargetType", [
1007
1085
  { no: 0, name: "TARGET_TYPE_UNKNOWN" },
@@ -1212,7 +1290,7 @@ var MethodOptions_IdempotencyLevel;
1212
1290
  * @generated from enum value: IDEMPOTENT = 2;
1213
1291
  */
1214
1292
  MethodOptions_IdempotencyLevel[MethodOptions_IdempotencyLevel["IDEMPOTENT"] = 2] = "IDEMPOTENT";
1215
- })(MethodOptions_IdempotencyLevel = exports.MethodOptions_IdempotencyLevel || (exports.MethodOptions_IdempotencyLevel = {}));
1293
+ })(MethodOptions_IdempotencyLevel || (exports.MethodOptions_IdempotencyLevel = MethodOptions_IdempotencyLevel = {}));
1216
1294
  // Retrieve enum metadata with: proto2.getEnumType(MethodOptions_IdempotencyLevel)
1217
1295
  proto2_js_1.proto2.util.setEnumType(MethodOptions_IdempotencyLevel, "google.protobuf.MethodOptions.IdempotencyLevel", [
1218
1296
  { no: 0, name: "IDEMPOTENCY_UNKNOWN" },
@@ -1550,7 +1628,7 @@ var GeneratedCodeInfo_Annotation_Semantic;
1550
1628
  * @generated from enum value: ALIAS = 2;
1551
1629
  */
1552
1630
  GeneratedCodeInfo_Annotation_Semantic[GeneratedCodeInfo_Annotation_Semantic["ALIAS"] = 2] = "ALIAS";
1553
- })(GeneratedCodeInfo_Annotation_Semantic = exports.GeneratedCodeInfo_Annotation_Semantic || (exports.GeneratedCodeInfo_Annotation_Semantic = {}));
1631
+ })(GeneratedCodeInfo_Annotation_Semantic || (exports.GeneratedCodeInfo_Annotation_Semantic = GeneratedCodeInfo_Annotation_Semantic = {}));
1554
1632
  // Retrieve enum metadata with: proto2.getEnumType(GeneratedCodeInfo_Annotation_Semantic)
1555
1633
  proto2_js_1.proto2.util.setEnumType(GeneratedCodeInfo_Annotation_Semantic, "google.protobuf.GeneratedCodeInfo.Annotation.Semantic", [
1556
1634
  { no: 0, name: "NONE" },
@@ -268,7 +268,7 @@ class FieldMask extends message_js_1.Message {
268
268
  }
269
269
  return this.paths.map(p => {
270
270
  if (p.match(/_[0-9]?_/g) || p.match(/[A-Z]/g)) {
271
- throw new Error("cannot decode google.protobuf.FieldMask from JSON: lowerCamelCase of path name \"" + p + "\" is irreversible");
271
+ throw new Error("cannot encode google.protobuf.FieldMask to JSON: lowerCamelCase of path name \"" + p + "\" is irreversible");
272
272
  }
273
273
  return protoCamelCase(p);
274
274
  }).join(",");
@@ -14,7 +14,7 @@
14
14
  // limitations under the License.
15
15
  Object.defineProperty(exports, "__esModule", { value: true });
16
16
  exports.ListValue = exports.Value = exports.Struct = exports.NullValue = void 0;
17
- // @generated by protoc-gen-es v1.2.0 with parameter "bootstrap_wkt=true,ts_nocheck=false,target=ts"
17
+ // @generated by protoc-gen-es v1.3.0 with parameter "bootstrap_wkt=true,ts_nocheck=false,target=ts"
18
18
  // @generated from file google/protobuf/struct.proto (package google.protobuf, syntax proto3)
19
19
  /* eslint-disable */
20
20
  const proto3_js_1 = require("../../proto3.js");
@@ -23,7 +23,7 @@ const message_js_1 = require("../../message.js");
23
23
  * `NullValue` is a singleton enumeration to represent the null value for the
24
24
  * `Value` type union.
25
25
  *
26
- * The JSON representation for `NullValue` is JSON `null`.
26
+ * The JSON representation for `NullValue` is JSON `null`.
27
27
  *
28
28
  * @generated from enum google.protobuf.NullValue
29
29
  */
@@ -35,7 +35,7 @@ var NullValue;
35
35
  * @generated from enum value: NULL_VALUE = 0;
36
36
  */
37
37
  NullValue[NullValue["NULL_VALUE"] = 0] = "NULL_VALUE";
38
- })(NullValue = exports.NullValue || (exports.NullValue = {}));
38
+ })(NullValue || (exports.NullValue = NullValue = {}));
39
39
  // Retrieve enum metadata with: proto3.getEnumType(NullValue)
40
40
  proto3_js_1.proto3.util.setEnumType(NullValue, "google.protobuf.NullValue", [
41
41
  { no: 0, name: "NULL_VALUE" },
@@ -105,7 +105,7 @@ const proto3_js_1 = require("../../proto3.js");
105
105
  * [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with
106
106
  * the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use
107
107
  * the Joda Time's [`ISODateTimeFormat.dateTime()`](
108
- * http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime%2D%2D
108
+ * http://joda-time.sourceforge.net/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime()
109
109
  * ) to obtain a formatter capable of generating timestamps in this format.
110
110
  *
111
111
  *
@@ -14,7 +14,7 @@
14
14
  // limitations under the License.
15
15
  Object.defineProperty(exports, "__esModule", { value: true });
16
16
  exports.Option = exports.EnumValue = exports.Enum = exports.Field_Cardinality = exports.Field_Kind = exports.Field = exports.Type = exports.Syntax = void 0;
17
- // @generated by protoc-gen-es v1.2.0 with parameter "bootstrap_wkt=true,ts_nocheck=false,target=ts"
17
+ // @generated by protoc-gen-es v1.3.0 with parameter "bootstrap_wkt=true,ts_nocheck=false,target=ts"
18
18
  // @generated from file google/protobuf/type.proto (package google.protobuf, syntax proto3)
19
19
  /* eslint-disable */
20
20
  const proto3_js_1 = require("../../proto3.js");
@@ -40,11 +40,18 @@ var Syntax;
40
40
  * @generated from enum value: SYNTAX_PROTO3 = 1;
41
41
  */
42
42
  Syntax[Syntax["PROTO3"] = 1] = "PROTO3";
43
- })(Syntax = exports.Syntax || (exports.Syntax = {}));
43
+ /**
44
+ * Syntax `editions`.
45
+ *
46
+ * @generated from enum value: SYNTAX_EDITIONS = 2;
47
+ */
48
+ Syntax[Syntax["EDITIONS"] = 2] = "EDITIONS";
49
+ })(Syntax || (exports.Syntax = Syntax = {}));
44
50
  // Retrieve enum metadata with: proto3.getEnumType(Syntax)
45
51
  proto3_js_1.proto3.util.setEnumType(Syntax, "google.protobuf.Syntax", [
46
52
  { no: 0, name: "SYNTAX_PROTO2" },
47
53
  { no: 1, name: "SYNTAX_PROTO3" },
54
+ { no: 2, name: "SYNTAX_EDITIONS" },
48
55
  ]);
49
56
  /**
50
57
  * A protocol buffer message type.
@@ -84,6 +91,12 @@ class Type extends message_js_1.Message {
84
91
  * @generated from field: google.protobuf.Syntax syntax = 6;
85
92
  */
86
93
  this.syntax = Syntax.PROTO2;
94
+ /**
95
+ * The source edition string, only valid when syntax is SYNTAX_EDITIONS.
96
+ *
97
+ * @generated from field: string edition = 7;
98
+ */
99
+ this.edition = "";
87
100
  proto3_js_1.proto3.util.initPartial(data, this);
88
101
  }
89
102
  static fromBinary(bytes, options) {
@@ -109,6 +122,7 @@ Type.fields = proto3_js_1.proto3.util.newFieldList(() => [
109
122
  { no: 4, name: "options", kind: "message", T: Option, repeated: true },
110
123
  { no: 5, name: "source_context", kind: "message", T: source_context_pb_js_1.SourceContext },
111
124
  { no: 6, name: "syntax", kind: "enum", T: proto3_js_1.proto3.getEnumType(Syntax) },
125
+ { no: 7, name: "edition", kind: "scalar", T: 9 /* ScalarType.STRING */ },
112
126
  ]);
113
127
  /**
114
128
  * A single field of a message type.
@@ -331,7 +345,7 @@ var Field_Kind;
331
345
  * @generated from enum value: TYPE_SINT64 = 18;
332
346
  */
333
347
  Field_Kind[Field_Kind["TYPE_SINT64"] = 18] = "TYPE_SINT64";
334
- })(Field_Kind = exports.Field_Kind || (exports.Field_Kind = {}));
348
+ })(Field_Kind || (exports.Field_Kind = Field_Kind = {}));
335
349
  // Retrieve enum metadata with: proto3.getEnumType(Field_Kind)
336
350
  proto3_js_1.proto3.util.setEnumType(Field_Kind, "google.protobuf.Field.Kind", [
337
351
  { no: 0, name: "TYPE_UNKNOWN" },
@@ -385,7 +399,7 @@ var Field_Cardinality;
385
399
  * @generated from enum value: CARDINALITY_REPEATED = 3;
386
400
  */
387
401
  Field_Cardinality[Field_Cardinality["REPEATED"] = 3] = "REPEATED";
388
- })(Field_Cardinality = exports.Field_Cardinality || (exports.Field_Cardinality = {}));
402
+ })(Field_Cardinality || (exports.Field_Cardinality = Field_Cardinality = {}));
389
403
  // Retrieve enum metadata with: proto3.getEnumType(Field_Cardinality)
390
404
  proto3_js_1.proto3.util.setEnumType(Field_Cardinality, "google.protobuf.Field.Cardinality", [
391
405
  { no: 0, name: "CARDINALITY_UNKNOWN" },
@@ -425,6 +439,12 @@ class Enum extends message_js_1.Message {
425
439
  * @generated from field: google.protobuf.Syntax syntax = 5;
426
440
  */
427
441
  this.syntax = Syntax.PROTO2;
442
+ /**
443
+ * The source edition string, only valid when syntax is SYNTAX_EDITIONS.
444
+ *
445
+ * @generated from field: string edition = 6;
446
+ */
447
+ this.edition = "";
428
448
  proto3_js_1.proto3.util.initPartial(data, this);
429
449
  }
430
450
  static fromBinary(bytes, options) {
@@ -449,6 +469,7 @@ Enum.fields = proto3_js_1.proto3.util.newFieldList(() => [
449
469
  { no: 3, name: "options", kind: "message", T: Option, repeated: true },
450
470
  { no: 4, name: "source_context", kind: "message", T: source_context_pb_js_1.SourceContext },
451
471
  { no: 5, name: "syntax", kind: "enum", T: proto3_js_1.proto3.getEnumType(Syntax) },
472
+ { no: 6, name: "edition", kind: "scalar", T: 9 /* ScalarType.STRING */ },
452
473
  ]);
453
474
  /**
454
475
  * Enum value definition.
package/dist/cjs/index.js CHANGED
@@ -27,11 +27,13 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
27
27
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
28
28
  };
29
29
  Object.defineProperty(exports, "__esModule", { value: true });
30
- exports.createRegistryFromDescriptors = exports.createRegistry = exports.createDescriptorSet = exports.BinaryReader = exports.BinaryWriter = exports.WireType = exports.MethodIdempotency = exports.MethodKind = exports.ScalarType = exports.Message = exports.codegenInfo = exports.protoDelimited = exports.protoBase64 = exports.protoInt64 = exports.proto2 = exports.proto3 = void 0;
30
+ exports.toPlainMessage = exports.createRegistryFromDescriptors = exports.createRegistry = exports.createDescriptorSet = exports.BinaryReader = exports.BinaryWriter = exports.WireType = exports.MethodIdempotency = exports.MethodKind = exports.ScalarType = exports.Message = exports.codegenInfo = exports.protoDelimited = exports.protoBase64 = exports.protoInt64 = exports.protoDouble = exports.proto2 = exports.proto3 = void 0;
31
31
  var proto3_js_1 = require("./proto3.js");
32
32
  Object.defineProperty(exports, "proto3", { enumerable: true, get: function () { return proto3_js_1.proto3; } });
33
33
  var proto2_js_1 = require("./proto2.js");
34
34
  Object.defineProperty(exports, "proto2", { enumerable: true, get: function () { return proto2_js_1.proto2; } });
35
+ var proto_double_js_1 = require("./proto-double.js");
36
+ Object.defineProperty(exports, "protoDouble", { enumerable: true, get: function () { return proto_double_js_1.protoDouble; } });
35
37
  var proto_int64_js_1 = require("./proto-int64.js");
36
38
  Object.defineProperty(exports, "protoInt64", { enumerable: true, get: function () { return proto_int64_js_1.protoInt64; } });
37
39
  var proto_base64_js_1 = require("./proto-base64.js");
@@ -51,15 +53,14 @@ var binary_encoding_js_1 = require("./binary-encoding.js");
51
53
  Object.defineProperty(exports, "WireType", { enumerable: true, get: function () { return binary_encoding_js_1.WireType; } });
52
54
  Object.defineProperty(exports, "BinaryWriter", { enumerable: true, get: function () { return binary_encoding_js_1.BinaryWriter; } });
53
55
  Object.defineProperty(exports, "BinaryReader", { enumerable: true, get: function () { return binary_encoding_js_1.BinaryReader; } });
54
- var json_format_js_1 = require("./json-format.js");
55
- var descriptor_set_js_1 = require("./descriptor-set.js");
56
56
  var create_descriptor_set_js_1 = require("./create-descriptor-set.js");
57
57
  Object.defineProperty(exports, "createDescriptorSet", { enumerable: true, get: function () { return create_descriptor_set_js_1.createDescriptorSet; } });
58
- var type_registry_js_1 = require("./type-registry.js");
59
58
  var create_registry_js_1 = require("./create-registry.js");
60
59
  Object.defineProperty(exports, "createRegistry", { enumerable: true, get: function () { return create_registry_js_1.createRegistry; } });
61
60
  var create_registry_from_desc_js_1 = require("./create-registry-from-desc.js");
62
61
  Object.defineProperty(exports, "createRegistryFromDescriptors", { enumerable: true, get: function () { return create_registry_from_desc_js_1.createRegistryFromDescriptors; } });
62
+ var to_plain_message_js_1 = require("./to-plain-message.js");
63
+ Object.defineProperty(exports, "toPlainMessage", { enumerable: true, get: function () { return to_plain_message_js_1.toPlainMessage; } });
63
64
  // ideally, we would export these types with sub-path exports:
64
65
  __exportStar(require("./google/protobuf/compiler/plugin_pb.js"), exports);
65
66
  __exportStar(require("./google/protobuf/api_pb.js"), exports);
@@ -112,14 +112,14 @@ function makeBinaryFormatCommon() {
112
112
  const messageType = field.T;
113
113
  if (repeated) {
114
114
  // safe to assume presence of array, oneof cannot contain repeated values
115
- target[localName].push(messageType.fromBinary(reader.bytes(), options));
115
+ target[localName].push(readMessageField(reader, new messageType(), options));
116
116
  }
117
117
  else {
118
118
  if (target[localName] instanceof message_js_1.Message) {
119
- target[localName].fromBinary(reader.bytes(), options);
119
+ readMessageField(reader, target[localName], options);
120
120
  }
121
121
  else {
122
- target[localName] = messageType.fromBinary(reader.bytes(), options);
122
+ target[localName] = readMessageField(reader, new messageType(), options);
123
123
  if (messageType.fieldWrapper &&
124
124
  !field.oneof &&
125
125
  !field.repeated) {
@@ -139,6 +139,13 @@ function makeBinaryFormatCommon() {
139
139
  };
140
140
  }
141
141
  exports.makeBinaryFormatCommon = makeBinaryFormatCommon;
142
+ // Read a message, avoiding MessageType.fromBinary() to re-use the
143
+ // BinaryReadOptions and the IBinaryReader.
144
+ function readMessageField(reader, message, options) {
145
+ const format = message.getType().runtime.bin;
146
+ format.readMessage(message, reader, reader.uint32(), options);
147
+ return message;
148
+ }
142
149
  // Read a map field, expecting key field = 1, value field = 2
143
150
  function readMapEntry(field, reader, options) {
144
151
  const length = reader.uint32(), end = reader.pos + length;
@@ -158,7 +165,7 @@ function readMapEntry(field, reader, options) {
158
165
  val = reader.int32();
159
166
  break;
160
167
  case "message":
161
- val = field.V.T.fromBinary(reader.bytes(), options);
168
+ val = readMessageField(reader, new field.V.T(), options);
162
169
  break;
163
170
  }
164
171
  break;
@@ -189,9 +196,40 @@ function readMapEntry(field, reader, options) {
189
196
  }
190
197
  return [key, val];
191
198
  }
199
+ // Does not use scalarTypeInfo() for better performance.
192
200
  function readScalar(reader, type) {
193
- let [, method] = (0, scalars_js_1.scalarTypeInfo)(type);
194
- return reader[method]();
201
+ switch (type) {
202
+ case field_js_1.ScalarType.STRING:
203
+ return reader.string();
204
+ case field_js_1.ScalarType.BOOL:
205
+ return reader.bool();
206
+ case field_js_1.ScalarType.DOUBLE:
207
+ return reader.double();
208
+ case field_js_1.ScalarType.FLOAT:
209
+ return reader.float();
210
+ case field_js_1.ScalarType.INT32:
211
+ return reader.int32();
212
+ case field_js_1.ScalarType.INT64:
213
+ return reader.int64();
214
+ case field_js_1.ScalarType.UINT64:
215
+ return reader.uint64();
216
+ case field_js_1.ScalarType.FIXED64:
217
+ return reader.fixed64();
218
+ case field_js_1.ScalarType.BYTES:
219
+ return reader.bytes();
220
+ case field_js_1.ScalarType.FIXED32:
221
+ return reader.fixed32();
222
+ case field_js_1.ScalarType.SFIXED32:
223
+ return reader.sfixed32();
224
+ case field_js_1.ScalarType.SFIXED64:
225
+ return reader.sfixed64();
226
+ case field_js_1.ScalarType.SINT64:
227
+ return reader.sint64();
228
+ case field_js_1.ScalarType.UINT32:
229
+ return reader.uint32();
230
+ case field_js_1.ScalarType.SINT32:
231
+ return reader.sint32();
232
+ }
195
233
  }
196
234
  function writeMapEntry(writer, options, field, key, value) {
197
235
  writer.tag(field.no, binary_encoding_js_1.WireType.LengthDelimited);
@@ -90,15 +90,7 @@ exports.protoBase64 = {
90
90
  return bytes.subarray(0, bytePos);
91
91
  },
92
92
  /**
93
- * Decodes a base64 string to a byte array.
94
- *
95
- * - ignores white-space, including line breaks and tabs
96
- * - allows inner padding (can decode concatenated base64 strings)
97
- * - does not require padding
98
- * - understands base64url encoding:
99
- * "-" instead of "+",
100
- * "_" instead of "/",
101
- * no padding
93
+ * Encode a byte array to a base64 string.
102
94
  */
103
95
  enc(bytes) {
104
96
  let base64 = "", groupPos = 0, // position in base64 group
@@ -124,7 +116,7 @@ exports.protoBase64 = {
124
116
  break;
125
117
  }
126
118
  }
127
- // padding required?
119
+ // add output padding
128
120
  if (groupPos) {
129
121
  base64 += encTable[p];
130
122
  base64 += "=";
@@ -75,28 +75,23 @@ exports.protoDelimited = {
75
75
  }
76
76
  let buffer = new Uint8Array(0);
77
77
  try {
78
- for (var _d = true, iterable_1 = __asyncValues(iterable), iterable_1_1; iterable_1_1 = yield __await(iterable_1.next()), _a = iterable_1_1.done, !_a;) {
78
+ for (var _d = true, iterable_1 = __asyncValues(iterable), iterable_1_1; iterable_1_1 = yield __await(iterable_1.next()), _a = iterable_1_1.done, !_a; _d = true) {
79
79
  _c = iterable_1_1.value;
80
80
  _d = false;
81
- try {
82
- const chunk = _c;
83
- buffer = append(buffer, chunk);
84
- for (;;) {
85
- const size = exports.protoDelimited.peekSize(buffer);
86
- if (size.eof) {
87
- // size is incomplete, buffer more data
88
- break;
89
- }
90
- if (size.offset + size.size > buffer.byteLength) {
91
- // message is incomplete, buffer more data
92
- break;
93
- }
94
- yield yield __await(exports.protoDelimited.dec(type, buffer));
95
- buffer = buffer.subarray(size.offset + size.size);
81
+ const chunk = _c;
82
+ buffer = append(buffer, chunk);
83
+ for (;;) {
84
+ const size = exports.protoDelimited.peekSize(buffer);
85
+ if (size.eof) {
86
+ // size is incomplete, buffer more data
87
+ break;
96
88
  }
97
- }
98
- finally {
99
- _d = true;
89
+ if (size.offset + size.size > buffer.byteLength) {
90
+ // message is incomplete, buffer more data
91
+ break;
92
+ }
93
+ yield yield __await(exports.protoDelimited.dec(type, buffer));
94
+ buffer = buffer.subarray(size.offset + size.size);
100
95
  }
101
96
  }
102
97
  }
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ // Copyright 2021-2023 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.protoDouble = void 0;
17
+ // Export global Number constants. This is done so that we can safely use
18
+ // these global constants when generating code and be assured we're using
19
+ // the correct values. We cannot rely on globalThis since we support ES2017
20
+ // and globalThis was introduced in ES2020. We also don't want to explicitly
21
+ // generate code using, for example, Number.NaN, since this could clash with
22
+ // a message name of Number. Instead we can export them here since this will
23
+ // be in a different scope as the generated code and we are guaranteed to use
24
+ // the intended global values.
25
+ exports.protoDouble = {
26
+ NaN: Number.NaN,
27
+ POSITIVE_INFINITY: Number.POSITIVE_INFINITY,
28
+ NEGATIVE_INFINITY: Number.NEGATIVE_INFINITY,
29
+ };
@@ -19,7 +19,7 @@ const varint_js_1 = require("./google/varint.js");
19
19
  function makeInt64Support() {
20
20
  const dv = new DataView(new ArrayBuffer(8));
21
21
  // note that Safari 14 implements BigInt, but not the DataView methods
22
- const ok = globalThis.BigInt !== undefined &&
22
+ const ok = typeof BigInt === "function" &&
23
23
  typeof dv.getBigInt64 === "function" &&
24
24
  typeof dv.getBigUint64 === "function" &&
25
25
  typeof dv.setBigInt64 === "function" &&