@bufbuild/protobuf 0.0.1-alpha.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 (146) hide show
  1. package/README.md +6 -0
  2. package/dist/cjs/binary-encoding.js +434 -0
  3. package/dist/cjs/binary-format.js +2 -0
  4. package/dist/cjs/descriptor-registry.js +518 -0
  5. package/dist/cjs/descriptor-set.js +557 -0
  6. package/dist/cjs/enum.js +2 -0
  7. package/dist/cjs/field-list.js +2 -0
  8. package/dist/cjs/field.js +40 -0
  9. package/dist/cjs/google/protobuf/any_pb.js +280 -0
  10. package/dist/cjs/google/protobuf/api_pb.js +383 -0
  11. package/dist/cjs/google/protobuf/compiler/plugin_pb.js +334 -0
  12. package/dist/cjs/google/protobuf/descriptor_pb.js +2311 -0
  13. package/dist/cjs/google/protobuf/duration_pb.js +201 -0
  14. package/dist/cjs/google/protobuf/empty_pb.js +72 -0
  15. package/dist/cjs/google/protobuf/field_mask_pb.js +347 -0
  16. package/dist/cjs/google/protobuf/source_context_pb.js +74 -0
  17. package/dist/cjs/google/protobuf/struct_pb.js +288 -0
  18. package/dist/cjs/google/protobuf/timestamp_pb.js +271 -0
  19. package/dist/cjs/google/protobuf/type_pb.js +613 -0
  20. package/dist/cjs/google/protobuf/wrappers_pb.js +658 -0
  21. package/dist/cjs/google/varint.js +280 -0
  22. package/dist/cjs/index.js +148 -0
  23. package/dist/cjs/json-format.js +2 -0
  24. package/dist/cjs/message-type.js +2 -0
  25. package/dist/cjs/message.js +98 -0
  26. package/dist/cjs/private/assert.js +52 -0
  27. package/dist/cjs/private/base64.js +118 -0
  28. package/dist/cjs/private/binary-format-common.js +253 -0
  29. package/dist/cjs/private/binary-format-proto2.js +120 -0
  30. package/dist/cjs/private/binary-format-proto3.js +102 -0
  31. package/dist/cjs/private/enum.js +70 -0
  32. package/dist/cjs/private/field-list.js +62 -0
  33. package/dist/cjs/private/field-wrapper.js +25 -0
  34. package/dist/cjs/private/field.js +34 -0
  35. package/dist/cjs/private/json-format-common.js +482 -0
  36. package/dist/cjs/private/json-format-proto2.js +100 -0
  37. package/dist/cjs/private/json-format-proto3.js +103 -0
  38. package/dist/cjs/private/message-type.js +37 -0
  39. package/dist/cjs/private/names.js +101 -0
  40. package/dist/cjs/private/options-map.js +2 -0
  41. package/dist/cjs/private/proto-runtime.js +24 -0
  42. package/dist/cjs/private/scalars.js +138 -0
  43. package/dist/cjs/private/util-common.js +229 -0
  44. package/dist/cjs/private/util.js +2 -0
  45. package/dist/cjs/proto-int64.js +121 -0
  46. package/dist/cjs/proto2.js +86 -0
  47. package/dist/cjs/proto3.js +99 -0
  48. package/dist/cjs/service-type.js +43 -0
  49. package/dist/cjs/type-registry.js +42 -0
  50. package/dist/esm/binary-encoding.js +434 -0
  51. package/dist/esm/binary-format.js +1 -0
  52. package/dist/esm/descriptor-registry.js +521 -0
  53. package/dist/esm/descriptor-set.js +517 -0
  54. package/dist/esm/enum.js +1 -0
  55. package/dist/esm/field-list.js +1 -0
  56. package/dist/esm/field.js +37 -0
  57. package/dist/esm/google/protobuf/any_pb.js +276 -0
  58. package/dist/esm/google/protobuf/api_pb.js +350 -0
  59. package/dist/esm/google/protobuf/compiler/plugin_pb.js +318 -0
  60. package/dist/esm/google/protobuf/descriptor_pb.js +2213 -0
  61. package/dist/esm/google/protobuf/duration_pb.js +197 -0
  62. package/dist/esm/google/protobuf/empty_pb.js +68 -0
  63. package/dist/esm/google/protobuf/field_mask_pb.js +343 -0
  64. package/dist/esm/google/protobuf/source_context_pb.js +70 -0
  65. package/dist/esm/google/protobuf/struct_pb.js +282 -0
  66. package/dist/esm/google/protobuf/timestamp_pb.js +267 -0
  67. package/dist/esm/google/protobuf/type_pb.js +569 -0
  68. package/dist/esm/google/protobuf/wrappers_pb.js +574 -0
  69. package/dist/esm/google/varint.js +265 -0
  70. package/dist/esm/index.js +24 -0
  71. package/dist/esm/json-format.js +1 -0
  72. package/dist/esm/message-type.js +1 -0
  73. package/dist/esm/message.js +94 -0
  74. package/dist/esm/private/assert.js +41 -0
  75. package/dist/esm/private/base64.js +113 -0
  76. package/dist/esm/private/binary-format-common.js +243 -0
  77. package/dist/esm/private/binary-format-proto2.js +87 -0
  78. package/dist/esm/private/binary-format-proto3.js +74 -0
  79. package/dist/esm/private/enum.js +64 -0
  80. package/dist/esm/private/field-list.js +58 -0
  81. package/dist/esm/private/field-wrapper.js +20 -0
  82. package/dist/esm/private/field.js +27 -0
  83. package/dist/esm/private/json-format-common.js +473 -0
  84. package/dist/esm/private/json-format-proto2.js +90 -0
  85. package/dist/esm/private/json-format-proto3.js +89 -0
  86. package/dist/esm/private/message-type.js +33 -0
  87. package/dist/esm/private/names.js +90 -0
  88. package/dist/esm/private/options-map.js +1 -0
  89. package/dist/esm/private/proto-runtime.js +15 -0
  90. package/dist/esm/private/scalars.js +129 -0
  91. package/dist/esm/private/util-common.js +207 -0
  92. package/dist/esm/private/util.js +1 -0
  93. package/dist/esm/proto-int64.js +118 -0
  94. package/dist/esm/proto2.js +77 -0
  95. package/dist/esm/proto3.js +90 -0
  96. package/dist/esm/service-type.js +37 -0
  97. package/dist/esm/type-registry.js +38 -0
  98. package/dist/types/binary-encoding.d.ts +421 -0
  99. package/dist/types/binary-format.d.ts +109 -0
  100. package/dist/types/descriptor-registry.d.ts +42 -0
  101. package/dist/types/descriptor-set.d.ts +171 -0
  102. package/dist/types/enum.d.ts +31 -0
  103. package/dist/types/field-list.d.ts +27 -0
  104. package/dist/types/field.d.ts +295 -0
  105. package/dist/types/google/protobuf/any_pb.d.ts +167 -0
  106. package/dist/types/google/protobuf/api_pb.d.ts +296 -0
  107. package/dist/types/google/protobuf/compiler/plugin_pb.d.ts +294 -0
  108. package/dist/types/google/protobuf/descriptor_pb.d.ts +1959 -0
  109. package/dist/types/google/protobuf/duration_pb.d.ts +117 -0
  110. package/dist/types/google/protobuf/empty_pb.d.ts +44 -0
  111. package/dist/types/google/protobuf/field_mask_pb.d.ts +243 -0
  112. package/dist/types/google/protobuf/source_context_pb.d.ts +44 -0
  113. package/dist/types/google/protobuf/struct_pb.d.ts +205 -0
  114. package/dist/types/google/protobuf/timestamp_pb.d.ts +151 -0
  115. package/dist/types/google/protobuf/type_pb.d.ts +482 -0
  116. package/dist/types/google/protobuf/wrappers_pb.d.ts +379 -0
  117. package/dist/types/google/varint.d.ts +65 -0
  118. package/dist/types/index.d.ts +53 -0
  119. package/dist/types/json-format.d.ts +129 -0
  120. package/dist/types/message-type.d.ts +58 -0
  121. package/dist/types/message.d.ts +124 -0
  122. package/dist/types/private/assert.d.ts +19 -0
  123. package/dist/types/private/base64.d.ts +18 -0
  124. package/dist/types/private/binary-format-common.d.ts +38 -0
  125. package/dist/types/private/binary-format-proto2.d.ts +2 -0
  126. package/dist/types/private/binary-format-proto3.d.ts +2 -0
  127. package/dist/types/private/enum.d.ts +29 -0
  128. package/dist/types/private/field-list.d.ts +25 -0
  129. package/dist/types/private/field-wrapper.d.ts +27 -0
  130. package/dist/types/private/field.d.ts +15 -0
  131. package/dist/types/private/json-format-common.d.ts +30 -0
  132. package/dist/types/private/json-format-proto2.d.ts +2 -0
  133. package/dist/types/private/json-format-proto3.d.ts +2 -0
  134. package/dist/types/private/message-type.d.ts +15 -0
  135. package/dist/types/private/names.d.ts +19 -0
  136. package/dist/types/private/options-map.d.ts +7 -0
  137. package/dist/types/private/proto-runtime.d.ts +55 -0
  138. package/dist/types/private/scalars.d.ts +33 -0
  139. package/dist/types/private/util-common.d.ts +5 -0
  140. package/dist/types/private/util.d.ts +55 -0
  141. package/dist/types/proto-int64.d.ts +94 -0
  142. package/dist/types/proto2.d.ts +4 -0
  143. package/dist/types/proto3.d.ts +4 -0
  144. package/dist/types/service-type.d.ts +118 -0
  145. package/dist/types/type-registry.d.ts +37 -0
  146. package/package.json +31 -0
