@bufbuild/protobuf 1.2.1 → 1.3.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.
Files changed (48) 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 +1 -1
  5. package/dist/cjs/google/protobuf/api_pb.js +3 -3
  6. package/dist/cjs/google/protobuf/compiler/plugin_pb.js +5 -5
  7. package/dist/cjs/google/protobuf/descriptor_pb.js +38 -38
  8. package/dist/cjs/google/protobuf/duration_pb.js +1 -1
  9. package/dist/cjs/google/protobuf/empty_pb.js +1 -1
  10. package/dist/cjs/google/protobuf/field_mask_pb.js +1 -1
  11. package/dist/cjs/google/protobuf/source_context_pb.js +1 -1
  12. package/dist/cjs/google/protobuf/struct_pb.js +5 -5
  13. package/dist/cjs/google/protobuf/timestamp_pb.js +1 -1
  14. package/dist/cjs/google/protobuf/type_pb.js +9 -9
  15. package/dist/cjs/google/protobuf/wrappers_pb.js +9 -9
  16. package/dist/cjs/index.js +5 -1
  17. package/dist/cjs/private/json-format-common.js +2 -1
  18. package/dist/cjs/private/util-common.js +37 -8
  19. package/dist/cjs/proto-delimited.js +14 -19
  20. package/dist/cjs/proto-double.js +29 -0
  21. package/dist/cjs/proto-int64.js +1 -1
  22. package/dist/cjs/service-type.js +2 -2
  23. package/dist/cjs/to-plain-message.js +67 -0
  24. package/dist/esm/codegen-info.js +1 -0
  25. package/dist/esm/google/protobuf/any_pb.js +1 -2
  26. package/dist/esm/google/protobuf/api_pb.js +3 -6
  27. package/dist/esm/google/protobuf/compiler/plugin_pb.js +4 -8
  28. package/dist/esm/google/protobuf/descriptor_pb.js +28 -56
  29. package/dist/esm/google/protobuf/duration_pb.js +1 -2
  30. package/dist/esm/google/protobuf/empty_pb.js +1 -2
  31. package/dist/esm/google/protobuf/field_mask_pb.js +1 -2
  32. package/dist/esm/google/protobuf/source_context_pb.js +1 -2
  33. package/dist/esm/google/protobuf/struct_pb.js +4 -7
  34. package/dist/esm/google/protobuf/timestamp_pb.js +1 -2
  35. package/dist/esm/google/protobuf/type_pb.js +6 -11
  36. package/dist/esm/google/protobuf/wrappers_pb.js +9 -18
  37. package/dist/esm/index.js +2 -0
  38. package/dist/esm/private/json-format-common.js +2 -1
  39. package/dist/esm/private/util-common.js +37 -8
  40. package/dist/esm/proto-delimited.js +14 -19
  41. package/dist/esm/proto-double.js +26 -0
  42. package/dist/esm/proto-int64.js +1 -1
  43. package/dist/esm/to-plain-message.js +63 -0
  44. package/dist/types/codegen-info.d.ts +1 -1
  45. package/dist/types/index.d.ts +2 -0
  46. package/dist/types/proto-double.d.ts +5 -0
  47. package/dist/types/to-plain-message.d.ts +9 -0
  48. package/package.json +1 -1
@@ -160,10 +160,10 @@ class Duration extends message_js_1.Message {
160
160
  return proto3_js_1.proto3.util.equals(Duration, a, b);
161
161
  }
162
162
  }
163
+ exports.Duration = Duration;
163
164
  Duration.runtime = proto3_js_1.proto3;
164
165
  Duration.typeName = "google.protobuf.Duration";
165
166
  Duration.fields = proto3_js_1.proto3.util.newFieldList(() => [
166
167
  { no: 1, name: "seconds", kind: "scalar", T: 3 /* ScalarType.INT64 */ },
167
168
  { no: 2, name: "nanos", kind: "scalar", T: 5 /* ScalarType.INT32 */ },
168
169
  ]);
169
- exports.Duration = Duration;
@@ -46,7 +46,7 @@ class Empty extends message_js_1.Message {
46
46
  return proto3_js_1.proto3.util.equals(Empty, a, b);
47
47
  }
48
48
  }
