@bufbuild/protobuf 0.0.2-alpha.3 → 0.0.5

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 (57) hide show
  1. package/README.md +5 -2
  2. package/dist/cjs/descriptor-registry.js +13 -0
  3. package/dist/cjs/google/protobuf/any_pb.js +6 -6
  4. package/dist/cjs/google/protobuf/api_pb.js +18 -18
  5. package/dist/cjs/google/protobuf/compiler/plugin_pb.js +22 -22
  6. package/dist/cjs/google/protobuf/descriptor_pb.js +148 -148
  7. package/dist/cjs/google/protobuf/duration_pb.js +11 -11
  8. package/dist/cjs/google/protobuf/empty_pb.js +6 -6
  9. package/dist/cjs/google/protobuf/field_mask_pb.js +7 -7
  10. package/dist/cjs/google/protobuf/source_context_pb.js +6 -6
  11. package/dist/cjs/google/protobuf/struct_pb.js +21 -21
  12. package/dist/cjs/google/protobuf/timestamp_pb.js +10 -10
  13. package/dist/cjs/google/protobuf/type_pb.js +33 -33
  14. package/dist/cjs/google/protobuf/wrappers_pb.js +66 -66
  15. package/dist/cjs/index-runtime.js +42 -0
  16. package/dist/cjs/index-wkt.js +42 -0
  17. package/dist/cjs/index.js +4 -40
  18. package/dist/cjs/package.json +1 -0
  19. package/dist/cjs/private/util-common.js +1 -1
  20. package/dist/cjs/type-registry.js +58 -13
  21. package/dist/esm/descriptor-registry.js +13 -0
  22. package/dist/esm/google/protobuf/any_pb.js +1 -1
  23. package/dist/esm/google/protobuf/api_pb.js +1 -1
  24. package/dist/esm/google/protobuf/compiler/plugin_pb.js +1 -1
  25. package/dist/esm/google/protobuf/descriptor_pb.js +1 -1
  26. package/dist/esm/google/protobuf/duration_pb.js +1 -1
  27. package/dist/esm/google/protobuf/empty_pb.js +1 -1
  28. package/dist/esm/google/protobuf/field_mask_pb.js +1 -1
  29. package/dist/esm/google/protobuf/source_context_pb.js +1 -1
  30. package/dist/esm/google/protobuf/struct_pb.js +1 -1
  31. package/dist/esm/google/protobuf/timestamp_pb.js +1 -1
  32. package/dist/esm/google/protobuf/type_pb.js +1 -1
  33. package/dist/esm/google/protobuf/wrappers_pb.js +1 -1
  34. package/dist/esm/index-runtime.js +25 -0
  35. package/dist/esm/index-wkt.js +26 -0
  36. package/dist/esm/index.js +4 -25
  37. package/dist/esm/private/util-common.js +1 -1
  38. package/dist/esm/type-registry.js +58 -13
  39. package/dist/types/descriptor-registry.d.ts +7 -0
  40. package/dist/types/google/protobuf/any_pb.d.ts +2 -2
  41. package/dist/types/google/protobuf/api_pb.d.ts +2 -2
  42. package/dist/types/google/protobuf/compiler/plugin_pb.d.ts +2 -2
  43. package/dist/types/google/protobuf/descriptor_pb.d.ts +2 -2
  44. package/dist/types/google/protobuf/duration_pb.d.ts +2 -2
  45. package/dist/types/google/protobuf/empty_pb.d.ts +2 -2
  46. package/dist/types/google/protobuf/field_mask_pb.d.ts +2 -2
  47. package/dist/types/google/protobuf/source_context_pb.d.ts +2 -2
  48. package/dist/types/google/protobuf/struct_pb.d.ts +2 -2
  49. package/dist/types/google/protobuf/timestamp_pb.d.ts +2 -2
  50. package/dist/types/google/protobuf/type_pb.d.ts +2 -2
  51. package/dist/types/google/protobuf/wrappers_pb.d.ts +2 -2
  52. package/dist/types/index-runtime.d.ts +19 -0
  53. package/dist/types/index-wkt.d.ts +12 -0
  54. package/dist/types/index.d.ts +2 -31
  55. package/dist/types/message.d.ts +1 -3
  56. package/dist/types/type-registry.d.ts +35 -2
  57. package/package.json +4 -3
@@ -14,7 +14,7 @@
14
14
  // limitations under the License.
15
15
  Object.defineProperty(exports, "__esModule", { value: true });
16
16
  exports.BytesValue = exports.StringValue = exports.BoolValue = exports.UInt32Value = exports.Int32Value = exports.UInt64Value = exports.Int64Value = exports.FloatValue = exports.DoubleValue = void 0;
17
- const index_js_1 = require("../../index.js");
17
+ const index_runtime_js_1 = require("../../index-runtime.js");
18
18
  /**
19
19
  * Wrapper message for `double`.
20
20
  *
@@ -22,7 +22,7 @@ const index_js_1 = require("../../index.js");
22
22
  *
23
23
  * @generated from message google.protobuf.DoubleValue
24
24
  */
