protobufjs 8.6.1 → 8.6.3
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/README.md +2 -2
- package/dist/light/protobuf.js +184 -63
- package/dist/light/protobuf.js.map +1 -1
- package/dist/light/protobuf.min.js +3 -3
- package/dist/light/protobuf.min.js.map +1 -1
- package/dist/minimal/protobuf.js +87 -22
- package/dist/minimal/protobuf.js.map +1 -1
- package/dist/minimal/protobuf.min.js +3 -3
- package/dist/minimal/protobuf.min.js.map +1 -1
- package/dist/protobuf.js +192 -71
- package/dist/protobuf.js.map +1 -1
- package/dist/protobuf.min.js +3 -3
- package/dist/protobuf.min.js.map +1 -1
- package/index.d.ts +31 -1
- package/package.json +1 -1
- package/src/common.js +2 -2
- package/src/decoder.js +11 -5
- package/src/index-light.js +29 -29
- package/src/index-minimal.js +12 -13
- package/src/index.js +6 -6
- package/src/message.js +1 -1
- package/src/namespace.js +2 -1
- package/src/reader.js +21 -6
- package/src/type.js +3 -4
- package/src/util/path.js +29 -1
- package/src/util/utf8.js +52 -1
- package/src/util.js +22 -0
package/dist/minimal/protobuf.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* protobuf.js v8.6.
|
|
3
|
-
* compiled
|
|
2
|
+
* protobuf.js v8.6.3 (c) 2016, daniel wirtz
|
|
3
|
+
* compiled thu, 11 jun 2026 00:02:30 utc
|
|
4
4
|
* licensed under the bsd-3-clause license
|
|
5
5
|
* see: https://github.com/dcodeio/protobuf.js for details
|
|
6
6
|
*/
|
|
@@ -39,7 +39,6 @@
|
|
|
39
39
|
|
|
40
40
|
})/* end of prelude */({1:[function(require,module,exports){
|
|
41
41
|
"use strict";
|
|
42
|
-
var protobuf = exports;
|
|
43
42
|
|
|
44
43
|
/**
|
|
45
44
|
* Build type, one of `"full"`, `"light"` or `"minimal"`.
|
|
@@ -47,19 +46,19 @@ var protobuf = exports;
|
|
|
47
46
|
* @type {string}
|
|
48
47
|
* @const
|
|
49
48
|
*/
|
|
50
|
-
|
|
49
|
+
exports.build = "minimal";
|
|
51
50
|
|
|
52
51
|
// Serialization
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
52
|
+
exports.Writer = require(15);
|
|
53
|
+
exports.BufferWriter = require(16);
|
|
54
|
+
exports.Reader = require(2);
|
|
55
|
+
exports.BufferReader = require(3);
|
|
57
56
|
|
|
58
57
|
// Utility
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
58
|
+
exports.util = require(12);
|
|
59
|
+
exports.rpc = require(5);
|
|
60
|
+
exports.roots = require(4);
|
|
61
|
+
exports.configure = configure;
|
|
63
62
|
|
|
64
63
|
/* istanbul ignore next */
|
|
65
64
|
/**
|
|
@@ -67,9 +66,9 @@ protobuf.configure = configure;
|
|
|
67
66
|
* @returns {undefined}
|
|
68
67
|
*/
|
|
69
68
|
function configure() {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
69
|
+
exports.util._configure();
|
|
70
|
+
exports.Writer._configure(exports.BufferWriter);
|
|
71
|
+
exports.Reader._configure(exports.BufferReader);
|
|
73
72
|
}
|
|
74
73
|
|
|
75
74
|
// Set up buffer utility according to the environment
|
|
@@ -302,18 +301,16 @@ function readLongVarint() {
|
|
|
302
301
|
return bits;
|
|
303
302
|
i = 0;
|
|
304
303
|
} else {
|
|
305
|
-
for (; i <
|
|
304
|
+
for (; i < 4; ++i) {
|
|
306
305
|
/* istanbul ignore if */
|
|
307
306
|
if (this.pos >= this.len)
|
|
308
307
|
throw indexOutOfRange(this);
|
|
309
|
-
// 1st..
|
|
308
|
+
// 1st..4th
|
|
310
309
|
bits.lo = (bits.lo | (this.buf[this.pos] & 127) << i * 7) >>> 0;
|
|
311
310
|
if (this.buf[this.pos++] < 128)
|
|
312
311
|
return bits;
|
|
313
312
|
}
|
|
314
|
-
|
|
315
|
-
bits.lo = (bits.lo | (this.buf[this.pos++] & 127) << i * 7) >>> 0;
|
|
316
|
-
return bits;
|
|
313
|
+
throw indexOutOfRange(this);
|
|
317
314
|
}
|
|
318
315
|
if (this.len - this.pos > 4) { // fast route (hi)
|
|
319
316
|
for (; i < 5; ++i) {
|
|
@@ -507,6 +504,23 @@ Reader.prototype.string = function read_string() {
|
|
|
507
504
|
return utf8.read(this.buf, start, end);
|
|
508
505
|
};
|
|
509
506
|
|
|
507
|
+
/**
|
|
508
|
+
* Reads a string preceeded by its byte length as a varint, rejecting invalid UTF8.
|
|
509
|
+
* @returns {string} Value read
|
|
510
|
+
*/
|
|
511
|
+
Reader.prototype.stringVerify = function read_string_verify() {
|
|
512
|
+
var length = this.uint32(),
|
|
513
|
+
start = this.pos,
|
|
514
|
+
end = this.pos + length;
|
|
515
|
+
|
|
516
|
+
/* istanbul ignore if */
|
|
517
|
+
if (end > this.len)
|
|
518
|
+
throw indexOutOfRange(this, length);
|
|
519
|
+
|
|
520
|
+
this.pos = end;
|
|
521
|
+
return utf8.readStrict(this.buf, start, end);
|
|
522
|
+
};
|
|
523
|
+
|
|
510
524
|
/**
|
|
511
525
|
* Skips the specified number of bytes if specified, otherwise skips a varint.
|
|
512
526
|
* @param {number} [length] Length if known, otherwise a varint is assumed
|
|
@@ -538,7 +552,7 @@ Reader.recursionLimit = util.recursionLimit;
|
|
|
538
552
|
* Whether readers discard unknown fields while decoding.
|
|
539
553
|
* @type {boolean}
|
|
540
554
|
*/
|
|
541
|
-
Reader.discardUnknown =
|
|
555
|
+
Reader.discardUnknown = true;
|
|
542
556
|
|
|
543
557
|
/**
|
|
544
558
|
* Skips the next element of the specified wire type.
|
|
@@ -2307,7 +2321,8 @@ function pool(alloc, slice, size) {
|
|
|
2307
2321
|
* @namespace
|
|
2308
2322
|
*/
|
|
2309
2323
|
var utf8 = exports,
|
|
2310
|
-
replacementChar = "\ufffd"
|
|
2324
|
+
replacementChar = "\ufffd",
|
|
2325
|
+
strictDecoder = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true });
|
|
2311
2326
|
|
|
2312
2327
|
/**
|
|
2313
2328
|
* Calculates the UTF8 byte length of a string.
|
|
@@ -2396,6 +2411,56 @@ utf8.read = function utf8_read_ascii(buffer, start, end) {
|
|
|
2396
2411
|
return str;
|
|
2397
2412
|
};
|
|
2398
2413
|
|
|
2414
|
+
function utf8_read_strict(buffer, start, end) {
|
|
2415
|
+
var source = start === 0 && end === buffer.length
|
|
2416
|
+
? buffer
|
|
2417
|
+
: buffer.subarray
|
|
2418
|
+
? buffer.subarray(start, end)
|
|
2419
|
+
: buffer.slice(start, end);
|
|
2420
|
+
if (Array.isArray(source))
|
|
2421
|
+
source = Uint8Array.from(source);
|
|
2422
|
+
return strictDecoder.decode(source);
|
|
2423
|
+
}
|
|
2424
|
+
|
|
2425
|
+
/**
|
|
2426
|
+
* Reads UTF8 bytes as a string, rejecting invalid UTF8.
|
|
2427
|
+
* @param {Uint8Array} buffer Source buffer
|
|
2428
|
+
* @param {number} start Source start
|
|
2429
|
+
* @param {number} end Source end
|
|
2430
|
+
* @returns {string} String read
|
|
2431
|
+
*/
|
|
2432
|
+
utf8.readStrict = function utf8_read_strict_ascii(buffer, start, end) {
|
|
2433
|
+
if (end - start < 1)
|
|
2434
|
+
return "";
|
|
2435
|
+
|
|
2436
|
+
var str = "",
|
|
2437
|
+
i = start,
|
|
2438
|
+
c1, c2, c3, c4, c5, c6, c7, c8;
|
|
2439
|
+
|
|
2440
|
+
for (; i + 7 < end; i += 8) {
|
|
2441
|
+
c1 = buffer[i];
|
|
2442
|
+
c2 = buffer[i + 1];
|
|
2443
|
+
c3 = buffer[i + 2];
|
|
2444
|
+
c4 = buffer[i + 3];
|
|
2445
|
+
c5 = buffer[i + 4];
|
|
2446
|
+
c6 = buffer[i + 5];
|
|
2447
|
+
c7 = buffer[i + 6];
|
|
2448
|
+
c8 = buffer[i + 7];
|
|
2449
|
+
if ((c1 | c2 | c3 | c4 | c5 | c6 | c7 | c8) & 0x80)
|
|
2450
|
+
return str + utf8_read_strict(buffer, i, end);
|
|
2451
|
+
str += String.fromCharCode(c1, c2, c3, c4, c5, c6, c7, c8);
|
|
2452
|
+
}
|
|
2453
|
+
|
|
2454
|
+
for (; i < end; ++i) {
|
|
2455
|
+
c1 = buffer[i];
|
|
2456
|
+
if (c1 & 0x80)
|
|
2457
|
+
return str + utf8_read_strict(buffer, i, end);
|
|
2458
|
+
str += String.fromCharCode(c1);
|
|
2459
|
+
}
|
|
2460
|
+
|
|
2461
|
+
return str;
|
|
2462
|
+
};
|
|
2463
|
+
|
|
2399
2464
|
/**
|
|
2400
2465
|
* Writes a string as UTF8 bytes.
|
|
2401
2466
|
* @param {string} string Source string
|