49
+ exports.Empty = Empty;
49
50
  Empty.runtime = proto3_js_1.proto3;
50
51
  Empty.typeName = "google.protobuf.Empty";
51
52
  Empty.fields = proto3_js_1.proto3.util.newFieldList(() => []);
52
- exports.Empty = Empty;
@@ -303,9 +303,9 @@ class FieldMask extends message_js_1.Message {
303
303
  return proto3_js_1.proto3.util.equals(FieldMask, a, b);
304
304
  }
305
305
  }
306
+ exports.FieldMask = FieldMask;
306
307
  FieldMask.runtime = proto3_js_1.proto3;
307
308
  FieldMask.typeName = "google.protobuf.FieldMask";
308
309
  FieldMask.fields = proto3_js_1.proto3.util.newFieldList(() => [
309
310
  { no: 1, name: "paths", kind: "scalar", T: 9 /* ScalarType.STRING */, repeated: true },
310
311
  ]);
311
- exports.FieldMask = FieldMask;
@@ -47,9 +47,9 @@ class SourceContext extends message_js_1.Message {
47
47
  return proto3_js_1.proto3.util.equals(SourceContext, a, b);
48
48
  }
49
49
  }
50
+ exports.SourceContext = SourceContext;
50
51
  SourceContext.runtime = proto3_js_1.proto3;
51
52
  SourceContext.typeName = "google.protobuf.SourceContext";
52
53
  SourceContext.fields = proto3_js_1.proto3.util.newFieldList(() => [
53
54
  { no: 1, name: "file_name", kind: "scalar", T: 9 /* ScalarType.STRING */ },
54
55
  ]);
55
- exports.SourceContext = SourceContext;
@@ -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.1 with parameter "bootstrap_wkt=true,ts_nocheck=false,target=ts"
17
+ // @generated by protoc-gen-es v1.3.1 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");
@@ -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" },
@@ -92,12 +92,12 @@ class Struct extends message_js_1.Message {
92
92
  return proto3_js_1.proto3.util.equals(Struct, a, b);
93
93
  }
94
94
  }
95
+ exports.Struct = Struct;
95
96
  Struct.runtime = proto3_js_1.proto3;
96
97
  Struct.typeName = "google.protobuf.Struct";
97
98
  Struct.fields = proto3_js_1.proto3.util.newFieldList(() => [
98
99
  { no: 1, name: "fields", kind: "map", K: 9 /* ScalarType.STRING */, V: { kind: "message", T: Value } },
99
100
  ]);
100
- exports.Struct = Struct;
101
101
  /**
102
102
  * `Value` represents a dynamically typed value which can be either
103
103
  * null, a number, a string, a boolean, a recursive struct value, or a
@@ -178,6 +178,7 @@ class Value extends message_js_1.Message {
178
178
  return proto3_js_1.proto3.util.equals(Value, a, b);
179
179
  }
180
180
  }
181
+ exports.Value = Value;
181
182
  Value.runtime = proto3_js_1.proto3;
182
183
  Value.typeName = "google.protobuf.Value";
183
184
  Value.fields = proto3_js_1.proto3.util.newFieldList(() => [
@@ -188,7 +189,6 @@ Value.fields = proto3_js_1.proto3.util.newFieldList(() => [
188
189
  { no: 5, name: "struct_value", kind: "message", T: Struct, oneof: "kind" },
189
190
  { no: 6, name: "list_value", kind: "message", T: ListValue, oneof: "kind" },
190
191
  ]);
191
- exports.Value = Value;
192
192
  /**
193
193
  * `ListValue` is a wrapper around a repeated field of values.
194
194
  *
@@ -232,9 +232,9 @@ class ListValue extends message_js_1.Message {
232
232
  return proto3_js_1.proto3.util.equals(ListValue, a, b);
233
233
  }
234
234
  }
235
+ exports.ListValue = ListValue;
235
236
  ListValue.runtime = proto3_js_1.proto3;
236
237
  ListValue.typeName = "google.protobuf.ListValue";
237
238
  ListValue.fields = proto3_js_1.proto3.util.newFieldList(() => [
238
239
  { no: 1, name: "values", kind: "message", T: Value, repeated: true },
239
240
  ]);
240
- exports.ListValue = ListValue;
@@ -204,10 +204,10 @@ class Timestamp extends message_js_1.Message {
204
204
  return proto3_js_1.proto3.util.equals(Timestamp, a, b);
205
205
  }
206
206
  }
207
+ exports.Timestamp = Timestamp;
207
208
  Timestamp.runtime = proto3_js_1.proto3;
208
209
  Timestamp.typeName = "google.protobuf.Timestamp";
209
210
  Timestamp.fields = proto3_js_1.proto3.util.newFieldList(() => [
210
211
  { no: 1, name: "seconds", kind: "scalar", T: 3 /* ScalarType.INT64 */ },
