@bufbuild/protobuf 0.0.6 → 0.0.9

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 (75) hide show
  1. package/README.md +34 -4
  2. package/dist/cjs/binary-encoding.js +2 -2
  3. package/dist/cjs/codegen-info.js +60 -0
  4. package/dist/cjs/create-descriptor-set.js +952 -0
  5. package/dist/cjs/create-registry-from-desc.js +376 -0
  6. package/dist/cjs/create-registry.js +75 -0
  7. package/dist/cjs/descriptor-set.js +0 -458
  8. package/dist/cjs/google/protobuf/any_pb.js +4 -2
  9. package/dist/cjs/google/protobuf/duration_pb.js +1 -1
  10. package/dist/cjs/google/protobuf/struct_pb.js +2 -2
  11. package/dist/cjs/google/protobuf/type_pb.js +1 -1
  12. package/dist/cjs/index.js +17 -7
  13. package/dist/cjs/{descriptor-registry.js → legacy-descriptor-registry.js} +35 -69
  14. package/dist/cjs/legacy-descriptor-set.js +453 -0
  15. package/dist/cjs/legacy-type-registry.js +104 -0
  16. package/dist/cjs/message.js +2 -1
  17. package/dist/cjs/private/binary-format-common.js +4 -3
  18. package/dist/cjs/private/binary-format-proto2.js +3 -6
  19. package/dist/cjs/private/binary-format-proto3.js +2 -5
  20. package/dist/cjs/private/enum.js +22 -31
  21. package/dist/cjs/private/field-wrapper.js +30 -1
  22. package/dist/cjs/private/field.js +1 -1
  23. package/dist/cjs/private/json-format-common.js +6 -5
  24. package/dist/cjs/private/message-type.js +2 -1
  25. package/dist/cjs/private/names.js +168 -29
  26. package/dist/cjs/proto-int64.js +1 -1
  27. package/dist/cjs/proto2.js +7 -9
  28. package/dist/cjs/proto3.js +10 -13
  29. package/dist/cjs/type-registry.js +0 -87
  30. package/dist/esm/binary-encoding.js +2 -2
  31. package/dist/esm/codegen-info.js +57 -0
  32. package/dist/esm/create-descriptor-set.js +947 -0
  33. package/dist/esm/create-registry-from-desc.js +371 -0
  34. package/dist/esm/create-registry.js +71 -0
  35. package/dist/esm/descriptor-set.js +1 -456
  36. package/dist/esm/google/protobuf/any_pb.js +4 -2
  37. package/dist/esm/google/protobuf/duration_pb.js +1 -1
  38. package/dist/esm/google/protobuf/struct_pb.js +2 -2
  39. package/dist/esm/google/protobuf/type_pb.js +1 -1
  40. package/dist/esm/index.js +9 -3
  41. package/dist/esm/{descriptor-registry.js → legacy-descriptor-registry.js} +33 -67
  42. package/dist/esm/legacy-descriptor-set.js +449 -0
  43. package/dist/esm/legacy-type-registry.js +100 -0
  44. package/dist/esm/message.js +2 -1
  45. package/dist/esm/private/binary-format-common.js +4 -3
  46. package/dist/esm/private/binary-format-proto2.js +3 -6
  47. package/dist/esm/private/binary-format-proto3.js +2 -5
  48. package/dist/esm/private/enum.js +22 -31
  49. package/dist/esm/private/field-wrapper.js +28 -0
  50. package/dist/esm/private/field.js +2 -2
  51. package/dist/esm/private/json-format-common.js +6 -5
  52. package/dist/esm/private/message-type.js +2 -1
  53. package/dist/esm/private/names.js +163 -24
  54. package/dist/esm/proto-int64.js +1 -1
  55. package/dist/esm/proto2.js +8 -10
  56. package/dist/esm/proto3.js +11 -14
  57. package/dist/esm/type-registry.js +1 -85
  58. package/dist/types/codegen-info.d.ts +19 -0
  59. package/dist/types/create-descriptor-set.d.ts +16 -0
  60. package/dist/types/create-registry-from-desc.d.ts +49 -0
  61. package/dist/types/create-registry.d.ts +8 -0
  62. package/dist/types/descriptor-set.d.ts +554 -108
  63. package/dist/types/enum.d.ts +9 -5
  64. package/dist/types/index.d.ts +9 -3
  65. package/dist/types/{descriptor-registry.d.ts → legacy-descriptor-registry.d.ts} +8 -6
  66. package/dist/types/legacy-descriptor-set.d.ts +152 -0
  67. package/dist/types/legacy-type-registry.d.ts +44 -0
  68. package/dist/types/private/enum.d.ts +4 -8
  69. package/dist/types/private/field-wrapper.d.ts +7 -0
  70. package/dist/types/private/message-type.d.ts +1 -4
  71. package/dist/types/private/names.d.ts +26 -8
  72. package/dist/types/private/proto-runtime.d.ts +2 -2
  73. package/dist/types/private/util.d.ts +1 -6
  74. package/dist/types/type-registry.d.ts +0 -38
  75. package/package.json +4 -3
