@bufbuild/protobuf 0.0.2-alpha.1 → 0.0.3

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 (67) hide show
  1. package/README.md +5 -2
  2. package/dist/cjs/google/protobuf/any_pb.js +19 -39
  3. package/dist/cjs/google/protobuf/api_pb.js +28 -48
  4. package/dist/cjs/google/protobuf/compiler/plugin_pb.js +32 -67
  5. package/dist/cjs/google/protobuf/descriptor_pb.js +161 -187
  6. package/dist/cjs/google/protobuf/duration_pb.js +21 -41
  7. package/dist/cjs/google/protobuf/empty_pb.js +16 -36
  8. package/dist/cjs/google/protobuf/field_mask_pb.js +17 -37
  9. package/dist/cjs/google/protobuf/source_context_pb.js +16 -36
  10. package/dist/cjs/google/protobuf/struct_pb.js +31 -51
  11. package/dist/cjs/google/protobuf/timestamp_pb.js +20 -40
  12. package/dist/cjs/google/protobuf/type_pb.js +43 -63
  13. package/dist/cjs/google/protobuf/wrappers_pb.js +76 -105
  14. package/dist/cjs/index-runtime.js +42 -0
  15. package/dist/cjs/index-wkt.js +42 -0
  16. package/dist/cjs/index.js +4 -38
  17. package/dist/cjs/private/enum.js +26 -1
  18. package/dist/cjs/private/json-format-common.js +3 -3
  19. package/dist/cjs/private/proto-runtime.js +1 -0
  20. package/dist/cjs/private/util-common.js +1 -1
  21. package/dist/cjs/proto-base64.js +138 -0
  22. package/dist/esm/google/protobuf/any_pb.js +14 -34
  23. package/dist/esm/google/protobuf/api_pb.js +11 -31
  24. package/dist/esm/google/protobuf/compiler/plugin_pb.js +11 -46
  25. package/dist/esm/google/protobuf/descriptor_pb.js +14 -40
  26. package/dist/esm/google/protobuf/duration_pb.js +11 -31
  27. package/dist/esm/google/protobuf/empty_pb.js +11 -31
  28. package/dist/esm/google/protobuf/field_mask_pb.js +11 -31
  29. package/dist/esm/google/protobuf/source_context_pb.js +11 -31
  30. package/dist/esm/google/protobuf/struct_pb.js +11 -31
  31. package/dist/esm/google/protobuf/timestamp_pb.js +11 -31
  32. package/dist/esm/google/protobuf/type_pb.js +11 -31
  33. package/dist/esm/google/protobuf/wrappers_pb.js +11 -40
  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 -24
  37. package/dist/esm/private/enum.js +24 -0
  38. package/dist/esm/private/json-format-common.js +3 -3
  39. package/dist/esm/private/proto-runtime.js +2 -1
  40. package/dist/esm/private/util-common.js +1 -1
  41. package/dist/esm/proto-base64.js +135 -0
  42. package/dist/types/google/protobuf/any_pb.d.ts +5 -5
  43. package/dist/types/google/protobuf/api_pb.d.ts +2 -2
  44. package/dist/types/google/protobuf/compiler/plugin_pb.d.ts +2 -2
  45. package/dist/types/google/protobuf/descriptor_pb.d.ts +18 -5
  46. package/dist/types/google/protobuf/duration_pb.d.ts +2 -2
  47. package/dist/types/google/protobuf/empty_pb.d.ts +2 -2
  48. package/dist/types/google/protobuf/field_mask_pb.d.ts +2 -2
  49. package/dist/types/google/protobuf/source_context_pb.d.ts +2 -2
  50. package/dist/types/google/protobuf/struct_pb.d.ts +2 -2
  51. package/dist/types/google/protobuf/timestamp_pb.d.ts +2 -2
  52. package/dist/types/google/protobuf/type_pb.d.ts +2 -2
  53. package/dist/types/google/protobuf/wrappers_pb.d.ts +2 -2
  54. package/dist/types/index-runtime.d.ts +19 -0
  55. package/dist/types/index-wkt.d.ts +12 -0
  56. package/dist/types/index.d.ts +2 -30
  57. package/dist/types/message-type.d.ts +2 -1
  58. package/dist/types/message.d.ts +4 -6
  59. package/dist/types/private/enum.d.ts +9 -0
  60. package/dist/types/private/message-type.d.ts +10 -0
  61. package/dist/types/private/proto-runtime.d.ts +16 -11
  62. package/dist/types/private/util.d.ts +2 -2
  63. package/dist/types/proto-base64.d.ts +26 -0
  64. package/package.json +2 -3
  65. package/dist/cjs/private/base64.js +0 -132
  66. package/dist/esm/private/base64.js +0 -127
  67. package/dist/types/private/base64.d.ts +0 -18
