protobufjs 8.6.0 → 8.6.1
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 +45 -88
- 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 +25 -68
- 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 +45 -88
- package/dist/protobuf.js.map +1 -1
- package/dist/protobuf.min.js +3 -3
- package/dist/protobuf.min.js.map +1 -1
- package/ext/README.md +1 -1
- package/ext/descriptor.d.ts +8 -7
- package/ext/descriptor.generated.d.ts +14 -6
- package/ext/descriptor.js +162 -111
- package/ext/protojson.js +29 -7
- package/index.d.ts +9 -17
- package/package.json +1 -1
- package/src/util/minimal.js +0 -3
- package/src/util/inquire.d.ts +0 -10
- package/src/util/inquire.js +0 -38
package/ext/protojson.js
CHANGED
|
@@ -393,6 +393,24 @@ function setOwn(o, k, v) {
|
|
|
393
393
|
o[k] = v;
|
|
394
394
|
}
|
|
395
395
|
|
|
396
|
+
function wktFieldName(type, name) {
|
|
397
|
+
var field = fieldsByJsonName(type)[name];
|
|
398
|
+
return field ? field.name : name;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
function wktFieldValue(type, message, name) {
|
|
402
|
+
var field = fieldsByJsonName(type)[name];
|
|
403
|
+
if (!field)
|
|
404
|
+
return message && message[name];
|
|
405
|
+
if (hasOwn(message, field.name))
|
|
406
|
+
return message[field.name];
|
|
407
|
+
if (hasOwn(message, field.protoName))
|
|
408
|
+
return message[field.protoName];
|
|
409
|
+
if (hasOwn(message, field.jsonName))
|
|
410
|
+
return message[field.jsonName];
|
|
411
|
+
return undefined;
|
|
412
|
+
}
|
|
413
|
+
|
|
396
414
|
function writeScalar(type, value) {
|
|
397
415
|
switch (type) {
|
|
398
416
|
case "int64": case "sint64": case "sfixed64":
|
|
@@ -713,23 +731,27 @@ WKT_FROM[".google.protobuf.Any"] = function (type, value, options, depth) {
|
|
|
713
731
|
setOwn(body, k, value[k]);
|
|
714
732
|
}
|
|
715
733
|
var inner = readMessage(msgType, body, options, depth + 1);
|
|
716
|
-
var url = typeUrl.charAt(0) === "." ? typeUrl.slice(1) : typeUrl
|
|
734
|
+
var url = typeUrl.charAt(0) === "." ? typeUrl.slice(1) : typeUrl,
|
|
735
|
+
out = {};
|
|
717
736
|
if (url.indexOf("/") === -1)
|
|
718
737
|
url = "/" + url;
|
|
719
|
-
|
|
738
|
+
out[wktFieldName(type, "type_url")] = url;
|
|
739
|
+
out[wktFieldName(type, "value")] = msgType.encode(inner).finish();
|
|
740
|
+
return out;
|
|
720
741
|
};
|
|
721
742
|
WKT_TO[".google.protobuf.Any"] = function (type, message, options, depth) {
|
|
722
|
-
|
|
743
|
+
var typeUrl = wktFieldValue(type, message, "type_url");
|
|
744
|
+
if (!typeUrl)
|
|
723
745
|
return {};
|
|
724
|
-
var name =
|
|
746
|
+
var name = typeUrl.substring(typeUrl.lastIndexOf("/") + 1),
|
|
725
747
|
msgType = type.root.lookupType(name),
|
|
726
|
-
decoded = msgType.decode(message
|
|
748
|
+
decoded = msgType.decode(wktFieldValue(type, message, "value")),
|
|
727
749
|
body = toJsonValue(msgType, decoded, options, depth + 1),
|
|
728
750
|
result;
|
|
729
751
|
if (WKT_TO[msgType.fullName])
|
|
730
|
-
result = { "@type":
|
|
752
|
+
result = { "@type": typeUrl, "value": body };
|
|
731
753
|
else {
|
|
732
|
-
result = { "@type":
|
|
754
|
+
result = { "@type": typeUrl };
|
|
733
755
|
for (var k in body)
|
|
734
756
|
if (hasOwn(body, k))
|
|
735
757
|
setOwn(result, k, body[k]);
|
package/index.d.ts
CHANGED
|
@@ -1482,15 +1482,15 @@ export namespace rpc {
|
|
|
1482
1482
|
|
|
1483
1483
|
/** A service method part of a {@link rpc.Service} as created by {@link Service.create}. */
|
|
1484
1484
|
type ServiceMethod<TReq extends Message<TReq>, TRes extends Message<TRes>> = {
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
};
|
|
1485
|
+
(request: TReq|Properties<TReq>, callback: rpc.ServiceMethodCallback<TRes>): void;
|
|
1486
|
+
(request: TReq|Properties<TReq>): Promise<TRes>;
|
|
1487
|
+
readonly name: string;
|
|
1488
|
+
readonly path: string;
|
|
1489
|
+
readonly requestType: string;
|
|
1490
|
+
readonly responseType: string;
|
|
1491
|
+
readonly requestStream: true|undefined;
|
|
1492
|
+
readonly responseStream: true|undefined;
|
|
1493
|
+
};
|
|
1494
1494
|
|
|
1495
1495
|
/** An RPC service as returned by {@link Service#create}. */
|
|
1496
1496
|
class Service extends util.EventEmitter {
|
|
@@ -2303,14 +2303,6 @@ export namespace util {
|
|
|
2303
2303
|
function readDoubleBE(buf: Uint8Array, pos: number): number;
|
|
2304
2304
|
}
|
|
2305
2305
|
|
|
2306
|
-
/**
|
|
2307
|
-
* Requires a module only if available.
|
|
2308
|
-
* @param moduleName Module to require
|
|
2309
|
-
* @returns Required module if available and not empty, otherwise `null`
|
|
2310
|
-
* @deprecated Legacy optional require helper. Will be removed in a future release.
|
|
2311
|
-
*/
|
|
2312
|
-
function inquire(moduleName: string): object;
|
|
2313
|
-
|
|
2314
2306
|
/** Helper class for working with the low and high bits of a 64 bit value. */
|
|
2315
2307
|
class LongBits {
|
|
2316
2308
|
|
package/package.json
CHANGED
package/src/util/minimal.js
CHANGED
|
@@ -13,9 +13,6 @@ util.EventEmitter = require("./eventemitter");
|
|
|
13
13
|
// float handling accross browsers
|
|
14
14
|
util.float = require("./float");
|
|
15
15
|
|
|
16
|
-
// requires modules optionally and hides the call from bundlers
|
|
17
|
-
util.inquire = require("./inquire");
|
|
18
|
-
|
|
19
16
|
// converts to / from utf8 encoded strings
|
|
20
17
|
util.utf8 = require("./utf8");
|
|
21
18
|
|
package/src/util/inquire.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export = inquire;
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Requires a module only if available.
|
|
5
|
-
* @memberof util
|
|
6
|
-
* @param {string} moduleName Module to require
|
|
7
|
-
* @returns {?Object} Required module if available and not empty, otherwise `null`
|
|
8
|
-
* @deprecated Legacy optional require helper. Will be removed in a future release.
|
|
9
|
-
*/
|
|
10
|
-
declare function inquire(moduleName: string): object;
|
package/src/util/inquire.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
module.exports = inquire;
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Requires a module only if available.
|
|
6
|
-
* @memberof util
|
|
7
|
-
* @param {string} moduleName Module to require
|
|
8
|
-
* @returns {?Object} Required module if available and not empty, otherwise `null`
|
|
9
|
-
* @deprecated Legacy optional require helper. Will be removed in a future release.
|
|
10
|
-
*/
|
|
11
|
-
function inquire(moduleName) {
|
|
12
|
-
try {
|
|
13
|
-
if (typeof require !== "function") {
|
|
14
|
-
return null;
|
|
15
|
-
}
|
|
16
|
-
var mod = require(moduleName);
|
|
17
|
-
if (mod && (mod.length || Object.keys(mod).length)) return mod;
|
|
18
|
-
return null;
|
|
19
|
-
} catch (err) {
|
|
20
|
-
// ignore
|
|
21
|
-
return null;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/*
|
|
26
|
-
// maybe worth a shot to prevent renaming issues:
|
|
27
|
-
// see: https://github.com/webpack/webpack/blob/master/lib/dependencies/CommonJsRequireDependencyParserPlugin.js
|
|
28
|
-
// triggers on:
|
|
29
|
-
// - expression require.cache
|
|
30
|
-
// - expression require (???)
|
|
31
|
-
// - call require
|
|
32
|
-
// - call require:commonjs:item
|
|
33
|
-
// - call require:commonjs:context
|
|
34
|
-
|
|
35
|
-
Object.defineProperty(Function.prototype, "__self", { get: function() { return this; } });
|
|
36
|
-
var r = require.__self;
|
|
37
|
-
delete Function.prototype.__self;
|
|
38
|
-
*/
|