@bufbuild/protobuf 0.5.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (121) hide show
  1. package/README.md +2 -2
  2. package/dist/cjs/binary-encoding.js +1 -1
  3. package/dist/cjs/binary-format.js +1 -1
  4. package/dist/cjs/codegen-info.js +1 -1
  5. package/dist/cjs/create-descriptor-set.js +1 -1
  6. package/dist/cjs/create-registry-from-desc.js +1 -1
  7. package/dist/cjs/create-registry.js +1 -1
  8. package/dist/cjs/descriptor-set.js +1 -1
  9. package/dist/cjs/enum.js +1 -1
  10. package/dist/cjs/field-list.js +1 -1
  11. package/dist/cjs/field.js +1 -1
  12. package/dist/cjs/google/protobuf/any_pb.js +5 -2
  13. package/dist/cjs/google/protobuf/api_pb.js +1 -2
  14. package/dist/cjs/google/protobuf/compiler/plugin_pb.js +1 -1
  15. package/dist/cjs/google/protobuf/descriptor_pb.js +134 -2
  16. package/dist/cjs/google/protobuf/duration_pb.js +5 -3
  17. package/dist/cjs/google/protobuf/empty_pb.js +1 -1
  18. package/dist/cjs/google/protobuf/field_mask_pb.js +1 -1
  19. package/dist/cjs/google/protobuf/source_context_pb.js +1 -1
  20. package/dist/cjs/google/protobuf/struct_pb.js +8 -3
  21. package/dist/cjs/google/protobuf/timestamp_pb.js +1 -4
  22. package/dist/cjs/google/protobuf/type_pb.js +2 -2
  23. package/dist/cjs/google/protobuf/wrappers_pb.js +1 -1
  24. package/dist/cjs/index.js +4 -2
  25. package/dist/cjs/json-format.js +1 -1
  26. package/dist/cjs/message-type.js +1 -1
  27. package/dist/cjs/message.js +5 -3
  28. package/dist/cjs/private/assert.js +1 -1
  29. package/dist/cjs/private/binary-format-common.js +1 -1
  30. package/dist/cjs/private/binary-format-proto2.js +1 -1
  31. package/dist/cjs/private/binary-format-proto3.js +1 -1
  32. package/dist/cjs/private/enum.js +1 -1
  33. package/dist/cjs/private/field-list.js +1 -1
  34. package/dist/cjs/private/field-wrapper.js +1 -1
  35. package/dist/cjs/private/field.js +1 -1
  36. package/dist/cjs/private/json-format-common.js +1 -1
  37. package/dist/cjs/private/json-format-proto2.js +1 -1
  38. package/dist/cjs/private/json-format-proto3.js +1 -1
  39. package/dist/cjs/private/message-type.js +1 -1
  40. package/dist/cjs/private/names.js +1 -1
  41. package/dist/cjs/private/options-map.js +1 -1
  42. package/dist/cjs/private/proto-runtime.js +1 -1
  43. package/dist/cjs/private/reify-wkt.js +1 -1
  44. package/dist/cjs/private/scalars.js +1 -1
  45. package/dist/cjs/private/util-common.js +1 -1
  46. package/dist/cjs/private/util.js +1 -1
  47. package/dist/cjs/proto-base64.js +1 -1
  48. package/dist/cjs/proto-delimited.js +160 -0
  49. package/dist/cjs/proto-int64.js +1 -1
  50. package/dist/cjs/proto2.js +1 -1
  51. package/dist/cjs/proto3.js +1 -1
  52. package/dist/cjs/service-type.js +1 -1
  53. package/dist/cjs/type-registry.js +1 -1
  54. package/dist/esm/binary-encoding.js +1 -1
  55. package/dist/esm/binary-format.js +1 -1
  56. package/dist/esm/codegen-info.js +1 -1
  57. package/dist/esm/create-descriptor-set.js +1 -1
  58. package/dist/esm/create-registry-from-desc.js +1 -1
  59. package/dist/esm/create-registry.js +1 -1
  60. package/dist/esm/descriptor-set.js +1 -1
  61. package/dist/esm/enum.js +1 -1
  62. package/dist/esm/field-list.js +1 -1
  63. package/dist/esm/field.js +1 -1
  64. package/dist/esm/google/protobuf/any_pb.js +5 -2
  65. package/dist/esm/google/protobuf/api_pb.js +1 -2
  66. package/dist/esm/google/protobuf/compiler/plugin_pb.js +1 -1
  67. package/dist/esm/google/protobuf/descriptor_pb.js +133 -1
  68. package/dist/esm/google/protobuf/duration_pb.js +5 -3
  69. package/dist/esm/google/protobuf/empty_pb.js +1 -1
  70. package/dist/esm/google/protobuf/field_mask_pb.js +1 -1
  71. package/dist/esm/google/protobuf/source_context_pb.js +1 -1
  72. package/dist/esm/google/protobuf/struct_pb.js +8 -3
  73. package/dist/esm/google/protobuf/timestamp_pb.js +1 -4
  74. package/dist/esm/google/protobuf/type_pb.js +2 -2
  75. package/dist/esm/google/protobuf/wrappers_pb.js +1 -1
  76. package/dist/esm/index.js +2 -1
  77. package/dist/esm/json-format.js +1 -1
  78. package/dist/esm/message-type.js +1 -1
  79. package/dist/esm/message.js +5 -3
  80. package/dist/esm/private/assert.js +1 -1
  81. package/dist/esm/private/binary-format-common.js +1 -1
  82. package/dist/esm/private/binary-format-proto2.js +1 -1
  83. package/dist/esm/private/binary-format-proto3.js +1 -1
  84. package/dist/esm/private/enum.js +1 -1
  85. package/dist/esm/private/field-list.js +1 -1
  86. package/dist/esm/private/field-wrapper.js +1 -1
  87. package/dist/esm/private/field.js +1 -1
  88. package/dist/esm/private/json-format-common.js +1 -1
  89. package/dist/esm/private/json-format-proto2.js +1 -1
  90. package/dist/esm/private/json-format-proto3.js +1 -1
  91. package/dist/esm/private/message-type.js +1 -1
  92. package/dist/esm/private/names.js +1 -1
  93. package/dist/esm/private/options-map.js +1 -1
  94. package/dist/esm/private/proto-runtime.js +1 -1
  95. package/dist/esm/private/reify-wkt.js +1 -1
  96. package/dist/esm/private/scalars.js +1 -1
  97. package/dist/esm/private/util-common.js +1 -1
  98. package/dist/esm/private/util.js +1 -1
  99. package/dist/esm/proto-base64.js +1 -1
  100. package/dist/esm/proto-delimited.js +157 -0
  101. package/dist/esm/proto-int64.js +1 -1
  102. package/dist/esm/proto2.js +1 -1
  103. package/dist/esm/proto3.js +1 -1
  104. package/dist/esm/service-type.js +1 -1
  105. package/dist/esm/type-registry.js +1 -1
  106. package/dist/types/google/protobuf/any_pb.d.ts +6 -2
  107. package/dist/types/google/protobuf/api_pb.d.ts +4 -4
  108. package/dist/types/google/protobuf/compiler/plugin_pb.d.ts +5 -4
  109. package/dist/types/google/protobuf/descriptor_pb.d.ts +188 -39
  110. package/dist/types/google/protobuf/duration_pb.d.ts +2 -2
  111. package/dist/types/google/protobuf/empty_pb.d.ts +2 -1
  112. package/dist/types/google/protobuf/field_mask_pb.d.ts +2 -1
  113. package/dist/types/google/protobuf/source_context_pb.d.ts +2 -1
  114. package/dist/types/google/protobuf/struct_pb.d.ts +4 -3
  115. package/dist/types/google/protobuf/timestamp_pb.d.ts +2 -4
  116. package/dist/types/google/protobuf/type_pb.d.ts +6 -5
  117. package/dist/types/google/protobuf/wrappers_pb.d.ts +10 -9
  118. package/dist/types/index.d.ts +1 -0
  119. package/dist/types/message.d.ts +4 -2
  120. package/dist/types/proto-delimited.d.ts +54 -0
  121. package/package.json +1 -1