@@ -1,49 +1,20 @@
1
1
  "use strict";
2
- /* eslint-disable */
3
- // @generated by protoc-gen-es v0.0.2-alpha.1 with parameter "bootstrap_wkt=true,ts_nocheck=false"
4
- // @generated from file google/protobuf/wrappers.proto (package google.protobuf, syntax proto3)
2
+ // Copyright 2021-2022 Buf Technologies, Inc.
5
3
  //
6
- // Protocol Buffers - Google's data interchange format
7
- // Copyright 2008 Google Inc. All rights reserved.
8
- // https://developers.google.com/protocol-buffers/
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
9
7
  //
10
- // Redistribution and use in source and binary forms, with or without
11
- // modification, are permitted provided that the following conditions are
12
- // met:
8
+ // http://www.apache.org/licenses/LICENSE-2.0
13
9
  //
14
- // * Redistributions of source code must retain the above copyright
15
- // notice, this list of conditions and the following disclaimer.
16
- // * Redistributions in binary form must reproduce the above
17
- // copyright notice, this list of conditions and the following disclaimer
18
- // in the documentation and/or other materials provided with the
19
- // distribution.
20
- // * Neither the name of Google Inc. nor the names of its
21
- // contributors may be used to endorse or promote products derived from
22
- // this software without specific prior written permission.
23
- //
24
- // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25
- // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26
- // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
27
- // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
28
- // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
29
- // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
30
- // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
31
- // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
32
- // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33
- // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34
- // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35
- // Wrappers for primitive (non-message) types. These types are useful
36
- // for embedding primitives in the `google.protobuf.Any` type and for places
37
- // where we need to distinguish between the absence of a primitive
38
- // typed field and its default value.
39
- //
40
- // These wrappers have no meaningful use within repeated fields as they lack
41
- // the ability to detect presence on individual elements.
42
- // These wrappers have no meaningful use within a map or a oneof since
43
- // individual entries of a map or fields of a oneof can already detect presence.
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.
44
15
  Object.defineProperty(exports, "__esModule", { value: true });
45
16
  exports.BytesValue = exports.StringValue = exports.BoolValue = exports.UInt32Value = exports.Int32Value = exports.UInt64Value = exports.Int64Value = exports.FloatValue = exports.DoubleValue = void 0;
46
- const index_js_1 = require("../../index.js");
17
+ const index_runtime_js_1 = require("../../index-runtime.js");
47
18
  /**
48
19
  * Wrapper message for `double`.
49
20
  *
@@ -51,7 +22,7 @@ const index_js_1 = require("../../index.js");
51
22
  *
52
23
  * @generated from message google.protobuf.DoubleValue
53
24
  */
