@bufbuild/protobuf 1.0.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (120) hide show
  1. package/dist/cjs/binary-encoding.js +1 -1
  2. package/dist/cjs/binary-format.js +1 -1
  3. package/dist/cjs/codegen-info.js +1 -1
  4. package/dist/cjs/create-descriptor-set.js +1 -1
  5. package/dist/cjs/create-registry-from-desc.js +4 -5
  6. package/dist/cjs/create-registry.js +1 -1
  7. package/dist/cjs/descriptor-set.js +1 -1
  8. package/dist/cjs/enum.js +1 -1
  9. package/dist/cjs/field-list.js +1 -1
  10. package/dist/cjs/field.js +1 -1
  11. package/dist/cjs/google/protobuf/any_pb.js +5 -2
  12. package/dist/cjs/google/protobuf/api_pb.js +1 -2
  13. package/dist/cjs/google/protobuf/compiler/plugin_pb.js +1 -1
  14. package/dist/cjs/google/protobuf/descriptor_pb.js +134 -2
  15. package/dist/cjs/google/protobuf/duration_pb.js +5 -3
  16. package/dist/cjs/google/protobuf/empty_pb.js +1 -1
  17. package/dist/cjs/google/protobuf/field_mask_pb.js +1 -1
  18. package/dist/cjs/google/protobuf/source_context_pb.js +1 -1
  19. package/dist/cjs/google/protobuf/struct_pb.js +8 -3
  20. package/dist/cjs/google/protobuf/timestamp_pb.js +1 -4
  21. package/dist/cjs/google/protobuf/type_pb.js +2 -2
  22. package/dist/cjs/google/protobuf/wrappers_pb.js +1 -1
  23. package/dist/cjs/index.js +4 -2
  24. package/dist/cjs/json-format.js +1 -1
  25. package/dist/cjs/message-type.js +1 -1
  26. package/dist/cjs/message.js +1 -1
  27. package/dist/cjs/private/assert.js +1 -1
  28. package/dist/cjs/private/binary-format-common.js +1 -1
  29. package/dist/cjs/private/binary-format-proto2.js +1 -1
  30. package/dist/cjs/private/binary-format-proto3.js +1 -1
  31. package/dist/cjs/private/enum.js +1 -1
  32. package/dist/cjs/private/field-list.js +1 -1
  33. package/dist/cjs/private/field-wrapper.js +1 -1
  34. package/dist/cjs/private/field.js +1 -1
  35. package/dist/cjs/private/json-format-common.js +1 -1
  36. package/dist/cjs/private/json-format-proto2.js +1 -1
  37. package/dist/cjs/private/json-format-proto3.js +1 -1
  38. package/dist/cjs/private/message-type.js +1 -1
  39. package/dist/cjs/private/names.js +1 -1
  40. package/dist/cjs/private/options-map.js +1 -1
  41. package/dist/cjs/private/proto-runtime.js +1 -1
  42. package/dist/cjs/private/reify-wkt.js +1 -1
  43. package/dist/cjs/private/scalars.js +1 -1
  44. package/dist/cjs/private/util-common.js +5 -5
  45. package/dist/cjs/private/util.js +1 -1
  46. package/dist/cjs/proto-base64.js +1 -3
  47. package/dist/cjs/proto-delimited.js +160 -0
  48. package/dist/cjs/proto-int64.js +1 -1
  49. package/dist/cjs/proto2.js +1 -1
  50. package/dist/cjs/proto3.js +1 -1
  51. package/dist/cjs/service-type.js +1 -1
  52. package/dist/cjs/type-registry.js +1 -1
  53. package/dist/esm/binary-encoding.js +1 -1
  54. package/dist/esm/binary-format.js +1 -1
  55. package/dist/esm/codegen-info.js +1 -1
  56. package/dist/esm/create-descriptor-set.js +1 -1
  57. package/dist/esm/create-registry-from-desc.js +4 -5
  58. package/dist/esm/create-registry.js +1 -1
  59. package/dist/esm/descriptor-set.js +1 -1
  60. package/dist/esm/enum.js +1 -1
  61. package/dist/esm/field-list.js +1 -1
  62. package/dist/esm/field.js +1 -1
  63. package/dist/esm/google/protobuf/any_pb.js +5 -2
  64. package/dist/esm/google/protobuf/api_pb.js +1 -2
  65. package/dist/esm/google/protobuf/compiler/plugin_pb.js +1 -1
  66. package/dist/esm/google/protobuf/descriptor_pb.js +133 -1
  67. package/dist/esm/google/protobuf/duration_pb.js +5 -3
  68. package/dist/esm/google/protobuf/empty_pb.js +1 -1
  69. package/dist/esm/google/protobuf/field_mask_pb.js +1 -1
  70. package/dist/esm/google/protobuf/source_context_pb.js +1 -1
  71. package/dist/esm/google/protobuf/struct_pb.js +8 -3
  72. package/dist/esm/google/protobuf/timestamp_pb.js +1 -4
  73. package/dist/esm/google/protobuf/type_pb.js +2 -2
  74. package/dist/esm/google/protobuf/wrappers_pb.js +1 -1
  75. package/dist/esm/index.js +2 -1
  76. package/dist/esm/json-format.js +1 -1
  77. package/dist/esm/message-type.js +1 -1
  78. package/dist/esm/message.js +1 -1
  79. package/dist/esm/private/assert.js +1 -1
  80. package/dist/esm/private/binary-format-common.js +1 -1
  81. package/dist/esm/private/binary-format-proto2.js +1 -1
  82. package/dist/esm/private/binary-format-proto3.js +1 -1
  83. package/dist/esm/private/enum.js +1 -1
  84. package/dist/esm/private/field-list.js +1 -1
  85. package/dist/esm/private/field-wrapper.js +1 -1
  86. package/dist/esm/private/field.js +1 -1
  87. package/dist/esm/private/json-format-common.js +1 -1
  88. package/dist/esm/private/json-format-proto2.js +1 -1
  89. package/dist/esm/private/json-format-proto3.js +1 -1
  90. package/dist/esm/private/message-type.js +1 -1
  91. package/dist/esm/private/names.js +1 -1
  92. package/dist/esm/private/options-map.js +1 -1
  93. package/dist/esm/private/proto-runtime.js +1 -1
  94. package/dist/esm/private/reify-wkt.js +1 -1
  95. package/dist/esm/private/scalars.js +1 -1
  96. package/dist/esm/private/util-common.js +5 -5
  97. package/dist/esm/private/util.js +1 -1
  98. package/dist/esm/proto-base64.js +1 -3
  99. package/dist/esm/proto-delimited.js +157 -0
  100. package/dist/esm/proto-int64.js +1 -1
  101. package/dist/esm/proto2.js +1 -1
  102. package/dist/esm/proto3.js +1 -1
  103. package/dist/esm/service-type.js +1 -1
  104. package/dist/esm/type-registry.js +1 -1
  105. package/dist/types/google/protobuf/any_pb.d.ts +6 -2
  106. package/dist/types/google/protobuf/api_pb.d.ts +4 -4
  107. package/dist/types/google/protobuf/compiler/plugin_pb.d.ts +5 -4
  108. package/dist/types/google/protobuf/descriptor_pb.d.ts +188 -39
  109. package/dist/types/google/protobuf/duration_pb.d.ts +2 -2
  110. package/dist/types/google/protobuf/empty_pb.d.ts +2 -1
  111. package/dist/types/google/protobuf/field_mask_pb.d.ts +2 -1
  112. package/dist/types/google/protobuf/source_context_pb.d.ts +2 -1
  113. package/dist/types/google/protobuf/struct_pb.d.ts +4 -3
  114. package/dist/types/google/protobuf/timestamp_pb.d.ts +2 -4
  115. package/dist/types/google/protobuf/type_pb.d.ts +6 -5
  116. package/dist/types/google/protobuf/wrappers_pb.d.ts +10 -9
  117. package/dist/types/index.d.ts +1 -0
  118. package/dist/types/proto-delimited.d.ts +54 -0
  119. package/dist/types/service-type.d.ts +0 -2
  120. package/package.json +2 -2
