Skip to content

Commit

Permalink
CLI: Reference dependency imports as a module to prevent name collisi…
Browse files Browse the repository at this point in the history
…ons, see #596
  • Loading branch information
dcodeIO committed Dec 30, 2016
1 parent 55f0323 commit 8493dbd
Show file tree
Hide file tree
Showing 11 changed files with 949 additions and 930 deletions.
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
# [6.3.2](https://github.com/dcodeIO/protobuf.js/releases/tag/6.3.2)

## Fixed
[:hash:](https://github.com/dcodeIO/protobuf.js/commit/7eb3d456370d7d66b0856e32b2d2602abf598516) Respect optional properties when writing interfaces in tsd-jsdoc, fixes [#598](https://github.com/dcodeIO/protobuf.js/issues/598)<br />

## New
[:hash:](https://github.com/dcodeIO/protobuf.js/commit/1f18453c7bfcce65c258fa98a3e3d4577d2e550f) Emit an error on resolveAll() if any extension fields cannot be resolved, see [#595](https://github.com/dcodeIO/protobuf.js/issues/595) + test case<br />

## CLI
[:hash:](https://github.com/dcodeIO/protobuf.js/commit/39a2ea361c50d7f4aaa0408a0d55bb13823b906c) Removed now unnecessary comment lines in generated static code<br />

## Other
[:hash:](https://github.com/dcodeIO/protobuf.js/commit/46ec8209b21cf9ff09ae8674e2a5bbc49fd4991b) Reference dependencies as imports in generated typescript definitions, see [#596](https://github.com/dcodeIO/protobuf.js/issues/596)<br />
[:hash:](https://github.com/dcodeIO/protobuf.js/commit/c0ab94c2e469c0fbf790e4807f24fddd6370e342) Reference dependencies as imports in generated typescript definitions, see [#596](https://github.com/dcodeIO/protobuf.js/issues/596)<br />
[:hash:](https://github.com/dcodeIO/protobuf.js/commit/3bab132b871798c7c50c60a4c14c2effdffa372e) Allow null values on optional long fields, see [#590](https://github.com/dcodeIO/protobuf.js/issues/590)<br />
[:hash:](https://github.com/dcodeIO/protobuf.js/commit/31da56c177f1e11ffe0072ad5f58a55e3f8008fd) Various jsdoc improvements and a workaround for d.ts generation, see [#592](https://github.com/dcodeIO/protobuf.js/issues/592)<br />

# [6.3.1](https://github.com/dcodeIO/protobuf.js/releases/tag/6.3.1)

## Fixed
Expand Down
8 changes: 4 additions & 4 deletions cli/pbts.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,13 @@ exports.main = function(args, callback) {
}

var output = [
"// $> pbts " + process.argv.slice(2).join(' '),
"// Generated " + (new Date()).toUTCString().replace(/GMT/, "UTC")
"// $> pbts " + process.argv.slice(2).join(" "),
"// Generated " + (new Date()).toUTCString().replace(/GMT/, "UTC"),
""
];
if (argv.name !== "protobufjs")
output.push(
"",
"import { Reader, Writer, Method } from \"protobufjs\";",
"import * as $protobuf from \"protobufjs\";",
""
);
output = output.join('\n') + "\n" + out.join('');
Expand Down
14 changes: 7 additions & 7 deletions cli/targets/static.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,8 @@ function buildType(ref, type) {
"Encodes the specified " + type.name + ".",
"@function",
"@param {" + fullName + "|Object} message " + type.name + " or plain object to encode",
"@param {Writer} [writer] Writer to encode to",
"@returns {Writer} Writer"
"@param {$protobuf.Writer} [writer] Writer to encode to",
"@returns {$protobuf.Writer} Writer"
]);
buildFunction(type, "encode", protobuf.encoder(type), {
Writer : "$protobuf.Writer",
Expand All @@ -319,8 +319,8 @@ function buildType(ref, type) {
pushComment([
"Encodes the specified " + type.name + ", length delimited.",
"@param {" + fullName + "|Object} message " + type.name + " or plain object to encode",
"@param {Writer} [writer] Writer to encode to",
"@returns {Writer} Writer"
"@param {$protobuf.Writer} [writer] Writer to encode to",
"@returns {$protobuf.Writer} Writer"
]);
push(name(type.name) + ".encodeDelimited = function encodeDelimited(message, writer) {");
++indent;
Expand All @@ -337,7 +337,7 @@ function buildType(ref, type) {
pushComment([
"Decodes a " + type.name + " from the specified reader or buffer.",
"@function",
"@param {Reader|Uint8Array} readerOrBuffer Reader or buffer to decode from",
"@param {$protobuf.Reader|Uint8Array} readerOrBuffer Reader or buffer to decode from",
"@param {number} [length] Message length if known beforehand",
"@returns {" + fullName + "} " + type.name
]);
Expand All @@ -350,7 +350,7 @@ function buildType(ref, type) {
push("");
pushComment([
"Decodes a " + type.name + " from the specified reader or buffer, length delimited.",
"@param {Reader|Uint8Array} readerOrBuffer Reader or buffer to decode from",
"@param {$protobuf.Reader|Uint8Array} readerOrBuffer Reader or buffer to decode from",
"@returns {" + fullName + "} " + type.name
]);
push(name(type.name) + ".decodeDelimited = function decodeDelimited(readerOrBuffer) {");
Expand Down Expand Up @@ -389,7 +389,7 @@ function buildService(ref, service) {
"RPC implementation passed to services performing a service request on network level, i.e. by utilizing http requests or websockets.",
"@typedef RPCImpl",
"@type {function}",
"@param {Method} method Reflected method being called",
"@param {$protobuf.Method} method Reflected method being called",
"@param {Uint8Array} requestData Request data",
"@param {RPCCallback} callback Callback function",
"@returns {undefined}"
Expand Down
24 changes: 12 additions & 12 deletions tests/data/ambiguous-names.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ $root.A = (function() {
* Encodes the specified A.
* @function
* @param {A|Object} message A or plain object to encode
* @param {Writer} [writer] Writer to encode to
* @returns {Writer} Writer
* @param {$protobuf.Writer} [writer] Writer to encode to
* @returns {$protobuf.Writer} Writer
*/
A.encode = (function() {
/* eslint-disable */
Expand All @@ -66,8 +66,8 @@ $root.A = (function() {
/**
* Encodes the specified A, length delimited.
* @param {A|Object} message A or plain object to encode
* @param {Writer} [writer] Writer to encode to
* @returns {Writer} Writer
* @param {$protobuf.Writer} [writer] Writer to encode to
* @returns {$protobuf.Writer} Writer
*/
A.encodeDelimited = function encodeDelimited(message, writer) {
return this.encode(message, writer).ldelim();
Expand All @@ -76,7 +76,7 @@ $root.A = (function() {
/**
* Decodes a A from the specified reader or buffer.
* @function
* @param {Reader|Uint8Array} readerOrBuffer Reader or buffer to decode from
* @param {$protobuf.Reader|Uint8Array} readerOrBuffer Reader or buffer to decode from
* @param {number} [length] Message length if known beforehand
* @returns {A} A
*/
Expand Down Expand Up @@ -106,7 +106,7 @@ $root.A = (function() {

/**
* Decodes a A from the specified reader or buffer, length delimited.
* @param {Reader|Uint8Array} readerOrBuffer Reader or buffer to decode from
* @param {$protobuf.Reader|Uint8Array} readerOrBuffer Reader or buffer to decode from
* @returns {A} A
*/
A.decodeDelimited = function decodeDelimited(readerOrBuffer) {
Expand Down Expand Up @@ -175,8 +175,8 @@ $root.B = (function() {
* Encodes the specified B.
* @function
* @param {B|Object} message B or plain object to encode
* @param {Writer} [writer] Writer to encode to
* @returns {Writer} Writer
* @param {$protobuf.Writer} [writer] Writer to encode to
* @returns {$protobuf.Writer} Writer
*/
B.encode = (function() {
/* eslint-disable */
Expand All @@ -195,8 +195,8 @@ $root.B = (function() {
/**
* Encodes the specified B, length delimited.
* @param {B|Object} message B or plain object to encode
* @param {Writer} [writer] Writer to encode to
* @returns {Writer} Writer
* @param {$protobuf.Writer} [writer] Writer to encode to
* @returns {$protobuf.Writer} Writer
*/
B.encodeDelimited = function encodeDelimited(message, writer) {
return this.encode(message, writer).ldelim();
Expand All @@ -205,7 +205,7 @@ $root.B = (function() {
/**
* Decodes a B from the specified reader or buffer.
* @function
* @param {Reader|Uint8Array} readerOrBuffer Reader or buffer to decode from
* @param {$protobuf.Reader|Uint8Array} readerOrBuffer Reader or buffer to decode from
* @param {number} [length] Message length if known beforehand
* @returns {B} B
*/
Expand Down Expand Up @@ -235,7 +235,7 @@ $root.B = (function() {

/**
* Decodes a B from the specified reader or buffer, length delimited.
* @param {Reader|Uint8Array} readerOrBuffer Reader or buffer to decode from
* @param {$protobuf.Reader|Uint8Array} readerOrBuffer Reader or buffer to decode from
* @returns {B} B
*/
B.decodeDelimited = function decodeDelimited(readerOrBuffer) {
Expand Down
56 changes: 28 additions & 28 deletions tests/data/mapbox/vector_tile.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ $root.vector_tile = (function() {
* Encodes the specified Tile.
* @function
* @param {vector_tile.Tile|Object} message Tile or plain object to encode
* @param {Writer} [writer] Writer to encode to
* @returns {Writer} Writer
* @param {$protobuf.Writer} [writer] Writer to encode to
* @returns {$protobuf.Writer} Writer
*/
Tile.encode = (function() {
/* eslint-disable */
Expand All @@ -76,8 +76,8 @@ $root.vector_tile = (function() {
/**
* Encodes the specified Tile, length delimited.
* @param {vector_tile.Tile|Object} message Tile or plain object to encode
* @param {Writer} [writer] Writer to encode to
* @returns {Writer} Writer
* @param {$protobuf.Writer} [writer] Writer to encode to
* @returns {$protobuf.Writer} Writer
*/
Tile.encodeDelimited = function encodeDelimited(message, writer) {
return this.encode(message, writer).ldelim();
Expand All @@ -86,7 +86,7 @@ $root.vector_tile = (function() {
/**
* Decodes a Tile from the specified reader or buffer.
* @function
* @param {Reader|Uint8Array} readerOrBuffer Reader or buffer to decode from
* @param {$protobuf.Reader|Uint8Array} readerOrBuffer Reader or buffer to decode from
* @param {number} [length] Message length if known beforehand
* @returns {vector_tile.Tile} Tile
*/
Expand Down Expand Up @@ -117,7 +117,7 @@ $root.vector_tile = (function() {

/**
* Decodes a Tile from the specified reader or buffer, length delimited.
* @param {Reader|Uint8Array} readerOrBuffer Reader or buffer to decode from
* @param {$protobuf.Reader|Uint8Array} readerOrBuffer Reader or buffer to decode from
* @returns {vector_tile.Tile} Tile
*/
Tile.decodeDelimited = function decodeDelimited(readerOrBuffer) {
Expand Down Expand Up @@ -237,8 +237,8 @@ $root.vector_tile = (function() {
* Encodes the specified Value.
* @function
* @param {vector_tile.Tile.Value|Object} message Value or plain object to encode
* @param {Writer} [writer] Writer to encode to
* @returns {Writer} Writer
* @param {$protobuf.Writer} [writer] Writer to encode to
* @returns {$protobuf.Writer} Writer
*/
Value.encode = (function() {
/* eslint-disable */
Expand All @@ -253,11 +253,11 @@ $root.vector_tile = (function() {
w.uint32(21).float(m.floatValue)
if(m.doubleValue!==undefined&&m.doubleValue!==0)
w.uint32(25).double(m.doubleValue)
if(m.intValue!==undefined&&util.longNe(m.intValue,0,0))
if(m.intValue!==undefined&&m.intValue!==null&&util.longNe(m.intValue,0,0))
w.uint32(32).int64(m.intValue)
if(m.uintValue!==undefined&&util.longNe(m.uintValue,0,0))
if(m.uintValue!==undefined&&m.uintValue!==null&&util.longNe(m.uintValue,0,0))
w.uint32(40).uint64(m.uintValue)
if(m.sintValue!==undefined&&util.longNe(m.sintValue,0,0))
if(m.sintValue!==undefined&&m.sintValue!==null&&util.longNe(m.sintValue,0,0))
w.uint32(48).sint64(m.sintValue)
if(m.boolValue!==undefined&&m.boolValue!==false)
w.uint32(56).bool(m.boolValue)
Expand All @@ -269,8 +269,8 @@ $root.vector_tile = (function() {
/**
* Encodes the specified Value, length delimited.
* @param {vector_tile.Tile.Value|Object} message Value or plain object to encode
* @param {Writer} [writer] Writer to encode to
* @returns {Writer} Writer
* @param {$protobuf.Writer} [writer] Writer to encode to
* @returns {$protobuf.Writer} Writer
*/
Value.encodeDelimited = function encodeDelimited(message, writer) {
return this.encode(message, writer).ldelim();
Expand All @@ -279,7 +279,7 @@ $root.vector_tile = (function() {
/**
* Decodes a Value from the specified reader or buffer.
* @function
* @param {Reader|Uint8Array} readerOrBuffer Reader or buffer to decode from
* @param {$protobuf.Reader|Uint8Array} readerOrBuffer Reader or buffer to decode from
* @param {number} [length] Message length if known beforehand
* @returns {vector_tile.Tile.Value} Value
*/
Expand Down Expand Up @@ -327,7 +327,7 @@ $root.vector_tile = (function() {

/**
* Decodes a Value from the specified reader or buffer, length delimited.
* @param {Reader|Uint8Array} readerOrBuffer Reader or buffer to decode from
* @param {$protobuf.Reader|Uint8Array} readerOrBuffer Reader or buffer to decode from
* @returns {vector_tile.Tile.Value} Value
*/
Value.decodeDelimited = function decodeDelimited(readerOrBuffer) {
Expand Down Expand Up @@ -438,8 +438,8 @@ $root.vector_tile = (function() {
* Encodes the specified Feature.
* @function
* @param {vector_tile.Tile.Feature|Object} message Feature or plain object to encode
* @param {Writer} [writer] Writer to encode to
* @returns {Writer} Writer
* @param {$protobuf.Writer} [writer] Writer to encode to
* @returns {$protobuf.Writer} Writer
*/
Feature.encode = (function() {
/* eslint-disable */
Expand All @@ -448,7 +448,7 @@ $root.vector_tile = (function() {
var types; $lazyTypes.push(types = [null,null,"vector_tile.Tile.GeomType",null]);
return function encode(m, w) {
w||(w=Writer.create())
if(m.id!==undefined&&util.longNe(m.id,0,0))
if(m.id!==undefined&&m.id!==null&&util.longNe(m.id,0,0))
w.uint32(8).uint64(m.id)
if(m.tags&&m.tags.length){
w.uint32(18).fork()
Expand All @@ -472,8 +472,8 @@ $root.vector_tile = (function() {
/**
* Encodes the specified Feature, length delimited.
* @param {vector_tile.Tile.Feature|Object} message Feature or plain object to encode
* @param {Writer} [writer] Writer to encode to
* @returns {Writer} Writer
* @param {$protobuf.Writer} [writer] Writer to encode to
* @returns {$protobuf.Writer} Writer
*/
Feature.encodeDelimited = function encodeDelimited(message, writer) {
return this.encode(message, writer).ldelim();
Expand All @@ -482,7 +482,7 @@ $root.vector_tile = (function() {
/**
* Decodes a Feature from the specified reader or buffer.
* @function
* @param {Reader|Uint8Array} readerOrBuffer Reader or buffer to decode from
* @param {$protobuf.Reader|Uint8Array} readerOrBuffer Reader or buffer to decode from
* @param {number} [length] Message length if known beforehand
* @returns {vector_tile.Tile.Feature} Feature
*/
Expand Down Expand Up @@ -533,7 +533,7 @@ $root.vector_tile = (function() {

/**
* Decodes a Feature from the specified reader or buffer, length delimited.
* @param {Reader|Uint8Array} readerOrBuffer Reader or buffer to decode from
* @param {$protobuf.Reader|Uint8Array} readerOrBuffer Reader or buffer to decode from
* @returns {vector_tile.Tile.Feature} Feature
*/
Feature.decodeDelimited = function decodeDelimited(readerOrBuffer) {
Expand Down Expand Up @@ -659,8 +659,8 @@ $root.vector_tile = (function() {
* Encodes the specified Layer.
* @function
* @param {vector_tile.Tile.Layer|Object} message Layer or plain object to encode
* @param {Writer} [writer] Writer to encode to
* @returns {Writer} Writer
* @param {$protobuf.Writer} [writer] Writer to encode to
* @returns {$protobuf.Writer} Writer
*/
Layer.encode = (function() {
/* eslint-disable */
Expand Down Expand Up @@ -690,8 +690,8 @@ $root.vector_tile = (function() {
/**
* Encodes the specified Layer, length delimited.
* @param {vector_tile.Tile.Layer|Object} message Layer or plain object to encode
* @param {Writer} [writer] Writer to encode to
* @returns {Writer} Writer
* @param {$protobuf.Writer} [writer] Writer to encode to
* @returns {$protobuf.Writer} Writer
*/
Layer.encodeDelimited = function encodeDelimited(message, writer) {
return this.encode(message, writer).ldelim();
Expand All @@ -700,7 +700,7 @@ $root.vector_tile = (function() {
/**
* Decodes a Layer from the specified reader or buffer.
* @function
* @param {Reader|Uint8Array} readerOrBuffer Reader or buffer to decode from
* @param {$protobuf.Reader|Uint8Array} readerOrBuffer Reader or buffer to decode from
* @param {number} [length] Message length if known beforehand
* @returns {vector_tile.Tile.Layer} Layer
*/
Expand Down Expand Up @@ -748,7 +748,7 @@ $root.vector_tile = (function() {

/**
* Decodes a Layer from the specified reader or buffer, length delimited.
* @param {Reader|Uint8Array} readerOrBuffer Reader or buffer to decode from
* @param {$protobuf.Reader|Uint8Array} readerOrBuffer Reader or buffer to decode from
* @returns {vector_tile.Tile.Layer} Layer
*/
Layer.decodeDelimited = function decodeDelimited(readerOrBuffer) {
Expand Down
Loading

0 comments on commit 8493dbd

Please sign in to comment.