211
212
  { no: 2, name: "nanos", kind: "scalar", T: 5 /* ScalarType.INT32 */ },
212
213
  ]);
213
- exports.Timestamp = Timestamp;
@@ -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.1 with parameter "bootstrap_wkt=true,ts_nocheck=false,target=ts"
17
+ // @generated by protoc-gen-es v1.3.1 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");
@@ -46,7 +46,7 @@ var Syntax;
46
46
  * @generated from enum value: SYNTAX_EDITIONS = 2;
47
47
  */
48
48
  Syntax[Syntax["EDITIONS"] = 2] = "EDITIONS";
49
- })(Syntax = exports.Syntax || (exports.Syntax = {}));
49
+ })(Syntax || (exports.Syntax = Syntax = {}));
50
50
  // Retrieve enum metadata with: proto3.getEnumType(Syntax)
51
51
  proto3_js_1.proto3.util.setEnumType(Syntax, "google.protobuf.Syntax", [
52
52
  { no: 0, name: "SYNTAX_PROTO2" },
@@ -112,6 +112,7 @@ class Type extends message_js_1.Message {
112
112
  return proto3_js_1.proto3.util.equals(Type, a, b);
113
113
  }
114
114
  }
115
+ exports.Type = Type;
115
116
  Type.runtime = proto3_js_1.proto3;
116
117
  Type.typeName = "google.protobuf.Type";
117
118
  Type.fields = proto3_js_1.proto3.util.newFieldList(() => [
@@ -123,7 +124,6 @@ Type.fields = proto3_js_1.proto3.util.newFieldList(() => [
123
124
  { no: 6, name: "syntax", kind: "enum", T: proto3_js_1.proto3.getEnumType(Syntax) },
124
125
  { no: 7, name: "edition", kind: "scalar", T: 9 /* ScalarType.STRING */ },
125
126
  ]);
126
- exports.Type = Type;
127
127
  /**
128
128
  * A single field of a message type.
129
129
  *
@@ -209,6 +209,7 @@ class Field extends message_js_1.Message {
209
209
  return proto3_js_1.proto3.util.equals(Field, a, b);
210
210
  }
211
211
  }
212
+ exports.Field = Field;
212
213
  Field.runtime = proto3_js_1.proto3;
213
214
  Field.typeName = "google.protobuf.Field";
214
215
  Field.fields = proto3_js_1.proto3.util.newFieldList(() => [
@@ -223,7 +224,6 @@ Field.fields = proto3_js_1.proto3.util.newFieldList(() => [
223
224
  { no: 10, name: "json_name", kind: "scalar", T: 9 /* ScalarType.STRING */ },
224
225
  { no: 11, name: "default_value", kind: "scalar", T: 9 /* ScalarType.STRING */ },
225
226
  ]);
226
- exports.Field = Field;
227
227
  /**
228
228
  * Basic field types.
229
229
  *
@@ -345,7 +345,7 @@ var Field_Kind;
345
345
  * @generated from enum value: TYPE_SINT64 = 18;
346
346
  */
347
347
  Field_Kind[Field_Kind["TYPE_SINT64"] = 18] = "TYPE_SINT64";
348
- })(Field_Kind = exports.Field_Kind || (exports.Field_Kind = {}));
348
+ })(Field_Kind || (exports.Field_Kind = Field_Kind = {}));
349
349
  // Retrieve enum metadata with: proto3.getEnumType(Field_Kind)