@@ -1,4 +1,4 @@
1
- // Copyright 2021-2022 Buf Technologies, Inc.
1
+ // Copyright 2021-2023 Buf Technologies, Inc.
2
2
  //
3
3
  // Licensed under the Apache License, Version 2.0 (the "License");
4
4
  // you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- // Copyright 2021-2022 Buf Technologies, Inc.
1
+ // Copyright 2021-2023 Buf Technologies, Inc.
2
2
  //
3
3
  // Licensed under the Apache License, Version 2.0 (the "License");
4
4
  // you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- // Copyright 2021-2022 Buf Technologies, Inc.
1
+ // Copyright 2021-2023 Buf Technologies, Inc.
2
2
  //
3
3
  // Licensed under the Apache License, Version 2.0 (the "License");
4
4
  // you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- // Copyright 2021-2022 Buf Technologies, Inc.
1
+ // Copyright 2021-2023 Buf Technologies, Inc.
2
2
  //
3
3
  // Licensed under the Apache License, Version 2.0 (the "License");
4
4
  // you may not use this file except in compliance with the License.
@@ -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 v1.0.0 with parameter "bootstrap_wkt=true,ts_nocheck=false,target=ts"
14
+ // @generated by protoc-gen-es v1.1.1 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";
@@ -119,8 +119,13 @@ export class Value extends Message {
119
119
  switch (this.kind.case) {
120
120
  case "nullValue":
121
121
  return null;
122
- case "boolValue":
123
122
  case "numberValue":
123
+ if (!Number.isFinite(this.kind.value)) {
124
+ throw new Error("google.protobuf.Value cannot be NaN or Infinity");
125
+ }
126
+ return this.kind.value;
127
+ case "boolValue":
128
+ return this.kind.value;
124
129
  case "stringValue":
125
130
  return this.kind.value;
126
131
  case "structValue":
@@ -1,4 +1,4 @@
1
- // Copyright 2021-2022 Buf Technologies, Inc.
1
+ // Copyright 2021-2023 Buf Technologies, Inc.
2
2
  //
3
3
  // Licensed under the Apache License, Version 2.0 (the "License");
4
4
  // you may not use this file except in compliance with the License.
@@ -65,7 +65,6 @@ import { proto3 } from "../../proto3.js";
65
65
  * Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000)
66
66
  * .setNanos((int) ((millis % 1000) * 1000000)).build();
67
67
  *
68
- *
69
68
  * Example 5: Compute Timestamp from Java `Instant.now()`.
70
69
  *
71
70
  * Instant now = Instant.now();
@@ -74,7 +73,6 @@ import { proto3 } from "../../proto3.js";
74
73
  * Timestamp.newBuilder().setSeconds(now.getEpochSecond())
75
74
  * .setNanos(now.getNano()).build();
76
75
  *
77
- *
78
76
  * Example 6: Compute Timestamp from current time in Python.
79
77
  *
80
78
  * timestamp = Timestamp()
@@ -108,7 +106,6 @@ import { proto3 } from "../../proto3.js";
108
106
  * ) to obtain a formatter capable of generating timestamps in this format.
