protobufjs 8.6.3 → 8.6.4
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/light/protobuf.js +9 -2
- 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 +9 -2
- 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 +9 -2
- package/dist/protobuf.js.map +1 -1
- package/dist/protobuf.min.js +3 -3
- package/dist/protobuf.min.js.map +1 -1
- package/ext/protojson.js +26 -6
- package/package.json +1 -1
- package/src/util/utf8.js +7 -0
package/ext/protojson.js
CHANGED
|
@@ -535,7 +535,12 @@ WKT_FROM[".google.protobuf.Duration"] = function (type, value) {
|
|
|
535
535
|
nanos = match[3] ? fracToNanos(match[3]) * sign || 0 : 0;
|
|
536
536
|
if (seconds > 315576000000 || seconds < -315576000000)
|
|
537
537
|
throw invalid(type.fullName, value, "duration out of range");
|
|
538
|
-
|
|
538
|
+
var message = {};
|
|
539
|
+
if (seconds !== 0)
|
|
540
|
+
message.seconds = seconds;
|
|
541
|
+
if (nanos !== 0)
|
|
542
|
+
message.nanos = nanos;
|
|
543
|
+
return message;
|
|
539
544
|
};
|
|
540
545
|
WKT_TO[".google.protobuf.Duration"] = function (type, message) {
|
|
541
546
|
var seconds = longToNumber(message.seconds),
|
|
@@ -568,7 +573,12 @@ WKT_FROM[".google.protobuf.Timestamp"] = function (type, value) {
|
|
|
568
573
|
nanos = match[7] ? fracToNanos(match[7]) : 0;
|
|
569
574
|
if (seconds < -62135596800 || seconds > 253402300799)
|
|
570
575
|
throw invalid(type.fullName, value, "timestamp out of range");
|
|
571
|
-
|
|
576
|
+
var message = {};
|
|
577
|
+
if (seconds !== 0)
|
|
578
|
+
message.seconds = seconds;
|
|
579
|
+
if (nanos !== 0)
|
|
580
|
+
message.nanos = nanos;
|
|
581
|
+
return message;
|
|
572
582
|
};
|
|
573
583
|
WKT_TO[".google.protobuf.Timestamp"] = function (type, message) {
|
|
574
584
|
var seconds = longToNumber(message.seconds),
|
|
@@ -611,10 +621,17 @@ WKT_TO[".google.protobuf.FieldMask"] = function (type, message) {
|
|
|
611
621
|
"UInt32Value", "BoolValue", "StringValue", "BytesValue"].forEach(function (name) {
|
|
612
622
|
var fullName = ".google.protobuf." + name;
|
|
613
623
|
WKT_FROM[fullName] = function (type, value, options, depth) {
|
|
614
|
-
|
|
624
|
+
var field = type.fields.value.resolve(),
|
|
625
|
+
fieldValue = readSingular(field, value, options, depth),
|
|
626
|
+
message = {};
|
|
627
|
+
if (!isImplicitDefault(field, fieldValue))
|
|
628
|
+
message.value = fieldValue;
|
|
629
|
+
return message;
|
|
615
630
|
};
|
|
616
631
|
WKT_TO[fullName] = function (type, message, options, depth) {
|
|
617
|
-
|
|
632
|
+
var field = type.fields.value.resolve(),
|
|
633
|
+
value = wktFieldValue(type, message, "value");
|
|
634
|
+
return writeSingular(field, value === undefined ? field.defaultValue : value, options, depth);
|
|
618
635
|
};
|
|
619
636
|
});
|
|
620
637
|
|
|
@@ -736,7 +753,9 @@ WKT_FROM[".google.protobuf.Any"] = function (type, value, options, depth) {
|
|
|
736
753
|
if (url.indexOf("/") === -1)
|
|
737
754
|
url = "/" + url;
|
|
738
755
|
out[wktFieldName(type, "type_url")] = url;
|
|
739
|
-
|
|
756
|
+
var bytes = msgType.encode(inner).finish();
|
|
757
|
+
if (bytes.length)
|
|
758
|
+
out[wktFieldName(type, "value")] = bytes;
|
|
740
759
|
return out;
|
|
741
760
|
};
|
|
742
761
|
WKT_TO[".google.protobuf.Any"] = function (type, message, options, depth) {
|
|
@@ -745,7 +764,8 @@ WKT_TO[".google.protobuf.Any"] = function (type, message, options, depth) {
|
|
|
745
764
|
return {};
|
|
746
765
|
var name = typeUrl.substring(typeUrl.lastIndexOf("/") + 1),
|
|
747
766
|
msgType = type.root.lookupType(name),
|
|
748
|
-
|
|
767
|
+
value = wktFieldValue(type, message, "value"),
|
|
768
|
+
decoded = msgType.decode(value || util.emptyArray),
|
|
749
769
|
body = toJsonValue(msgType, decoded, options, depth + 1),
|
|
750
770
|
result;
|
|
751
771
|
if (WKT_TO[msgType.fullName])
|
package/package.json
CHANGED
package/src/util/utf8.js
CHANGED
|
@@ -7,7 +7,14 @@
|
|
|
7
7
|
*/
|
|
8
8
|
var utf8 = exports,
|
|
9
9
|
replacementChar = "\ufffd",
|
|
10
|
+
strictDecoder;
|
|
11
|
+
|
|
12
|
+
try {
|
|
10
13
|
strictDecoder = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true });
|
|
14
|
+
} catch (err) {
|
|
15
|
+
// "fatal" option is not supported on Node.js compiled without ICU
|
|
16
|
+
strictDecoder = new TextDecoder("utf-8", { ignoreBOM: true });
|
|
17
|
+
}
|
|
11
18
|
|
|
12
19
|
/**
|
|
13
20
|
* Calculates the UTF8 byte length of a string.
|