350
350
  proto3_js_1.proto3.util.setEnumType(Field_Kind, "google.protobuf.Field.Kind", [
351
351
  { no: 0, name: "TYPE_UNKNOWN" },
@@ -399,7 +399,7 @@ var Field_Cardinality;
399
399
  * @generated from enum value: CARDINALITY_REPEATED = 3;
400
400
  */
401
401
  Field_Cardinality[Field_Cardinality["REPEATED"] = 3] = "REPEATED";
402
- })(Field_Cardinality = exports.Field_Cardinality || (exports.Field_Cardinality = {}));
402
+ })(Field_Cardinality || (exports.Field_Cardinality = Field_Cardinality = {}));
403
403
  // Retrieve enum metadata with: proto3.getEnumType(Field_Cardinality)
404
404
  proto3_js_1.proto3.util.setEnumType(Field_Cardinality, "google.protobuf.Field.Cardinality", [
405
405
  { no: 0, name: "CARDINALITY_UNKNOWN" },
@@ -460,6 +460,7 @@ class Enum extends message_js_1.Message {
460
460
  return proto3_js_1.proto3.util.equals(Enum, a, b);
461
461
  }
462
462
  }
463
+ exports.Enum = Enum;
463
464
  Enum.runtime = proto3_js_1.proto3;
464
465
  Enum.typeName = "google.protobuf.Enum";
465
466
  Enum.fields = proto3_js_1.proto3.util.newFieldList(() => [
@@ -470,7 +471,6 @@ Enum.fields = proto3_js_1.proto3.util.newFieldList(() => [
470
471
  { no: 5, name: "syntax", kind: "enum", T: proto3_js_1.proto3.getEnumType(Syntax) },
471
472
  { no: 6, name: "edition", kind: "scalar", T: 9 /* ScalarType.STRING */ },
472
473
  ]);
473
- exports.Enum = Enum;
474
474
  /**
475
475
  * Enum value definition.
476
476
  *
@@ -512,6 +512,7 @@ class EnumValue extends message_js_1.Message {
512
512
  return proto3_js_1.proto3.util.equals(EnumValue, a, b);
513
513
  }
514
514
  }
515
+ exports.EnumValue = EnumValue;
515
516
  EnumValue.runtime = proto3_js_1.proto3;
516
517
  EnumValue.typeName = "google.protobuf.EnumValue";
517
518
  EnumValue.fields = proto3_js_1.proto3.util.newFieldList(() => [
@@ -519,7 +520,6 @@ EnumValue.fields = proto3_js_1.proto3.util.newFieldList(() => [
519
520
  { no: 2, name: "number", kind: "scalar", T: 5 /* ScalarType.INT32 */ },
520
521
  { no: 3, name: "options", kind: "message", T: Option, repeated: true },
521
522
  ]);
522
- exports.EnumValue = EnumValue;
523
523
  /**
524
524
  * A protocol buffer option, which can be attached to a message, field,
525
525
  * enumeration, etc.
@@ -553,10 +553,10 @@ class Option extends message_js_1.Message {
553
553
  return proto3_js_1.proto3.util.equals(Option, a, b);
554
554
  }
555
555
  }
556
+ exports.Option = Option;
556
557
  Option.runtime = proto3_js_1.proto3;
557
558
  Option.typeName = "google.protobuf.Option";
558
559
  Option.fields = proto3_js_1.proto3.util.newFieldList(() => [
559
560
  { no: 1, name: "name", kind: "scalar", T: 9 /* ScalarType.STRING */ },
560
561
  { no: 2, name: "value", kind: "message", T: any_pb_js_1.Any },
561
562
  ]);
562
- exports.Option = Option;
@@ -65,6 +65,7 @@ class DoubleValue extends message_js_1.Message {
65
65
  return proto3_js_1.proto3.util.equals(DoubleValue, a, b);
66
66
  }
67
67
  }
68
+ exports.DoubleValue = DoubleValue;
68
69
  DoubleValue.runtime = proto3_js_1.proto3;
69
70
  DoubleValue.typeName = "google.protobuf.DoubleValue";