@@ -1,3 +1,4 @@
1
+ import { proto3 } from "../../proto3.js";
1
2
  import type { PartialMessage, PlainMessage } from "../../message.js";
2
3
  import { Message } from "../../message.js";
3
4
  import { SourceContext } from "./source_context_pb.js";
@@ -67,7 +68,7 @@ export declare class Type extends Message<Type> {
67
68
  */
68
69
  syntax: Syntax;
69
70
  constructor(data?: PartialMessage<Type>);
70
- static readonly runtime: import("../../private/proto-runtime.js").ProtoRuntime;
71
+ static readonly runtime: typeof proto3;
71
72
  static readonly typeName = "google.protobuf.Type";
72
73
  static readonly fields: FieldList;
73
74
  static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): Type;
@@ -144,7 +145,7 @@ export declare class Field extends Message<Field> {
144
145
  */
145
146
  defaultValue: string;
146
147
  constructor(data?: PartialMessage<Field>);
147
- static readonly runtime: import("../../private/proto-runtime.js").ProtoRuntime;
148
+ static readonly runtime: typeof proto3;
148
149
  static readonly typeName = "google.protobuf.Field";
149
150
  static readonly fields: FieldList;
150
151
  static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): Field;
@@ -341,7 +342,7 @@ export declare class Enum extends Message<Enum> {
341
342
  */
342
343
  syntax: Syntax;
343
344
  constructor(data?: PartialMessage<Enum>);
344
- static readonly runtime: import("../../private/proto-runtime.js").ProtoRuntime;
345
+ static readonly runtime: typeof proto3;
345
346
  static readonly typeName = "google.protobuf.Enum";
346
347
  static readonly fields: FieldList;
347
348
  static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): Enum;