@@ -11,459 +11,4 @@
11
11
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
12
  // See the License for the specific language governing permissions and
13
13
  // limitations under the License.
14
- import { FieldDescriptorProto_Label, FieldDescriptorProto_Type, MethodOptions_IdempotencyLevel, } from "./google/protobuf/descriptor_pb.js";
15
- import { assert } from "./private/assert.js";
16
- import { ScalarType } from "./field.js";
17
- import { MethodIdempotency, MethodKind } from "./service-type.js";
18
- /**
19
- * DescriptorSet wraps a set of google.protobuf.FileDescriptorProto,
20
- * asserting basic expectations and providing hierarchical information.
21
- *
22
- * Note that all types are kept by their fully qualified type name
23
- * with a leading dot.
24
- */
25
- export class DescriptorSet {
26
- constructor() {
27
- this.enums = {};
28
- this.messages = {};
29
- this.services = {};
30
- }
31
- /**
32
- * May raise an error on invalid descriptors.
33
- */
34
- add(...files) {
35
- for (const file of files) {
36
- newFile(file, this);
37
- }
38
- }
39
- listEnums() {
40
- return Object.values(this.enums).filter(isDefined);
41
- }
42
- listMessages() {
43
- return Object.values(this.messages).filter(isDefined);
44
- }
45
- listServices() {
46
- return Object.values(this.services).filter(isDefined);
47
- }
48
- }
49
- function isDefined(v) {
50
- return v !== undefined;
51
- }
52
- const fieldTypeToScalarType = {
53
- [FieldDescriptorProto_Type.DOUBLE]: ScalarType.DOUBLE,
54
- [FieldDescriptorProto_Type.FLOAT]: ScalarType.FLOAT,
55
- [FieldDescriptorProto_Type.INT64]: ScalarType.INT64,
56
- [FieldDescriptorProto_Type.UINT64]: ScalarType.UINT64,
57
- [FieldDescriptorProto_Type.INT32]: ScalarType.INT32,
58
- [FieldDescriptorProto_Type.FIXED64]: ScalarType.FIXED64,
59
- [FieldDescriptorProto_Type.FIXED32]: ScalarType.FIXED32,
60
- [FieldDescriptorProto_Type.BOOL]: ScalarType.BOOL,
61
- [FieldDescriptorProto_Type.STRING]: ScalarType.STRING,
62
- [FieldDescriptorProto_Type.GROUP]: undefined,
63
- [FieldDescriptorProto_Type.MESSAGE]: undefined,
64
- [FieldDescriptorProto_Type.BYTES]: ScalarType.BYTES,
65
- [FieldDescriptorProto_Type.UINT32]: ScalarType.UINT32,
66
- [FieldDescriptorProto_Type.ENUM]: undefined,
67
- [FieldDescriptorProto_Type.SFIXED32]: ScalarType.SFIXED32,
68
- [FieldDescriptorProto_Type.SFIXED64]: ScalarType.SFIXED64,
69
- [FieldDescriptorProto_Type.SINT32]: ScalarType.SINT32,
70
- [FieldDescriptorProto_Type.SINT64]: ScalarType.SINT64,
71
- };
72
- function newFile(proto, ds) {
73
- assert(proto.name, `missing file descriptor name`);
74
- if (proto.syntax !== undefined && proto.syntax !== "proto3") {
75
- throw new Error(`invalid descriptor: unsupported syntax: ${proto.syntax}`);
76
- }
77
- const file = {
78
- proto,
79
- syntax: proto.syntax === "proto3" ? "proto3" : "proto2",
80
- name: proto.name.endsWith(".proto")
81
- ? proto.name.substring(-".proto".length)
82
- : proto.name,
83
- toString() {
84
- // eslint-disable-next-line @typescript-eslint/restrict-template-expressions -- we asserted above
85
- return `file ${this.proto.name}`;
86
- },
87
- };
88
- for (const messageType of proto.messageType) {
89
- newMessage(messageType, undefined, file, ds);
90
- }
91
- for (const enumType of proto.enumType) {
92
- newEnum(enumType, undefined, file, ds);
93
- }
94
- for (const extension of proto.extension) {
95
- newExtension(extension, undefined, file, ds);
96
- }
97
- for (const service of proto.service) {
98
- newService(service, file, ds);
99
- }
100
- return file;
101
- }
102
- function newEnum(proto, parent, file, us) {
103
- assert(proto.name, `invalid descriptor: missing enum descriptor name`);
104
- let protoTypeName;
105
- if (parent) {
106
- protoTypeName = `${parent.protoTypeName}.${proto.name}`;
107
- }
108
- else if (file.proto.package !== undefined) {
109
- protoTypeName = `.${file.proto.package}.${proto.name}`;
110
- }
111
- else {
112
- protoTypeName = `.${proto.name}`;
113
- }
114
- const values = [];
115
- const enumT = {
116
- proto,
117
- file,
118
- parent,
119
- name: proto.name,
120
- protoTypeName,
121
- typeName: protoTypeName.startsWith(".")
122
- ? protoTypeName.substring(1)
123
- : protoTypeName,
124
- values,
125
- toString() {
126
- return `enum ${this.typeName}`;
127
- },
128
- };
129
- us.enums[enumT.protoTypeName] = enumT;
130
- for (const value of proto.value) {
131
- values.push(newEnumValue(value, enumT));
132
- }
133
- return enumT;
134
- }
135
- function newEnumValue(proto, parent) {
136
- assert(proto.name, `invalid descriptor: missing enum value descriptor name`);
137
- assert(proto.number !== undefined, `invalid descriptor: missing enum value descriptor number`);
138
- return {
139
- proto,
140
- name: proto.name,
141
- number: proto.number,
142
- parent,
143
- toString() {
144
- // eslint-disable-next-line @typescript-eslint/restrict-template-expressions -- we asserted above
145
- return `enum value ${this.parent.typeName}.${this.proto.name}`;
146
- },
147
- };
148
- }
149
- function newMessage(proto, parent, file, us) {
150
- assert(proto.name, `invalid descriptor: missing name`);
151
- const nestedMessages = [];
152
- const fields = [];
153
- const oneofs = [];
154
- const nestedEnums = [];
155
- const nestedExtensions = [];
156
- let protoTypeName;
157
- if (parent) {
158
- protoTypeName = `${parent.protoTypeName}.${proto.name}`;
159
- }
160
- else if (file.proto.package !== undefined) {
161
- protoTypeName = `.${file.proto.package}.${proto.name}`;
162
- }
163
- else {
164
- protoTypeName = `.${proto.name}`;
165
- }
166
- const message = {
167
- proto,
168
- file,
169
- parent,
170
- name: proto.name,
171
- typeName: protoTypeName.startsWith(".")
172
- ? protoTypeName.substring(1)
173
- : protoTypeName,
174
- protoTypeName,
175
- fields,
176
- oneofs,
177
- nestedEnums,
178
- nestedMessages,
179
- nestedExtensions,
180
- toString() {
181
- return `message ${this.typeName}`;
182
- },
183
- };
184
- us.messages[message.protoTypeName] = message;
185
- for (const nestedType of proto.nestedType) {
186
- nestedMessages.push(newMessage(nestedType, message, file, us));
187
- }
188
- for (const oneofDecl of proto.oneofDecl) {
189
- oneofs.push(newOneof(oneofDecl, message, file));
190
- }
191
- for (const field of proto.field) {
192
- let oneof = undefined;
193
- if (field.oneofIndex !== undefined) {
194
- oneof = oneofs[field.oneofIndex];
195
- assert(oneof, `invalid descriptor: oneof declaration index ${field.oneofIndex} specified by field #${field.number ?? -1} not found`);
196
- }
197
- fields.push(newField(field, message, oneof));
198
- }
199
- for (const enumType of proto.enumType) {
200
- nestedEnums.push(newEnum(enumType, message, file, us));
201
- }
202
- for (const extension of proto.extension) {
203
- nestedExtensions.push(newExtension(extension, message, file, us));
204
- }
205
- return message;
206
- }
207
- function newField(proto, parent, oneof) {
208
- assert(proto.name, `invalid descriptor: missing name`);
209
- assert(proto.number, `invalid descriptor: missing number`);
210
- assert(proto.type, `invalid descriptor: missing type`);
211
- let optional = false;
212
- let packed = proto.options?.packed === true;
213
- switch (parent.file.syntax) {
214
- case "proto2":
215
- optional =
216
- oneof === undefined &&
217
- proto.label === FieldDescriptorProto_Label.OPTIONAL;
218
- break;
219
- case "proto3":
220
- optional = proto.proto3Optional === true;
221
- switch (proto.type) {
222
- case FieldDescriptorProto_Type.DOUBLE:
223
- case FieldDescriptorProto_Type.FLOAT:
224
- case FieldDescriptorProto_Type.INT64:
225
- case FieldDescriptorProto_Type.UINT64:
226
- case FieldDescriptorProto_Type.INT32:
227
- case FieldDescriptorProto_Type.FIXED64:
228
- case FieldDescriptorProto_Type.FIXED32:
229
- case FieldDescriptorProto_Type.UINT32:
230
- case FieldDescriptorProto_Type.SFIXED32:
231
- case FieldDescriptorProto_Type.SFIXED64:
232
- case FieldDescriptorProto_Type.SINT32:
233
- case FieldDescriptorProto_Type.SINT64:
234
- case FieldDescriptorProto_Type.BOOL:
235
- case FieldDescriptorProto_Type.ENUM:
236
- // From the proto3 language guide:
237
- // > In proto3, repeated fields of scalar numeric types are packed by default.
238
- // This information is incomplete - according to the conformance tests, BOOL
239
- // and ENUM are packed by default as well. This means only STRING and BYTES
240
- // are not packed by default, which makes sense because they are length-delimited.
241
- packed = true;
242
- break;
243
- case FieldDescriptorProto_Type.STRING:
244
- case FieldDescriptorProto_Type.GROUP:
245
- case FieldDescriptorProto_Type.MESSAGE:
246
- case FieldDescriptorProto_Type.BYTES:
247
- assert(!packed, `invalid descriptor: ${FieldDescriptorProto_Type[proto.type]} cannot be packed`);
248
- break;
249
- }
250
- break;
251
- }
252
- const field = {
253
- proto,
254
- name: proto.name,
255
- number: proto.number,
256
- type: proto.type,
257
- parent,
258
- oneof: proto.proto3Optional === true ? undefined : oneof,
259
- optional,
260
- packed,
261
- toString() {
262
- // eslint-disable-next-line @typescript-eslint/restrict-template-expressions -- we asserted above
263
- return `field ${parent.typeName}.${proto.name}`;
264
- },
265
- resolve(us) {
266
- return resolveField(this, us);
267
- },
268
- };
269
- if (oneof) {
270
- oneof.fields.push(field);
271
- }
272
- return field;
273
- }
274
- function resolveField(u, us) {
275
- const repeated = u.proto.label === FieldDescriptorProto_Label.REPEATED;
276
- switch (u.type) {
277
- case FieldDescriptorProto_Type.MESSAGE:
278
- case FieldDescriptorProto_Type.GROUP: {
279
- assert(u.proto.typeName, `invalid descriptor: ${u.toString()} has type ${FieldDescriptorProto_Type[u.type]}, but type_name is unset`);
280
- const refMessage = us.messages[u.proto.typeName];
281
- assert(refMessage, `invalid descriptor: cannot find type_name "${u.proto.typeName}" specified by ${u.toString()}`);
282
- if (refMessage.proto.options?.mapEntry !== undefined) {
283
- return {
284
- ...u,
285
- repeated: false,
286
- scalarType: undefined,
287
- message: undefined,
288
- enum: undefined,
289
- map: resolveMap(refMessage, us),
290
- };
291
- }
292
- return {
293
- ...u,
294
- repeated,
295
- scalarType: undefined,
296
- message: refMessage,
297
- enum: undefined,
298
- map: undefined,
299
- };
300
- }
301
- case FieldDescriptorProto_Type.ENUM: {
302
- assert(u.proto.typeName, `invalid descriptor: ${u.toString()} has type ${FieldDescriptorProto_Type[u.type]}, but type_name is unset`);
303
- const refEnum = us.enums[u.proto.typeName];
304
- assert(refEnum, `invalid descriptor: cannot find type_name "${u.proto.typeName}" specified by ${u.toString()}`);
305
- return {
306
- ...u,
307
- repeated,
308
- scalarType: undefined,
309
- message: undefined,
310
- enum: refEnum,
311
- map: undefined,
312
- };
313
- }
314
- default: {
315
- const scalarType = fieldTypeToScalarType[u.type];
316
- assert(scalarType, `invalid descriptor: unable to convert google.protobuf.FieldDescriptorProto.Type ${FieldDescriptorProto_Type[u.type]} to ScalarType`);
317
- return {
318
- ...u,
319
- repeated,
320
- scalarType,
321
- message: undefined,
322
- enum: undefined,
323
- map: undefined,
324
- };
325
- }
326
- }
327
- }
328
- function resolveMap(mapEntry, us) {
329
- assert(mapEntry.proto.options?.mapEntry, `invalid descriptor: expected ${mapEntry.toString()} to be a map entry`);
330
- assert(mapEntry.fields.length === 2, `invalid descriptor: map entry ${mapEntry.toString()} has ${mapEntry.fields.length} fields`);
331
- const uKeyField = mapEntry.fields.find((f) => f.proto.number === 1);
332
- assert(uKeyField, `invalid descriptor: map entry ${mapEntry.toString()} is missing key field`);
333
- const keyField = resolveField(uKeyField, us);
334
- assert(keyField.scalarType !== undefined &&
335
- keyField.scalarType !== ScalarType.BYTES &&
336
- keyField.scalarType !== ScalarType.FLOAT &&
337
- keyField.scalarType !== ScalarType.DOUBLE, `invalid descriptor: map entry ${mapEntry.toString()} has unexpected key type ${FieldDescriptorProto_Type[keyField.type]}`);
338
- const uValueField = mapEntry.fields.find((f) => f.proto.number === 2);
339
- assert(uValueField, `invalid descriptor: map entry ${mapEntry.toString()} is missing value field`);
340
- const valueField = resolveField(uValueField, us);
341
- if (valueField.scalarType !== undefined) {
342
- return {
343
- key: keyField.scalarType,
344
- value: {
345
- scalarType: valueField.scalarType,
346
- enum: undefined,
347
- message: undefined,
348
- },
349
- };
350
- }
351
- if (valueField.enum !== undefined) {
352
- return {
353
- key: keyField.scalarType,
354
- value: { scalar: undefined, enum: valueField.enum, message: undefined },
355
- };
356
- }
357
- if (valueField.message !== undefined) {
358
- return {
359
- key: keyField.scalarType,
360
- value: {
361
- scalar: undefined,
362
- enum: undefined,
363
- message: valueField.message,
364
- },
365
- };
366
- }
367
- throw new Error(`invalid descriptor: map entry ${mapEntry.toString()} has unexpected value type ${FieldDescriptorProto_Type[keyField.type]}`);
368
- }
369
- function newOneof(proto, parent, file) {
370
- assert(proto.name, `invalid descriptor: missing oneof descriptor name`);
371
- return {
372
- proto,
373
- parent,
374
- file,
375
- fields: [],
376
- name: proto.name,
377
- toString() {
378
- // eslint-disable-next-line @typescript-eslint/restrict-template-expressions -- we asserted above
379
- return `oneof ${parent.typeName}.${proto.name}`;
380
- },
381
- };
382
- }
383
- function newExtension(proto, parent, file, us // eslint-disable-line @typescript-eslint/no-unused-vars
384
- ) {
385
- assert(proto.name, `invalid descriptor: missing field descriptor name`);
386
- return {
387
- proto,
388
- file,
389
- parent,
390
- };
391
- }
392
- function newService(proto, file, us) {
393
- assert(proto.name, `invalid descriptor: missing service descriptor name`);
394
- let protoTypeName;
395
- if (file.proto.package !== undefined) {
396
- protoTypeName = `.${file.proto.package}.${proto.name}`;
397
- }
398
- else {
399
- protoTypeName = `.${proto.name}`;
400
- }
401
- const methods = [];
402
- const service = {
403
- proto,
404
- file,
405
- typeName: protoTypeName.startsWith(".")
406
- ? protoTypeName.substring(1)
407
- : protoTypeName,
408
- protoTypeName,
409
- methods,
410
- toString() {
411
- return `service ${this.typeName}`;
412
- },
413
- };
414
- for (const method of proto.method) {
415
- methods.push(newMethod(method, service));
416
- }
417
- us.services[service.protoTypeName] = service;
418
- return service;
419
- }
420
- function newMethod(proto, parent) {
421
- assert(proto.name, `invalid descriptor: missing method descriptor name`);
422
- assert(proto.inputType, `invalid descriptor: missing method input type`);
423
- assert(proto.outputType, `invalid descriptor: missing method output type`);
424
- let kind;
425
- if (proto.clientStreaming === true && proto.serverStreaming === true) {
426
- kind = MethodKind.BiDiStreaming;
427
- }
428
- else if (proto.clientStreaming === true) {
429
- kind = MethodKind.ClientStreaming;
430
- }
431
- else if (proto.serverStreaming === true) {
432
- kind = MethodKind.ServerStreaming;
433
- }
434
- else {
435
- kind = MethodKind.Unary;
436
- }
437
- let idempotency;
438
- switch (proto.options?.idempotencyLevel) {
439
- case MethodOptions_IdempotencyLevel.IDEMPOTENT:
440
- idempotency = MethodIdempotency.Idempotent;
441
- break;
442
- case MethodOptions_IdempotencyLevel.NO_SIDE_EFFECTS:
443
- idempotency = MethodIdempotency.NoSideEffects;
444
- break;
445
- case MethodOptions_IdempotencyLevel.IDEMPOTENCY_UNKNOWN:
446
- case undefined:
447
- idempotency = undefined;
448
- break;
449
- }
450
- const inputTypeName = proto.inputType.startsWith(".")
451
- ? proto.inputType.substring(1)
452
- : proto.inputType;
453
- const outputTypeName = proto.outputType.startsWith(".")
454
- ? proto.outputType.substring(1)
455
- : proto.outputType;
456
- return {
457
- proto,
458
- parent,
459
- name: proto.name,
460
- kind,
461
- idempotency,
462
- inputTypeName,
463
- outputTypeName,
464
- toString() {
465
- // eslint-disable-next-line @typescript-eslint/restrict-template-expressions -- we asserted above
466
- return `rpc ${this.parent.typeName}.${proto.name}`;
467
- },
468
- };
469
- }
14
+ export {};
@@ -145,11 +145,12 @@ export class Any extends Message {
145
145
  proto3.util.initPartial(data, this);
146
146
  }