70
71
  DoubleValue.fields = proto3_js_1.proto3.util.newFieldList(() => [
@@ -78,7 +79,6 @@ DoubleValue.fieldWrapper = {
78
79
  return value.value;
79
80
  }
80
81
  };
81
- exports.DoubleValue = DoubleValue;
82
82
  /**
83
83
  * Wrapper message for `float`.
84
84
  *
@@ -126,6 +126,7 @@ class FloatValue extends message_js_1.Message {
126
126
  return proto3_js_1.proto3.util.equals(FloatValue, a, b);
127
127
  }
128
128
  }
129
+ exports.FloatValue = FloatValue;
129
130
  FloatValue.runtime = proto3_js_1.proto3;
130
131
  FloatValue.typeName = "google.protobuf.FloatValue";
131
132
  FloatValue.fields = proto3_js_1.proto3.util.newFieldList(() => [
@@ -139,7 +140,6 @@ FloatValue.fieldWrapper = {
139
140
  return value.value;
140
141
  }
141
142
  };
142
- exports.FloatValue = FloatValue;
143
143
  /**
144
144
  * Wrapper message for `int64`.
145
145
  *
@@ -187,6 +187,7 @@ class Int64Value extends message_js_1.Message {
187
187
  return proto3_js_1.proto3.util.equals(Int64Value, a, b);
188
188
  }
189
189
  }
190
+ exports.Int64Value = Int64Value;
190
191
  Int64Value.runtime = proto3_js_1.proto3;
191
192
  Int64Value.typeName = "google.protobuf.Int64Value";
192
193
  Int64Value.fields = proto3_js_1.proto3.util.newFieldList(() => [
@@ -200,7 +201,6 @@ Int64Value.fieldWrapper = {
200
201
  return value.value;
201
202
  }
202
203
  };
203
- exports.Int64Value = Int64Value;
204
204
  /**
205
205
  * Wrapper message for `uint64`.
206
206
  *
@@ -248,6 +248,7 @@ class UInt64Value extends message_js_1.Message {
248
248
  return proto3_js_1.proto3.util.equals(UInt64Value, a, b);
249
249
  }
250
250
  }
251
+ exports.UInt64Value = UInt64Value;
251
252
  UInt64Value.runtime = proto3_js_1.proto3;
252
253
  UInt64Value.typeName = "google.protobuf.UInt64Value";
253
254
  UInt64Value.fields = proto3_js_1.proto3.util.newFieldList(() => [
@@ -261,7 +262,6 @@ UInt64Value.fieldWrapper = {
261
262
  return value.value;
262
263
  }
263
264
  };
264
- exports.UInt64Value = UInt64Value;
265
265
  /**
266
266
  * Wrapper message for `int32`.
267
267
  *
@@ -309,6 +309,7 @@ class Int32Value extends message_js_1.Message {
309
309
  return proto3_js_1.proto3.util.equals(Int32Value, a, b);
310
310
  }
311
311
  }
312
+ exports.Int32Value = Int32Value;
312
313
  Int32Value.runtime = proto3_js_1.proto3;
313
314
  Int32Value.typeName = "google.protobuf.Int32Value";
314
315
  Int32Value.fields = proto3_js_1.proto3.util.newFieldList(() => [
@@ -322,7 +323,6 @@ Int32Value.fieldWrapper = {
322
323
  return value.value;
323
324
  }
324
325
  };
325
- exports.Int32Value = Int32Value;
326
326
  /**
327
327
  * Wrapper message for `uint32`.
328
328
  *
@@ -370,6 +370,7 @@ class UInt32Value extends message_js_1.Message {
370
370
  return proto3_js_1.proto3.util.equals(UInt32Value, a, b);
371
371
  }
372
372
  }
373
+ exports.UInt32Value = UInt32Value;
373
374
  UInt32Value.runtime = proto3_js_1.proto3;
374
375
  UInt32Value.typeName = "google.protobuf.UInt32Value";
375
376
  UInt32Value.fields = proto3_js_1.proto3.util.newFieldList(() => [
@@ -383,7 +384,6 @@ UInt32Value.fieldWrapper = {
383
384
  return value.value;
384
385
  }
385
386
  };
386
- exports.UInt32Value = UInt32Value;
387
387
  /**
388
388
  * Wrapper message for `bool`.
389
389
  *
@@ -431,6 +431,7 @@ class BoolValue extends message_js_1.Message {
431
431
  return proto3_js_1.proto3.util.equals(BoolValue, a, b);
432
432
  }
433
433
  }
434
+ exports.BoolValue = BoolValue;
434
435
  BoolValue.runtime = proto3_js_1.proto3;
435
436
  BoolValue.typeName = "google.protobuf.BoolValue";
436
437
  BoolValue.fields = proto3_js_1.proto3.util.newFieldList(() => [
@@ -444,7 +445,6 @@ BoolValue.fieldWrapper = {
444
445
  return value.value;
445
446
  }
446
447
  };
447
- exports.BoolValue = BoolValue;
448
448
  /**
449
449
  * Wrapper message for `string`.
450
450
  *
@@ -492,6 +492,7 @@ class StringValue extends message_js_1.Message {
492
492
  return proto3_js_1.proto3.util.equals(StringValue, a, b);
493
493
  }
494
494
  }
495
+ exports.StringValue = StringValue;
495
496
  StringValue.runtime = proto3_js_1.proto3;
496
497
  StringValue.typeName = "google.protobuf.StringValue";
497
498
  StringValue.fields = proto3_js_1.proto3.util.newFieldList(() => [
@@ -505,7 +506,6 @@ StringValue.fieldWrapper = {
505
506
  return value.value;
506
507
  }
507
508
  };
508
- exports.StringValue = StringValue;
509
509
  /**
510
510
  * Wrapper message for `bytes`.
511
511
  *
@@ -553,6 +553,7 @@ class BytesValue extends message_js_1.Message {
553
553
  return proto3_js_1.proto3.util.equals(BytesValue, a, b);
554
554
  }
555
555
  }
556
+ exports.BytesValue = BytesValue;
556
557
  BytesValue.runtime = proto3_js_1.proto3;
557
558
  BytesValue.typeName = "google.protobuf.BytesValue";
558
559
  BytesValue.fields = proto3_js_1.proto3.util.newFieldList(() => [
@@ -566,4 +567,3 @@ BytesValue.fieldWrapper = {
566
567
  return value.value;
567
568
  }
568
569
  };
569
- exports.BytesValue = BytesValue;
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");
@@ -57,6 +59,8 @@ var create_registry_js_1 = require("./create-registry.js");
57
59
  Object.defineProperty(exports, "createRegistry", { enumerable: true, get: function () { return create_registry_js_1.createRegistry; } });
58
60
  var create_registry_from_desc_js_1 = require("./create-registry-from-desc.js");
59
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; } });
60
64
  // ideally, we would export these types with sub-path exports:
61
65
  __exportStar(require("./google/protobuf/compiler/plugin_pb.js"), exports);
62
66
  __exportStar(require("./google/protobuf/api_pb.js"), exports);
@@ -260,7 +260,7 @@ function debugJsonValue(json) {
260
260
  case "string":
261
261
  return json.length > 100 ? "string" : `"${json.split('"').join('\\"')}"`;
262
262
  default:
263
- return json.toString();
263
+ return String(json);
264
264
  }
265
265
  }
266
266
  // May throw an error. If the error message is non-blank, it should be shown.
@@ -390,6 +390,7 @@ function readEnum(type, json, ignoreUnknownFields) {
390
390
  break;
391
391
  case "string":
392
392
  const value = type.findName(json);
393
+ // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
393
394
  if (value || ignoreUnknownFields) {
394
395
  return value === null || value === void 0 ? void 0 : value.no;
395
396
  }
@@ -45,17 +45,35 @@ function makeUtilCommon() {
45
45
  !(val instanceof sourceField.T)) {
46
46
  val = new sourceField.T(val);
47
47
  }
48
+ else if (sourceField &&
49
+ sourceField.kind === "scalar" &&
50
+ sourceField.T === field_js_1.ScalarType.BYTES) {
51
+ val = toU8Arr(val);
52
+ }
48
53
  t[localName] = { case: sk, value: val };
49
54
  break;
50
55
  case "scalar":
51
56
  case "enum":
52
- t[localName] = s[localName];
57
+ let copy = s[localName];
58
+ if (member.T === field_js_1.ScalarType.BYTES) {
59
+ copy = member.repeated
60
+ ? copy.map(toU8Arr)
61
+ : toU8Arr(copy);
62
+ }
63
+ t[localName] = copy;
53
64
  break;
54
65
  case "map":
55
66
  switch (member.V.kind) {
56
67
  case "scalar":
57
68
  case "enum":
58
- Object.assign(t[localName], s[localName]);
69
+ if (member.V.T === field_js_1.ScalarType.BYTES) {
70
+ for (const [k, v] of Object.entries(s[localName])) {
71
+ t[localName][k] = toU8Arr(v);
72
+ }
73
+ }
74
+ else {
75
+ Object.assign(t[localName], s[localName]);
76
+ }
59
77
  break;
60
78
  case "message":
61
79
  const messageType = member.V.T;
@@ -79,7 +97,14 @@ function makeUtilCommon() {
79
97
  else if (s[localName] !== undefined) {
80
98
  const val = s[localName];
81
99
  if (mt.fieldWrapper) {
82
- t[localName] = val;
100
+ if (
101
+ // We can't use BytesValue.typeName as that will create a circular import
102
+ mt.typeName === "google.protobuf.BytesValue") {
103
+ t[localName] = toU8Arr(val);
104
+ }
105
+ else {
106
+ t[localName] = val;
107
+ }
83
108
  }
84
109
  else {
85
110
  t[localName] = val instanceof mt ? val : new mt(val);
@@ -161,22 +186,22 @@ function makeUtilCommon() {
161
186
  const source = message[member.localName];
162
187
  let copy;
163
188
  if (member.repeated) {
164
- copy = source.map((e) => cloneSingularField(member, e));
189
+ copy = source.map(cloneSingularField);
165
190
  }
166
191
  else if (member.kind == "map") {
167
192
  copy = any[member.localName];
168
193
  for (const [key, v] of Object.entries(source)) {
169
- copy[key] = cloneSingularField(member.V, v);
194
+ copy[key] = cloneSingularField(v);
170
195
  }
171
196
  }
172
197
  else if (member.kind == "oneof") {
173
198
  const f = member.findField(source.case);
174
199
  copy = f
175
- ? { case: source.case, value: cloneSingularField(f, source.value) }
200
+ ? { case: source.case, value: cloneSingularField(source.value) }
176
201
  : { case: undefined };
177
202
  }
178
203
  else {
179
- copy = cloneSingularField(member, source);
204
+ copy = cloneSingularField(source);
180
205
  }
181
206
  any[member.localName] = copy;
182
207
  }
@@ -186,7 +211,7 @@ function makeUtilCommon() {
186
211
  }
187
212
  exports.makeUtilCommon = makeUtilCommon;
188
213
  // clone a single field value - i.e. the element type of repeated fields, the value type of maps
189
- function cloneSingularField(field, value) {
214
+ function cloneSingularField(value) {
190
215
  if (value === undefined) {
191
216
  return value;
192
217
  }
@@ -200,3 +225,7 @@ function cloneSingularField(field, value) {
200
225
  }
201
226
  return value;
202
227
  }
228
+ // converts any ArrayLike<number> to Uint8Array if necessary.
229
+ function toU8Arr(input) {
230
+ return input instanceof Uint8Array ? input : new Uint8Array(input);
231
+ }
@@ -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" &&
@@ -29,7 +29,7 @@ var MethodKind;
29
29
  MethodKind[MethodKind["ServerStreaming"] = 1] = "ServerStreaming";
30
30
  MethodKind[MethodKind["ClientStreaming"] = 2] = "ClientStreaming";
31
31
  MethodKind[MethodKind["BiDiStreaming"] = 3] = "BiDiStreaming";
32
- })(MethodKind = exports.MethodKind || (exports.MethodKind = {}));
32
+ })(MethodKind || (exports.MethodKind = MethodKind = {}));
33
33
  /**
34
34
  * Is this method side-effect-free (or safe in HTTP parlance), or just
35
35
  * idempotent, or neither? HTTP based RPC implementation may choose GET verb
@@ -50,4 +50,4 @@ var MethodIdempotency;
50
50
  * Idempotent, but may have side effects.
51
51
  */
52
52
  MethodIdempotency[MethodIdempotency["Idempotent"] = 2] = "Idempotent";
53
- })(MethodIdempotency = exports.MethodIdempotency || (exports.MethodIdempotency = {}));
53
+ })(MethodIdempotency || (exports.MethodIdempotency = MethodIdempotency = {}));