@bufbuild/protobuf 0.0.1-alpha.1 → 0.0.2-alpha.2
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.
- package/dist/cjs/binary-encoding.js +414 -409
- package/dist/cjs/binary-format.js +13 -0
- package/dist/cjs/descriptor-registry.js +420 -449
- package/dist/cjs/descriptor-set.js +429 -513
- package/dist/cjs/enum.js +13 -0
- package/dist/cjs/field-list.js +13 -0
- package/dist/cjs/field.js +43 -30
- package/dist/cjs/google/protobuf/any_pb.js +122 -140
- package/dist/cjs/google/protobuf/api_pb.js +177 -224
- package/dist/cjs/google/protobuf/compiler/plugin_pb.js +125 -227
- package/dist/cjs/google/protobuf/descriptor_pb.js +1029 -1888
- package/dist/cjs/google/protobuf/duration_pb.js +72 -88
- package/dist/cjs/google/protobuf/empty_pb.js +17 -17
- package/dist/cjs/google/protobuf/field_mask_pb.js +77 -94
- package/dist/cjs/google/protobuf/source_context_pb.js +25 -25
- package/dist/cjs/google/protobuf/struct_pb.js +144 -181
- package/dist/cjs/google/protobuf/timestamp_pb.js +86 -123
- package/dist/cjs/google/protobuf/type_pb.js +406 -462
- package/dist/cjs/google/protobuf/wrappers_pb.js +407 -470
- package/dist/cjs/google/varint.js +166 -171
- package/dist/cjs/index.js +41 -122
- package/dist/cjs/json-format.js +13 -0
- package/dist/cjs/message-type.js +13 -0
- package/dist/cjs/message.js +89 -85
- package/dist/cjs/private/assert.js +33 -26
- package/dist/cjs/private/base64.js +93 -79
- package/dist/cjs/private/binary-format-common.js +208 -208
- package/dist/cjs/private/binary-format-proto2.js +88 -109
- package/dist/cjs/private/binary-format-proto3.js +70 -90
- package/dist/cjs/private/enum.js +77 -44
- package/dist/cjs/private/field-list.js +64 -50
- package/dist/cjs/private/field-wrapper.js +21 -10
- package/dist/cjs/private/field.js +35 -25
- package/dist/cjs/private/json-format-common.js +427 -440
- package/dist/cjs/private/json-format-proto2.js +91 -89
- package/dist/cjs/private/json-format-proto3.js +82 -93
- package/dist/cjs/private/message-type.js +39 -27
- package/dist/cjs/private/names.js +71 -62
- package/dist/cjs/private/options-map.js +13 -0
- package/dist/cjs/private/proto-runtime.js +25 -16
- package/dist/cjs/private/scalars.js +113 -103
- package/dist/cjs/private/util-common.js +193 -210
- package/dist/cjs/private/util.js +13 -0
- package/dist/cjs/proto-int64.js +123 -111
- package/dist/cjs/proto2.js +63 -63
- package/dist/cjs/proto3.js +74 -74
- package/dist/cjs/service-type.js +27 -17
- package/dist/cjs/type-registry.js +46 -31
- package/dist/esm/binary-encoding.js +414 -414
- package/dist/esm/binary-format.js +13 -0
- package/dist/esm/descriptor-registry.js +422 -458
- package/dist/esm/descriptor-set.js +430 -478
- package/dist/esm/enum.js +13 -0
- package/dist/esm/field-list.js +13 -0
- package/dist/esm/field.js +42 -29
- package/dist/esm/google/protobuf/any_pb.js +122 -140
- package/dist/esm/google/protobuf/api_pb.js +177 -197
- package/dist/esm/google/protobuf/compiler/plugin_pb.js +123 -216
- package/dist/esm/google/protobuf/descriptor_pb.js +1013 -1804
- package/dist/esm/google/protobuf/duration_pb.js +72 -88
- package/dist/esm/google/protobuf/empty_pb.js +17 -17
- package/dist/esm/google/protobuf/field_mask_pb.js +77 -94
- package/dist/esm/google/protobuf/source_context_pb.js +25 -25
- package/dist/esm/google/protobuf/struct_pb.js +143 -180
- package/dist/esm/google/protobuf/timestamp_pb.js +86 -123
- package/dist/esm/google/protobuf/type_pb.js +401 -421
- package/dist/esm/google/protobuf/wrappers_pb.js +406 -397
- package/dist/esm/google/varint.js +165 -164
- package/dist/esm/index.js +14 -1
- package/dist/esm/json-format.js +13 -0
- package/dist/esm/message-type.js +13 -0
- package/dist/esm/message.js +89 -85
- package/dist/esm/private/assert.js +32 -21
- package/dist/esm/private/base64.js +92 -78
- package/dist/esm/private/binary-format-common.js +209 -207
- package/dist/esm/private/binary-format-proto2.js +89 -81
- package/dist/esm/private/binary-format-proto3.js +71 -67
- package/dist/esm/private/enum.js +75 -43
- package/dist/esm/private/field-list.js +64 -50
- package/dist/esm/private/field-wrapper.js +21 -10
- package/dist/esm/private/field.js +35 -22
- package/dist/esm/private/json-format-common.js +427 -435
- package/dist/esm/private/json-format-proto2.js +89 -81
- package/dist/esm/private/json-format-proto3.js +79 -80
- package/dist/esm/private/message-type.js +40 -28
- package/dist/esm/private/names.js +70 -57
- package/dist/esm/private/options-map.js +13 -0
- package/dist/esm/private/proto-runtime.js +26 -12
- package/dist/esm/private/scalars.js +112 -99
- package/dist/esm/private/util-common.js +193 -192
- package/dist/esm/private/util.js +13 -0
- package/dist/esm/proto-int64.js +123 -111
- package/dist/esm/proto2.js +63 -57
- package/dist/esm/proto3.js +74 -68
- package/dist/esm/service-type.js +25 -12
- package/dist/esm/type-registry.js +46 -31
- package/dist/types/binary-encoding.d.ts +398 -398
- package/dist/types/binary-format.d.ts +69 -91
- package/dist/types/descriptor-registry.d.ts +23 -29
- package/dist/types/descriptor-set.d.ts +107 -128
- package/dist/types/enum.d.ts +21 -21
- package/dist/types/field-list.d.ts +21 -21
- package/dist/types/field.d.ts +191 -231
- package/dist/types/google/protobuf/any_pb.d.ts +56 -77
- package/dist/types/google/protobuf/api_pb.d.ts +144 -187
- package/dist/types/google/protobuf/compiler/plugin_pb.d.ts +195 -257
- package/dist/types/google/protobuf/descriptor_pb.d.ts +1360 -1737
- package/dist/types/google/protobuf/duration_pb.d.ts +30 -50
- package/dist/types/google/protobuf/empty_pb.d.ts +9 -28
- package/dist/types/google/protobuf/field_mask_pb.d.ts +17 -37
- package/dist/types/google/protobuf/source_context_pb.d.ts +16 -35
- package/dist/types/google/protobuf/struct_pb.d.ts +64 -115
- package/dist/types/google/protobuf/timestamp_pb.d.ts +31 -51
- package/dist/types/google/protobuf/type_pb.d.ts +355 -422
- package/dist/types/google/protobuf/wrappers_pb.d.ts +181 -297
- package/dist/types/google/varint.d.ts +6 -13
- package/dist/types/index.d.ts +4 -27
- package/dist/types/json-format.d.ts +70 -89
- package/dist/types/message-type.d.ts +37 -45
- package/dist/types/message.d.ts +62 -87
- package/dist/types/private/assert.d.ts +1 -4
- package/dist/types/private/binary-format-common.d.ts +6 -32
- package/dist/types/private/enum.d.ts +13 -11
- package/dist/types/private/field-list.d.ts +14 -21
- package/dist/types/private/field-wrapper.d.ts +4 -10
- package/dist/types/private/field.d.ts +12 -12
- package/dist/types/private/json-format-common.d.ts +5 -27
- package/dist/types/private/message-type.d.ts +12 -7
- package/dist/types/private/names.d.ts +1 -4
- package/dist/types/private/options-map.d.ts +1 -1
- package/dist/types/private/proto-runtime.d.ts +34 -42
- package/dist/types/private/scalars.d.ts +5 -12
- package/dist/types/private/util-common.d.ts +1 -4
- package/dist/types/private/util.d.ts +29 -41
- package/dist/types/proto-int64.d.ts +42 -42
- package/dist/types/service-type.d.ts +36 -56
- package/dist/types/type-registry.d.ts +13 -15
- package/package.json +2 -3
|
@@ -32,13 +32,7 @@
|
|
|
32
32
|
// standalone and requires a support library to be linked with it. This
|
|
33
33
|
// support library is itself covered by the above license.
|
|
34
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;
|
|
35
|
+
exports.varint32read = exports.varint32write = exports.int64toString = exports.int64fromString = exports.varint64write = exports.varint64read = void 0;
|
|
42
36
|
/* eslint-disable prefer-const,@typescript-eslint/restrict-plus-operands */
|
|
43
37
|
/**
|
|
44
38
|
* Read a 64 bit varint as two JS numbers.
|
|
@@ -52,34 +46,34 @@ exports.varint32read =
|
|
|
52
46
|
* See https://github.com/protocolbuffers/protobuf/blob/8a71927d74a4ce34efe2d8769fda198f52d20d12/js/experimental/runtime/kernel/buffer_decoder.js#L175
|
|
53
47
|
*/
|
|
54
48
|
function varint64read() {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
49
|
+
let lowBits = 0;
|
|
50
|
+
let highBits = 0;
|
|
51
|
+
for (let shift = 0; shift < 28; shift += 7) {
|
|
52
|
+
let b = this.buf[this.pos++];
|
|
53
|
+
lowBits |= (b & 0x7f) << shift;
|
|
54
|
+
if ((b & 0x80) == 0) {
|
|
55
|
+
this.assertBounds();
|
|
56
|
+
return [lowBits, highBits];
|
|
57
|
+
}
|
|
63
58
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
59
|
+
let middleByte = this.buf[this.pos++];
|
|
60
|
+
// last four bits of the first 32 bit number
|
|
61
|
+
lowBits |= (middleByte & 0x0f) << 28;
|
|
62
|
+
// 3 upper bits are part of the next 32 bit number
|
|
63
|
+
highBits = (middleByte & 0x70) >> 4;
|
|
64
|
+
if ((middleByte & 0x80) == 0) {
|
|
65
|
+
this.assertBounds();
|
|
66
|
+
return [lowBits, highBits];
|
|
67
|
+
}
|
|
68
|
+
for (let shift = 3; shift <= 31; shift += 7) {
|
|
69
|
+
let b = this.buf[this.pos++];
|
|
70
|
+
highBits |= (b & 0x7f) << shift;
|
|
71
|
+
if ((b & 0x80) == 0) {
|
|
72
|
+
this.assertBounds();
|
|
73
|
+
return [lowBits, highBits];
|
|
74
|
+
}
|
|
80
75
|
}
|
|
81
|
-
|
|
82
|
-
throw new Error("invalid varint");
|
|
76
|
+
throw new Error("invalid varint");
|
|
83
77
|
}
|
|
84
78
|
exports.varint64read = varint64read;
|
|
85
79
|
/**
|
|
@@ -90,31 +84,31 @@ exports.varint64read = varint64read;
|
|
|
90
84
|
* See https://github.com/protocolbuffers/protobuf/blob/8a71927d74a4ce34efe2d8769fda198f52d20d12/js/experimental/runtime/kernel/writer.js#L344
|
|
91
85
|
*/
|
|
92
86
|
function varint64write(lo, hi, bytes) {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
87
|
+
for (let i = 0; i < 28; i = i + 7) {
|
|
88
|
+
const shift = lo >>> i;
|
|
89
|
+
const hasNext = !(shift >>> 7 == 0 && hi == 0);
|
|
90
|
+
const byte = (hasNext ? shift | 0x80 : shift) & 0xff;
|
|
91
|
+
bytes.push(byte);
|
|
92
|
+
if (!hasNext) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
const splitBits = ((lo >>> 28) & 0x0f) | ((hi & 0x07) << 4);
|
|
97
|
+
const hasMoreBits = !(hi >> 3 == 0);
|
|
98
|
+
bytes.push((hasMoreBits ? splitBits | 0x80 : splitBits) & 0xff);
|
|
99
|
+
if (!hasMoreBits) {
|
|
100
|
+
return;
|
|
100
101
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
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;
|
|
102
|
+
for (let i = 3; i < 31; i = i + 7) {
|
|
103
|
+
const shift = hi >>> i;
|
|
104
|
+
const hasNext = !(shift >>> 7 == 0);
|
|
105
|
+
const byte = (hasNext ? shift | 0x80 : shift) & 0xff;
|
|
106
|
+
bytes.push(byte);
|
|
107
|
+
if (!hasNext) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
115
110
|
}
|
|
116
|
-
|
|
117
|
-
bytes.push((hi >>> 31) & 0x01);
|
|
111
|
+
bytes.push((hi >>> 31) & 0x01);
|
|
118
112
|
}
|
|
119
113
|
exports.varint64write = varint64write;
|
|
120
114
|
// constants for binary math
|
|
@@ -130,31 +124,32 @@ const TWO_PWR_32_DBL = (1 << 16) * (1 << 16);
|
|
|
130
124
|
* Copyright 2008 Google Inc.
|
|
131
125
|
*/
|
|
132
126
|
function int64fromString(dec) {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
127
|
+
// Check for minus sign.
|
|
128
|
+
let minus = dec[0] == "-";
|
|
129
|
+
if (minus)
|
|
130
|
+
dec = dec.slice(1);
|
|
131
|
+
// Work 6 decimal digits at a time, acting like we're converting base 1e6
|
|
132
|
+
// digits to binary. This is safe to do with floating point math because
|
|
133
|
+
// Number.isSafeInteger(ALL_32_BITS * 1e6) == true.
|
|
134
|
+
const base = 1e6;
|
|
135
|
+
let lowBits = 0;
|
|
136
|
+
let highBits = 0;
|
|
137
|
+
function add1e6digit(begin, end) {
|
|
138
|
+
// Note: Number('') is 0.
|
|
139
|
+
const digit1e6 = Number(dec.slice(begin, end));
|
|
140
|
+
highBits *= base;
|
|
141
|
+
lowBits = lowBits * base + digit1e6;
|
|
142
|
+
// Carry bits from lowBits to
|
|
143
|
+
if (lowBits >= TWO_PWR_32_DBL) {
|
|
144
|
+
highBits = highBits + ((lowBits / TWO_PWR_32_DBL) | 0);
|
|
145
|
+
lowBits = lowBits % TWO_PWR_32_DBL;
|
|
146
|
+
}
|
|
151
147
|
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
return [minus, lowBits, highBits];
|
|
148
|
+
add1e6digit(-24, -18);
|
|
149
|
+
add1e6digit(-18, -12);
|
|
150
|
+
add1e6digit(-12, -6);
|
|
151
|
+
add1e6digit(-6);
|
|
152
|
+
return [minus, lowBits, highBits];
|
|
158
153
|
}
|
|
159
154
|
exports.int64fromString = int64fromString;
|
|
160
155
|
/**
|
|
@@ -163,54 +158,52 @@ exports.int64fromString = int64fromString;
|
|
|
163
158
|
* Copyright 2008 Google Inc.
|
|
164
159
|
*/
|
|
165
160
|
function int64toString(bitsLow, bitsHigh) {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
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;
|
|
161
|
+
// Skip the expensive conversion if the number is small enough to use the
|
|
162
|
+
// built-in conversions.
|
|
163
|
+
if (bitsHigh <= 0x1fffff) {
|
|
164
|
+
return "" + (TWO_PWR_32_DBL * bitsHigh + bitsLow);
|
|
204
165
|
}
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
//
|
|
211
|
-
//
|
|
212
|
-
|
|
213
|
-
|
|
166
|
+
// What this code is doing is essentially converting the input number from
|
|
167
|
+
// base-2 to base-1e7, which allows us to represent the 64-bit range with
|
|
168
|
+
// only 3 (very large) digits. Those digits are then trivial to convert to
|
|
169
|
+
// a base-10 string.
|
|
170
|
+
// The magic numbers used here are -
|
|
171
|
+
// 2^24 = 16777216 = (1,6777216) in base-1e7.
|
|
172
|
+
// 2^48 = 281474976710656 = (2,8147497,6710656) in base-1e7.
|
|
173
|
+
// Split 32:32 representation into 16:24:24 representation so our
|
|
174
|
+
// intermediate digits don't overflow.
|
|
175
|
+
let low = bitsLow & 0xffffff;
|
|
176
|
+
let mid = (((bitsLow >>> 24) | (bitsHigh << 8)) >>> 0) & 0xffffff;
|
|
177
|
+
let high = (bitsHigh >> 16) & 0xffff;
|
|
178
|
+
// Assemble our three base-1e7 digits, ignoring carries. The maximum
|
|
179
|
+
// value in a digit at this step is representable as a 48-bit integer, which
|
|
180
|
+
// can be stored in a 64-bit floating point number.
|
|
181
|
+
let digitA = low + mid * 6777216 + high * 6710656;
|
|
182
|
+
let digitB = mid + high * 8147497;
|
|
183
|
+
let digitC = high * 2;
|
|
184
|
+
// Apply carries from A to B and from B to C.
|
|
185
|
+
let base = 10000000;
|
|
186
|
+
if (digitA >= base) {
|
|
187
|
+
digitB += Math.floor(digitA / base);
|
|
188
|
+
digitA %= base;
|
|
189
|
+
}
|
|
190
|
+
if (digitB >= base) {
|
|
191
|
+
digitC += Math.floor(digitB / base);
|
|
192
|
+
digitB %= base;
|
|
193
|
+
}
|
|
194
|
+
// Convert base-1e7 digits to base-10, with optional leading zeroes.
|
|
195
|
+
function decimalFrom1e7(digit1e7, needLeadingZeros) {
|
|
196
|
+
let partial = digit1e7 ? String(digit1e7) : "";
|
|
197
|
+
if (needLeadingZeros) {
|
|
198
|
+
return "0000000".slice(partial.length) + partial;
|
|
199
|
+
}
|
|
200
|
+
return partial;
|
|
201
|
+
}
|
|
202
|
+
return (decimalFrom1e7(digitC, /*needLeadingZeros=*/ 0) +
|
|
203
|
+
decimalFrom1e7(digitB, /*needLeadingZeros=*/ digitC) +
|
|
204
|
+
// If the final 1e7 digit didn't need leading zeros, we would have
|
|
205
|
+
// returned via the trivial code path at the top.
|
|
206
|
+
decimalFrom1e7(digitA, /*needLeadingZeros=*/ 1));
|
|
214
207
|
}
|
|
215
208
|
exports.int64toString = int64toString;
|
|
216
209
|
/**
|
|
@@ -221,20 +214,21 @@ exports.int64toString = int64toString;
|
|
|
221
214
|
* See https://github.com/protocolbuffers/protobuf/blob/1b18833f4f2a2f681f4e4a25cdf3b0a43115ec26/js/binary/encoder.js#L144
|
|
222
215
|
*/
|
|
223
216
|
function varint32write(value, bytes) {
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
217
|
+
if (value >= 0) {
|
|
218
|
+
// write value as varint 32
|
|
219
|
+
while (value > 0x7f) {
|
|
220
|
+
bytes.push((value & 0x7f) | 0x80);
|
|
221
|
+
value = value >>> 7;
|
|
222
|
+
}
|
|
223
|
+
bytes.push(value);
|
|
229
224
|
}
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
225
|
+
else {
|
|
226
|
+
for (let i = 0; i < 9; i++) {
|
|
227
|
+
bytes.push((value & 127) | 128);
|
|
228
|
+
value = value >> 7;
|
|
229
|
+
}
|
|
230
|
+
bytes.push(1);
|
|
235
231
|
}
|
|
236
|
-
bytes.push(1);
|
|
237
|
-
}
|
|
238
232
|
}
|
|
239
233
|
exports.varint32write = varint32write;
|
|
240
234
|
/**
|
|
@@ -243,38 +237,39 @@ exports.varint32write = varint32write;
|
|
|
243
237
|
* See https://github.com/protocolbuffers/protobuf/blob/8a71927d74a4ce34efe2d8769fda198f52d20d12/js/experimental/runtime/kernel/buffer_decoder.js#L220
|
|
244
238
|
*/
|
|
245
239
|
function varint32read() {
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
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++)
|
|
240
|
+
let b = this.buf[this.pos++];
|
|
241
|
+
let result = b & 0x7f;
|
|
242
|
+
if ((b & 0x80) == 0) {
|
|
243
|
+
this.assertBounds();
|
|
244
|
+
return result;
|
|
245
|
+
}
|
|
274
246
|
b = this.buf[this.pos++];
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
247
|
+
result |= (b & 0x7f) << 7;
|
|
248
|
+
if ((b & 0x80) == 0) {
|
|
249
|
+
this.assertBounds();
|
|
250
|
+
return result;
|
|
251
|
+
}
|
|
252
|
+
b = this.buf[this.pos++];
|
|
253
|
+
result |= (b & 0x7f) << 14;
|
|
254
|
+
if ((b & 0x80) == 0) {
|
|
255
|
+
this.assertBounds();
|
|
256
|
+
return result;
|
|
257
|
+
}
|
|
258
|
+
b = this.buf[this.pos++];
|
|
259
|
+
result |= (b & 0x7f) << 21;
|
|
260
|
+
if ((b & 0x80) == 0) {
|
|
261
|
+
this.assertBounds();
|
|
262
|
+
return result;
|
|
263
|
+
}
|
|
264
|
+
// Extract only last 4 bits
|
|
265
|
+
b = this.buf[this.pos++];
|
|
266
|
+
result |= (b & 0x0f) << 28;
|
|
267
|
+
for (let readBytes = 5; (b & 0x80) !== 0 && readBytes < 10; readBytes++)
|
|
268
|
+
b = this.buf[this.pos++];
|
|
269
|
+
if ((b & 0x80) != 0)
|
|
270
|
+
throw new Error("invalid varint");
|
|
271
|
+
this.assertBounds();
|
|
272
|
+
// Result can have 32 bits, convert it to unsigned
|
|
273
|
+
return result >>> 0;
|
|
279
274
|
}
|
|
280
275
|
exports.varint32read = varint32read;
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,137 +1,56 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p))
|
|
30
|
-
__createBinding(exports, m, p);
|
|
31
|
-
};
|
|
2
|
+
// Copyright 2021-2022 Buf Technologies, Inc.
|
|
3
|
+
//
|
|
4
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
// you may not use this file except in compliance with the License.
|
|
6
|
+
// You may obtain a copy of the License at
|
|
7
|
+
//
|
|
8
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
//
|
|
10
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
// See the License for the specific language governing permissions and
|
|
14
|
+
// limitations under the License.
|
|
15
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
18
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
19
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
20
|
+
}
|
|
21
|
+
Object.defineProperty(o, k2, desc);
|
|
22
|
+
}) : (function(o, m, k, k2) {
|
|
23
|
+
if (k2 === undefined) k2 = k;
|
|
24
|
+
o[k2] = m[k];
|
|
25
|
+
}));
|
|
26
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
27
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
28
|
+
};
|
|
32
29
|
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;
|
|
30
|
+
exports.BinaryReader = exports.BinaryWriter = exports.WireType = exports.DescriptorSet = exports.DescriptorRegistry = exports.TypeRegistry = exports.MethodIdempotency = exports.MethodKind = exports.ScalarType = exports.Message = exports.protoInt64 = exports.proto2 = exports.proto3 = void 0;
|
|
47
31
|
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
|
-
});
|
|
32
|
+
Object.defineProperty(exports, "proto3", { enumerable: true, get: function () { return proto3_js_1.proto3; } });
|
|
54
33
|
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
|
-
});
|
|
34
|
+
Object.defineProperty(exports, "proto2", { enumerable: true, get: function () { return proto2_js_1.proto2; } });
|
|
61
35
|
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
|
-
});
|
|
36
|
+
Object.defineProperty(exports, "protoInt64", { enumerable: true, get: function () { return proto_int64_js_1.protoInt64; } });
|
|
68
37
|
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
|
-
});
|
|
38
|
+
Object.defineProperty(exports, "Message", { enumerable: true, get: function () { return message_js_1.Message; } });
|
|
75
39
|
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
|
-
});
|
|
40
|
+
Object.defineProperty(exports, "ScalarType", { enumerable: true, get: function () { return field_js_1.ScalarType; } });
|
|
82
41
|
var service_type_js_1 = require("./service-type.js");
|
|
83
|
-
Object.defineProperty(exports, "MethodKind", {
|
|
84
|
-
|
|
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
|
-
});
|
|
42
|
+
Object.defineProperty(exports, "MethodKind", { enumerable: true, get: function () { return service_type_js_1.MethodKind; } });
|
|
43
|
+
Object.defineProperty(exports, "MethodIdempotency", { enumerable: true, get: function () { return service_type_js_1.MethodIdempotency; } });
|
|
95
44
|
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
|
-
});
|
|
45
|
+
Object.defineProperty(exports, "TypeRegistry", { enumerable: true, get: function () { return type_registry_js_1.TypeRegistry; } });
|
|
102
46
|
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
|
-
});
|
|
47
|
+
Object.defineProperty(exports, "DescriptorRegistry", { enumerable: true, get: function () { return descriptor_registry_js_1.DescriptorRegistry; } });
|
|
109
48
|
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
|
-
});
|
|
49
|
+
Object.defineProperty(exports, "DescriptorSet", { enumerable: true, get: function () { return descriptor_set_js_1.DescriptorSet; } });
|
|
116
50
|
var binary_encoding_js_1 = require("./binary-encoding.js");
|
|
117
|
-
Object.defineProperty(exports, "WireType", {
|
|
118
|
-
|
|
119
|
-
|
|
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
|
-
});
|
|
51
|
+
Object.defineProperty(exports, "WireType", { enumerable: true, get: function () { return binary_encoding_js_1.WireType; } });
|
|
52
|
+
Object.defineProperty(exports, "BinaryWriter", { enumerable: true, get: function () { return binary_encoding_js_1.BinaryWriter; } });
|
|
53
|
+
Object.defineProperty(exports, "BinaryReader", { enumerable: true, get: function () { return binary_encoding_js_1.BinaryReader; } });
|
|
135
54
|
var json_format_js_1 = require("./json-format.js");
|
|
136
55
|
// ideally, we would export these types with sub-path exports:
|
|
137
56
|
__exportStar(require("./google/protobuf/compiler/plugin_pb.js"), exports);
|
package/dist/cjs/json-format.js
CHANGED
|
@@ -1,2 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
// Copyright 2021-2022 Buf Technologies, Inc.
|
|
3
|
+
//
|
|
4
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
// you may not use this file except in compliance with the License.
|
|
6
|
+
// You may obtain a copy of the License at
|
|
7
|
+
//
|
|
8
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
//
|
|
10
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
// See the License for the specific language governing permissions and
|
|
14
|
+
// limitations under the License.
|
|
2
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
package/dist/cjs/message-type.js
CHANGED
|
@@ -1,2 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
// Copyright 2021-2022 Buf Technologies, Inc.
|
|
3
|
+
//
|
|
4
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
// you may not use this file except in compliance with the License.
|
|
6
|
+
// You may obtain a copy of the License at
|
|
7
|
+
//
|
|
8
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
//
|
|
10
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
// See the License for the specific language governing permissions and
|
|
14
|
+
// limitations under the License.
|
|
2
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|