@depup/apollo__protobufjs 1.2.7-depup.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/LICENSE +39 -0
  2. package/README.md +32 -0
  3. package/bin/pbjs +6 -0
  4. package/bin/pbts +6 -0
  5. package/changes.json +14 -0
  6. package/cli/LICENSE +33 -0
  7. package/cli/README.md +11 -0
  8. package/cli/bin/pbjs +6 -0
  9. package/cli/bin/pbts +6 -0
  10. package/cli/index.d.ts +3 -0
  11. package/cli/index.js +3 -0
  12. package/cli/lib/tsd-jsdoc/LICENSE +21 -0
  13. package/cli/lib/tsd-jsdoc/README.md +23 -0
  14. package/cli/lib/tsd-jsdoc/plugin.js +21 -0
  15. package/cli/lib/tsd-jsdoc/publish.js +693 -0
  16. package/cli/lib/tsd-jsdoc.json +18 -0
  17. package/cli/package.json +7 -0
  18. package/cli/package.standalone.json +32 -0
  19. package/cli/pbjs.d.ts +9 -0
  20. package/cli/pbjs.js +331 -0
  21. package/cli/pbts.d.ts +9 -0
  22. package/cli/pbts.js +198 -0
  23. package/cli/targets/json-module.js +38 -0
  24. package/cli/targets/json.js +8 -0
  25. package/cli/targets/proto.js +326 -0
  26. package/cli/targets/proto2.js +10 -0
  27. package/cli/targets/proto3.js +10 -0
  28. package/cli/targets/static-module.js +29 -0
  29. package/cli/targets/static.js +709 -0
  30. package/cli/util.js +183 -0
  31. package/cli/wrappers/amd.js +7 -0
  32. package/cli/wrappers/closure.js +7 -0
  33. package/cli/wrappers/commonjs.js +7 -0
  34. package/cli/wrappers/default.js +15 -0
  35. package/cli/wrappers/es6.js +5 -0
  36. package/dist/README.md +31 -0
  37. package/dist/light/README.md +31 -0
  38. package/dist/light/protobuf.js +7198 -0
  39. package/dist/light/protobuf.js.map +1 -0
  40. package/dist/light/protobuf.min.js +7 -0
  41. package/dist/light/protobuf.min.js.map +1 -0
  42. package/dist/minimal/README.md +31 -0
  43. package/dist/minimal/protobuf.js +2675 -0
  44. package/dist/minimal/protobuf.js.map +1 -0
  45. package/dist/minimal/protobuf.min.js +7 -0
  46. package/dist/minimal/protobuf.min.js.map +1 -0
  47. package/dist/protobuf.js +8775 -0
  48. package/dist/protobuf.js.map +1 -0
  49. package/dist/protobuf.min.js +7 -0
  50. package/dist/protobuf.min.js.map +1 -0
  51. package/ext/debug/README.md +4 -0
  52. package/ext/debug/index.js +71 -0
  53. package/ext/descriptor/README.md +72 -0
  54. package/ext/descriptor/index.d.ts +191 -0
  55. package/ext/descriptor/index.js +1052 -0
  56. package/ext/descriptor/test.js +54 -0
  57. package/google/LICENSE +27 -0
  58. package/google/README.md +1 -0
  59. package/google/api/annotations.json +83 -0
  60. package/google/api/annotations.proto +11 -0
  61. package/google/api/http.json +86 -0
  62. package/google/api/http.proto +31 -0
  63. package/google/protobuf/api.json +118 -0
  64. package/google/protobuf/api.proto +34 -0
  65. package/google/protobuf/descriptor.json +739 -0
  66. package/google/protobuf/descriptor.proto +286 -0
  67. package/google/protobuf/source_context.json +20 -0
  68. package/google/protobuf/source_context.proto +7 -0
  69. package/google/protobuf/type.json +202 -0
  70. package/google/protobuf/type.proto +89 -0
  71. package/index.d.ts +2628 -0
  72. package/index.js +4 -0
  73. package/light.d.ts +2 -0
  74. package/light.js +4 -0
  75. package/minimal.d.ts +2 -0
  76. package/minimal.js +4 -0
  77. package/package.json +147 -0
  78. package/scripts/postinstall.js +35 -0
  79. package/src/common.js +399 -0
  80. package/src/converter.js +304 -0
  81. package/src/decoder.js +106 -0
  82. package/src/encoder.js +119 -0
  83. package/src/enum.js +181 -0
  84. package/src/field.js +379 -0
  85. package/src/index-light.js +104 -0
  86. package/src/index-minimal.js +36 -0
  87. package/src/index.js +12 -0
  88. package/src/mapfield.js +126 -0
  89. package/src/message.js +139 -0
  90. package/src/method.js +151 -0
  91. package/src/namespace.js +433 -0
  92. package/src/object.js +200 -0
  93. package/src/oneof.js +203 -0
  94. package/src/parse.js +761 -0
  95. package/src/reader.js +405 -0
  96. package/src/reader_buffer.js +44 -0
  97. package/src/root.js +353 -0
  98. package/src/roots.js +18 -0
  99. package/src/rpc/service.js +142 -0
  100. package/src/rpc.js +36 -0
  101. package/src/service.js +167 -0
  102. package/src/tokenize.js +397 -0
  103. package/src/type.js +589 -0
  104. package/src/types.js +196 -0
  105. package/src/typescript.jsdoc +22 -0
  106. package/src/util/longbits.js +200 -0
  107. package/src/util/minimal.js +406 -0
  108. package/src/util.js +178 -0
  109. package/src/verifier.js +191 -0
  110. package/src/wrappers.js +83 -0
  111. package/src/writer.js +459 -0
  112. package/src/writer_buffer.js +81 -0
  113. package/tsconfig.json +7 -0
