protobufjs 6.11.3 → 7.0.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.
- package/README.md +7 -174
- package/dist/light/protobuf.js +40 -16
- 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 +27 -10
- 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 +109 -46
- 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 +1 -4
- package/package.json +9 -28
- package/scripts/postinstall.js +0 -3
- package/src/converter.js +1 -1
- package/src/decoder.js +4 -3
- package/src/field.js +6 -3
- package/src/namespace.js +1 -2
- package/src/parse.js +38 -14
- package/src/roots.js +1 -1
- package/src/tokenize.js +31 -16
- package/src/util/minimal.js +24 -7
- package/src/wrappers.js +2 -2
- package/CHANGELOG.md +0 -1027
- package/bin/pbjs +0 -6
- package/bin/pbts +0 -6
- package/cli/LICENSE +0 -33
- package/cli/README.md +0 -174
- package/cli/bin/pbjs +0 -6
- package/cli/bin/pbts +0 -6
- package/cli/index.d.ts +0 -3
- package/cli/index.js +0 -3
- package/cli/lib/tsd-jsdoc/LICENSE +0 -21
- package/cli/lib/tsd-jsdoc/README.md +0 -23
- package/cli/lib/tsd-jsdoc/plugin.js +0 -21
- package/cli/lib/tsd-jsdoc/publish.js +0 -705
- package/cli/lib/tsd-jsdoc.json +0 -18
- package/cli/package.json +0 -8
- package/cli/package.standalone.json +0 -32
- package/cli/pbjs.d.ts +0 -9
- package/cli/pbjs.js +0 -330
- package/cli/pbts.d.ts +0 -9
- package/cli/pbts.js +0 -197
- package/cli/targets/json-module.js +0 -38
- package/cli/targets/json.js +0 -8
- package/cli/targets/proto.js +0 -326
- package/cli/targets/proto2.js +0 -10
- package/cli/targets/proto3.js +0 -10
- package/cli/targets/static-module.js +0 -29
- package/cli/targets/static.js +0 -711
- package/cli/util.js +0 -183
- package/cli/wrappers/amd.js +0 -7
- package/cli/wrappers/closure.js +0 -7
- package/cli/wrappers/commonjs.js +0 -7
- package/cli/wrappers/default.js +0 -15
- package/cli/wrappers/es6.js +0 -5
- package/package-lock.json +0 -7870
- package/scripts/changelog.js +0 -150
package/dist/protobuf.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* protobuf.js v6.
|
|
3
|
-
* compiled
|
|
2
|
+
* protobuf.js v6.10.2 (c) 2016, daniel wirtz
|
|
3
|
+
* compiled fri, 08 jul 2022 16:17:13 utc
|
|
4
4
|
* licensed under the bsd-3-clause license
|
|
5
5
|
* see: https://github.com/dcodeio/protobuf.js for details
|
|
6
6
|
*/
|
|
@@ -1583,7 +1583,7 @@ function genValuePartial_fromObject(gen, field, fieldIndex, prop) {
|
|
|
1583
1583
|
case "bytes": gen
|
|
1584
1584
|
("if(typeof d%s===\"string\")", prop)
|
|
1585
1585
|
("util.base64.decode(d%s,m%s=util.newBuffer(util.base64.length(d%s)),0)", prop, prop, prop)
|
|
1586
|
-
("else if(d%s.length)", prop)
|
|
1586
|
+
("else if(d%s.length >= 0)", prop)
|
|
1587
1587
|
("m%s=d%s", prop, prop);
|
|
1588
1588
|
break;
|
|
1589
1589
|
case "string": gen
|
|
@@ -1840,7 +1840,7 @@ function decoder(mtype) {
|
|
|
1840
1840
|
var field = mtype._fieldsArray[i].resolve(),
|
|
1841
1841
|
type = field.resolvedType instanceof Enum ? "int32" : field.type,
|
|
1842
1842
|
ref = "m" + util.safeProp(field.name); gen
|
|
1843
|
-
("case %i:", field.id);
|
|
1843
|
+
("case %i: {", field.id);
|
|
1844
1844
|
|
|
1845
1845
|
// Map fields
|
|
1846
1846
|
if (field.map) { gen
|
|
@@ -1911,8 +1911,9 @@ function decoder(mtype) {
|
|
|
1911
1911
|
else gen
|
|
1912
1912
|
("%s=r.%s()", ref, type);
|
|
1913
1913
|
gen
|
|
1914
|
-
("break")
|
|
1915
|
-
|
|
1914
|
+
("break")
|
|
1915
|
+
("}");
|
|
1916
|
+
// Unknown fields
|
|
1916
1917
|
} gen
|
|
1917
1918
|
("default:")
|
|
1918
1919
|
("r.skipType(t&7)")
|
|
@@ -2492,6 +2493,9 @@ Field.prototype.resolve = function resolve() {
|
|
|
2492
2493
|
this.typeDefault = null;
|
|
2493
2494
|
else // instanceof Enum
|
|
2494
2495
|
this.typeDefault = this.resolvedType.values[Object.keys(this.resolvedType.values)[0]]; // first defined
|
|
2496
|
+
} else if (this.options && this.options.proto3_optional) {
|
|
2497
|
+
// proto3 scalar value marked optional; should default to null
|
|
2498
|
+
this.typeDefault = null;
|
|
2495
2499
|
}
|
|
2496
2500
|
|
|
2497
2501
|
// use explicitly set default value if present
|
|
@@ -4647,7 +4651,7 @@ function parse(source, root, options) {
|
|
|
4647
4651
|
option = name;
|
|
4648
4652
|
token = peek();
|
|
4649
4653
|
if (fqTypeRefRe.test(token)) {
|
|
4650
|
-
propName = token.
|
|
4654
|
+
propName = token.slice(1); //remove '.' before property name
|
|
4651
4655
|
name += token;
|
|
4652
4656
|
next();
|
|
4653
4657
|
}
|
|
@@ -4658,33 +4662,57 @@ function parse(source, root, options) {
|
|
|
4658
4662
|
}
|
|
4659
4663
|
|
|
4660
4664
|
function parseOptionValue(parent, name) {
|
|
4661
|
-
|
|
4662
|
-
|
|
4665
|
+
// { a: "foo" b { c: "bar" } }
|
|
4666
|
+
if (skip("{", true)) {
|
|
4667
|
+
var objectResult = {};
|
|
4668
|
+
|
|
4663
4669
|
while (!skip("}", true)) {
|
|
4664
4670
|
/* istanbul ignore if */
|
|
4665
|
-
if (!nameRe.test(token = next()))
|
|
4671
|
+
if (!nameRe.test(token = next())) {
|
|
4666
4672
|
throw illegal(token, "name");
|
|
4673
|
+
}
|
|
4667
4674
|
|
|
4668
4675
|
var value;
|
|
4669
4676
|
var propName = token;
|
|
4677
|
+
|
|
4678
|
+
skip(":", true);
|
|
4679
|
+
|
|
4670
4680
|
if (peek() === "{")
|
|
4671
4681
|
value = parseOptionValue(parent, name + "." + token);
|
|
4672
|
-
else {
|
|
4673
|
-
|
|
4674
|
-
|
|
4675
|
-
|
|
4676
|
-
|
|
4677
|
-
|
|
4678
|
-
|
|
4682
|
+
else if (peek() === "[") {
|
|
4683
|
+
// option (my_option) = {
|
|
4684
|
+
// repeated_value: [ "foo", "bar" ]
|
|
4685
|
+
// };
|
|
4686
|
+
value = [];
|
|
4687
|
+
var lastValue;
|
|
4688
|
+
if (skip("[", true)) {
|
|
4689
|
+
do {
|
|
4690
|
+
lastValue = readValue(true);
|
|
4691
|
+
value.push(lastValue);
|
|
4692
|
+
} while (skip(",", true));
|
|
4693
|
+
skip("]");
|
|
4694
|
+
if (typeof lastValue !== "undefined") {
|
|
4695
|
+
setOption(parent, name + "." + token, lastValue);
|
|
4696
|
+
}
|
|
4679
4697
|
}
|
|
4698
|
+
} else {
|
|
4699
|
+
value = readValue(true);
|
|
4700
|
+
setOption(parent, name + "." + token, value);
|
|
4680
4701
|
}
|
|
4681
|
-
|
|
4702
|
+
|
|
4703
|
+
var prevValue = objectResult[propName];
|
|
4704
|
+
|
|
4682
4705
|
if (prevValue)
|
|
4683
4706
|
value = [].concat(prevValue).concat(value);
|
|
4684
|
-
|
|
4707
|
+
|
|
4708
|
+
objectResult[propName] = value;
|
|
4709
|
+
|
|
4710
|
+
// Semicolons and commas can be optional
|
|
4685
4711
|
skip(",", true);
|
|
4712
|
+
skip(";", true);
|
|
4686
4713
|
}
|
|
4687
|
-
|
|
4714
|
+
|
|
4715
|
+
return objectResult;
|
|
4688
4716
|
}
|
|
4689
4717
|
|
|
4690
4718
|
var simpleValue = readValue(true);
|
|
@@ -5728,7 +5756,7 @@ module.exports = {};
|
|
|
5728
5756
|
/**
|
|
5729
5757
|
* Named roots.
|
|
5730
5758
|
* This is where pbjs stores generated structures (the option `-r, --root` specifies a name).
|
|
5731
|
-
* Can also be used manually to make roots available
|
|
5759
|
+
* Can also be used manually to make roots available across modules.
|
|
5732
5760
|
* @name roots
|
|
5733
5761
|
* @type {Object.<string,Root>}
|
|
5734
5762
|
* @example
|
|
@@ -6198,11 +6226,8 @@ function tokenize(source, alternateCommentMode) {
|
|
|
6198
6226
|
var offset = 0,
|
|
6199
6227
|
length = source.length,
|
|
6200
6228
|
line = 1,
|
|
6201
|
-
|
|
6202
|
-
|
|
6203
|
-
commentLine = 0,
|
|
6204
|
-
commentLineEmpty = false,
|
|
6205
|
-
commentIsLeading = false;
|
|
6229
|
+
lastCommentLine = 0,
|
|
6230
|
+
comments = {};
|
|
6206
6231
|
|
|
6207
6232
|
var stack = [];
|
|
6208
6233
|
|
|
@@ -6255,10 +6280,11 @@ function tokenize(source, alternateCommentMode) {
|
|
|
6255
6280
|
* @inner
|
|
6256
6281
|
*/
|
|
6257
6282
|
function setComment(start, end, isLeading) {
|
|
6258
|
-
|
|
6259
|
-
|
|
6260
|
-
|
|
6261
|
-
|
|
6283
|
+
var comment = {
|
|
6284
|
+
type: source.charAt(start++),
|
|
6285
|
+
lineEmpty: false,
|
|
6286
|
+
leading: isLeading,
|
|
6287
|
+
};
|
|
6262
6288
|
var lookback;
|
|
6263
6289
|
if (alternateCommentMode) {
|
|
6264
6290
|
lookback = 2; // alternate comment parsing: "//" or "/*"
|
|
@@ -6270,7 +6296,7 @@ function tokenize(source, alternateCommentMode) {
|
|
|
6270
6296
|
do {
|
|
6271
6297
|
if (--commentOffset < 0 ||
|
|
6272
6298
|
(c = source.charAt(commentOffset)) === "\n") {
|
|
6273
|
-
|
|
6299
|
+
comment.lineEmpty = true;
|
|
6274
6300
|
break;
|
|
6275
6301
|
}
|
|
6276
6302
|
} while (c === " " || c === "\t");
|
|
@@ -6281,9 +6307,12 @@ function tokenize(source, alternateCommentMode) {
|
|
|
6281
6307
|
lines[i] = lines[i]
|
|
6282
6308
|
.replace(alternateCommentMode ? setCommentAltRe : setCommentRe, "")
|
|
6283
6309
|
.trim();
|
|
6284
|
-
|
|
6310
|
+
comment.text = lines
|
|
6285
6311
|
.join("\n")
|
|
6286
6312
|
.trim();
|
|
6313
|
+
|
|
6314
|
+
comments[line] = comment;
|
|
6315
|
+
lastCommentLine = line;
|
|
6287
6316
|
}
|
|
6288
6317
|
|
|
6289
6318
|
function isDoubleSlashCommentLine(startOffset) {
|
|
@@ -6352,6 +6381,9 @@ function tokenize(source, alternateCommentMode) {
|
|
|
6352
6381
|
++offset;
|
|
6353
6382
|
if (isDoc) {
|
|
6354
6383
|
setComment(start, offset - 1, isLeadingComment);
|
|
6384
|
+
// Trailing comment cannot not be multi-line,
|
|
6385
|
+
// so leading comment state should be reset to handle potential next comments
|
|
6386
|
+
isLeadingComment = true;
|
|
6355
6387
|
}
|
|
6356
6388
|
++line;
|
|
6357
6389
|
repeat = true;
|
|
@@ -6367,12 +6399,17 @@ function tokenize(source, alternateCommentMode) {
|
|
|
6367
6399
|
break;
|
|
6368
6400
|
}
|
|
6369
6401
|
offset++;
|
|
6402
|
+
if (!isLeadingComment) {
|
|
6403
|
+
// Trailing comment cannot not be multi-line
|
|
6404
|
+
break;
|
|
6405
|
+
}
|
|
6370
6406
|
} while (isDoubleSlashCommentLine(offset));
|
|
6371
6407
|
} else {
|
|
6372
6408
|
offset = Math.min(length, findEndOfLine(offset) + 1);
|
|
6373
6409
|
}
|
|
6374
6410
|
if (isDoc) {
|
|
6375
6411
|
setComment(start, offset, isLeadingComment);
|
|
6412
|
+
isLeadingComment = true;
|
|
6376
6413
|
}
|
|
6377
6414
|
line++;
|
|
6378
6415
|
repeat = true;
|
|
@@ -6394,6 +6431,7 @@ function tokenize(source, alternateCommentMode) {
|
|
|
6394
6431
|
++offset;
|
|
6395
6432
|
if (isDoc) {
|
|
6396
6433
|
setComment(start, offset - 2, isLeadingComment);
|
|
6434
|
+
isLeadingComment = true;
|
|
6397
6435
|
}
|
|
6398
6436
|
repeat = true;
|
|
6399
6437
|
} else {
|
|
@@ -6469,17 +6507,22 @@ function tokenize(source, alternateCommentMode) {
|
|
|
6469
6507
|
*/
|
|
6470
6508
|
function cmnt(trailingLine) {
|
|
6471
6509
|
var ret = null;
|
|
6510
|
+
var comment;
|
|
6472
6511
|
if (trailingLine === undefined) {
|
|
6473
|
-
|
|
6474
|
-
|
|
6512
|
+
comment = comments[line - 1];
|
|
6513
|
+
delete comments[line - 1];
|
|
6514
|
+
if (comment && (alternateCommentMode || comment.type === "*" || comment.lineEmpty)) {
|
|
6515
|
+
ret = comment.leading ? comment.text : null;
|
|
6475
6516
|
}
|
|
6476
6517
|
} else {
|
|
6477
6518
|
/* istanbul ignore else */
|
|
6478
|
-
if (
|
|
6519
|
+
if (lastCommentLine < trailingLine) {
|
|
6479
6520
|
peek();
|
|
6480
6521
|
}
|
|
6481
|
-
|
|
6482
|
-
|
|
6522
|
+
comment = comments[trailingLine];
|
|
6523
|
+
delete comments[trailingLine];
|
|
6524
|
+
if (comment && !comment.lineEmpty && (alternateCommentMode || comment.type === "/")) {
|
|
6525
|
+
ret = comment.leading ? null : comment.text;
|
|
6483
6526
|
}
|
|
6484
6527
|
}
|
|
6485
6528
|
return ret;
|
|
@@ -7465,6 +7508,9 @@ util.decorateEnum = function decorateEnum(object) {
|
|
|
7465
7508
|
util.setProperty = function setProperty(dst, path, value) {
|
|
7466
7509
|
function setProp(dst, path, value) {
|
|
7467
7510
|
var part = path.shift();
|
|
7511
|
+
if (part === "__proto__") {
|
|
7512
|
+
return dst;
|
|
7513
|
+
}
|
|
7468
7514
|
if (path.length > 0) {
|
|
7469
7515
|
dst[part] = setProp(dst[part] || {}, path, value);
|
|
7470
7516
|
} else {
|
|
@@ -7982,13 +8028,30 @@ function newError(name) {
|
|
|
7982
8028
|
merge(this, properties);
|
|
7983
8029
|
}
|
|
7984
8030
|
|
|
7985
|
-
|
|
7986
|
-
|
|
7987
|
-
|
|
7988
|
-
|
|
7989
|
-
|
|
7990
|
-
|
|
7991
|
-
|
|
8031
|
+
CustomError.prototype = Object.create(Error.prototype, {
|
|
8032
|
+
constructor: {
|
|
8033
|
+
value: CustomError,
|
|
8034
|
+
writable: true,
|
|
8035
|
+
enumerable: false,
|
|
8036
|
+
configurable: true,
|
|
8037
|
+
},
|
|
8038
|
+
name: {
|
|
8039
|
+
get() { return name; },
|
|
8040
|
+
set: undefined,
|
|
8041
|
+
enumerable: false,
|
|
8042
|
+
// configurable: false would accurately preserve the behavior of
|
|
8043
|
+
// the original, but I'm guessing that was not intentional.
|
|
8044
|
+
// For an actual error subclass, this property would
|
|
8045
|
+
// be configurable.
|
|
8046
|
+
configurable: true,
|
|
8047
|
+
},
|
|
8048
|
+
toString: {
|
|
8049
|
+
value() { return this.name + ": " + this.message; },
|
|
8050
|
+
writable: true,
|
|
8051
|
+
enumerable: false,
|
|
8052
|
+
configurable: true,
|
|
8053
|
+
},
|
|
8054
|
+
});
|
|
7992
8055
|
|
|
7993
8056
|
return CustomError;
|
|
7994
8057
|
}
|
|
@@ -8352,7 +8415,7 @@ wrappers[".google.protobuf.Any"] = {
|
|
|
8352
8415
|
if (type) {
|
|
8353
8416
|
// type_url does not accept leading "."
|
|
8354
8417
|
var type_url = object["@type"].charAt(0) === "." ?
|
|
8355
|
-
object["@type"].
|
|
8418
|
+
object["@type"].slice(1) : object["@type"];
|
|
8356
8419
|
// type_url prefix is optional, but path seperator is required
|
|
8357
8420
|
if (type_url.indexOf("/") === -1) {
|
|
8358
8421
|
type_url = "/" + type_url;
|
|
@@ -8390,7 +8453,7 @@ wrappers[".google.protobuf.Any"] = {
|
|
|
8390
8453
|
if (!(message instanceof this.ctor) && message instanceof Message) {
|
|
8391
8454
|
var object = message.$type.toObject(message, options);
|
|
8392
8455
|
var messageName = message.$type.fullName[0] === "." ?
|
|
8393
|
-
message.$type.fullName.
|
|
8456
|
+
message.$type.fullName.slice(1) : message.$type.fullName;
|
|
8394
8457
|
// Default to type.googleapis.com prefix if no prefix is used
|
|
8395
8458
|
if (prefix === "") {
|
|
8396
8459
|
prefix = googleApi;
|