@@ -374,7 +375,7 @@ export declare class EnumValue extends Message<EnumValue> {
374
375
  */
375
376
  options: Option[];
376
377
  constructor(data?: PartialMessage<EnumValue>);
377
- static readonly runtime: import("../../private/proto-runtime.js").ProtoRuntime;
378
+ static readonly runtime: typeof proto3;
378
379
  static readonly typeName = "google.protobuf.EnumValue";
379
380
  static readonly fields: FieldList;
380
381
  static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): EnumValue;
@@ -408,7 +409,7 @@ export declare class Option extends Message<Option> {
408
409
  */
409
410
  value?: Any;
410
411
  constructor(data?: PartialMessage<Option>);
411
- static readonly runtime: import("../../private/proto-runtime.js").ProtoRuntime;
412
+ static readonly runtime: typeof proto3;
412
413
  static readonly typeName = "google.protobuf.Option";
413
414
  static readonly fields: FieldList;
414
415
  static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): Option;
@@ -1,5 +1,6 @@
1
1
  import type { PartialMessage, PlainMessage } from "../../message.js";
2
2
  import { Message } from "../../message.js";
3
+ import { proto3 } from "../../proto3.js";
3
4
  import type { JsonReadOptions, JsonValue, JsonWriteOptions } from "../../json-format.js";
4
5
  import type { FieldList } from "../../field-list.js";
5
6
  import type { BinaryReadOptions } from "../../binary-format.js";
