protobufjs 8.7.0 → 8.7.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/README.md +62 -85
- package/dist/light/protobuf.js +80 -54
- 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 +59 -47
- 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 +162 -99
- package/dist/protobuf.js.map +1 -1
- package/dist/protobuf.min.js +3 -3
- package/dist/protobuf.min.js.map +1 -1
- package/ext/descriptor.js +26 -10
- package/ext/protojson.js +5 -1
- package/google/api/annotations.json +3 -1
- package/google/api/http.json +2 -1
- package/google/protobuf/api.json +12 -6
- package/google/protobuf/descriptor.json +170 -87
- package/google/protobuf/descriptor.proto +0 -8
- package/google/protobuf/source_context.json +2 -1
- package/google/protobuf/type.json +14 -7
- package/index.d.ts +3 -0
- package/package.json +4 -4
- package/src/common.js +12 -6
- package/src/converter.js +6 -2
- package/src/decoder.js +1 -1
- package/src/enum.js +5 -2
- package/src/field.js +6 -1
- package/src/index-minimal.js +1 -0
- package/src/parse.js +70 -39
- package/src/reader.js +36 -9
- package/src/util/codegen.js +3 -1
- package/src/util/longbits.js +10 -6
- package/src/util/utf8.js +2 -28
- package/src/writer.js +7 -1
package/ext/descriptor.js
CHANGED
|
@@ -13,7 +13,7 @@ var Namespace = $protobuf.Namespace,
|
|
|
13
13
|
Method = $protobuf.Method,
|
|
14
14
|
patterns = $protobuf.util.patterns;
|
|
15
15
|
|
|
16
|
-
var
|
|
16
|
+
var integerRe = /^[+-]?[0-9]+$/,
|
|
17
17
|
typeRefRe = patterns.typeRefRe;
|
|
18
18
|
|
|
19
19
|
// --- Root ---
|
|
@@ -519,17 +519,33 @@ function Field_fromDescriptor(descriptor, ctx, nested) {
|
|
|
519
519
|
|
|
520
520
|
if (descriptor.defaultValue && descriptor.defaultValue.length) {
|
|
521
521
|
var defaultValue = descriptor.defaultValue;
|
|
522
|
-
switch (
|
|
523
|
-
case "
|
|
524
|
-
defaultValue
|
|
522
|
+
switch (fieldType) {
|
|
523
|
+
case "double": case "float":
|
|
524
|
+
switch (defaultValue.toLowerCase()) {
|
|
525
|
+
case "inf": defaultValue = Infinity; break;
|
|
526
|
+
case "-inf": defaultValue = -Infinity; break;
|
|
527
|
+
case "nan": case "-nan": defaultValue = NaN; break;
|
|
528
|
+
default:
|
|
529
|
+
defaultValue = Number(defaultValue);
|
|
530
|
+
if (Number.isNaN(defaultValue))
|
|
531
|
+
throw Error("illegal default value for " + fieldType);
|
|
532
|
+
break;
|
|
533
|
+
}
|
|
525
534
|
break;
|
|
526
|
-
case "
|
|
527
|
-
defaultValue
|
|
535
|
+
case "int32": case "uint32": case "sint32": case "fixed32": case "sfixed32":
|
|
536
|
+
if (!integerRe.test(defaultValue))
|
|
537
|
+
throw Error("illegal default value for " + fieldType);
|
|
538
|
+
defaultValue = parseInt(defaultValue, 10);
|
|
528
539
|
break;
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
540
|
+
case "int64": case "uint64": case "sint64": case "fixed64": case "sfixed64":
|
|
541
|
+
if (!integerRe.test(defaultValue))
|
|
542
|
+
throw Error("illegal default value for " + fieldType);
|
|
543
|
+
break;
|
|
544
|
+
case "bool":
|
|
545
|
+
switch (defaultValue) {
|
|
546
|
+
case "true": case "TRUE": defaultValue = true; break;
|
|
547
|
+
case "false": case "FALSE": defaultValue = false; break;
|
|
548
|
+
}
|
|
533
549
|
break;
|
|
534
550
|
}
|
|
535
551
|
field.setOption("default", defaultValue);
|
package/ext/protojson.js
CHANGED
|
@@ -295,7 +295,7 @@ function readField(field, value, options, depth) {
|
|
|
295
295
|
throw invalid(field.fullName, value, "expected array");
|
|
296
296
|
var arr = [], i = 0;
|
|
297
297
|
for (; i < value.length; ++i) {
|
|
298
|
-
if (value[i] === null && !isValueType(field.resolvedType))
|
|
298
|
+
if (value[i] === null && !isValueType(field.resolvedType) && !isNullValueType(field.resolvedType))
|
|
299
299
|
throw invalid(field.fullName, null, "null element");
|
|
300
300
|
var el = readSingular(field, value[i], options, depth);
|
|
301
301
|
if (el !== SKIP)
|
|
@@ -318,6 +318,10 @@ function isValueType(type) {
|
|
|
318
318
|
return type instanceof Type && type.fullName === ".google.protobuf.Value";
|
|
319
319
|
}
|
|
320
320
|
|
|
321
|
+
function isNullValueType(type) {
|
|
322
|
+
return type instanceof Enum && type.fullName === ".google.protobuf.NullValue";
|
|
323
|
+
}
|
|
324
|
+
|
|
321
325
|
function isImplicitDefault(field, value) {
|
|
322
326
|
if (field.hasPresence || field.repeated || field.map || field.resolvedType instanceof Type)
|
|
323
327
|
return false;
|
|
@@ -58,7 +58,8 @@
|
|
|
58
58
|
"additionalBindings": {
|
|
59
59
|
"rule": "repeated",
|
|
60
60
|
"type": "HttpRule",
|
|
61
|
-
"id": 11
|
|
61
|
+
"id": 11,
|
|
62
|
+
"protoName": "additional_bindings"
|
|
62
63
|
}
|
|
63
64
|
}
|
|
64
65
|
}
|
|
@@ -67,6 +68,7 @@
|
|
|
67
68
|
"protobuf": {
|
|
68
69
|
"nested": {
|
|
69
70
|
"MethodOptions": {
|
|
71
|
+
"edition": "proto2",
|
|
70
72
|
"fields": {},
|
|
71
73
|
"extensions": [
|
|
72
74
|
[
|
package/google/api/http.json
CHANGED
package/google/protobuf/api.json
CHANGED
|
@@ -26,7 +26,8 @@
|
|
|
26
26
|
},
|
|
27
27
|
"sourceContext": {
|
|
28
28
|
"type": "SourceContext",
|
|
29
|
-
"id": 5
|
|
29
|
+
"id": 5,
|
|
30
|
+
"protoName": "source_context"
|
|
30
31
|
},
|
|
31
32
|
"mixins": {
|
|
32
33
|
"rule": "repeated",
|
|
@@ -47,19 +48,23 @@
|
|
|
47
48
|
},
|
|
48
49
|
"requestTypeUrl": {
|
|
49
50
|
"type": "string",
|
|
50
|
-
"id": 2
|
|
51
|
+
"id": 2,
|
|
52
|
+
"protoName": "request_type_url"
|
|
51
53
|
},
|
|
52
54
|
"requestStreaming": {
|
|
53
55
|
"type": "bool",
|
|
54
|
-
"id": 3
|
|
56
|
+
"id": 3,
|
|
57
|
+
"protoName": "request_streaming"
|
|
55
58
|
},
|
|
56
59
|
"responseTypeUrl": {
|
|
57
60
|
"type": "string",
|
|
58
|
-
"id": 4
|
|
61
|
+
"id": 4,
|
|
62
|
+
"protoName": "response_type_url"
|
|
59
63
|
},
|
|
60
64
|
"responseStreaming": {
|
|
61
65
|
"type": "bool",
|
|
62
|
-
"id": 5
|
|
66
|
+
"id": 5,
|
|
67
|
+
"protoName": "response_streaming"
|
|
63
68
|
},
|
|
64
69
|
"options": {
|
|
65
70
|
"rule": "repeated",
|
|
@@ -88,7 +93,8 @@
|
|
|
88
93
|
"fields": {
|
|
89
94
|
"fileName": {
|
|
90
95
|
"type": "string",
|
|
91
|
-
"id": 1
|
|
96
|
+
"id": 1,
|
|
97
|
+
"protoName": "file_name"
|
|
92
98
|
}
|
|
93
99
|
}
|
|
94
100
|
},
|