147
147
  toJson(options) {
148
+ var _a;
148
149
  if (this.typeUrl === "") {
149
150
  return {};
150
151
  }
151
152
  const typeName = this.typeUrlToName(this.typeUrl);
152
- const messageType = options?.typeRegistry?.findMessage(typeName);
153
+ const messageType = (_a = options === null || options === void 0 ? void 0 : options.typeRegistry) === null || _a === void 0 ? void 0 : _a.findMessage(typeName);
153
154
  if (!messageType) {
154
155
  throw new Error(`cannot encode message google.protobuf.Any to JSON: "${this.typeUrl}" is not in the type registry`);
155
156
  }
@@ -162,6 +163,7 @@ export class Any extends Message {
162
163
  return json;
163
164
  }
164
165
  fromJson(json, options) {
166
+ var _a;
165
167
  if (json === null || Array.isArray(json) || typeof json != "object") {
166
168
  throw new Error(`cannot decode message google.protobuf.Any from JSON: expected object but got ${json === null ? "null" : Array.isArray(json) ? "array" : typeof json}`);
167
169
  }
@@ -169,7 +171,7 @@ export class Any extends Message {
169
171
  if (typeof typeUrl != "string" || typeUrl == "") {
170
172
  throw new Error(`cannot decode message google.protobuf.Any from JSON: "@type" is empty`);
171
173
  }
172
- const typeName = this.typeUrlToName(typeUrl), messageType = options?.typeRegistry?.findMessage(typeName);
174
+ const typeName = this.typeUrlToName(typeUrl), messageType = (_a = options === null || options === void 0 ? void 0 : options.typeRegistry) === null || _a === void 0 ? void 0 : _a.findMessage(typeName);
173
175
  if (!messageType) {
174
176
  throw new Error(`cannot decode message google.protobuf.Any from JSON: ${typeUrl} is not in the type registry`);
175
177
  }
@@ -118,7 +118,7 @@ export class Duration extends Message {
118
118
  if (typeof match[2] == "string") {
119
119
  const nanosStr = match[2] + "0".repeat(9 - match[2].length);
120
120
  this.nanos = parseInt(nanosStr);
121
- if (longSeconds < 0n) {
121
+ if (longSeconds < protoInt64.zero) {
122
122
  this.nanos = -this.nanos;
123
123
  }
124
124
  }
@@ -11,7 +11,7 @@
11
11
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
12
  // See the License for the specific language governing permissions and
13
13
  // limitations under the License.
14
- // @generated by protoc-gen-es v0.0.6 with parameter "bootstrap_wkt=true,ts_nocheck=false,target=ts"
14
+ // @generated by protoc-gen-es v0.0.9 with parameter "bootstrap_wkt=true,ts_nocheck=false,target=ts"
15
15
  // @generated from file google/protobuf/struct.proto (package google.protobuf, syntax proto3)
16
16
  /* eslint-disable */
17
17
  import { proto3 } from "../../proto3.js";
@@ -125,7 +125,7 @@ export class Value extends Message {
125
125
  return this.kind.value;
126
126
  case "structValue":
127
127
  case "listValue":
128
- return this.kind.value.toJson({ ...options, emitDefaultValues: true });
128
+ return this.kind.value.toJson(Object.assign(Object.assign({}, options), { emitDefaultValues: true }));
129
129
  }
130
130
  throw new Error("google.protobuf.Value must have a value");
131
131
  }
@@ -11,7 +11,7 @@
11
11
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
12
  // See the License for the specific language governing permissions and
13
13
  // limitations under the License.
14
- // @generated by protoc-gen-es v0.0.6 with parameter "bootstrap_wkt=true,ts_nocheck=false,target=ts"
14
+ // @generated by protoc-gen-es v0.0.9 with parameter "bootstrap_wkt=true,ts_nocheck=false,target=ts"
15
15
  // @generated from file google/protobuf/type.proto (package google.protobuf, syntax proto3)
16
16
  /* eslint-disable */
17
17
  import { proto3 } from "../../proto3.js";
package/dist/esm/index.js CHANGED
@@ -15,14 +15,20 @@ export { proto3 } from "./proto3.js";
15
15
  export { proto2 } from "./proto2.js";
16
16
  export { protoInt64 } from "./proto-int64.js";
17
17
  export { protoBase64 } from "./proto-base64.js";
18
+ export { codegenInfo } from "./codegen-info.js";
18
19
  export { Message, } from "./message.js";
19
20
  export { ScalarType } from "./field.js";
20
21
  export { MethodKind, MethodIdempotency } from "./service-type.js";
21
- export { TypeRegistry } from "./type-registry.js";
22
- export { DescriptorRegistry } from "./descriptor-registry.js";
23
- export { DescriptorSet } from "./descriptor-set.js";
24
22
  export { WireType, BinaryWriter, BinaryReader } from "./binary-encoding.js";
25
23
  export {} from "./json-format.js";
24
+ export {} from "./descriptor-set.js";
25
+ export { createDescriptorSet } from "./create-descriptor-set.js";
26
+ export {} from "./type-registry.js";
27
+ export { createRegistry } from "./create-registry.js";
28
+ export { createRegistryFromDescriptors } from "./create-registry-from-desc.js";
29
+ export { LegacyDescriptorRegistry } from "./legacy-descriptor-registry.js";
30
+ export { LegacyDescriptorSet } from "./legacy-descriptor-set.js";
31
+ export { TypeRegistry } from "./legacy-type-registry.js";
26
32
  // ideally, we would export these types with sub-path exports:
27
33
  export * from "./google/protobuf/compiler/plugin_pb.js";
28
34
  export * from "./google/protobuf/api_pb.js";