@@ -20,7 +21,7 @@ export declare class DoubleValue extends Message<DoubleValue> {
20
21
  constructor(data?: PartialMessage<DoubleValue>);
21
22
  toJson(options?: Partial<JsonWriteOptions>): JsonValue;
22
23
  fromJson(json: JsonValue, options?: Partial<JsonReadOptions>): this;
23
- static readonly runtime: import("../../private/proto-runtime.js").ProtoRuntime;
24
+ static readonly runtime: typeof proto3;
24
25
  static readonly typeName = "google.protobuf.DoubleValue";
25
26
  static readonly fields: FieldList;
26
27
  static readonly fieldWrapper: {
@@ -49,7 +50,7 @@ export declare class FloatValue extends Message<FloatValue> {
49
50
  constructor(data?: PartialMessage<FloatValue>);
50
51
  toJson(options?: Partial<JsonWriteOptions>): JsonValue;
51
52
  fromJson(json: JsonValue, options?: Partial<JsonReadOptions>): this;
52
- static readonly runtime: import("../../private/proto-runtime.js").ProtoRuntime;
53
+ static readonly runtime: typeof proto3;
53
54
  static readonly typeName = "google.protobuf.FloatValue";
54
55
  static readonly fields: FieldList;
55
56
  static readonly fieldWrapper: {
@@ -78,7 +79,7 @@ export declare class Int64Value extends Message<Int64Value> {
78
79
  constructor(data?: PartialMessage<Int64Value>);
79
80
  toJson(options?: Partial<JsonWriteOptions>): JsonValue;
80
81
  fromJson(json: JsonValue, options?: Partial<JsonReadOptions>): this;
81
- static readonly runtime: import("../../private/proto-runtime.js").ProtoRuntime;
82
+ static readonly runtime: typeof proto3;
82
83
  static readonly typeName = "google.protobuf.Int64Value";
83
84
  static readonly fields: FieldList;
84
85
  static readonly fieldWrapper: {
@@ -107,7 +108,7 @@ export declare class UInt64Value extends Message<UInt64Value> {
107
108
  constructor(data?: PartialMessage<UInt64Value>);
108
109
  toJson(options?: Partial<JsonWriteOptions>): JsonValue;
109
110
  fromJson(json: JsonValue, options?: Partial<JsonReadOptions>): this;
110
- static readonly runtime: import("../../private/proto-runtime.js").ProtoRuntime;
111
+ static readonly runtime: typeof proto3;
111
112
  static readonly typeName = "google.protobuf.UInt64Value";
112
113
  static readonly fields: FieldList;
113
114
  static readonly fieldWrapper: {
@@ -136,7 +137,7 @@ export declare class Int32Value extends Message<Int32Value> {
136
137
  constructor(data?: PartialMessage<Int32Value>);
137
138
  toJson(options?: Partial<JsonWriteOptions>): JsonValue;
138
139
  fromJson(json: JsonValue, options?: Partial<JsonReadOptions>): this;
139
- static readonly runtime: import("../../private/proto-runtime.js").ProtoRuntime;
140
+ static readonly runtime: typeof proto3;
140
141
  static readonly typeName = "google.protobuf.Int32Value";
141
142
  static readonly fields: FieldList;
142
143
  static readonly fieldWrapper: {
@@ -165,7 +166,7 @@ export declare class UInt32Value extends Message<UInt32Value> {
165
166
  constructor(data?: PartialMessage<UInt32Value>);
166
167
  toJson(options?: Partial<JsonWriteOptions>): JsonValue;
167
168
  fromJson(json: JsonValue, options?: Partial<JsonReadOptions>): this;
168
- static readonly runtime: import("../../private/proto-runtime.js").ProtoRuntime;
169
+ static readonly runtime: typeof proto3;
169
170
  static readonly typeName = "google.protobuf.UInt32Value";
170
171
  static readonly fields: FieldList;
171
172
  static readonly fieldWrapper: {
@@ -194,7 +195,7 @@ export declare class BoolValue extends Message<BoolValue> {
194
195
  constructor(data?: PartialMessage<BoolValue>);
195
196
  toJson(options?: Partial<JsonWriteOptions>): JsonValue;
196
197
  fromJson(json: JsonValue, options?: Partial<JsonReadOptions>): this;
197
- static readonly runtime: import("../../private/proto-runtime.js").ProtoRuntime;
198
+ static readonly runtime: typeof proto3;
198
199
  static readonly typeName = "google.protobuf.BoolValue";
199
200
  static readonly fields: FieldList;
200
201
  static readonly fieldWrapper: {
@@ -223,7 +224,7 @@ export declare class StringValue extends Message<StringValue> {
223
224
  constructor(data?: PartialMessage<StringValue>);
224
225
  toJson(options?: Partial<JsonWriteOptions>): JsonValue;
225
226
  fromJson(json: JsonValue, options?: Partial<JsonReadOptions>): this;
226
- static readonly runtime: import("../../private/proto-runtime.js").ProtoRuntime;
227
+ static readonly runtime: typeof proto3;
227
228
  static readonly typeName = "google.protobuf.StringValue";
228
229
  static readonly fields: FieldList;
229
230
  static readonly fieldWrapper: {
@@ -252,7 +253,7 @@ export declare class BytesValue extends Message<BytesValue> {
252
253
  constructor(data?: PartialMessage<BytesValue>);
253
254
  toJson(options?: Partial<JsonWriteOptions>): JsonValue;
254
255
  fromJson(json: JsonValue, options?: Partial<JsonReadOptions>): this;
255
- static readonly runtime: import("../../private/proto-runtime.js").ProtoRuntime;
256
+ static readonly runtime: typeof proto3;
256
257
  static readonly typeName = "google.protobuf.BytesValue";
257
258
  static readonly fields: FieldList;
258
259
  static readonly fieldWrapper: {
@@ -2,6 +2,7 @@ export { proto3 } from "./proto3.js";
2
2
  export { proto2 } from "./proto2.js";
3
3
  export { protoInt64 } from "./proto-int64.js";
4
4
  export { protoBase64 } from "./proto-base64.js";
5
+ export { protoDelimited } from "./proto-delimited.js";
5
6
  export { codegenInfo } from "./codegen-info.js";
6
7
  export { Message, AnyMessage, PartialMessage, PlainMessage, } from "./message.js";
7
8
  export type { FieldInfo } from "./field.js";
@@ -66,8 +66,10 @@ export declare class Message<T extends Message<T> = AnyMessage> {
66
66
  * message type. As a result, attempting to serialize a message with this
67
67
  * type will throw an Error.
68
68
  *
69
- * Note that this method is protected because users should not need to invoke
70
- * it directly -- they can use JSON.stringify.
69
+ * This method is protected because you should not need to invoke it
70
+ * directly -- instead use JSON.stringify or toJsonString for
71
+ * stringified JSON. Alternatively, if actual JSON is desired, you should
72
+ * use toJson.
71
73
  */
72
74
  protected toJSON(): JsonValue;
73
75
  /**
@@ -0,0 +1,54 @@
1
+ import type { BinaryReadOptions, BinaryWriteOptions } from "./binary-format.js";
2
+ import type { Message } from "./message.js";
3
+ import type { MessageType } from "./message-type.js";
4
+ /**
5
+ * protoDelimited provides functions to serialize and parse size-delimited
6
+ * messages.
7
+ *
8
+ * A size-delimited message is a varint size in bytes, followed by exactly
9
+ * that many bytes of a message serialized with the binary format.
10
+ *
11
+ * This size-delimited format is compatible with other implementations.
12
+ * For details, see https://github.com/protocolbuffers/protobuf/issues/10229
13
+ */
14
+ export declare const protoDelimited: {
15
+ /**
16
+ * Serialize a message, prefixing it with its size.
17
+ */
18
+ enc(message: Message, options?: BinaryWriteOptions): Uint8Array;
19
+ /**
20
+ * Parse a size-delimited message, ignoring extra bytes.
21
+ */
22
+ dec<T extends Message<T>>(type: MessageType<T>, bytes: Uint8Array, options?: BinaryReadOptions): T;
23
+ /**
24
+ * Parse a stream of size-delimited messages.
25
+ */
26
+ decStream<T_1 extends Message<T_1>>(type: MessageType<T_1>, iterable: AsyncIterable<Uint8Array>): AsyncGenerator<T_1, void, unknown>;
27
+ /**
28
+ * Decodes the size from the given size-delimited message, which may be
29
+ * incomplete.
30
+ *
31
+ * Returns an object with the following properties:
32
+ * - size: The size of the delimited message in bytes
33
+ * - offset: The offset in the given byte array where the message starts
34
+ * - eof: true
35
+ *
36
+ * If the size-delimited data does not include all bytes of the varint size,
37
+ * the following object is returned:
38
+ * - size: null
39
+ * - offset: null
40
+ * - eof: false
41
+ *
42
+ * This function can be used to implement parsing of size-delimited messages
43
+ * from a stream.
44
+ */
45
+ peekSize(data: Uint8Array): {
46
+ readonly eof: false;
47
+ readonly size: number;
48
+ readonly offset: number;
49
+ } | {
50
+ readonly eof: true;
51
+ readonly size: null;
52
+ readonly offset: null;
53
+ };
54
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bufbuild/protobuf",
3
- "version": "0.5.0",
3
+ "version": "1.1.0",
4
4
  "license": "(Apache-2.0 AND BSD-3-Clause)",
5
5
  "description": "A complete implementation of Protocol Buffers in TypeScript, suitable for web browsers and Node.js.",
6
6
  "repository": {