25
- class DoubleValue extends index_js_1.Message {
25
+ class DoubleValue extends index_runtime_js_1.Message {
26
26
  constructor(data) {
27
27
  super();
28
28
  /**
@@ -31,14 +31,14 @@ class DoubleValue extends index_js_1.Message {
31
31
  * @generated from field: double value = 1;
32
32
  */
33
33
  this.value = 0;
34
- index_js_1.proto3.util.initPartial(data, this);
34
+ index_runtime_js_1.proto3.util.initPartial(data, this);
35
35
  }
36
36
  toJson(options) {
37
- return index_js_1.proto3.json.writeScalar(index_js_1.ScalarType.DOUBLE, this.value, true);
37
+ return index_runtime_js_1.proto3.json.writeScalar(index_runtime_js_1.ScalarType.DOUBLE, this.value, true);
38
38
  }
39
39
  fromJson(json, options) {
40
40
  try {
41
- this.value = index_js_1.proto3.json.readScalar(index_js_1.ScalarType.DOUBLE, json);
41
+ this.value = index_runtime_js_1.proto3.json.readScalar(index_runtime_js_1.ScalarType.DOUBLE, json);
42
42
  }
43
43
  catch (e) {
44
44
  let m = `cannot decode message google.protobuf.DoubleValue from JSON"`;
@@ -59,13 +59,13 @@ class DoubleValue extends index_js_1.Message {
59
59
  return new DoubleValue().fromJsonString(jsonString, options);
60
60
  }
61
61
  static equals(a, b) {
62
- return index_js_1.proto3.util.equals(DoubleValue, a, b);
62
+ return index_runtime_js_1.proto3.util.equals(DoubleValue, a, b);
63
63
  }
64
64
  }
65
65
  exports.DoubleValue = DoubleValue;
66
- DoubleValue.runtime = index_js_1.proto3;
66
+ DoubleValue.runtime = index_runtime_js_1.proto3;
67
67
  DoubleValue.typeName = "google.protobuf.DoubleValue";
68
- DoubleValue.fields = index_js_1.proto3.util.newFieldList(() => [
68
+ DoubleValue.fields = index_runtime_js_1.proto3.util.newFieldList(() => [
69
69
  { no: 1, name: "value", kind: "scalar", T: 1 /* ScalarType.DOUBLE */ },
70
70
  ]);
71
71
  DoubleValue.fieldWrapper = {
@@ -83,7 +83,7 @@ DoubleValue.fieldWrapper = {
83
83
  *
84
84
  * @generated from message google.protobuf.FloatValue
85
85
  */
86
- class FloatValue extends index_js_1.Message {
86
+ class FloatValue extends index_runtime_js_1.Message {
87
87
  constructor(data) {
88
88
  super();
89
89
  /**
@@ -92,14 +92,14 @@ class FloatValue extends index_js_1.Message {
92
92
  * @generated from field: float value = 1;
93
93
  */
94
94
  this.value = 0;
95
- index_js_1.proto3.util.initPartial(data, this);
95
+ index_runtime_js_1.proto3.util.initPartial(data, this);
96
96
  }
97
97
  toJson(options) {
98
- return index_js_1.proto3.json.writeScalar(index_js_1.ScalarType.FLOAT, this.value, true);
98
+ return index_runtime_js_1.proto3.json.writeScalar(index_runtime_js_1.ScalarType.FLOAT, this.value, true);
99
99
  }
100
100
  fromJson(json, options) {
101
101
  try {
102
- this.value = index_js_1.proto3.json.readScalar(index_js_1.ScalarType.FLOAT, json);
102
+ this.value = index_runtime_js_1.proto3.json.readScalar(index_runtime_js_1.ScalarType.FLOAT, json);
103
103
  }
104
104
  catch (e) {
105
105
  let m = `cannot decode message google.protobuf.FloatValue from JSON"`;
@@ -120,13 +120,13 @@ class FloatValue extends index_js_1.Message {
120
120
  return new FloatValue().fromJsonString(jsonString, options);
121
121
  }
122
122
  static equals(a, b) {
123
- return index_js_1.proto3.util.equals(FloatValue, a, b);
123
+ return index_runtime_js_1.proto3.util.equals(FloatValue, a, b);
124
124
  }
125
125
  }
126
126
  exports.FloatValue = FloatValue;
127
- FloatValue.runtime = index_js_1.proto3;
127
+ FloatValue.runtime = index_runtime_js_1.proto3;
128
128
  FloatValue.typeName = "google.protobuf.FloatValue";
129
- FloatValue.fields = index_js_1.proto3.util.newFieldList(() => [
129
+ FloatValue.fields = index_runtime_js_1.proto3.util.newFieldList(() => [
130
130
  { no: 1, name: "value", kind: "scalar", T: 2 /* ScalarType.FLOAT */ },
131
131
  ]);
132
132
  FloatValue.fieldWrapper = {
@@ -144,7 +144,7 @@ FloatValue.fieldWrapper = {
144
144
  *
145
145
  * @generated from message google.protobuf.Int64Value
146
146
  */
147
- class Int64Value extends index_js_1.Message {
147
+ class Int64Value extends index_runtime_js_1.Message {
148
148
  constructor(data) {
149
149
  super();
150
150
  /**
@@ -152,15 +152,15 @@ class Int64Value extends index_js_1.Message {
152
152
  *
153
153
  * @generated from field: int64 value = 1;
154
154
  */
155
- this.value = index_js_1.protoInt64.zero;
156
- index_js_1.proto3.util.initPartial(data, this);
155
+ this.value = index_runtime_js_1.protoInt64.zero;
156
+ index_runtime_js_1.proto3.util.initPartial(data, this);
157
157
  }
158
158
  toJson(options) {
159
- return index_js_1.proto3.json.writeScalar(index_js_1.ScalarType.INT64, this.value, true);
159
+ return index_runtime_js_1.proto3.json.writeScalar(index_runtime_js_1.ScalarType.INT64, this.value, true);
160
160
  }
161
161
  fromJson(json, options) {
162
162
  try {
163
- this.value = index_js_1.proto3.json.readScalar(index_js_1.ScalarType.INT64, json);
163
+ this.value = index_runtime_js_1.proto3.json.readScalar(index_runtime_js_1.ScalarType.INT64, json);
164
164
  }
165
165
  catch (e) {
166
166
  let m = `cannot decode message google.protobuf.Int64Value from JSON"`;
@@ -181,13 +181,13 @@ class Int64Value extends index_js_1.Message {
181
181
  return new Int64Value().fromJsonString(jsonString, options);
182
182
  }
183
183
  static equals(a, b) {
184
- return index_js_1.proto3.util.equals(Int64Value, a, b);
184
+ return index_runtime_js_1.proto3.util.equals(Int64Value, a, b);
185
185
  }
186
186
  }
187
187
  exports.Int64Value = Int64Value;
188
- Int64Value.runtime = index_js_1.proto3;
188
+ Int64Value.runtime = index_runtime_js_1.proto3;
189
189
  Int64Value.typeName = "google.protobuf.Int64Value";
190
- Int64Value.fields = index_js_1.proto3.util.newFieldList(() => [
190
+ Int64Value.fields = index_runtime_js_1.proto3.util.newFieldList(() => [
191
191
  { no: 1, name: "value", kind: "scalar", T: 3 /* ScalarType.INT64 */ },
192
192
  ]);
193
193
  Int64Value.fieldWrapper = {
@@ -205,7 +205,7 @@ Int64Value.fieldWrapper = {
205
205
  *
206
206
  * @generated from message google.protobuf.UInt64Value
207
207
  */
208
- class UInt64Value extends index_js_1.Message {
208
+ class UInt64Value extends index_runtime_js_1.Message {
209
209
  constructor(data) {
210
210
  super();
211
211
  /**
@@ -213,15 +213,15 @@ class UInt64Value extends index_js_1.Message {
213
213
  *
214
214
  * @generated from field: uint64 value = 1;
215
215
  */
216
- this.value = index_js_1.protoInt64.zero;
217
- index_js_1.proto3.util.initPartial(data, this);
216
+ this.value = index_runtime_js_1.protoInt64.zero;
217
+ index_runtime_js_1.proto3.util.initPartial(data, this);
218
218
  }
219
219
  toJson(options) {
220
- return index_js_1.proto3.json.writeScalar(index_js_1.ScalarType.UINT64, this.value, true);
220
+ return index_runtime_js_1.proto3.json.writeScalar(index_runtime_js_1.ScalarType.UINT64, this.value, true);
221
221
  }
222
222
  fromJson(json, options) {
223
223
  try {
224
- this.value = index_js_1.proto3.json.readScalar(index_js_1.ScalarType.UINT64, json);
224
+ this.value = index_runtime_js_1.proto3.json.readScalar(index_runtime_js_1.ScalarType.UINT64, json);
225
225
  }
226
226
  catch (e) {
227
227
  let m = `cannot decode message google.protobuf.UInt64Value from JSON"`;
@@ -242,13 +242,13 @@ class UInt64Value extends index_js_1.Message {
242
242
  return new UInt64Value().fromJsonString(jsonString, options);
243
243
  }
244
244
  static equals(a, b) {
245
- return index_js_1.proto3.util.equals(UInt64Value, a, b);
245
+ return index_runtime_js_1.proto3.util.equals(UInt64Value, a, b);
246
246
  }
247
247
  }
248
248
  exports.UInt64Value = UInt64Value;
249
- UInt64Value.runtime = index_js_1.proto3;
249
+ UInt64Value.runtime = index_runtime_js_1.proto3;
250
250
  UInt64Value.typeName = "google.protobuf.UInt64Value";
251
- UInt64Value.fields = index_js_1.proto3.util.newFieldList(() => [
251
+ UInt64Value.fields = index_runtime_js_1.proto3.util.newFieldList(() => [
252
252
  { no: 1, name: "value", kind: "scalar", T: 4 /* ScalarType.UINT64 */ },
253
253
  ]);
254
254
  UInt64Value.fieldWrapper = {
@@ -266,7 +266,7 @@ UInt64Value.fieldWrapper = {
266
266
  *
267
267
  * @generated from message google.protobuf.Int32Value
268
268
  */
269
- class Int32Value extends index_js_1.Message {
269
+ class Int32Value extends index_runtime_js_1.Message {
270
270
  constructor(data) {
271
271
  super();
272
272
  /**
@@ -275,14 +275,14 @@ class Int32Value extends index_js_1.Message {
275
275
  * @generated from field: int32 value = 1;
276
276
  */
277
277
  this.value = 0;
278
- index_js_1.proto3.util.initPartial(data, this);
278
+ index_runtime_js_1.proto3.util.initPartial(data, this);
279
279
  }
280
280
  toJson(options) {
281
- return index_js_1.proto3.json.writeScalar(index_js_1.ScalarType.INT32, this.value, true);
281
+ return index_runtime_js_1.proto3.json.writeScalar(index_runtime_js_1.ScalarType.INT32, this.value, true);
282
282
  }
283
283
  fromJson(json, options) {
284
284
  try {
285
- this.value = index_js_1.proto3.json.readScalar(index_js_1.ScalarType.INT32, json);
285
+ this.value = index_runtime_js_1.proto3.json.readScalar(index_runtime_js_1.ScalarType.INT32, json);
286
286
  }
287
287
  catch (e) {
288
288
  let m = `cannot decode message google.protobuf.Int32Value from JSON"`;
@@ -303,13 +303,13 @@ class Int32Value extends index_js_1.Message {
303
303
  return new Int32Value().fromJsonString(jsonString, options);
304
304
  }
305
305
  static equals(a, b) {
306
- return index_js_1.proto3.util.equals(Int32Value, a, b);
306
+ return index_runtime_js_1.proto3.util.equals(Int32Value, a, b);
307
307
  }
308
308
  }
309
309
  exports.Int32Value = Int32Value;
310
- Int32Value.runtime = index_js_1.proto3;
310
+ Int32Value.runtime = index_runtime_js_1.proto3;
311
311
  Int32Value.typeName = "google.protobuf.Int32Value";
312
- Int32Value.fields = index_js_1.proto3.util.newFieldList(() => [
312
+ Int32Value.fields = index_runtime_js_1.proto3.util.newFieldList(() => [
313
313
  { no: 1, name: "value", kind: "scalar", T: 5 /* ScalarType.INT32 */ },
314
314
  ]);
315
315
  Int32Value.fieldWrapper = {
@@ -327,7 +327,7 @@ Int32Value.fieldWrapper = {
327
327
  *
328
328
  * @generated from message google.protobuf.UInt32Value
329
329
  */
330
- class UInt32Value extends index_js_1.Message {
330
+ class UInt32Value extends index_runtime_js_1.Message {
331
331
  constructor(data) {
332
332
  super();
333
333
  /**
@@ -336,14 +336,14 @@ class UInt32Value extends index_js_1.Message {
336
336
  * @generated from field: uint32 value = 1;
337
337
  */
338
338
  this.value = 0;
339
- index_js_1.proto3.util.initPartial(data, this);
339
+ index_runtime_js_1.proto3.util.initPartial(data, this);
340
340
  }
341
341
  toJson(options) {
342
- return index_js_1.proto3.json.writeScalar(index_js_1.ScalarType.UINT32, this.value, true);
342
+ return index_runtime_js_1.proto3.json.writeScalar(index_runtime_js_1.ScalarType.UINT32, this.value, true);
343
343
  }
344
344
  fromJson(json, options) {
345
345
  try {
346
- this.value = index_js_1.proto3.json.readScalar(index_js_1.ScalarType.UINT32, json);
346
+ this.value = index_runtime_js_1.proto3.json.readScalar(index_runtime_js_1.ScalarType.UINT32, json);
347
347
  }
348
348
  catch (e) {
349
349
  let m = `cannot decode message google.protobuf.UInt32Value from JSON"`;
@@ -364,13 +364,13 @@ class UInt32Value extends index_js_1.Message {
364
364
  return new UInt32Value().fromJsonString(jsonString, options);
365
365
  }
366
366
  static equals(a, b) {
367
- return index_js_1.proto3.util.equals(UInt32Value, a, b);
367
+ return index_runtime_js_1.proto3.util.equals(UInt32Value, a, b);
368
368
  }
369
369
  }
370
370
  exports.UInt32Value = UInt32Value;
371
- UInt32Value.runtime = index_js_1.proto3;
371
+ UInt32Value.runtime = index_runtime_js_1.proto3;
372
372
  UInt32Value.typeName = "google.protobuf.UInt32Value";
373
- UInt32Value.fields = index_js_1.proto3.util.newFieldList(() => [
373
+ UInt32Value.fields = index_runtime_js_1.proto3.util.newFieldList(() => [
374
374
  { no: 1, name: "value", kind: "scalar", T: 13 /* ScalarType.UINT32 */ },
375
375
  ]);
376
376
  UInt32Value.fieldWrapper = {
@@ -388,7 +388,7 @@ UInt32Value.fieldWrapper = {
388
388
  *
389
389
  * @generated from message google.protobuf.BoolValue
390
390
  */
391
- class BoolValue extends index_js_1.Message {
391
+ class BoolValue extends index_runtime_js_1.Message {
392
392
  constructor(data) {
393
393
  super();
394
394
  /**
@@ -397,14 +397,14 @@ class BoolValue extends index_js_1.Message {
397
397
  * @generated from field: bool value = 1;
398
398
  */
399
399
  this.value = false;
400
- index_js_1.proto3.util.initPartial(data, this);
400
+ index_runtime_js_1.proto3.util.initPartial(data, this);
401
401
  }
402
402
  toJson(options) {
403
- return index_js_1.proto3.json.writeScalar(index_js_1.ScalarType.BOOL, this.value, true);
403
+ return index_runtime_js_1.proto3.json.writeScalar(index_runtime_js_1.ScalarType.BOOL, this.value, true);
404
404
  }
405
405
  fromJson(json, options) {
406
406
  try {
407
- this.value = index_js_1.proto3.json.readScalar(index_js_1.ScalarType.BOOL, json);
407
+ this.value = index_runtime_js_1.proto3.json.readScalar(index_runtime_js_1.ScalarType.BOOL, json);
408
408
  }
409
409
  catch (e) {
410
410
  let m = `cannot decode message google.protobuf.BoolValue from JSON"`;
@@ -425,13 +425,13 @@ class BoolValue extends index_js_1.Message {
425
425
  return new BoolValue().fromJsonString(jsonString, options);
426
426
  }
427
427
  static equals(a, b) {
428
- return index_js_1.proto3.util.equals(BoolValue, a, b);
428
+ return index_runtime_js_1.proto3.util.equals(BoolValue, a, b);
429
429
  }
430
430
  }
431
431
  exports.BoolValue = BoolValue;
432
- BoolValue.runtime = index_js_1.proto3;
432
+ BoolValue.runtime = index_runtime_js_1.proto3;
433
433
  BoolValue.typeName = "google.protobuf.BoolValue";
434
- BoolValue.fields = index_js_1.proto3.util.newFieldList(() => [
434
+ BoolValue.fields = index_runtime_js_1.proto3.util.newFieldList(() => [
435
435
  { no: 1, name: "value", kind: "scalar", T: 8 /* ScalarType.BOOL */ },
436
436
  ]);
437
437
  BoolValue.fieldWrapper = {
@@ -449,7 +449,7 @@ BoolValue.fieldWrapper = {
449
449
  *
450
450
  * @generated from message google.protobuf.StringValue
451
451
  */
452
- class StringValue extends index_js_1.Message {
452
+ class StringValue extends index_runtime_js_1.Message {
453
453
  constructor(data) {
454
454
  super();
455
455
  /**
@@ -458,14 +458,14 @@ class StringValue extends index_js_1.Message {
458
458
  * @generated from field: string value = 1;
459
459
  */
460
460
  this.value = "";
461
- index_js_1.proto3.util.initPartial(data, this);
461
+ index_runtime_js_1.proto3.util.initPartial(data, this);
462
462
  }
463
463
  toJson(options) {
464
- return index_js_1.proto3.json.writeScalar(index_js_1.ScalarType.STRING, this.value, true);
464
+ return index_runtime_js_1.proto3.json.writeScalar(index_runtime_js_1.ScalarType.STRING, this.value, true);
465
465
  }
466
466
  fromJson(json, options) {
467
467
  try {
468
- this.value = index_js_1.proto3.json.readScalar(index_js_1.ScalarType.STRING, json);
468
+ this.value = index_runtime_js_1.proto3.json.readScalar(index_runtime_js_1.ScalarType.STRING, json);
469
469
  }
470
470
  catch (e) {
471
471
  let m = `cannot decode message google.protobuf.StringValue from JSON"`;
@@ -486,13 +486,13 @@ class StringValue extends index_js_1.Message {
486
486
  return new StringValue().fromJsonString(jsonString, options);
487
487
  }
488
488
  static equals(a, b) {
489
- return index_js_1.proto3.util.equals(StringValue, a, b);
489
+ return index_runtime_js_1.proto3.util.equals(StringValue, a, b);
490
490
  }
491
491
  }
492
492
  exports.StringValue = StringValue;
493
- StringValue.runtime = index_js_1.proto3;
493
+ StringValue.runtime = index_runtime_js_1.proto3;
494
494
  StringValue.typeName = "google.protobuf.StringValue";
495
- StringValue.fields = index_js_1.proto3.util.newFieldList(() => [
495
+ StringValue.fields = index_runtime_js_1.proto3.util.newFieldList(() => [
496
496
  { no: 1, name: "value", kind: "scalar", T: 9 /* ScalarType.STRING */ },
497
497
  ]);
498
498
  StringValue.fieldWrapper = {
@@ -510,7 +510,7 @@ StringValue.fieldWrapper = {
510
510
  *
511
511
  * @generated from message google.protobuf.BytesValue
512
512
  */
513
- class BytesValue extends index_js_1.Message {
513
+ class BytesValue extends index_runtime_js_1.Message {
514
514
  constructor(data) {
515
515
  super();
516
516
  /**
@@ -519,14 +519,14 @@ class BytesValue extends index_js_1.Message {
519
519
  * @generated from field: bytes value = 1;
520
520
  */
521
521
  this.value = new Uint8Array(0);
522
- index_js_1.proto3.util.initPartial(data, this);
522
+ index_runtime_js_1.proto3.util.initPartial(data, this);
523
523
  }
524
524
  toJson(options) {
525
- return index_js_1.proto3.json.writeScalar(index_js_1.ScalarType.BYTES, this.value, true);
525
+ return index_runtime_js_1.proto3.json.writeScalar(index_runtime_js_1.ScalarType.BYTES, this.value, true);
526
526
  }
527
527
  fromJson(json, options) {
528
528
  try {
529
- this.value = index_js_1.proto3.json.readScalar(index_js_1.ScalarType.BYTES, json);
529
+ this.value = index_runtime_js_1.proto3.json.readScalar(index_runtime_js_1.ScalarType.BYTES, json);
530
530
  }
531
531
  catch (e) {
532
532
  let m = `cannot decode message google.protobuf.BytesValue from JSON"`;
@@ -547,13 +547,13 @@ class BytesValue extends index_js_1.Message {
547
547
  return new BytesValue().fromJsonString(jsonString, options);
548
548
  }
549
549
  static equals(a, b) {
550
- return index_js_1.proto3.util.equals(BytesValue, a, b);
550
+ return index_runtime_js_1.proto3.util.equals(BytesValue, a, b);
551
551
  }
552
552
  }
553
553
  exports.BytesValue = BytesValue;
554
- BytesValue.runtime = index_js_1.proto3;
554
+ BytesValue.runtime = index_runtime_js_1.proto3;
555
555
  BytesValue.typeName = "google.protobuf.BytesValue";
556
- BytesValue.fields = index_js_1.proto3.util.newFieldList(() => [
556
+ BytesValue.fields = index_runtime_js_1.proto3.util.newFieldList(() => [
557
557
  { no: 1, name: "value", kind: "scalar", T: 12 /* ScalarType.BYTES */ },
558
558
  ]);
559
559
  BytesValue.fieldWrapper = {
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ // Copyright 2021-2022 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.BinaryReader = exports.BinaryWriter = exports.WireType = exports.DescriptorSet = exports.DescriptorRegistry = exports.TypeRegistry = exports.MethodIdempotency = exports.MethodKind = exports.ScalarType = exports.Message = exports.protoBase64 = exports.protoInt64 = exports.proto2 = exports.proto3 = void 0;
17
+ var proto3_js_1 = require("./proto3.js");
18
+ Object.defineProperty(exports, "proto3", { enumerable: true, get: function () { return proto3_js_1.proto3; } });
19
+ var proto2_js_1 = require("./proto2.js");
20
+ Object.defineProperty(exports, "proto2", { enumerable: true, get: function () { return proto2_js_1.proto2; } });
21
+ var proto_int64_js_1 = require("./proto-int64.js");
22
+ Object.defineProperty(exports, "protoInt64", { enumerable: true, get: function () { return proto_int64_js_1.protoInt64; } });
23
+ var proto_base64_js_1 = require("./proto-base64.js");
24
+ Object.defineProperty(exports, "protoBase64", { enumerable: true, get: function () { return proto_base64_js_1.protoBase64; } });
25
+ var message_js_1 = require("./message.js");
26
+ Object.defineProperty(exports, "Message", { enumerable: true, get: function () { return message_js_1.Message; } });
27
+ var field_js_1 = require("./field.js");
28
+ Object.defineProperty(exports, "ScalarType", { enumerable: true, get: function () { return field_js_1.ScalarType; } });
29
+ var service_type_js_1 = require("./service-type.js");
30
+ Object.defineProperty(exports, "MethodKind", { enumerable: true, get: function () { return service_type_js_1.MethodKind; } });
31
+ Object.defineProperty(exports, "MethodIdempotency", { enumerable: true, get: function () { return service_type_js_1.MethodIdempotency; } });
32
+ var type_registry_js_1 = require("./type-registry.js");
33
+ Object.defineProperty(exports, "TypeRegistry", { enumerable: true, get: function () { return type_registry_js_1.TypeRegistry; } });
34
+ var descriptor_registry_js_1 = require("./descriptor-registry.js");
35
+ Object.defineProperty(exports, "DescriptorRegistry", { enumerable: true, get: function () { return descriptor_registry_js_1.DescriptorRegistry; } });
36
+ var descriptor_set_js_1 = require("./descriptor-set.js");
37
+ Object.defineProperty(exports, "DescriptorSet", { enumerable: true, get: function () { return descriptor_set_js_1.DescriptorSet; } });
38
+ var binary_encoding_js_1 = require("./binary-encoding.js");
39
+ Object.defineProperty(exports, "WireType", { enumerable: true, get: function () { return binary_encoding_js_1.WireType; } });
40
+ Object.defineProperty(exports, "BinaryWriter", { enumerable: true, get: function () { return binary_encoding_js_1.BinaryWriter; } });
41
+ Object.defineProperty(exports, "BinaryReader", { enumerable: true, get: function () { return binary_encoding_js_1.BinaryReader; } });
42
+ var json_format_js_1 = require("./json-format.js");
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ // Copyright 2021-2022 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
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
16
+ if (k2 === undefined) k2 = k;
17
+ var desc = Object.getOwnPropertyDescriptor(m, k);
18
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
19
+ desc = { enumerable: true, get: function() { return m[k]; } };
20
+ }
21
+ Object.defineProperty(o, k2, desc);
22
+ }) : (function(o, m, k, k2) {
23
+ if (k2 === undefined) k2 = k;
24
+ o[k2] = m[k];
25
+ }));
26
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
27
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
28
+ };
29
+ Object.defineProperty(exports, "__esModule", { value: true });
30
+ // ideally, we would export these types with sub-path exports:
31
+ __exportStar(require("./google/protobuf/compiler/plugin_pb.js"), exports);
32
+ __exportStar(require("./google/protobuf/api_pb.js"), exports);
33
+ __exportStar(require("./google/protobuf/any_pb.js"), exports);
34
+ __exportStar(require("./google/protobuf/descriptor_pb.js"), exports);
35
+ __exportStar(require("./google/protobuf/duration_pb.js"), exports);
36
+ __exportStar(require("./google/protobuf/empty_pb.js"), exports);
37
+ __exportStar(require("./google/protobuf/field_mask_pb.js"), exports);
38
+ __exportStar(require("./google/protobuf/source_context_pb.js"), exports);
39
+ __exportStar(require("./google/protobuf/struct_pb.js"), exports);
40
+ __exportStar(require("./google/protobuf/timestamp_pb.js"), exports);
41
+ __exportStar(require("./google/protobuf/type_pb.js"), exports);
42
+ __exportStar(require("./google/protobuf/wrappers_pb.js"), exports);
package/dist/cjs/index.js CHANGED
@@ -27,43 +27,7 @@ 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.BinaryReader = exports.BinaryWriter = exports.WireType = exports.DescriptorSet = exports.DescriptorRegistry = exports.TypeRegistry = exports.MethodIdempotency = exports.MethodKind = exports.ScalarType = exports.Message = exports.protoBase64 = exports.protoInt64 = exports.proto2 = exports.proto3 = void 0;
31
- var proto3_js_1 = require("./proto3.js");
32
- Object.defineProperty(exports, "proto3", { enumerable: true, get: function () { return proto3_js_1.proto3; } });
33
- var proto2_js_1 = require("./proto2.js");
34
- Object.defineProperty(exports, "proto2", { enumerable: true, get: function () { return proto2_js_1.proto2; } });
35
- var proto_int64_js_1 = require("./proto-int64.js");
36
- Object.defineProperty(exports, "protoInt64", { enumerable: true, get: function () { return proto_int64_js_1.protoInt64; } });
37
- var proto_base64_js_1 = require("./proto-base64.js");
38
- Object.defineProperty(exports, "protoBase64", { enumerable: true, get: function () { return proto_base64_js_1.protoBase64; } });
39
- var message_js_1 = require("./message.js");
40
- Object.defineProperty(exports, "Message", { enumerable: true, get: function () { return message_js_1.Message; } });
41
- var field_js_1 = require("./field.js");
42
- Object.defineProperty(exports, "ScalarType", { enumerable: true, get: function () { return field_js_1.ScalarType; } });
43
- var service_type_js_1 = require("./service-type.js");
44
- Object.defineProperty(exports, "MethodKind", { enumerable: true, get: function () { return service_type_js_1.MethodKind; } });
45
- Object.defineProperty(exports, "MethodIdempotency", { enumerable: true, get: function () { return service_type_js_1.MethodIdempotency; } });
46
- var type_registry_js_1 = require("./type-registry.js");
47
- Object.defineProperty(exports, "TypeRegistry", { enumerable: true, get: function () { return type_registry_js_1.TypeRegistry; } });
48
- var descriptor_registry_js_1 = require("./descriptor-registry.js");
49
- Object.defineProperty(exports, "DescriptorRegistry", { enumerable: true, get: function () { return descriptor_registry_js_1.DescriptorRegistry; } });
50
- var descriptor_set_js_1 = require("./descriptor-set.js");
51
- Object.defineProperty(exports, "DescriptorSet", { enumerable: true, get: function () { return descriptor_set_js_1.DescriptorSet; } });
52
- var binary_encoding_js_1 = require("./binary-encoding.js");
53
- Object.defineProperty(exports, "WireType", { enumerable: true, get: function () { return binary_encoding_js_1.WireType; } });
54
- Object.defineProperty(exports, "BinaryWriter", { enumerable: true, get: function () { return binary_encoding_js_1.BinaryWriter; } });
55
- Object.defineProperty(exports, "BinaryReader", { enumerable: true, get: function () { return binary_encoding_js_1.BinaryReader; } });
56
- var json_format_js_1 = require("./json-format.js");
57
- // ideally, we would export these types with sub-path exports:
58
- __exportStar(require("./google/protobuf/compiler/plugin_pb.js"), exports);
59
- __exportStar(require("./google/protobuf/api_pb.js"), exports);
60
- __exportStar(require("./google/protobuf/any_pb.js"), exports);
61
- __exportStar(require("./google/protobuf/descriptor_pb.js"), exports);
62
- __exportStar(require("./google/protobuf/duration_pb.js"), exports);
63
- __exportStar(require("./google/protobuf/empty_pb.js"), exports);
64
- __exportStar(require("./google/protobuf/field_mask_pb.js"), exports);
65
- __exportStar(require("./google/protobuf/source_context_pb.js"), exports);
66
- __exportStar(require("./google/protobuf/struct_pb.js"), exports);
67
- __exportStar(require("./google/protobuf/timestamp_pb.js"), exports);
68
- __exportStar(require("./google/protobuf/type_pb.js"), exports);
69
- __exportStar(require("./google/protobuf/wrappers_pb.js"), exports);
30
+ // To avoid circular imports when the wkt import from ./index.js, we
31
+ // use a separate ./index-runtime.js
32
+ __exportStar(require("./index-runtime.js"), exports);
33
+ __exportStar(require("./index-wkt.js"), exports);
@@ -0,0 +1 @@
1
+ {"type":"commonjs"}
@@ -81,7 +81,7 @@ function makeUtilCommon() {
81
81
  t[localName] = val;
82
82
  }
83
83
  else {
84
- t[localName] = val instanceof mt ? mt : new mt(val);
84
+ t[localName] = val instanceof mt ? val : new mt(val);
85
85
  }
86
86
  }
87
87
  break;
@@ -15,7 +15,7 @@
15
15
  Object.defineProperty(exports, "__esModule", { value: true });
16
16
  exports.TypeRegistry = void 0;
17
17
  /**
18
- * TypeRegistry is a basic type registry
18
+ * TypeRegistry is a simple registry for all message, enum, or service types.
19
19
  */
20
20
  class TypeRegistry {
21
21
  constructor() {
@@ -23,35 +23,80 @@ class TypeRegistry {
23
23
  this.enums = {};
24
24
  this.services = {};
25
25
  }
26
+ /**
27
+ * Find a message type by its protobuf type name.
28
+ */
26
29
  findMessage(typeName) {
27
30
  return this.messages[typeName];
28
31
  }
32
+ /**
33
+ * Find an enum type by its protobuf type name.
34
+ */
29
35
  findEnum(typeName) {
30
36
  return this.enums[typeName];
31
37
  }
38
+ /**
39
+ * Find a service type by its protobuf type name.
40
+ */
32
41
  findService(typeName) {
33
42
  return this.services[typeName];
34
43
  }
44
+ /**
45
+ * Create a new TypeRegistry from the given types.
46
+ */
47
+ static from(...types) {
48
+ const registry = new TypeRegistry();
49
+ for (const type of types) {
50
+ registry.add(type);
51
+ }
52
+ return registry;
53
+ }
54
+ /**
55
+ * @deprecated use TypeRegistry.from()
56
+ */
57
+ static fromIterable(types) {
58
+ return TypeRegistry.from(...types);
59
+ }
60
+ /**
61
+ * @deprecated use TypeRegistry.from()
62
+ */
63
+ static fromTypes(...types) {
64
+ return TypeRegistry.from(...types);
65
+ }
66
+ /**
67
+ * Add a type to the registry. For messages, the types used in message
68
+ * fields are added recursively. For services, the message types used
69
+ * for requests and responses are added recursively.
70
+ */
35
71
  add(type) {
36
72
  if ("fields" in type) {
37
- this.messages[type.typeName] = type;
73
+ if (!this.findMessage(type.typeName)) {
74
+ this.messages[type.typeName] = type;
75
+ for (const field of type.fields.list()) {
76
+ if (field.kind == "message") {
77
+ this.add(field.T);
78
+ }
79
+ else if (field.kind == "map" && field.V.kind == "message") {
80
+ this.add(field.V.T);
81
+ }
82
+ else if (field.kind == "enum") {
83
+ this.add(field.T);
84
+ }
85
+ }
86
+ }
38
87
  }
39
88
  else if ("methods" in type) {
40
- this.services[type.typeName] = type;
89
+ if (!this.findService(type.typeName)) {
90
+ this.services[type.typeName] = type;
91
+ for (const method of Object.values(type.methods)) {
92
+ this.add(method.I);
93
+ this.add(method.O);
94
+ }
95
+ }
41
96
  }
42
97
  else {
43
98
  this.enums[type.typeName] = type;
44
99
  }
45
100
  }
46
- static fromIterable(types) {
47
- const r = new TypeRegistry();
48
- for (const t of types) {
49
- r.add(t);
50
- }
51
- return r;
52
- }
53
- static fromTypes(...types) {
54
- return TypeRegistry.fromIterable(types);
55
- }
56
101
  }
57
102
  exports.TypeRegistry = TypeRegistry;