109
107
  *
110
108
  *
111
- *
112
109
  * @generated from message google.protobuf.Timestamp
113
110
  */
114
111
  export class Timestamp extends Message {
@@ -1,4 +1,4 @@
1
- // Copyright 2021-2022 Buf Technologies, Inc.
1
+ // Copyright 2021-2023 Buf Technologies, Inc.
2
2
  //
3
3
  // Licensed under the Apache License, Version 2.0 (the "License");
4
4
  // you may not use this file except in compliance with the License.
@@ -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 v1.0.0 with parameter "bootstrap_wkt=true,ts_nocheck=false,target=ts"
14
+ // @generated by protoc-gen-es v1.1.1 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";
@@ -1,4 +1,4 @@
1
- // Copyright 2021-2022 Buf Technologies, Inc.
1
+ // Copyright 2021-2023 Buf Technologies, Inc.
2
2
  //
3
3
  // Licensed under the Apache License, Version 2.0 (the "License");
4
4
  // you may not use this file except in compliance with the License.
package/dist/esm/index.js CHANGED
@@ -1,4 +1,4 @@
1
- // Copyright 2021-2022 Buf Technologies, Inc.
1
+ // Copyright 2021-2023 Buf Technologies, Inc.
2
2
  //
3
3
  // Licensed under the Apache License, Version 2.0 (the "License");
4
4
  // you may not use this file except in compliance with the License.
@@ -15,6 +15,7 @@ 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 { protoDelimited } from "./proto-delimited.js";
18
19
  export { codegenInfo } from "./codegen-info.js";
19
20
  export { Message, } from "./message.js";
20
21
  export { ScalarType } from "./field.js";
@@ -1,4 +1,4 @@
1
- // Copyright 2021-2022 Buf Technologies, Inc.
1
+ // Copyright 2021-2023 Buf Technologies, Inc.
2
2
  //
3
3
  // Licensed under the Apache License, Version 2.0 (the "License");
4
4
  // you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- // Copyright 2021-2022 Buf Technologies, Inc.
1
+ // Copyright 2021-2023 Buf Technologies, Inc.
2
2
  //
3
3
  // Licensed under the Apache License, Version 2.0 (the "License");
4
4
  // you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- // Copyright 2021-2022 Buf Technologies, Inc.
1
+ // Copyright 2021-2023 Buf Technologies, Inc.
2
2
  //
3
3
  // Licensed under the Apache License, Version 2.0 (the "License");
4
4
  // you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- // Copyright 2021-2022 Buf Technologies, Inc.
1
+ // Copyright 2021-2023 Buf Technologies, Inc.
2
2
  //
3
3
  // Licensed under the Apache License, Version 2.0 (the "License");
4
4
  // you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- // Copyright 2021-2022 Buf Technologies, Inc.
1
+ // Copyright 2021-2023 Buf Technologies, Inc.
2
2
  //
3
3
  // Licensed under the Apache License, Version 2.0 (the "License");
4
4
  // you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- // Copyright 2021-2022 Buf Technologies, Inc.
1
+ // Copyright 2021-2023 Buf Technologies, Inc.
2
2
  //
3
3
  // Licensed under the Apache License, Version 2.0 (the "License");
4
4
  // you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- // Copyright 2021-2022 Buf Technologies, Inc.
1
+ // Copyright 2021-2023 Buf Technologies, Inc.
2
2
  //
3
3
  // Licensed under the Apache License, Version 2.0 (the "License");
4
4
  // you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- // Copyright 2021-2022 Buf Technologies, Inc.
1
+ // Copyright 2021-2023 Buf Technologies, Inc.
2
2
  //
3
3
  // Licensed under the Apache License, Version 2.0 (the "License");
4
4
  // you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- // Copyright 2021-2022 Buf Technologies, Inc.
1
+ // Copyright 2021-2023 Buf Technologies, Inc.
2
2
  //
3
3
  // Licensed under the Apache License, Version 2.0 (the "License");
4
4
  // you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- // Copyright 2021-2022 Buf Technologies, Inc.
1
+ // Copyright 2021-2023 Buf Technologies, Inc.
2
2
  //
3
3
  // Licensed under the Apache License, Version 2.0 (the "License");
4
4
  // you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- // Copyright 2021-2022 Buf Technologies, Inc.
1
+ // Copyright 2021-2023 Buf Technologies, Inc.
2
2
  //
3
3
  // Licensed under the Apache License, Version 2.0 (the "License");
4
4
  // you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- // Copyright 2021-2022 Buf Technologies, Inc.
1
+ // Copyright 2021-2023 Buf Technologies, Inc.
2
2
  //
3
3
  // Licensed under the Apache License, Version 2.0 (the "License");
4
4
  // you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- // Copyright 2021-2022 Buf Technologies, Inc.
1
+ // Copyright 2021-2023 Buf Technologies, Inc.
2
2
  //
3
3
  // Licensed under the Apache License, Version 2.0 (the "License");
4
4
  // you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- // Copyright 2021-2022 Buf Technologies, Inc.
1
+ // Copyright 2021-2023 Buf Technologies, Inc.
2
2
  //
3
3
  // Licensed under the Apache License, Version 2.0 (the "License");
4
4
  // you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- // Copyright 2021-2022 Buf Technologies, Inc.
1
+ // Copyright 2021-2023 Buf Technologies, Inc.
2
2
  //
3
3
  // Licensed under the Apache License, Version 2.0 (the "License");
4
4
  // you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- // Copyright 2021-2022 Buf Technologies, Inc.
1
+ // Copyright 2021-2023 Buf Technologies, Inc.
2
2
  //
3
3
  // Licensed under the Apache License, Version 2.0 (the "License");
4
4
  // you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- // Copyright 2021-2022 Buf Technologies, Inc.
1
+ // Copyright 2021-2023 Buf Technologies, Inc.
2
2
  //
3
3
  // Licensed under the Apache License, Version 2.0 (the "License");
4
4
  // you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- // Copyright 2021-2022 Buf Technologies, Inc.
1
+ // Copyright 2021-2023 Buf Technologies, Inc.
2
2
  //
3
3
  // Licensed under the Apache License, Version 2.0 (the "License");
4
4
  // you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- // Copyright 2021-2022 Buf Technologies, Inc.
1
+ // Copyright 2021-2023 Buf Technologies, Inc.
2
2
  //
3
3
  // Licensed under the Apache License, Version 2.0 (the "License");
4
4
  // you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- // Copyright 2021-2022 Buf Technologies, Inc.
1
+ // Copyright 2021-2023 Buf Technologies, Inc.
2
2
  //
3
3
  // Licensed under the Apache License, Version 2.0 (the "License");
4
4
  // you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- // Copyright 2021-2022 Buf Technologies, Inc.
1
+ // Copyright 2021-2023 Buf Technologies, Inc.
2
2
  //
3
3
  // Licensed under the Apache License, Version 2.0 (the "License");
4
4
  // you may not use this file except in compliance with the License.
@@ -122,18 +122,18 @@ export function makeUtilCommon() {
122
122
  if (va.case !== vb.case) {
123
123
  return false;
124
124
  }
125
- const k = va.case, s = m.findField(k);
125
+ const s = m.findField(va.case);
126
126
  if (s === undefined) {
127
127
  return true;
128
128
  }
129
129
  // eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check -- oneof fields are never "map"
130
130
  switch (s.kind) {
131
131
  case "message":
132
- return s.T.equals(va[k], vb[k]);
132
+ return s.T.equals(va.value, vb.value);
133
133
  case "enum":
134
- return scalarEquals(ScalarType.INT32, va, vb);
134
+ return scalarEquals(ScalarType.INT32, va.value, vb.value);
135
135
  case "scalar":
136
- return scalarEquals(s.T, va, vb);
136
+ return scalarEquals(s.T, va.value, vb.value);
137
137
  }
138
138
  throw new Error(`oneof cannot contain ${s.kind}`);
139
139
  case "map":
@@ -1,4 +1,4 @@
1
- // Copyright 2021-2022 Buf Technologies, Inc.
1
+ // Copyright 2021-2023 Buf Technologies, Inc.
2
2
  //
3
3
  // Licensed under the Apache License, Version 2.0 (the "License");
4
4
  // you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- // Copyright 2021-2022 Buf Technologies, Inc.
1
+ // Copyright 2021-2023 Buf Technologies, Inc.
2
2
  //
3
3
  // Licensed under the Apache License, Version 2.0 (the "License");
4
4
  // you may not use this file except in compliance with the License.
@@ -36,8 +36,6 @@ export const protoBase64 = {
36
36
  dec(base64Str) {
37
37
  // estimate byte size, not accounting for inner padding and whitespace
38
38
  let es = (base64Str.length * 3) / 4;
39
- // if (es % 3 !== 0)
40
- // throw new Error("invalid base64 string");
41
39
  if (base64Str[base64Str.length - 2] == "=")
42
40
  es -= 2;
43
41
  else if (base64Str[base64Str.length - 1] == "=")
@@ -0,0 +1,157 @@
1
+ // Copyright 2021-2023 Buf Technologies, Inc.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ var __asyncValues = (this && this.__asyncValues) || function (o) {
15
+ if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
16
+ var m = o[Symbol.asyncIterator], i;
17
+ return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
18
+ function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
19
+ function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
20
+ };
21
+ var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
22
+ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
23
+ if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
24
+ var g = generator.apply(thisArg, _arguments || []), i, q = [];
25
+ return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
26
+ function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
27
+ function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
28
+ function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
29
+ function fulfill(value) { resume("next", value); }
30
+ function reject(value) { resume("throw", value); }
31
+ function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
32
+ };
33
+ import { makeBinaryFormatCommon } from "./private/binary-format-common.js";
34
+ import { BinaryReader } from "./binary-encoding.js";
35
+ /**
36
+ * protoDelimited provides functions to serialize and parse size-delimited
37
+ * messages.
38
+ *
39
+ * A size-delimited message is a varint size in bytes, followed by exactly
40
+ * that many bytes of a message serialized with the binary format.
41
+ *
42
+ * This size-delimited format is compatible with other implementations.
43
+ * For details, see https://github.com/protocolbuffers/protobuf/issues/10229
44
+ */
45
+ export const protoDelimited = {
46
+ /**
47
+ * Serialize a message, prefixing it with its size.
48
+ */
49
+ enc(message, options) {
50
+ const opt = makeBinaryFormatCommon().makeWriteOptions(options);
51
+ return opt.writerFactory().bytes(message.toBinary(opt)).finish();
52
+ },
53
+ /**
54
+ * Parse a size-delimited message, ignoring extra bytes.
55
+ */
56
+ dec(type, bytes, options) {
57
+ const opt = makeBinaryFormatCommon().makeReadOptions(options);
58
+ return type.fromBinary(opt.readerFactory(bytes).bytes(), opt);
59
+ },
60
+ /**
61
+ * Parse a stream of size-delimited messages.
62
+ */
63
+ decStream(type, iterable) {
64
+ return __asyncGenerator(this, arguments, function* decStream_1() {
65
+ var _a, e_1, _b, _c;
66
+ // append chunk to buffer, returning updated buffer
67
+ function append(buffer, chunk) {
68
+ const n = new Uint8Array(buffer.byteLength + chunk.byteLength);
69
+ n.set(buffer);
70
+ n.set(chunk, buffer.length);
71
+ return n;
72
+ }
73
+ let buffer = new Uint8Array(0);
74
+ try {
75
+ for (var _d = true, iterable_1 = __asyncValues(iterable), iterable_1_1; iterable_1_1 = yield __await(iterable_1.next()), _a = iterable_1_1.done, !_a;) {
76
+ _c = iterable_1_1.value;
77
+ _d = false;
78
+ try {
79
+ const chunk = _c;
80
+ buffer = append(buffer, chunk);
81
+ for (;;) {
82
+ const size = protoDelimited.peekSize(buffer);
83
+ if (size.eof) {
84
+ // size is incomplete, buffer more data
85
+ break;
86
+ }
87
+ if (size.offset + size.size > buffer.byteLength) {
88
+ // message is incomplete, buffer more data
89
+ break;
90
+ }
91
+ yield yield __await(protoDelimited.dec(type, buffer));
92
+ buffer = buffer.subarray(size.offset + size.size);
93
+ }
94
+ }
95
+ finally {
96
+ _d = true;
97
+ }
98
+ }
99
+ }
100
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
101
+ finally {
102
+ try {
103
+ if (!_d && !_a && (_b = iterable_1.return)) yield __await(_b.call(iterable_1));
104
+ }
105
+ finally { if (e_1) throw e_1.error; }
106
+ }
107
+ if (buffer.byteLength > 0) {
108
+ throw new Error("incomplete data");
109
+ }
110
+ });
111
+ },
112
+ /**
113
+ * Decodes the size from the given size-delimited message, which may be
114
+ * incomplete.
115
+ *
116
+ * Returns an object with the following properties:
117
+ * - size: The size of the delimited message in bytes
118
+ * - offset: The offset in the given byte array where the message starts
119
+ * - eof: true
120
+ *
121
+ * If the size-delimited data does not include all bytes of the varint size,
122
+ * the following object is returned:
123
+ * - size: null
124
+ * - offset: null
125
+ * - eof: false
126
+ *
127
+ * This function can be used to implement parsing of size-delimited messages
128
+ * from a stream.
129
+ */
130
+ peekSize(data) {
131
+ const sizeEof = { eof: true, size: null, offset: null };
132
+ for (let i = 0; i < 10; i++) {
133
+ if (i > data.byteLength) {
134
+ return sizeEof;
135
+ }
136
+ if ((data[i] & 0x80) == 0) {
137
+ const reader = new BinaryReader(data);
138
+ let size;
139
+ try {
140
+ size = reader.uint32();
141
+ }
142
+ catch (e) {
143
+ if (e instanceof RangeError) {
144
+ return sizeEof;
145
+ }
146
+ throw e;
147
+ }
148
+ return {
149
+ eof: false,
150
+ size,
151
+ offset: reader.pos,
152
+ };
153
+ }
154
+ }
155
+ throw new Error("invalid varint");
156
+ },
157
+ };
@@ -1,4 +1,4 @@
1
- // Copyright 2021-2022 Buf Technologies, Inc.
1
+ // Copyright 2021-2023 Buf Technologies, Inc.
2
2
  //
3
3
  // Licensed under the Apache License, Version 2.0 (the "License");
4
4
  // you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- // Copyright 2021-2022 Buf Technologies, Inc.
1
+ // Copyright 2021-2023 Buf Technologies, Inc.
2
2
  //
3
3
  // Licensed under the Apache License, Version 2.0 (the "License");
4
4
  // you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- // Copyright 2021-2022 Buf Technologies, Inc.
1
+ // Copyright 2021-2023 Buf Technologies, Inc.
2
2
  //
3
3
  // Licensed under the Apache License, Version 2.0 (the "License");
4
4
  // you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- // Copyright 2021-2022 Buf Technologies, Inc.
1
+ // Copyright 2021-2023 Buf Technologies, Inc.
2
2
  //
3
3
  // Licensed under the Apache License, Version 2.0 (the "License");
4
4
  // you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- // Copyright 2021-2022 Buf Technologies, Inc.
1
+ // Copyright 2021-2023 Buf Technologies, Inc.
2
2
  //
3
3
  // Licensed under the Apache License, Version 2.0 (the "License");
4
4
  // you may not use this file except in compliance with the License.
@@ -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 { IMessageTypeRegistry } from "../../type-registry.js";
5
6
  import type { MessageType } from "../../message-type.js";
@@ -30,6 +31,10 @@ import type { BinaryReadOptions } from "../../binary-format.js";
30
31
  * if (any.is(Foo.class)) {
31
32
  * foo = any.unpack(Foo.class);
32
33
  * }
34
+ * // or ...
35
+ * if (any.isSameTypeAs(Foo.getDefaultInstance())) {
36
+ * foo = any.unpack(Foo.getDefaultInstance());
37
+ * }
33
38
  *
34
39
  * Example 3: Pack and unpack a message in Python.
35
40
  *
@@ -60,7 +65,6 @@ import type { BinaryReadOptions } from "../../binary-format.js";
60
65
  * in the type URL, for example "foo.bar.com/x/y.z" will yield type
61
66
  * name "y.z".
62
67
  *
63
- *
64
68
  * JSON
65
69
  *
66
70
  * The JSON representation of an `Any` value uses the regular
@@ -141,7 +145,7 @@ export declare class Any extends Message<Any> {
141
145
  is(type: MessageType | string): boolean;
142
146
  private typeNameToUrl;
143
147
  private typeUrlToName;
144
- static readonly runtime: import("../../private/proto-runtime.js").ProtoRuntime;
148
+ static readonly runtime: typeof proto3;
145
149
  static readonly typeName = "google.protobuf.Any";
146
150
  static readonly fields: FieldList;
147
151
  static pack(message: Message): Any;
@@ -2,6 +2,7 @@ import type { PartialMessage, PlainMessage } from "../../message.js";
2
2
  import { Message } from "../../message.js";
3
3
  import { Option, Syntax } from "./type_pb.js";
4
4
  import { SourceContext } from "./source_context_pb.js";
5
+ import { proto3 } from "../../proto3.js";
5
6
  import type { FieldList } from "../../field-list.js";
6
7
  import type { BinaryReadOptions } from "../../binary-format.js";
7
8
  import type { JsonReadOptions, JsonValue } from "../../json-format.js";
@@ -60,7 +61,6 @@ export declare class Api extends Message<Api> {
60
61
  * experimental, non-GA interfaces.
61
62
  *
62
63
  *
63
- *
64
64
  * @generated from field: string version = 4;
65
65
  */
66
66
  version: string;
@@ -84,7 +84,7 @@ export declare class Api extends Message<Api> {
84
84
  */
85
85
  syntax: Syntax;
86
86
  constructor(data?: PartialMessage<Api>);
87
- static readonly runtime: import("../../private/proto-runtime.js").ProtoRuntime;
87
+ static readonly runtime: typeof proto3;
88
88
  static readonly typeName = "google.protobuf.Api";
89
89
  static readonly fields: FieldList;
90
90
  static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): Api;
@@ -141,7 +141,7 @@ export declare class Method extends Message<Method> {
141
141
  */
142
142
  syntax: Syntax;
143
143
  constructor(data?: PartialMessage<Method>);
144
- static readonly runtime: import("../../private/proto-runtime.js").ProtoRuntime;
144
+ static readonly runtime: typeof proto3;
145
145
  static readonly typeName = "google.protobuf.Method";
146
146
  static readonly fields: FieldList;
147
147
  static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): Method;
@@ -246,7 +246,7 @@ export declare class Mixin extends Message<Mixin> {
246
246
  */
247
247
  root: string;
248
248
  constructor(data?: PartialMessage<Mixin>);
249
- static readonly runtime: import("../../private/proto-runtime.js").ProtoRuntime;
249
+ static readonly runtime: typeof proto3;
250
250
  static readonly typeName = "google.protobuf.Mixin";
251
251
  static readonly fields: FieldList;
252
252
  static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): Mixin;
@@ -1,5 +1,6 @@
1
1
  import type { PartialMessage, PlainMessage } from "../../../message.js";
2
2
  import { Message } from "../../../message.js";
3
+ import { proto2 } from "../../../proto2.js";
3
4
  import type { FieldList } from "../../../field-list.js";
4
5
  import type { BinaryReadOptions } from "../../../binary-format.js";
5
6
  import type { JsonReadOptions, JsonValue } from "../../../json-format.js";
@@ -30,7 +31,7 @@ export declare class Version extends Message<Version> {
30
31
  */
31
32
  suffix?: string;
32
33
  constructor(data?: PartialMessage<Version>);
33
- static readonly runtime: import("../../../private/proto-runtime.js").ProtoRuntime;
34
+ static readonly runtime: typeof proto2;
34
35
  static readonly typeName = "google.protobuf.compiler.Version";
35
36
  static readonly fields: FieldList;
36
37
  static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): Version;
@@ -84,7 +85,7 @@ export declare class CodeGeneratorRequest extends Message<CodeGeneratorRequest>
84
85
  */
85
86
  compilerVersion?: Version;
86
87
  constructor(data?: PartialMessage<CodeGeneratorRequest>);
87
- static readonly runtime: import("../../../private/proto-runtime.js").ProtoRuntime;
88
+ static readonly runtime: typeof proto2;
88
89
  static readonly typeName = "google.protobuf.compiler.CodeGeneratorRequest";
89
90
  static readonly fields: FieldList;
90
91
  static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): CodeGeneratorRequest;
@@ -123,7 +124,7 @@ export declare class CodeGeneratorResponse extends Message<CodeGeneratorResponse
123
124
  */
124
125
  file: CodeGeneratorResponse_File[];
125
126
  constructor(data?: PartialMessage<CodeGeneratorResponse>);
126
- static readonly runtime: import("../../../private/proto-runtime.js").ProtoRuntime;
127
+ static readonly runtime: typeof proto2;
127
128
  static readonly typeName = "google.protobuf.compiler.CodeGeneratorResponse";
128
129
  static readonly fields: FieldList;
129
130
  static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): CodeGeneratorResponse;
@@ -225,7 +226,7 @@ export declare class CodeGeneratorResponse_File extends Message<CodeGeneratorRes
225
226
  */
226
227
  generatedCodeInfo?: GeneratedCodeInfo;
227
228
  constructor(data?: PartialMessage<CodeGeneratorResponse_File>);
228
- static readonly runtime: import("../../../private/proto-runtime.js").ProtoRuntime;
229
+ static readonly runtime: typeof proto2;
229
230
  static readonly typeName = "google.protobuf.compiler.CodeGeneratorResponse.File";
230
231
  static readonly fields: FieldList;
231
232
  static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): CodeGeneratorResponse_File;