Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

protobufjs-cli

Package Overview
Dependencies
Maintainers
3
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

protobufjs-cli - npm Package Compare versions

Comparing version
2.4.2
to
2.5.0
+21
-0
CHANGELOG.md
# Changelog
## [2.5.0](https://github.com/protobufjs/protobuf.js/compare/protobufjs-cli-v2.4.2...protobufjs-cli-v2.5.0) (2026-05-29)
### Features
* Expose RPC metadata on service methods ([#2286](https://github.com/protobufjs/protobuf.js/issues/2286)) ([711a279](https://github.com/protobufjs/protobuf.js/commit/711a27995f5d15597462b14a7f2cae3852619a6d))
### Bug Fixes
* **cli:** Consistently handle derived names ([#2293](https://github.com/protobufjs/protobuf.js/issues/2293)) ([9e80030](https://github.com/protobufjs/protobuf.js/commit/9e80030b25a24c587fe5f2cae67f66e19b24fee4))
### Dependencies
* The following workspace dependencies were updated
* devDependencies
* protobufjs bumped from file:.. to 8.5.0
* peerDependencies
* protobufjs bumped from ^8.4.2 to ^8.5.0
## [2.4.2](https://github.com/protobufjs/protobuf.js/compare/protobufjs-cli-v2.4.1...protobufjs-cli-v2.4.2) (2026-05-22)

@@ -4,0 +25,0 @@

+14
-2

@@ -840,4 +840,16 @@ "use strict";

else {
if (element.type && element.type.names.length === 1 && element.type.names[0] === "function")
writeFunctionSignature(element, false, true);
if (element.type && element.type.names.length === 1 && element.type.names[0] === "function") {
if (element.properties && element.properties.length) {
writeln("{");
++indent;
writeFunctionSignature(element, false, false);
writeln(";");
element.properties.forEach(function(property) {
writeProperty(property);
});
--indent;
write("}");
} else
writeFunctionSignature(element, false, true);
}
else if (type === "object") {

@@ -844,0 +856,0 @@ if (element.properties && element.properties.length)

+2
-2
{
"name": "protobufjs-cli",
"description": "Translates between file formats and generates static code as well as TypeScript definitions.",
"version": "2.4.2",
"version": "2.5.0",
"author": "Daniel Wirtz <dcode+protobufjs@dcode.io>",

@@ -23,3 +23,3 @@ "repository": {

"peerDependencies": {
"protobufjs": "^8.4.2"
"protobufjs": "^8.5.0"
},

@@ -26,0 +26,0 @@ "dependencies": {

@@ -41,3 +41,3 @@ "use strict";

try {
var rootProp = protobuf.util.safeProp(options.root || "default");
var rootProp = "[" + JSON.stringify(String(options.root || "default")) + "]";
var output = [

@@ -44,0 +44,0 @@ (options.es6 ? "const" : "var") + " $root = ($protobuf.roots" + rootProp + " || ($protobuf.roots" + rootProp + " = new $protobuf.Root()))\n"

@@ -44,3 +44,3 @@ "use strict";

}
var rootProp = util.safeProp(config.root || "default");
var rootProp = "[" + JSON.stringify(String(config.root || "default")) + "]";
push((config.es6 ? "const" : "var") + " $root = $protobuf.roots" + rootProp + " || ($protobuf.roots" + rootProp + " = {});");

@@ -83,2 +83,11 @@ buildNamespace(null, root);

function objectPath(object) {
var parts = [];
while (object && object.name !== "") {
parts.unshift(escapeName(object.name));
object = object.parent;
}
return parts;
}
function exportName(object, asInterface) {

@@ -90,8 +99,5 @@ if (asInterface) {

return object.__exportName;
var parts = object.fullName.substring(1).split("."),
i = 0;
while (i < parts.length)
parts[i] = escapeName(parts[i++]);
if (asInterface)
parts[i - 1] = "I" + parts[i - 1];
var parts = objectPath(object);
if (asInterface && parts.length)
parts[parts.length - 1] = "I" + parts[parts.length - 1];
return object[asInterface ? "__interfaceName" : "__exportName"] = parts.join(".");

@@ -147,3 +153,11 @@ }

var seenNames = new Set();
ns.nestedArray.forEach(function(nested) {
// Only check names of elements that are emitted below
if (!(nested instanceof Enum || nested instanceof Namespace) || nested instanceof Service && !config.service)
return;
var name = escapeName(nested.name);
if (seenNames.has(name))
throw Error("duplicate generated name '" + name + "'");
seenNames.add(name);
if (nested instanceof Enum)

@@ -244,4 +258,23 @@ buildEnum(ns.name, nested);

var code = gen.toString(functionName);
var ast = espree.parse(code);
var ast = espree.parse(code);
function rootMemberRef(object) {
var ref = {
"type": "Identifier",
"name": "$root"
};
var parts = objectPath(object);
for (var i = 0; i < parts.length; ++i)
ref = {
"type": "MemberExpression",
"computed": false,
"object": ref,
"property": {
"type": "Identifier",
"name": parts[i]
}
};
return ref;
}
/* eslint-disable no-extra-parens */

@@ -271,6 +304,3 @@ estraverse.replace(ast, {

)
return {
"type": "Identifier",
"name": "$root" + type.fullName
};
return rootMemberRef(type);
// replace types[N].ctor with the field's actual type constructor

@@ -284,6 +314,3 @@ if (

)
return {
"type": "Identifier",
"name": "$root" + type.fieldsArray[node.object.property.value].resolvedType.fullName
};
return rootMemberRef(type.fieldsArray[node.object.property.value].resolvedType);
// replace types[N].values with the field's actual enum object

@@ -297,6 +324,3 @@ if (

)
return {
"type": "Identifier",
"name": "$root" + type.fieldsArray[node.object.property.value].resolvedType.fullName
};
return rootMemberRef(type.fieldsArray[node.object.property.value].resolvedType);
// replace types[N] with the field's actual type

@@ -308,6 +332,3 @@ if (

)
return {
"type": "Identifier",
"name": "$root" + type.fieldsArray[node.property.value].resolvedType.fullName
};
return rootMemberRef(type.fieldsArray[node.property.value].resolvedType);
return undefined;

@@ -895,3 +916,4 @@ }

var lcName = protobuf.util.lcFirst(method.name),
cbName = escapeName(method.name + "Callback");
cbName = escapeName(method.name + "Callback"),
methodTypeName = escapeName(method.name);
push("");

@@ -910,26 +932,35 @@ pushComment([

method.comment || "Calls " + method.name + ".",
"@function " + lcName,
"@memberof " + exportName(service),
"@instance",
"@param {" + exportName(method.resolvedRequestType, !config.forceMessage) + "} request " + method.resolvedRequestType.name + " message or plain object",
"@param {" + exportName(service) + "." + cbName + "} callback Node-style callback called with the error, if any, and " + method.resolvedResponseType.name,
"@returns {undefined}",
"@variation 1"
"@typedef " + methodTypeName,
"@type {{",
" (request: " + exportName(method.resolvedRequestType, !config.forceMessage) + ", callback: " + exportName(service) + "." + cbName + "): void;",
" (request: " + exportName(method.resolvedRequestType, !config.forceMessage) + "): Promise<" + exportName(method.resolvedResponseType) + ">;",
" readonly name: " + JSON.stringify(method.name) + ";",
" readonly path: " + JSON.stringify(method.path) + ";",
" readonly requestType: " + JSON.stringify(method.requestType) + ";",
" readonly responseType: " + JSON.stringify(method.responseType) + ";",
" readonly requestStream: " + (method.requestStream ? "true" : "undefined") + ";",
" readonly responseStream: " + (method.responseStream ? "true" : "undefined") + ";",
"}}"
]);
push("Object.defineProperty(" + escapeName(service.name) + ".prototype" + util.safeProp(lcName) + " = function " + escapeName(lcName) + "(request, callback) {");
push("");
pushComment([
method.comment || "Calls " + method.name + ".",
"@name " + exportName(service) + "#" + lcName,
"@type {" + exportName(service) + "." + methodTypeName + "}"
]);
push("Object.defineProperties(" + escapeName(service.name) + ".prototype" + util.safeProp(lcName) + " = function " + escapeName(lcName) + "(request, callback) {");
++indent;
push("return this.rpcCall(" + escapeName(lcName) + ", $root." + exportName(method.resolvedRequestType) + ", $root." + exportName(method.resolvedResponseType) + ", request, callback);");
--indent;
push("}, \"name\", { value: " + JSON.stringify(method.name) + " });");
if (config.comments)
push("");
pushComment([
method.comment || "Calls " + method.name + ".",
"@function " + lcName,
"@memberof " + exportName(service),
"@instance",
"@param {" + exportName(method.resolvedRequestType, !config.forceMessage) + "} request " + method.resolvedRequestType.name + " message or plain object",
"@returns {Promise<" + exportName(method.resolvedResponseType) + ">} Promise",
"@variation 2"
]);
push("}, {");
++indent;
push("name: { value: " + JSON.stringify(method.name) + " },");
push("path: { value: " + JSON.stringify(method.path) + " },");
push("requestType: { value: " + JSON.stringify(method.requestType) + " },");
push("responseType: { value: " + JSON.stringify(method.responseType) + " },");
push("requestStream: { value: " + (method.requestStream ? "true" : "undefined") + " },");
push("responseStream: { value: " + (method.responseStream ? "true" : "undefined") + " }");
--indent;
push("});");
});

@@ -936,0 +967,0 @@ }

@@ -129,3 +129,3 @@ "use strict";

if (options.lint !== "")
wrap = "/*" + options.lint + "*/\n" + wrap;
wrap = "/*" + String(options.lint).replace(/\*\//g, "* /") + "*/\n" + wrap;
return wrap.replace(/\r?\n/g, "\n");

@@ -132,0 +132,0 @@ };