package/src/reader.js ADDED
@@ -0,0 +1,405 @@
1
+ "use strict";
2
+ module.exports = Reader;
3
+
4
+ var util = require("./util/minimal");
5
+
6
+ var BufferReader; // cyclic
7
+
8
+ var LongBits = util.LongBits,
9
+ utf8 = util.utf8;
10
+
11
+ /* istanbul ignore next */
12
+ function indexOutOfRange(reader, writeLength) {
13
+ return RangeError("index out of range: " + reader.pos + " + " + (writeLength || 1) + " > " + reader.len);
14
+ }
15
+
16
+ /**
17
+ * Constructs a new reader instance using the specified buffer.
18
+ * @classdesc Wire format reader using `Uint8Array` if available, otherwise `Array`.
19
+ * @constructor
20
+ * @param {Uint8Array} buffer Buffer to read from
21
+ */
22
+ function Reader(buffer) {
23
+
24
+ /**
25
+ * Read buffer.
26
+ * @type {Uint8Array}
27
+ */
28
+ this.buf = buffer;
29
+
30
+ /**
31
+ * Read buffer position.
32
+ * @type {number}
33
+ */
34
+ this.pos = 0;
35
+
36
+ /**
37
+ * Read buffer length.
38
+ * @type {number}
39
+ */
40
+ this.len = buffer.length;
41
+ }
42
+
43
+ var create_array = typeof Uint8Array !== "undefined"
44
+ ? function create_typed_array(buffer) {
45
+ if (buffer instanceof Uint8Array || Array.isArray(buffer))
46
+ return new Reader(buffer);
47
+ throw Error("illegal buffer");
48
+ }
49
+ /* istanbul ignore next */
50
+ : function create_array(buffer) {
51
+ if (Array.isArray(buffer))
52
+ return new Reader(buffer);
53
+ throw Error("illegal buffer");
54
+ };
55
+
56
+ /**
57
+ * Creates a new reader using the specified buffer.
58
+ * @function
59
+ * @param {Uint8Array|Buffer} buffer Buffer to read from
60
+ * @returns {Reader|BufferReader} A {@link BufferReader} if `buffer` is a Buffer, otherwise a {@link Reader}
61
+ * @throws {Error} If `buffer` is not a valid buffer
62
+ */
63
+ Reader.create = util.Buffer
64
+ ? function create_buffer_setup(buffer) {
65
+ return (Reader.create = function create_buffer(buffer) {
66
+ return util.Buffer.isBuffer(buffer)
67
+ ? new BufferReader(buffer)
68
+ /* istanbul ignore next */
69
+ : create_array(buffer);
70
+ })(buffer);
71
+ }
72
+ /* istanbul ignore next */
73
+ : create_array;
74
+
75
+ Reader.prototype._slice = util.Array.prototype.subarray || /* istanbul ignore next */ util.Array.prototype.slice;
76
+
77
+ /**
78
+ * Reads a varint as an unsigned 32 bit value.
79
+ * @function
80
+ * @returns {number} Value read
81
+ */
82
+ Reader.prototype.uint32 = (function read_uint32_setup() {
83
+ var value = 4294967295; // optimizer type-hint, tends to deopt otherwise (?!)
84
+ return function read_uint32() {
85
+ value = ( this.buf[this.pos] & 127 ) >>> 0; if (this.buf[this.pos++] < 128) return value;
86
+ value = (value | (this.buf[this.pos] & 127) << 7) >>> 0; if (this.buf[this.pos++] < 128) return value;
87
+ value = (value | (this.buf[this.pos] & 127) << 14) >>> 0; if (this.buf[this.pos++] < 128) return value;
88
+ value = (value | (this.buf[this.pos] & 127) << 21) >>> 0; if (this.buf[this.pos++] < 128) return value;
89
+ value = (value | (this.buf[this.pos] & 15) << 28) >>> 0; if (this.buf[this.pos++] < 128) return value;
90
+
91
+ /* istanbul ignore if */
92
+ if ((this.pos += 5) > this.len) {
93
+ this.pos = this.len;
94
+ throw indexOutOfRange(this, 10);
95
+ }
96
+ return value;
97
+ };
98
+ })();
99
+
100
+ /**
101
+ * Reads a varint as a signed 32 bit value.
102
+ * @returns {number} Value read
103
+ */
104
+ Reader.prototype.int32 = function read_int32() {
105
+ return this.uint32() | 0;
106
+ };
107
+
108
+ /**
109
+ * Reads a zig-zag encoded varint as a signed 32 bit value.
110
+ * @returns {number} Value read
111
+ */
112
+ Reader.prototype.sint32 = function read_sint32() {
113
+ var value = this.uint32();
114
+ return value >>> 1 ^ -(value & 1) | 0;
115
+ };
116
+
117
+ /* eslint-disable no-invalid-this */
118
+
119
+ function readLongVarint() {
120
+ // tends to deopt with local vars for octet etc.
121
+ var bits = new LongBits(0, 0);
122
+ var i = 0;
123
+ if (this.len - this.pos > 4) { // fast route (lo)
124
+ for (; i < 4; ++i) {
125
+ // 1st..4th
126
+ bits.lo = (bits.lo | (this.buf[this.pos] & 127) << i * 7) >>> 0;
127
+ if (this.buf[this.pos++] < 128)
128
+ return bits;
129
+ }
130
+ // 5th
131
+ bits.lo = (bits.lo | (this.buf[this.pos] & 127) << 28) >>> 0;
132
+ bits.hi = (bits.hi | (this.buf[this.pos] & 127) >> 4) >>> 0;
133
+ if (this.buf[this.pos++] < 128)
134
+ return bits;
135
+ i = 0;
136
+ } else {
137
+ for (; i < 3; ++i) {
138
+ /* istanbul ignore if */
139
+ if (this.pos >= this.len)
140
+ throw indexOutOfRange(this);
141
+ // 1st..3th
142
+ bits.lo = (bits.lo | (this.buf[this.pos] & 127) << i * 7) >>> 0;
143
+ if (this.buf[this.pos++] < 128)
144
+ return bits;
145
+ }
146
+ // 4th
147
+ bits.lo = (bits.lo | (this.buf[this.pos++] & 127) << i * 7) >>> 0;
148
+ return bits;
149
+ }
150
+ if (this.len - this.pos > 4) { // fast route (hi)
151
+ for (; i < 5; ++i) {
152
+ // 6th..10th
153
+ bits.hi = (bits.hi | (this.buf[this.pos] & 127) << i * 7 + 3) >>> 0;
154
+ if (this.buf[this.pos++] < 128)
155
+ return bits;
156
+ }
157
+ } else {
158
+ for (; i < 5; ++i) {
159
+ /* istanbul ignore if */
160
+ if (this.pos >= this.len)
161
+ throw indexOutOfRange(this);
162
+ // 6th..10th
163
+ bits.hi = (bits.hi | (this.buf[this.pos] & 127) << i * 7 + 3) >>> 0;
164
+ if (this.buf[this.pos++] < 128)
165
+ return bits;
166
+ }
167
+ }
168
+ /* istanbul ignore next */
169
+ throw Error("invalid varint encoding");
170
+ }
171
+
172
+ /* eslint-enable no-invalid-this */
173
+
174
+ /*
175
+ * Reads a varint as a signed 64 bit value.
176
+ * @name Reader#int64
177
+ * @function
178
+ * @returns {Long} Value read
179
+ */
180
+
181
+ /*
182
+ * Reads a varint as an unsigned 64 bit value.
183
+ * @name Reader#uint64
184
+ * @function
185
+ * @returns {Long} Value read
186
+ */
187
+
188
+ /*
189
+ * Reads a zig-zag encoded varint as a signed 64 bit value.
190
+ * @name Reader#sint64
191
+ * @function
192
+ * @returns {Long} Value read
193
+ */
194
+
195
+ /**
196
+ * Reads a varint as a boolean.
197
+ * @returns {boolean} Value read
198
+ */
199
+ Reader.prototype.bool = function read_bool() {
200
+ return this.uint32() !== 0;
201
+ };
202
+
203
+ function readFixed32_end(buf, end) { // note that this uses `end`, not `pos`
204
+ return (buf[end - 4]
205
+ | buf[end - 3] << 8
206
+ | buf[end - 2] << 16
207
+ | buf[end - 1] << 24) >>> 0;
208
+ }
209
+
210
+ /**
211
+ * Reads fixed 32 bits as an unsigned 32 bit integer.
212
+ * @returns {number} Value read
213
+ */
214
+ Reader.prototype.fixed32 = function read_fixed32() {
215
+
216
+ /* istanbul ignore if */
217
+ if (this.pos + 4 > this.len)
218
+ throw indexOutOfRange(this, 4);
219
+
220
+ return readFixed32_end(this.buf, this.pos += 4);
221
+ };
222
+
223
+ /**
224
+ * Reads fixed 32 bits as a signed 32 bit integer.
225
+ * @returns {number} Value read
226
+ */
227
+ Reader.prototype.sfixed32 = function read_sfixed32() {
228
+
229
+ /* istanbul ignore if */
230
+ if (this.pos + 4 > this.len)
231
+ throw indexOutOfRange(this, 4);
232
+
233
+ return readFixed32_end(this.buf, this.pos += 4) | 0;
234
+ };
235
+
236
+ /* eslint-disable no-invalid-this */
237
+
238
+ function readFixed64(/* this: Reader */) {
239
+
240
+ /* istanbul ignore if */
241
+ if (this.pos + 8 > this.len)
242
+ throw indexOutOfRange(this, 8);
243
+
244
+ return new LongBits(readFixed32_end(this.buf, this.pos += 4), readFixed32_end(this.buf, this.pos += 4));
245
+ }
246
+
247
+ /* eslint-enable no-invalid-this */
248
+
249
+ /*
250
+ * Reads fixed 64 bits.
251
+ * @name Reader#fixed64
252
+ * @function
253
+ * @returns {Long} Value read
254
+ */
255
+
256
+ /*
257
+ * Reads zig-zag encoded fixed 64 bits.
258
+ * @name Reader#sfixed64
259
+ * @function
260
+ * @returns {Long} Value read
261
+ */
262
+
263
+ /**
264
+ * Reads a float (32 bit) as a number.
265
+ * @function
266
+ * @returns {number} Value read
267
+ */
268
+ Reader.prototype.float = function read_float() {
269
+
270
+ /* istanbul ignore if */
271
+ if (this.pos + 4 > this.len)
272
+ throw indexOutOfRange(this, 4);
273
+
274
+ var value = util.float.readFloatLE(this.buf, this.pos);
275
+ this.pos += 4;
276
+ return value;
277
+ };
278
+
279
+ /**
280
+ * Reads a double (64 bit float) as a number.
281
+ * @function
282
+ * @returns {number} Value read
283
+ */
284
+ Reader.prototype.double = function read_double() {
285
+
286
+ /* istanbul ignore if */
287
+ if (this.pos + 8 > this.len)
288
+ throw indexOutOfRange(this, 4);
289
+
290
+ var value = util.float.readDoubleLE(this.buf, this.pos);
291
+ this.pos += 8;
292
+ return value;
293
+ };
294
+
295
+ /**
296
+ * Reads a sequence of bytes preceeded by its length as a varint.
297
+ * @returns {Uint8Array} Value read
298
+ */
299
+ Reader.prototype.bytes = function read_bytes() {
300
+ var length = this.uint32(),
301
+ start = this.pos,
302
+ end = this.pos + length;
303
+
304
+ /* istanbul ignore if */
305
+ if (end > this.len)
306
+ throw indexOutOfRange(this, length);
307
+
308
+ this.pos += length;
309
+ if (Array.isArray(this.buf)) // plain array
310
+ return this.buf.slice(start, end);
311
+ return start === end // fix for IE 10/Win8 and others' subarray returning array of size 1
312
+ ? new this.buf.constructor(0)
313
+ : this._slice.call(this.buf, start, end);
314
+ };
315
+
316
+ /**
317
+ * Reads a string preceeded by its byte length as a varint.
318
+ * @returns {string} Value read
319
+ */
320
+ Reader.prototype.string = function read_string() {
321
+ var bytes = this.bytes();
322
+ return utf8.read(bytes, 0, bytes.length);
323
+ };
324
+
325
+ /**
326
+ * Skips the specified number of bytes if specified, otherwise skips a varint.
327
+ * @param {number} [length] Length if known, otherwise a varint is assumed
328
+ * @returns {Reader} `this`
329
+ */
330
+ Reader.prototype.skip = function skip(length) {
331
+ if (typeof length === "number") {
332
+ /* istanbul ignore if */
333
+ if (this.pos + length > this.len)
334
+ throw indexOutOfRange(this, length);
335
+ this.pos += length;
336
+ } else {
337
+ do {
338
+ /* istanbul ignore if */
339
+ if (this.pos >= this.len)
340
+ throw indexOutOfRange(this);
341
+ } while (this.buf[this.pos++] & 128);
342
+ }
343
+ return this;
344
+ };
345
+
346
+ /**
347
+ * Skips the next element of the specified wire type.
348
+ * @param {number} wireType Wire type received
349
+ * @returns {Reader} `this`
350
+ */
351
+ Reader.prototype.skipType = function(wireType) {
352
+ switch (wireType) {
353
+ case 0:
354
+ this.skip();
355
+ break;
356
+ case 1:
357
+ this.skip(8);
358
+ break;
359
+ case 2:
360
+ this.skip(this.uint32());
361
+ break;
362
+ case 3:
363
+ while ((wireType = this.uint32() & 7) !== 4) {
364
+ this.skipType(wireType);
365
+ }
366
+ break;
367
+ case 5:
368
+ this.skip(4);
369
+ break;
370
+
371
+ /* istanbul ignore next */
372
+ default:
373
+ throw Error("invalid wire type " + wireType + " at offset " + this.pos);
374
+ }
375
+ return this;
376
+ };
377
+
378
+ Reader._configure = function(BufferReader_) {
379
+ BufferReader = BufferReader_;
380
+
381
+ var fn = util.Long ? "toLong" : /* istanbul ignore next */ "toNumber";
382
+ util.merge(Reader.prototype, {
383
+
384
+ int64: function read_int64() {
385
+ return readLongVarint.call(this)[fn](false);
386
+ },
387
+
388
+ uint64: function read_uint64() {
389
+ return readLongVarint.call(this)[fn](true);
390
+ },
391
+
392
+ sint64: function read_sint64() {
393
+ return readLongVarint.call(this).zzDecode()[fn](false);
394
+ },
395
+
396
+ fixed64: function read_fixed64() {
397
+ return readFixed64.call(this)[fn](true);
398
+ },
399
+
400
+ sfixed64: function read_sfixed64() {
401
+ return readFixed64.call(this)[fn](false);
402
+ }
403
+
404
+ });
405
+ };
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ module.exports = BufferReader;
3
+
4
+ // extends Reader
5
+ var Reader = require("./reader");
6
+ (BufferReader.prototype = Object.create(Reader.prototype)).constructor = BufferReader;
7
+
8
+ var util = require("./util/minimal");
9
+
10
+ /**
11
+ * Constructs a new buffer reader instance.
12
+ * @classdesc Wire format reader using node buffers.
13
+ * @extends Reader
14
+ * @constructor
15
+ * @param {Buffer} buffer Buffer to read from
16
+ */
17
+ function BufferReader(buffer) {
18
+ Reader.call(this, buffer);
19
+
20
+ /**
21
+ * Read buffer.
22
+ * @name BufferReader#buf
23
+ * @type {Buffer}
24
+ */
25
+ }
26
+
27
+ /* istanbul ignore else */
28
+ if (util.Buffer)
29
+ BufferReader.prototype._slice = util.Buffer.prototype.slice;
30
+
31
+ /**
32
+ * @override
33
+ */
34
+ BufferReader.prototype.string = function read_string_buffer() {
35
+ var len = this.uint32(); // modifies pos
36
+ return this.buf.utf8Slice(this.pos, this.pos = Math.min(this.pos + len, this.len));
37
+ };
38
+
39
+ /**
40
+ * Reads a sequence of bytes preceeded by its length as a varint.
41
+ * @name BufferReader#bytes
42
+ * @function
43
+ * @returns {Buffer} Value read
44
+ */