@@ -0,0 +1,280 @@
1
+ "use strict";
2
+ // Copyright 2008 Google Inc. All rights reserved.
3
+ //
4
+ // Redistribution and use in source and binary forms, with or without
5
+ // modification, are permitted provided that the following conditions are
6
+ // met:
7
+ //
8
+ // * Redistributions of source code must retain the above copyright
9
+ // notice, this list of conditions and the following disclaimer.
10
+ // * Redistributions in binary form must reproduce the above
11
+ // copyright notice, this list of conditions and the following disclaimer
12
+ // in the documentation and/or other materials provided with the
13
+ // distribution.
14
+ // * Neither the name of Google Inc. nor the names of its
15
+ // contributors may be used to endorse or promote products derived from
16
+ // this software without specific prior written permission.
17
+ //
18
+ // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19
+ // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20
+ // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21
+ // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22
+ // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23
+ // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24
+ // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25
+ // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26
+ // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27
+ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
+ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
+ //
30
+ // Code generated by the Protocol Buffer compiler is owned by the owner
31
+ // of the input file used when generating it. This code is not
32
+ // standalone and requires a support library to be linked with it. This
33
+ // support library is itself covered by the above license.
34
+ Object.defineProperty(exports, "__esModule", { value: true });
35
+ exports.varint32read =
36
+ exports.varint32write =
37
+ exports.int64toString =
38
+ exports.int64fromString =
39
+ exports.varint64write =
40
+ exports.varint64read =
41
+ void 0;
42
+ /* eslint-disable prefer-const,@typescript-eslint/restrict-plus-operands */
43
+ /**
44
+ * Read a 64 bit varint as two JS numbers.
45
+ *
46
+ * Returns tuple:
47
+ * [0]: low bits
48
+ * [1]: high bits
49
+ *
50
+ * Copyright 2008 Google Inc. All rights reserved.
51
+ *
52
+ * See https://github.com/protocolbuffers/protobuf/blob/8a71927d74a4ce34efe2d8769fda198f52d20d12/js/experimental/runtime/kernel/buffer_decoder.js#L175
53
+ */
54
+ function varint64read() {
55
+ let lowBits = 0;
56
+ let highBits = 0;
57
+ for (let shift = 0; shift < 28; shift += 7) {
58
+ let b = this.buf[this.pos++];
59
+ lowBits |= (b & 0x7f) << shift;
60
+ if ((b & 0x80) == 0) {
61
+ this.assertBounds();
62
+ return [lowBits, highBits];
63
+ }
64
+ }
65
+ let middleByte = this.buf[this.pos++];
66
+ // last four bits of the first 32 bit number
67
+ lowBits |= (middleByte & 0x0f) << 28;
68
+ // 3 upper bits are part of the next 32 bit number
69
+ highBits = (middleByte & 0x70) >> 4;
70
+ if ((middleByte & 0x80) == 0) {
71
+ this.assertBounds();
72
+ return [lowBits, highBits];
73
+ }
74
+ for (let shift = 3; shift <= 31; shift += 7) {
75
+ let b = this.buf[this.pos++];
76
+ highBits |= (b & 0x7f) << shift;
77
+ if ((b & 0x80) == 0) {
78
+ this.assertBounds();
79
+ return [lowBits, highBits];
80
+ }
81
+ }
82
+ throw new Error("invalid varint");
83
+ }
84
+ exports.varint64read = varint64read;
85
+ /**
86
+ * Write a 64 bit varint, given as two JS numbers, to the given bytes array.
87
+ *
88
+ * Copyright 2008 Google Inc. All rights reserved.
89
+ *
90
+ * See https://github.com/protocolbuffers/protobuf/blob/8a71927d74a4ce34efe2d8769fda198f52d20d12/js/experimental/runtime/kernel/writer.js#L344
91
+ */
92
+ function varint64write(lo, hi, bytes) {
93
+ for (let i = 0; i < 28; i = i + 7) {
94
+ const shift = lo >>> i;
95
+ const hasNext = !(shift >>> 7 == 0 && hi == 0);
96
+ const byte = (hasNext ? shift | 0x80 : shift) & 0xff;
97
+ bytes.push(byte);
98
+ if (!hasNext) {
99
+ return;
100
+ }
101
+ }
102
+ const splitBits = ((lo >>> 28) & 0x0f) | ((hi & 0x07) << 4);
103
+ const hasMoreBits = !(hi >> 3 == 0);
104
+ bytes.push((hasMoreBits ? splitBits | 0x80 : splitBits) & 0xff);
105
+ if (!hasMoreBits) {
106
+ return;
107
+ }
108
+ for (let i = 3; i < 31; i = i + 7) {
109
+ const shift = hi >>> i;
110
+ const hasNext = !(shift >>> 7 == 0);
111
+ const byte = (hasNext ? shift | 0x80 : shift) & 0xff;
112
+ bytes.push(byte);
113
+ if (!hasNext) {
114
+ return;
115
+ }
116
+ }
117
+ bytes.push((hi >>> 31) & 0x01);
118
+ }
119
+ exports.varint64write = varint64write;
120
+ // constants for binary math
121
+ const TWO_PWR_32_DBL = (1 << 16) * (1 << 16);
122
+ /**
123
+ * Parse decimal string of 64 bit integer value as two JS numbers.
124
+ *
125
+ * Returns tuple:
126
+ * [0]: minus sign?
127
+ * [1]: low bits
128
+ * [2]: high bits
129
+ *
130
+ * Copyright 2008 Google Inc.
131
+ */
132
+ function int64fromString(dec) {
133
+ // Check for minus sign.
134
+ let minus = dec[0] == "-";
135
+ if (minus) dec = dec.slice(1);
136
+ // Work 6 decimal digits at a time, acting like we're converting base 1e6
137
+ // digits to binary. This is safe to do with floating point math because
138
+ // Number.isSafeInteger(ALL_32_BITS * 1e6) == true.
139
+ const base = 1e6;
140
+ let lowBits = 0;
141
+ let highBits = 0;
142
+ function add1e6digit(begin, end) {
143
+ // Note: Number('') is 0.
144
+ const digit1e6 = Number(dec.slice(begin, end));
145
+ highBits *= base;
146
+ lowBits = lowBits * base + digit1e6;
147
+ // Carry bits from lowBits to
148
+ if (lowBits >= TWO_PWR_32_DBL) {
149
+ highBits = highBits + ((lowBits / TWO_PWR_32_DBL) | 0);
150
+ lowBits = lowBits % TWO_PWR_32_DBL;
151
+ }
152
+ }
153
+ add1e6digit(-24, -18);
154
+ add1e6digit(-18, -12);
155
+ add1e6digit(-12, -6);
156
+ add1e6digit(-6);
157
+ return [minus, lowBits, highBits];
158
+ }
159
+ exports.int64fromString = int64fromString;
160
+ /**
161
+ * Format 64 bit integer value (as two JS numbers) to decimal string.
162
+ *
163
+ * Copyright 2008 Google Inc.
164
+ */
165
+ function int64toString(bitsLow, bitsHigh) {
166
+ // Skip the expensive conversion if the number is small enough to use the
167
+ // built-in conversions.
168
+ if (bitsHigh <= 0x1fffff) {
169
+ return "" + (TWO_PWR_32_DBL * bitsHigh + bitsLow);
170
+ }
171
+ // What this code is doing is essentially converting the input number from
172
+ // base-2 to base-1e7, which allows us to represent the 64-bit range with
173
+ // only 3 (very large) digits. Those digits are then trivial to convert to
174
+ // a base-10 string.
175
+ // The magic numbers used here are -
176
+ // 2^24 = 16777216 = (1,6777216) in base-1e7.
177
+ // 2^48 = 281474976710656 = (2,8147497,6710656) in base-1e7.
178
+ // Split 32:32 representation into 16:24:24 representation so our
179
+ // intermediate digits don't overflow.
180
+ let low = bitsLow & 0xffffff;
181
+ let mid = (((bitsLow >>> 24) | (bitsHigh << 8)) >>> 0) & 0xffffff;
182
+ let high = (bitsHigh >> 16) & 0xffff;
183
+ // Assemble our three base-1e7 digits, ignoring carries. The maximum
184
+ // value in a digit at this step is representable as a 48-bit integer, which
185
+ // can be stored in a 64-bit floating point number.
186
+ let digitA = low + mid * 6777216 + high * 6710656;
187
+ let digitB = mid + high * 8147497;
188
+ let digitC = high * 2;
189
+ // Apply carries from A to B and from B to C.
190
+ let base = 10000000;
191
+ if (digitA >= base) {
192
+ digitB += Math.floor(digitA / base);
193
+ digitA %= base;
194
+ }
195
+ if (digitB >= base) {
196
+ digitC += Math.floor(digitB / base);
197
+ digitB %= base;
198
+ }
199
+ // Convert base-1e7 digits to base-10, with optional leading zeroes.
200
+ function decimalFrom1e7(digit1e7, needLeadingZeros) {
201
+ let partial = digit1e7 ? String(digit1e7) : "";
202
+ if (needLeadingZeros) {
203
+ return "0000000".slice(partial.length) + partial;
204
+ }
205
+ return partial;
206
+ }
207
+ return (
208
+ decimalFrom1e7(digitC, /*needLeadingZeros=*/ 0) +
209
+ decimalFrom1e7(digitB, /*needLeadingZeros=*/ digitC) +
210
+ // If the final 1e7 digit didn't need leading zeros, we would have
211
+ // returned via the trivial code path at the top.
212
+ decimalFrom1e7(digitA, /*needLeadingZeros=*/ 1)
213
+ );
214
+ }
215
+ exports.int64toString = int64toString;
216
+ /**
217
+ * Write a 32 bit varint, signed or unsigned. Same as `varint64write(0, value, bytes)`
218
+ *
219
+ * Copyright 2008 Google Inc. All rights reserved.
220
+ *
221
+ * See https://github.com/protocolbuffers/protobuf/blob/1b18833f4f2a2f681f4e4a25cdf3b0a43115ec26/js/binary/encoder.js#L144
222
+ */
223
+ function varint32write(value, bytes) {
224
+ if (value >= 0) {
225
+ // write value as varint 32
226
+ while (value > 0x7f) {
227
+ bytes.push((value & 0x7f) | 0x80);
228
+ value = value >>> 7;
229
+ }
230
+ bytes.push(value);
231
+ } else {
232
+ for (let i = 0; i < 9; i++) {
233
+ bytes.push((value & 127) | 128);
234
+ value = value >> 7;
235
+ }
236
+ bytes.push(1);
237
+ }
238
+ }
239
+ exports.varint32write = varint32write;
240
+ /**
241
+ * Read an unsigned 32 bit varint.
242
+ *
243
+ * See https://github.com/protocolbuffers/protobuf/blob/8a71927d74a4ce34efe2d8769fda198f52d20d12/js/experimental/runtime/kernel/buffer_decoder.js#L220
244
+ */
245
+ function varint32read() {
246
+ let b = this.buf[this.pos++];
247
+ let result = b & 0x7f;
248
+ if ((b & 0x80) == 0) {
249
+ this.assertBounds();
250
+ return result;
251
+ }
252
+ b = this.buf[this.pos++];
253
+ result |= (b & 0x7f) << 7;
254
+ if ((b & 0x80) == 0) {
255
+ this.assertBounds();
256
+ return result;
257
+ }
258
+ b = this.buf[this.pos++];
259
+ result |= (b & 0x7f) << 14;
260
+ if ((b & 0x80) == 0) {
261
+ this.assertBounds();
262
+ return result;
263
+ }
264
+ b = this.buf[this.pos++];
265
+ result |= (b & 0x7f) << 21;
266
+ if ((b & 0x80) == 0) {
267
+ this.assertBounds();
268
+ return result;
269
+ }
270
+ // Extract only last 4 bits
271
+ b = this.buf[this.pos++];
272
+ result |= (b & 0x0f) << 28;
273
+ for (let readBytes = 5; (b & 0x80) !== 0 && readBytes < 10; readBytes++)
274
+ b = this.buf[this.pos++];
275
+ if ((b & 0x80) != 0) throw new Error("invalid varint");
276
+ this.assertBounds();
277
+ // Result can have 32 bits, convert it to unsigned
278
+ return result >>> 0;
279
+ }
280
+ exports.varint32read = varint32read;
@@ -0,0 +1,148 @@
1
+ "use strict";
2
+ var __createBinding =
3
+ (this && this.__createBinding) ||
4
+ (Object.create
5
+ ? function (o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ var desc = Object.getOwnPropertyDescriptor(m, k);
8
+ if (
9
+ !desc ||
10
+ ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)
11
+ ) {
12
+ desc = {
13
+ enumerable: true,
14
+ get: function () {
15
+ return m[k];
16
+ },
17
+ };
18
+ }
19
+ Object.defineProperty(o, k2, desc);
20
+ }
21
+ : function (o, m, k, k2) {
22
+ if (k2 === undefined) k2 = k;
23
+ o[k2] = m[k];
24
+ });
25
+ var __exportStar =
26
+ (this && this.__exportStar) ||
27
+ function (m, exports) {
28
+ for (var p in m)
29
+ if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p))
30
+ __createBinding(exports, m, p);
31
+ };
32
+ Object.defineProperty(exports, "__esModule", { value: true });
33
+ exports.BinaryReader =
34
+ exports.BinaryWriter =
35
+ exports.WireType =
36
+ exports.DescriptorSet =
37
+ exports.DescriptorRegistry =
38
+ exports.TypeRegistry =
39
+ exports.MethodIdempotency =
40
+ exports.MethodKind =
41
+ exports.ScalarType =
42
+ exports.Message =
43
+ exports.protoInt64 =
44
+ exports.proto2 =
45
+ exports.proto3 =
46
+ void 0;
47
+ var proto3_js_1 = require("./proto3.js");
48
+ Object.defineProperty(exports, "proto3", {
49
+ enumerable: true,
50
+ get: function () {
51
+ return proto3_js_1.proto3;
52
+ },
53
+ });
54
+ var proto2_js_1 = require("./proto2.js");
55
+ Object.defineProperty(exports, "proto2", {
56
+ enumerable: true,
57
+ get: function () {
58
+ return proto2_js_1.proto2;
59
+ },
60
+ });
61
+ var proto_int64_js_1 = require("./proto-int64.js");
62
+ Object.defineProperty(exports, "protoInt64", {
63
+ enumerable: true,
64
+ get: function () {
65
+ return proto_int64_js_1.protoInt64;
66
+ },
67
+ });
68
+ var message_js_1 = require("./message.js");
69
+ Object.defineProperty(exports, "Message", {
70
+ enumerable: true,
71
+ get: function () {
72
+ return message_js_1.Message;
73
+ },
74
+ });
75
+ var field_js_1 = require("./field.js");
76
+ Object.defineProperty(exports, "ScalarType", {
77
+ enumerable: true,
78
+ get: function () {
79
+ return field_js_1.ScalarType;
80
+ },
81
+ });
82
+ var service_type_js_1 = require("./service-type.js");
83
+ Object.defineProperty(exports, "MethodKind", {
84
+ enumerable: true,
85
+ get: function () {
86
+ return service_type_js_1.MethodKind;
87
+ },
88
+ });
89
+ Object.defineProperty(exports, "MethodIdempotency", {
90
+ enumerable: true,
91
+ get: function () {
92
+ return service_type_js_1.MethodIdempotency;
93
+ },
94
+ });
95
+ var type_registry_js_1 = require("./type-registry.js");
96
+ Object.defineProperty(exports, "TypeRegistry", {
97
+ enumerable: true,
98
+ get: function () {
99
+ return type_registry_js_1.TypeRegistry;
100
+ },
101
+ });
102
+ var descriptor_registry_js_1 = require("./descriptor-registry.js");
103
+ Object.defineProperty(exports, "DescriptorRegistry", {
104
+ enumerable: true,
105
+ get: function () {
106
+ return descriptor_registry_js_1.DescriptorRegistry;
107
+ },
108
+ });
109
+ var descriptor_set_js_1 = require("./descriptor-set.js");
110
+ Object.defineProperty(exports, "DescriptorSet", {
111
+ enumerable: true,
112
+ get: function () {
113
+ return descriptor_set_js_1.DescriptorSet;
114
+ },
115
+ });
116
+ var binary_encoding_js_1 = require("./binary-encoding.js");
117
+ Object.defineProperty(exports, "WireType", {
118
+ enumerable: true,
119
+ get: function () {
120
+ return binary_encoding_js_1.WireType;
121
+ },
122
+ });
123
+ Object.defineProperty(exports, "BinaryWriter", {
124
+ enumerable: true,
125
+ get: function () {
126
+ return binary_encoding_js_1.BinaryWriter;
127
+ },
128
+ });
129
+ Object.defineProperty(exports, "BinaryReader", {
130
+ enumerable: true,
131
+ get: function () {
132
+ return binary_encoding_js_1.BinaryReader;
133
+ },
134
+ });
135
+ var json_format_js_1 = require("./json-format.js");
136
+ // ideally, we would export these types with sub-path exports:
137
+ __exportStar(require("./google/protobuf/compiler/plugin_pb.js"), exports);
138
+ __exportStar(require("./google/protobuf/api_pb.js"), exports);
139
+ __exportStar(require("./google/protobuf/any_pb.js"), exports);
140
+ __exportStar(require("./google/protobuf/descriptor_pb.js"), exports);
141
+ __exportStar(require("./google/protobuf/duration_pb.js"), exports);
142
+ __exportStar(require("./google/protobuf/empty_pb.js"), exports);
143
+ __exportStar(require("./google/protobuf/field_mask_pb.js"), exports);
144
+ __exportStar(require("./google/protobuf/source_context_pb.js"), exports);
145
+ __exportStar(require("./google/protobuf/struct_pb.js"), exports);
146
+ __exportStar(require("./google/protobuf/timestamp_pb.js"), exports);
147
+ __exportStar(require("./google/protobuf/type_pb.js"), exports);
148
+ __exportStar(require("./google/protobuf/wrappers_pb.js"), exports);
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,98 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Message = void 0;
4
+ /**
5
+ * Message is the base class of every message, generated, or created at
6
+ * runtime.
7
+ *
8
+ * It is _not_ safe to extend this class. If you want to create a message at
9
+ * run time, use proto3.makeMessageType().
10
+ */
11
+ class Message {
12
+ /**
13
+ * Compare with a message of the same type.
14
+ */
15
+ equals(other) {
16
+ return this.getType().runtime.util.equals(this.getType(), this, other);
17
+ }
18
+ /**
19
+ * Create a deep copy.
20
+ */
21
+ clone() {
22
+ // return this.getType().runtime.util.clone(this);
23
+ return this.getType().runtime.util.clone(this);
24
+ }
25
+ /**
26
+ * Parse from binary data, merging fields.
27
+ *
28
+ * Repeated fields are appended. Map entries are added, overwriting
29
+ * existing keys.
30
+ *
31
+ * If a message field is already present, it will be merged with the
32
+ * new data.
33
+ */
34
+ fromBinary(bytes, options) {
35
+ const type = this.getType(),
36
+ format = type.runtime.bin,
37
+ opt = format.makeReadOptions(options);
38
+ format.readMessage(this, opt.readerFactory(bytes), bytes.byteLength, opt);
39
+ return this;
40
+ }
41
+ /**
42
+ * Parse a message from a JSON value.
43
+ */
44
+ fromJson(jsonValue, options) {
45
+ const type = this.getType(),
46
+ format = type.runtime.json,
47
+ opt = format.makeReadOptions(options);
48
+ format.readMessage(type, jsonValue, opt, this);
49
+ return this;
50
+ }
51
+ /**
52
+ * Parse a message from a JSON string.
53
+ */
54
+ fromJsonString(jsonString, options) {
55
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument -- assigning to JsonValue is safe here
56
+ return this.fromJson(JSON.parse(jsonString), options);
57
+ }
58
+ /**
59
+ * Serialize the message to binary data.
60
+ */
61
+ toBinary(options) {
62
+ const type = this.getType(),
63
+ bin = type.runtime.bin,
64
+ opt = bin.makeWriteOptions(options),
65
+ writer = opt.writerFactory();
66
+ bin.writeMessage(this, writer, opt);
67
+ return writer.finish();
68
+ }
69
+ /**
70
+ * Serialize the message to a JSON value, a JavaScript value that can be
71
+ * passed to JSON.stringify().
72
+ */
73
+ toJson(options) {
74
+ const type = this.getType(),
75
+ json = type.runtime.json,
76
+ opt = json.makeWriteOptions(options);
77
+ return json.writeMessage(this, opt);
78
+ }
79
+ /**
80
+ * Serialize the message to a JSON string.
81
+ */
82
+ toJsonString(options) {
83
+ const value = this.toJson(options);
84
+ return JSON.stringify(value, null, options?.prettySpaces ?? 0);
85
+ }
86
+ /**
87
+ * Retrieve the MessageType of this message - a singleton that represents
88
+ * the protobuf message declaration and provides metadata for reflection-
89
+ * based operations.
90
+ */
91
+ getType() {
92
+ // Any class that extends Message _must_ provide a complete static
93
+ // implementation of MessageType.
94
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-return
95
+ return Object.getPrototypeOf(this).constructor;
96
+ }
97
+ }
98
+ exports.Message = Message;
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.assertFloat32 =
4
+ exports.assertUInt32 =
5
+ exports.assertInt32 =
6
+ exports.assert =
7
+ void 0;
8
+ /**
9
+ * Assert that condition is truthy or throw error (with message)
10
+ */
11
+ function assert(condition, msg) {
12
+ // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions -- we want the implicit conversion to boolean
13
+ if (!condition) {
14
+ throw new Error(msg);
15
+ }
16
+ }
17
+ exports.assert = assert;
18
+ const FLOAT32_MAX = 3.4028234663852886e38,
19
+ FLOAT32_MIN = -3.4028234663852886e38,
20
+ UINT32_MAX = 0xffffffff,
21
+ INT32_MAX = 0x7fffffff,
22
+ INT32_MIN = -0x80000000;
23
+ /**
24
+ * Assert a valid signed protobuf 32-bit integer.
25
+ */
26
+ function assertInt32(arg) {
27
+ if (typeof arg !== "number") throw new Error("invalid int 32: " + typeof arg);
28
+ if (!Number.isInteger(arg) || arg > INT32_MAX || arg < INT32_MIN)
29
+ throw new Error("invalid int 32: " + arg); // eslint-disable-line @typescript-eslint/restrict-plus-operands -- we want the implicit conversion to string
30
+ }
31
+ exports.assertInt32 = assertInt32;
32
+ /**
33
+ * Assert a valid unsigned protobuf 32-bit integer.
34
+ */
35
+ function assertUInt32(arg) {
36
+ if (typeof arg !== "number")
37
+ throw new Error("invalid uint 32: " + typeof arg);
38
+ if (!Number.isInteger(arg) || arg > UINT32_MAX || arg < 0)
39
+ throw new Error("invalid uint 32: " + arg); // eslint-disable-line @typescript-eslint/restrict-plus-operands -- we want the implicit conversion to string
40
+ }
41
+ exports.assertUInt32 = assertUInt32;
42
+ /**
43
+ * Assert a valid protobuf float value.
44
+ */
45
+ function assertFloat32(arg) {
46
+ if (typeof arg !== "number")
47
+ throw new Error("invalid float 32: " + typeof arg);
48
+ if (!Number.isFinite(arg)) return;
49
+ if (arg > FLOAT32_MAX || arg < FLOAT32_MIN)
50
+ throw new Error("invalid float 32: " + arg); // eslint-disable-line @typescript-eslint/restrict-plus-operands -- we want the implicit conversion to string
51
+ }
52
+ exports.assertFloat32 = assertFloat32;