54
- class DoubleValue extends index_js_1.Message {
25
+ class DoubleValue extends index_runtime_js_1.Message {
55
26
  constructor(data) {
56
27
  super();
57
28
  /**
@@ -60,14 +31,14 @@ class DoubleValue extends index_js_1.Message {
60
31
  * @generated from field: double value = 1;
61
32
  */
62
33
  this.value = 0;
63
- index_js_1.proto3.util.initPartial(data, this);
34
+ index_runtime_js_1.proto3.util.initPartial(data, this);
64
35
  }
65
36
  toJson(options) {
66
- 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);
67
38
  }
68
39
  fromJson(json, options) {
69
40
  try {
70
- 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);
71
42
  }
72
43
  catch (e) {
73
44
  let m = `cannot decode message google.protobuf.DoubleValue from JSON"`;
@@ -88,13 +59,13 @@ class DoubleValue extends index_js_1.Message {
88
59
  return new DoubleValue().fromJsonString(jsonString, options);
89
60
  }
90
61
  static equals(a, b) {
91
- return index_js_1.proto3.util.equals(DoubleValue, a, b);
62
+ return index_runtime_js_1.proto3.util.equals(DoubleValue, a, b);
92
63
  }
93
64
  }
94
65
  exports.DoubleValue = DoubleValue;
95
- DoubleValue.runtime = index_js_1.proto3;
66
+ DoubleValue.runtime = index_runtime_js_1.proto3;
96
67
  DoubleValue.typeName = "google.protobuf.DoubleValue";
97
- DoubleValue.fields = index_js_1.proto3.util.newFieldList(() => [
68
+ DoubleValue.fields = index_runtime_js_1.proto3.util.newFieldList(() => [
98
69
  { no: 1, name: "value", kind: "scalar", T: 1 /* ScalarType.DOUBLE */ },
99
70
  ]);
100
71
  DoubleValue.fieldWrapper = {
@@ -112,7 +83,7 @@ DoubleValue.fieldWrapper = {
112
83
  *
113
84
  * @generated from message google.protobuf.FloatValue
114
85
  */
115
- class FloatValue extends index_js_1.Message {
86
+ class FloatValue extends index_runtime_js_1.Message {
116
87
  constructor(data) {
117
88
  super();
118
89
  /**
@@ -121,14 +92,14 @@ class FloatValue extends index_js_1.Message {
121
92
  * @generated from field: float value = 1;
122
93
  */
123
94
  this.value = 0;
124
- index_js_1.proto3.util.initPartial(data, this);
95
+ index_runtime_js_1.proto3.util.initPartial(data, this);
125
96
  }
126
97
  toJson(options) {
127
- 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);
128
99
  }
129
100
  fromJson(json, options) {
130
101
  try {
131
- 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);
132
103
  }
133
104
  catch (e) {
134
105
  let m = `cannot decode message google.protobuf.FloatValue from JSON"`;
@@ -149,13 +120,13 @@ class FloatValue extends index_js_1.Message {
149
120
  return new FloatValue().fromJsonString(jsonString, options);
150
121
  }
151
122
  static equals(a, b) {
152
- return index_js_1.proto3.util.equals(FloatValue, a, b);
123
+ return index_runtime_js_1.proto3.util.equals(FloatValue, a, b);
153
124
  }
154
125
  }
155
126
  exports.FloatValue = FloatValue;
156
- FloatValue.runtime = index_js_1.proto3;
127
+ FloatValue.runtime = index_runtime_js_1.proto3;
157
128
  FloatValue.typeName = "google.protobuf.FloatValue";
158
- FloatValue.fields = index_js_1.proto3.util.newFieldList(() => [
129
+ FloatValue.fields = index_runtime_js_1.proto3.util.newFieldList(() => [
159
130
  { no: 1, name: "value", kind: "scalar", T: 2 /* ScalarType.FLOAT */ },
160
131
  ]);
161
132
  FloatValue.fieldWrapper = {
@@ -173,7 +144,7 @@ FloatValue.fieldWrapper = {
173
144
  *
174
145
  * @generated from message google.protobuf.Int64Value
175
146
  */
176
- class Int64Value extends index_js_1.Message {
147
+ class Int64Value extends index_runtime_js_1.Message {
177
148
  constructor(data) {
178
149
  super();
179
150
  /**
@@ -181,15 +152,15 @@ class Int64Value extends index_js_1.Message {
181
152
  *
182
153
  * @generated from field: int64 value = 1;
183
154
  */
184
- this.value = index_js_1.protoInt64.zero;
185
- 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);
186
157
  }
187
158
  toJson(options) {
188
- 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);
189
160
  }
190
161
  fromJson(json, options) {
191
162
  try {
192
- 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);
193
164
  }
194
165
  catch (e) {
195
166
  let m = `cannot decode message google.protobuf.Int64Value from JSON"`;
@@ -210,13 +181,13 @@ class Int64Value extends index_js_1.Message {
210
181
  return new Int64Value().fromJsonString(jsonString, options);
211
182
  }
212
183
  static equals(a, b) {
213
- return index_js_1.proto3.util.equals(Int64Value, a, b);
184
+ return index_runtime_js_1.proto3.util.equals(Int64Value, a, b);
214
185
  }
215
186
  }
216
187
  exports.Int64Value = Int64Value;
217
- Int64Value.runtime = index_js_1.proto3;
188
+ Int64Value.runtime = index_runtime_js_1.proto3;
218
189
  Int64Value.typeName = "google.protobuf.Int64Value";
219
- Int64Value.fields = index_js_1.proto3.util.newFieldList(() => [
190
+ Int64Value.fields = index_runtime_js_1.proto3.util.newFieldList(() => [
220
191
  { no: 1, name: "value", kind: "scalar", T: 3 /* ScalarType.INT64 */ },
221
192
  ]);
222
193
  Int64Value.fieldWrapper = {
@@ -234,7 +205,7 @@ Int64Value.fieldWrapper = {
234
205
  *
235
206
  * @generated from message google.protobuf.UInt64Value
236
207
  */
237
- class UInt64Value extends index_js_1.Message {
208
+ class UInt64Value extends index_runtime_js_1.Message {
238
209
  constructor(data) {
239
210
  super();
240
211
  /**
@@ -242,15 +213,15 @@ class UInt64Value extends index_js_1.Message {
242
213
  *
243
214
  * @generated from field: uint64 value = 1;
244
215
  */
245
- this.value = index_js_1.protoInt64.zero;
246
- 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);
247
218
  }
248
219
  toJson(options) {
249
- 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);
250
221
  }
251
222
  fromJson(json, options) {
252
223
  try {
253
- 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);
254
225
  }
255
226
  catch (e) {
256
227
  let m = `cannot decode message google.protobuf.UInt64Value from JSON"`;
@@ -271,13 +242,13 @@ class UInt64Value extends index_js_1.Message {
271
242
  return new UInt64Value().fromJsonString(jsonString, options);
272
243
  }
273
244
  static equals(a, b) {
274
- return index_js_1.proto3.util.equals(UInt64Value, a, b);
245
+ return index_runtime_js_1.proto3.util.equals(UInt64Value, a, b);
275
246
  }
276
247
  }
277
248
  exports.UInt64Value = UInt64Value;
278
- UInt64Value.runtime = index_js_1.proto3;
249
+ UInt64Value.runtime = index_runtime_js_1.proto3;
279
250
  UInt64Value.typeName = "google.protobuf.UInt64Value";
280
- UInt64Value.fields = index_js_1.proto3.util.newFieldList(() => [
251
+ UInt64Value.fields = index_runtime_js_1.proto3.util.newFieldList(() => [
281
252
  { no: 1, name: "value", kind: "scalar", T: 4 /* ScalarType.UINT64 */ },
282
253
  ]);
283
254
  UInt64Value.fieldWrapper = {
@@ -295,7 +266,7 @@ UInt64Value.fieldWrapper = {
295
266
  *
296
267
  * @generated from message google.protobuf.Int32Value
297
268
  */
298
- class Int32Value extends index_js_1.Message {
269
+ class Int32Value extends index_runtime_js_1.Message {
299
270
  constructor(data) {
300
271
  super();
301
272
  /**
@@ -304,14 +275,14 @@ class Int32Value extends index_js_1.Message {
304
275
  * @generated from field: int32 value = 1;
305
276
  */
306
277
  this.value = 0;
307
- index_js_1.proto3.util.initPartial(data, this);
278
+ index_runtime_js_1.proto3.util.initPartial(data, this);
308
279
  }
309
280
  toJson(options) {
310
- 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);
311
282
  }
312
283
  fromJson(json, options) {
313
284
  try {
314
- 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);
315
286
  }
316
287
  catch (e) {
317
288
  let m = `cannot decode message google.protobuf.Int32Value from JSON"`;
@@ -332,13 +303,13 @@ class Int32Value extends index_js_1.Message {
332
303
  return new Int32Value().fromJsonString(jsonString, options);
333
304
  }
334
305
  static equals(a, b) {
335
- return index_js_1.proto3.util.equals(Int32Value, a, b);
306
+ return index_runtime_js_1.proto3.util.equals(Int32Value, a, b);
336
307
  }
337
308
  }
338
309
  exports.Int32Value = Int32Value;
339
- Int32Value.runtime = index_js_1.proto3;
310
+ Int32Value.runtime = index_runtime_js_1.proto3;
340
311
  Int32Value.typeName = "google.protobuf.Int32Value";
341
- Int32Value.fields = index_js_1.proto3.util.newFieldList(() => [
312
+ Int32Value.fields = index_runtime_js_1.proto3.util.newFieldList(() => [
342
313
  { no: 1, name: "value", kind: "scalar", T: 5 /* ScalarType.INT32 */ },
343
314
  ]);
344
315
  Int32Value.fieldWrapper = {
@@ -356,7 +327,7 @@ Int32Value.fieldWrapper = {
356
327
  *
357
328
  * @generated from message google.protobuf.UInt32Value
358
329
  */
359
- class UInt32Value extends index_js_1.Message {
330
+ class UInt32Value extends index_runtime_js_1.Message {
360
331
  constructor(data) {
361
332
  super();
362
333
  /**
@@ -365,14 +336,14 @@ class UInt32Value extends index_js_1.Message {
365
336
  * @generated from field: uint32 value = 1;
366
337
  */
367
338
  this.value = 0;
368
- index_js_1.proto3.util.initPartial(data, this);
339
+ index_runtime_js_1.proto3.util.initPartial(data, this);
369
340
  }
370
341
  toJson(options) {
371
- 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);
372
343
  }
373
344
  fromJson(json, options) {
374
345
  try {
375
- 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);
376
347
  }
377
348
  catch (e) {
378
349
  let m = `cannot decode message google.protobuf.UInt32Value from JSON"`;
@@ -393,13 +364,13 @@ class UInt32Value extends index_js_1.Message {
393
364
  return new UInt32Value().fromJsonString(jsonString, options);
394
365
  }
395
366
  static equals(a, b) {
396
- return index_js_1.proto3.util.equals(UInt32Value, a, b);
367
+ return index_runtime_js_1.proto3.util.equals(UInt32Value, a, b);
397
368
  }
398
369
  }
399
370
  exports.UInt32Value = UInt32Value;
400
- UInt32Value.runtime = index_js_1.proto3;
371
+ UInt32Value.runtime = index_runtime_js_1.proto3;
401
372
  UInt32Value.typeName = "google.protobuf.UInt32Value";
402
- UInt32Value.fields = index_js_1.proto3.util.newFieldList(() => [
373
+ UInt32Value.fields = index_runtime_js_1.proto3.util.newFieldList(() => [
403
374
  { no: 1, name: "value", kind: "scalar", T: 13 /* ScalarType.UINT32 */ },
404
375
  ]);
405
376
  UInt32Value.fieldWrapper = {
@@ -417,7 +388,7 @@ UInt32Value.fieldWrapper = {
417
388
  *
418
389
  * @generated from message google.protobuf.BoolValue
419
390
  */
420
- class BoolValue extends index_js_1.Message {
391
+ class BoolValue extends index_runtime_js_1.Message {
421
392
  constructor(data) {
422
393
  super();
423
394
  /**
@@ -426,14 +397,14 @@ class BoolValue extends index_js_1.Message {
426
397
  * @generated from field: bool value = 1;
427
398
  */
428
399
  this.value = false;
429
- index_js_1.proto3.util.initPartial(data, this);
400
+ index_runtime_js_1.proto3.util.initPartial(data, this);
430
401
  }
431
402
  toJson(options) {
432
- 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);
433
404
  }
434
405
  fromJson(json, options) {
435
406
  try {
436
- 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);
437
408
  }
438
409
  catch (e) {
439
410
  let m = `cannot decode message google.protobuf.BoolValue from JSON"`;
@@ -454,13 +425,13 @@ class BoolValue extends index_js_1.Message {
454
425
  return new BoolValue().fromJsonString(jsonString, options);
455
426
  }
456
427
  static equals(a, b) {
457
- return index_js_1.proto3.util.equals(BoolValue, a, b);
428
+ return index_runtime_js_1.proto3.util.equals(BoolValue, a, b);
458
429
  }
459
430
  }
460
431
  exports.BoolValue = BoolValue;
461
- BoolValue.runtime = index_js_1.proto3;
432
+ BoolValue.runtime = index_runtime_js_1.proto3;
462
433
  BoolValue.typeName = "google.protobuf.BoolValue";
463
- BoolValue.fields = index_js_1.proto3.util.newFieldList(() => [
434
+ BoolValue.fields = index_runtime_js_1.proto3.util.newFieldList(() => [
464
435
  { no: 1, name: "value", kind: "scalar", T: 8 /* ScalarType.BOOL */ },
465
436
  ]);
466
437
  BoolValue.fieldWrapper = {
@@ -478,7 +449,7 @@ BoolValue.fieldWrapper = {
478
449
  *
479
450
  * @generated from message google.protobuf.StringValue
480
451
  */
481
- class StringValue extends index_js_1.Message {
452
+ class StringValue extends index_runtime_js_1.Message {
482
453
  constructor(data) {
483
454
  super();
484
455
  /**
@@ -487,14 +458,14 @@ class StringValue extends index_js_1.Message {
487
458
  * @generated from field: string value = 1;
488
459
  */
489
460
  this.value = "";
490
- index_js_1.proto3.util.initPartial(data, this);
461
+ index_runtime_js_1.proto3.util.initPartial(data, this);
491
462
  }
492
463
  toJson(options) {
493
- 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);
494
465
  }
495
466
  fromJson(json, options) {
496
467
  try {
497
- 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);
498
469
  }
499
470
  catch (e) {
500
471
  let m = `cannot decode message google.protobuf.StringValue from JSON"`;
@@ -515,13 +486,13 @@ class StringValue extends index_js_1.Message {
515
486
  return new StringValue().fromJsonString(jsonString, options);
516
487
  }
517
488
  static equals(a, b) {
518
- return index_js_1.proto3.util.equals(StringValue, a, b);
489
+ return index_runtime_js_1.proto3.util.equals(StringValue, a, b);
519
490
  }
520
491
  }
521
492
  exports.StringValue = StringValue;
522
- StringValue.runtime = index_js_1.proto3;
493
+ StringValue.runtime = index_runtime_js_1.proto3;
523
494
  StringValue.typeName = "google.protobuf.StringValue";
524
- StringValue.fields = index_js_1.proto3.util.newFieldList(() => [
495
+ StringValue.fields = index_runtime_js_1.proto3.util.newFieldList(() => [
525
496
  { no: 1, name: "value", kind: "scalar", T: 9 /* ScalarType.STRING */ },
526
497
  ]);
527
498
  StringValue.fieldWrapper = {
@@ -539,7 +510,7 @@ StringValue.fieldWrapper = {
539
510
  *
540
511
  * @generated from message google.protobuf.BytesValue
541
512
  */
542
- class BytesValue extends index_js_1.Message {
513
+ class BytesValue extends index_runtime_js_1.Message {
543
514
  constructor(data) {
544
515
  super();
545
516
  /**
@@ -548,14 +519,14 @@ class BytesValue extends index_js_1.Message {
548
519
  * @generated from field: bytes value = 1;
549
520
  */
550
521
  this.value = new Uint8Array(0);
551
- index_js_1.proto3.util.initPartial(data, this);
522
+ index_runtime_js_1.proto3.util.initPartial(data, this);
552
523
  }
553
524
  toJson(options) {
554
- 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);
555
526
  }
556
527
  fromJson(json, options) {
557
528
  try {
558
- 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);
559
530
  }
560
531
  catch (e) {
561
532
  let m = `cannot decode message google.protobuf.BytesValue from JSON"`;
@@ -576,13 +547,13 @@ class BytesValue extends index_js_1.Message {
576
547
  return new BytesValue().fromJsonString(jsonString, options);
577
548
  }
578
549
  static equals(a, b) {
579
- return index_js_1.proto3.util.equals(BytesValue, a, b);
550
+ return index_runtime_js_1.proto3.util.equals(BytesValue, a, b);
580
551
  }
581
552
  }
582
553
  exports.BytesValue = BytesValue;
583
- BytesValue.runtime = index_js_1.proto3;
554
+ BytesValue.runtime = index_runtime_js_1.proto3;
584
555
  BytesValue.typeName = "google.protobuf.BytesValue";
585
- BytesValue.fields = index_js_1.proto3.util.newFieldList(() => [
556
+ BytesValue.fields = index_runtime_js_1.proto3.util.newFieldList(() => [
586
557
  { no: 1, name: "value", kind: "scalar", T: 12 /* ScalarType.BYTES */ },
587
558
  ]);
588
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,41 +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.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 message_js_1 = require("./message.js");
38
- Object.defineProperty(exports, "Message", { enumerable: true, get: function () { return message_js_1.Message; } });
39
- var field_js_1 = require("./field.js");
40
- Object.defineProperty(exports, "ScalarType", { enumerable: true, get: function () { return field_js_1.ScalarType; } });
41
- var service_type_js_1 = require("./service-type.js");
42
- Object.defineProperty(exports, "MethodKind", { enumerable: true, get: function () { return service_type_js_1.MethodKind; } });
43
- Object.defineProperty(exports, "MethodIdempotency", { enumerable: true, get: function () { return service_type_js_1.MethodIdempotency; } });
44
- var type_registry_js_1 = require("./type-registry.js");
45
- Object.defineProperty(exports, "TypeRegistry", { enumerable: true, get: function () { return type_registry_js_1.TypeRegistry; } });
46
- var descriptor_registry_js_1 = require("./descriptor-registry.js");
47
- Object.defineProperty(exports, "DescriptorRegistry", { enumerable: true, get: function () { return descriptor_registry_js_1.DescriptorRegistry; } });
48
- var descriptor_set_js_1 = require("./descriptor-set.js");
49
- Object.defineProperty(exports, "DescriptorSet", { enumerable: true, get: function () { return descriptor_set_js_1.DescriptorSet; } });
50
- var binary_encoding_js_1 = require("./binary-encoding.js");
51
- Object.defineProperty(exports, "WireType", { enumerable: true, get: function () { return binary_encoding_js_1.WireType; } });
52
- Object.defineProperty(exports, "BinaryWriter", { enumerable: true, get: function () { return binary_encoding_js_1.BinaryWriter; } });
53
- 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
- // ideally, we would export these types with sub-path exports:
56
- __exportStar(require("./google/protobuf/compiler/plugin_pb.js"), exports);
57
- __exportStar(require("./google/protobuf/api_pb.js"), exports);
58
- __exportStar(require("./google/protobuf/any_pb.js"), exports);
59
- __exportStar(require("./google/protobuf/descriptor_pb.js"), exports);
60
- __exportStar(require("./google/protobuf/duration_pb.js"), exports);
61
- __exportStar(require("./google/protobuf/empty_pb.js"), exports);
62
- __exportStar(require("./google/protobuf/field_mask_pb.js"), exports);
63
- __exportStar(require("./google/protobuf/source_context_pb.js"), exports);
64
- __exportStar(require("./google/protobuf/struct_pb.js"), exports);
65
- __exportStar(require("./google/protobuf/timestamp_pb.js"), exports);
66
- __exportStar(require("./google/protobuf/type_pb.js"), exports);
67
- __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);
@@ -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.makeEnumType = exports.setEnumType = exports.getEnumType = void 0;
16
+ exports.makeEnum = exports.makeEnumType = exports.setEnumType = exports.getEnumType = void 0;
17
17
  const assert_js_1 = require("./assert.js");
18
18
  const enumTypeSymbol = Symbol("@bufbuild/protobuf/enum-type");
19
19
  /**
@@ -76,3 +76,28 @@ function makeEnumType(typeName, values
76
76
  };
77
77
  }
78
78
  exports.makeEnumType = makeEnumType;
79
+ /**
80
+ * Create a new enum object with the given values.
81
+ */
82
+ function makeEnum(typeName, values, opt) {
83
+ const enumObject = {};
84
+ for (const value of values) {
85
+ const name = makeEnumValueName(value, opt?.sharedPrefix);
86
+ enumObject[name] = value.no;
87
+ enumObject[value.no] = name;
88
+ }
89
+ setEnumType(enumObject, typeName, values);
90
+ return enumObject;
91
+ }
92
+ exports.makeEnum = makeEnum;
93
+ // Construct a local name for an enum value.
94
+ // This logic matches the Go function with the same name in private/protoplugin/names.go
95
+ function makeEnumValueName(value, sharedPrefix) {
96
+ if (sharedPrefix === undefined) {
97
+ return value.name;
98
+ }
99
+ if (!value.name.startsWith(sharedPrefix)) {
100
+ return value.name;
101
+ }
102
+ return value.name.substring(sharedPrefix.length);
103
+ }
@@ -18,7 +18,7 @@ const field_wrapper_js_1 = require("./field-wrapper.js");
18
18
  const field_js_1 = require("../field.js");
19
19
  const assert_js_1 = require("./assert.js");
20
20
  const proto_int64_js_1 = require("../proto-int64.js");
21
- const base64_js_1 = require("./base64.js");
21
+ const proto_base64_js_1 = require("../proto-base64.js");
22
22
  /* eslint-disable no-case-declarations, @typescript-eslint/restrict-plus-operands,@typescript-eslint/no-explicit-any,@typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-argument */
23
23
  // Default options for parsing JSON.
24
24
  const jsonReadDefaults = {
@@ -367,7 +367,7 @@ function readScalar(type, json) {
367
367
  return new Uint8Array(0);
368
368
  if (typeof json !== "string")
369
369
  break;
370
- return (0, base64_js_1.base64decode)(json);
370
+ return proto_base64_js_1.protoBase64.dec(json);
371
371
  }
372
372
  throw new Error();
373
373
  }
@@ -463,7 +463,7 @@ function writeScalar(type, value, emitIntrinsicDefault) {
463
463
  case field_js_1.ScalarType.BYTES:
464
464
  (0, assert_js_1.assert)(value instanceof Uint8Array);
465
465
  return emitIntrinsicDefault || value.byteLength > 0
466
- ? (0, base64_js_1.base64encode)(value)
466
+ ? proto_base64_js_1.protoBase64.enc(value)
467
467
  : undefined;
468
468
  }
469
469
  }