Skip to content

Commit 8493dbd

Browse files
committed
CLI: Reference dependency imports as a module to prevent name collisions, see #596
1 parent 55f0323 commit 8493dbd

11 files changed

Lines changed: 949 additions & 930 deletions

File tree

CHANGELOG.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
# [6.3.2](https://github.com/dcodeIO/protobuf.js/releases/tag/6.3.2)
2+
3+
## Fixed
4+
[: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 />
5+
6+
## New
7+
[: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 />
8+
9+
## CLI
10+
[:hash:](https://github.com/dcodeIO/protobuf.js/commit/39a2ea361c50d7f4aaa0408a0d55bb13823b906c) Removed now unnecessary comment lines in generated static code<br />
11+
12+
## Other
13+
[: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 />
14+
[: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 />
15+
[: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 />
16+
[: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 />
17+
118
# [6.3.1](https://github.com/dcodeIO/protobuf.js/releases/tag/6.3.1)
219

320
## Fixed

cli/pbts.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,13 @@ exports.main = function(args, callback) {
9292
}
9393

9494
var output = [
95-
"// $> pbts " + process.argv.slice(2).join(' '),
96-
"// Generated " + (new Date()).toUTCString().replace(/GMT/, "UTC")
95+
"// $> pbts " + process.argv.slice(2).join(" "),
96+
"// Generated " + (new Date()).toUTCString().replace(/GMT/, "UTC"),
97+
""
9798
];
9899
if (argv.name !== "protobufjs")
99100
output.push(
100-
"",
101-
"import { Reader, Writer, Method } from \"protobufjs\";",
101+
"import * as $protobuf from \"protobufjs\";",
102102
""
103103
);
104104
output = output.join('\n') + "\n" + out.join('');

cli/targets/static.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -306,8 +306,8 @@ function buildType(ref, type) {
306306
"Encodes the specified " + type.name + ".",
307307
"@function",
308308
"@param {" + fullName + "|Object} message " + type.name + " or plain object to encode",
309-
"@param {Writer} [writer] Writer to encode to",
310-
"@returns {Writer} Writer"
309+
"@param {$protobuf.Writer} [writer] Writer to encode to",
310+
"@returns {$protobuf.Writer} Writer"
311311
]);
312312
buildFunction(type, "encode", protobuf.encoder(type), {
313313
Writer : "$protobuf.Writer",
@@ -319,8 +319,8 @@ function buildType(ref, type) {
319319
pushComment([
320320
"Encodes the specified " + type.name + ", length delimited.",
321321
"@param {" + fullName + "|Object} message " + type.name + " or plain object to encode",
322-
"@param {Writer} [writer] Writer to encode to",
323-
"@returns {Writer} Writer"
322+
"@param {$protobuf.Writer} [writer] Writer to encode to",
323+
"@returns {$protobuf.Writer} Writer"
324324
]);
325325
push(name(type.name) + ".encodeDelimited = function encodeDelimited(message, writer) {");
326326
++indent;
@@ -337,7 +337,7 @@ function buildType(ref, type) {
337337
pushComment([
338338
"Decodes a " + type.name + " from the specified reader or buffer.",
339339
"@function",
340-
"@param {Reader|Uint8Array} readerOrBuffer Reader or buffer to decode from",
340+
"@param {$protobuf.Reader|Uint8Array} readerOrBuffer Reader or buffer to decode from",
341341
"@param {number} [length] Message length if known beforehand",
342342
"@returns {" + fullName + "} " + type.name
343343
]);
@@ -350,7 +350,7 @@ function buildType(ref, type) {
350350
push("");
351351
pushComment([
352352
"Decodes a " + type.name + " from the specified reader or buffer, length delimited.",
353-
"@param {Reader|Uint8Array} readerOrBuffer Reader or buffer to decode from",
353+
"@param {$protobuf.Reader|Uint8Array} readerOrBuffer Reader or buffer to decode from",
354354
"@returns {" + fullName + "} " + type.name
355355
]);
356356
push(name(type.name) + ".decodeDelimited = function decodeDelimited(readerOrBuffer) {");
@@ -389,7 +389,7 @@ function buildService(ref, service) {
389389
"RPC implementation passed to services performing a service request on network level, i.e. by utilizing http requests or websockets.",
390390
"@typedef RPCImpl",
391391
"@type {function}",
392-
"@param {Method} method Reflected method being called",
392+
"@param {$protobuf.Method} method Reflected method being called",
393393
"@param {Uint8Array} requestData Request data",
394394
"@param {RPCCallback} callback Callback function",
395395
"@returns {undefined}"

tests/data/ambiguous-names.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ $root.A = (function() {
4646
* Encodes the specified A.
4747
* @function
4848
* @param {A|Object} message A or plain object to encode
49-
* @param {Writer} [writer] Writer to encode to
50-
* @returns {Writer} Writer
49+
* @param {$protobuf.Writer} [writer] Writer to encode to
50+
* @returns {$protobuf.Writer} Writer
5151
*/
5252
A.encode = (function() {
5353
/* eslint-disable */
@@ -66,8 +66,8 @@ $root.A = (function() {
6666
/**
6767
* Encodes the specified A, length delimited.
6868
* @param {A|Object} message A or plain object to encode
69-
* @param {Writer} [writer] Writer to encode to
70-
* @returns {Writer} Writer
69+
* @param {$protobuf.Writer} [writer] Writer to encode to
70+
* @returns {$protobuf.Writer} Writer
7171
*/
7272
A.encodeDelimited = function encodeDelimited(message, writer) {
7373
return this.encode(message, writer).ldelim();
@@ -76,7 +76,7 @@ $root.A = (function() {
7676
/**
7777
* Decodes a A from the specified reader or buffer.
7878
* @function
79-
* @param {Reader|Uint8Array} readerOrBuffer Reader or buffer to decode from
79+
* @param {$protobuf.Reader|Uint8Array} readerOrBuffer Reader or buffer to decode from
8080
* @param {number} [length] Message length if known beforehand
8181
* @returns {A} A
8282
*/
@@ -106,7 +106,7 @@ $root.A = (function() {
106106

107107
/**
108108
* Decodes a A from the specified reader or buffer, length delimited.
109-
* @param {Reader|Uint8Array} readerOrBuffer Reader or buffer to decode from
109+
* @param {$protobuf.Reader|Uint8Array} readerOrBuffer Reader or buffer to decode from
110110
* @returns {A} A
111111
*/
112112
A.decodeDelimited = function decodeDelimited(readerOrBuffer) {
@@ -175,8 +175,8 @@ $root.B = (function() {
175175
* Encodes the specified B.
176176
* @function
177177
* @param {B|Object} message B or plain object to encode
178-
* @param {Writer} [writer] Writer to encode to
179-
* @returns {Writer} Writer
178+
* @param {$protobuf.Writer} [writer] Writer to encode to
179+
* @returns {$protobuf.Writer} Writer
180180
*/
181181
B.encode = (function() {
182182
/* eslint-disable */
@@ -195,8 +195,8 @@ $root.B = (function() {
195195
/**
196196
* Encodes the specified B, length delimited.
197197
* @param {B|Object} message B or plain object to encode
198-
* @param {Writer} [writer] Writer to encode to
199-
* @returns {Writer} Writer
198+
* @param {$protobuf.Writer} [writer] Writer to encode to
199+
* @returns {$protobuf.Writer} Writer
200200
*/
201201
B.encodeDelimited = function encodeDelimited(message, writer) {
202202
return this.encode(message, writer).ldelim();
@@ -205,7 +205,7 @@ $root.B = (function() {
205205
/**
206206
* Decodes a B from the specified reader or buffer.
207207
* @function
208-
* @param {Reader|Uint8Array} readerOrBuffer Reader or buffer to decode from
208+
* @param {$protobuf.Reader|Uint8Array} readerOrBuffer Reader or buffer to decode from
209209
* @param {number} [length] Message length if known beforehand
210210
* @returns {B} B
211211
*/
@@ -235,7 +235,7 @@ $root.B = (function() {
235235

236236
/**
237237
* Decodes a B from the specified reader or buffer, length delimited.
238-
* @param {Reader|Uint8Array} readerOrBuffer Reader or buffer to decode from
238+
* @param {$protobuf.Reader|Uint8Array} readerOrBuffer Reader or buffer to decode from
239239
* @returns {B} B
240240
*/
241241
B.decodeDelimited = function decodeDelimited(readerOrBuffer) {

tests/data/mapbox/vector_tile.js

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ $root.vector_tile = (function() {
5555
* Encodes the specified Tile.
5656
* @function
5757
* @param {vector_tile.Tile|Object} message Tile or plain object to encode
58-
* @param {Writer} [writer] Writer to encode to
59-
* @returns {Writer} Writer
58+
* @param {$protobuf.Writer} [writer] Writer to encode to
59+
* @returns {$protobuf.Writer} Writer
6060
*/
6161
Tile.encode = (function() {
6262
/* eslint-disable */
@@ -76,8 +76,8 @@ $root.vector_tile = (function() {
7676
/**
7777
* Encodes the specified Tile, length delimited.
7878
* @param {vector_tile.Tile|Object} message Tile or plain object to encode
79-
* @param {Writer} [writer] Writer to encode to
80-
* @returns {Writer} Writer
79+
* @param {$protobuf.Writer} [writer] Writer to encode to
80+
* @returns {$protobuf.Writer} Writer
8181
*/
8282
Tile.encodeDelimited = function encodeDelimited(message, writer) {
8383
return this.encode(message, writer).ldelim();
@@ -86,7 +86,7 @@ $root.vector_tile = (function() {
8686
/**
8787
* Decodes a Tile from the specified reader or buffer.
8888
* @function
89-
* @param {Reader|Uint8Array} readerOrBuffer Reader or buffer to decode from
89+
* @param {$protobuf.Reader|Uint8Array} readerOrBuffer Reader or buffer to decode from
9090
* @param {number} [length] Message length if known beforehand
9191
* @returns {vector_tile.Tile} Tile
9292
*/
@@ -117,7 +117,7 @@ $root.vector_tile = (function() {
117117

118118
/**
119119
* Decodes a Tile from the specified reader or buffer, length delimited.
120-
* @param {Reader|Uint8Array} readerOrBuffer Reader or buffer to decode from
120+
* @param {$protobuf.Reader|Uint8Array} readerOrBuffer Reader or buffer to decode from
121121
* @returns {vector_tile.Tile} Tile
122122
*/
123123
Tile.decodeDelimited = function decodeDelimited(readerOrBuffer) {
@@ -237,8 +237,8 @@ $root.vector_tile = (function() {
237237
* Encodes the specified Value.
238238
* @function
239239
* @param {vector_tile.Tile.Value|Object} message Value or plain object to encode
240-
* @param {Writer} [writer] Writer to encode to
241-
* @returns {Writer} Writer
240+
* @param {$protobuf.Writer} [writer] Writer to encode to
241+
* @returns {$protobuf.Writer} Writer
242242
*/
243243
Value.encode = (function() {
244244
/* eslint-disable */
@@ -253,11 +253,11 @@ $root.vector_tile = (function() {
253253
w.uint32(21).float(m.floatValue)
254254
if(m.doubleValue!==undefined&&m.doubleValue!==0)
255255
w.uint32(25).double(m.doubleValue)
256-
if(m.intValue!==undefined&&util.longNe(m.intValue,0,0))
256+
if(m.intValue!==undefined&&m.intValue!==null&&util.longNe(m.intValue,0,0))
257257
w.uint32(32).int64(m.intValue)
258-
if(m.uintValue!==undefined&&util.longNe(m.uintValue,0,0))
258+
if(m.uintValue!==undefined&&m.uintValue!==null&&util.longNe(m.uintValue,0,0))
259259
w.uint32(40).uint64(m.uintValue)
260-
if(m.sintValue!==undefined&&util.longNe(m.sintValue,0,0))
260+
if(m.sintValue!==undefined&&m.sintValue!==null&&util.longNe(m.sintValue,0,0))
261261
w.uint32(48).sint64(m.sintValue)
262262
if(m.boolValue!==undefined&&m.boolValue!==false)
263263
w.uint32(56).bool(m.boolValue)
@@ -269,8 +269,8 @@ $root.vector_tile = (function() {
269269
/**
270270
* Encodes the specified Value, length delimited.
271271
* @param {vector_tile.Tile.Value|Object} message Value or plain object to encode
272-
* @param {Writer} [writer] Writer to encode to
273-
* @returns {Writer} Writer
272+
* @param {$protobuf.Writer} [writer] Writer to encode to
273+
* @returns {$protobuf.Writer} Writer
274274
*/
275275
Value.encodeDelimited = function encodeDelimited(message, writer) {
276276
return this.encode(message, writer).ldelim();
@@ -279,7 +279,7 @@ $root.vector_tile = (function() {
279279
/**
280280
* Decodes a Value from the specified reader or buffer.
281281
* @function
282-
* @param {Reader|Uint8Array} readerOrBuffer Reader or buffer to decode from
282+
* @param {$protobuf.Reader|Uint8Array} readerOrBuffer Reader or buffer to decode from
283283
* @param {number} [length] Message length if known beforehand
284284
* @returns {vector_tile.Tile.Value} Value
285285
*/
@@ -327,7 +327,7 @@ $root.vector_tile = (function() {
327327

328328
/**
329329
* Decodes a Value from the specified reader or buffer, length delimited.
330-
* @param {Reader|Uint8Array} readerOrBuffer Reader or buffer to decode from
330+
* @param {$protobuf.Reader|Uint8Array} readerOrBuffer Reader or buffer to decode from
331331
* @returns {vector_tile.Tile.Value} Value
332332
*/
333333
Value.decodeDelimited = function decodeDelimited(readerOrBuffer) {
@@ -438,8 +438,8 @@ $root.vector_tile = (function() {
438438
* Encodes the specified Feature.
439439
* @function
440440
* @param {vector_tile.Tile.Feature|Object} message Feature or plain object to encode
441-
* @param {Writer} [writer] Writer to encode to
442-
* @returns {Writer} Writer
441+
* @param {$protobuf.Writer} [writer] Writer to encode to
442+
* @returns {$protobuf.Writer} Writer
443443
*/
444444
Feature.encode = (function() {
445445
/* eslint-disable */
@@ -448,7 +448,7 @@ $root.vector_tile = (function() {
448448
var types; $lazyTypes.push(types = [null,null,"vector_tile.Tile.GeomType",null]);
449449
return function encode(m, w) {
450450
w||(w=Writer.create())
451-
if(m.id!==undefined&&util.longNe(m.id,0,0))
451+
if(m.id!==undefined&&m.id!==null&&util.longNe(m.id,0,0))
452452
w.uint32(8).uint64(m.id)
453453
if(m.tags&&m.tags.length){
454454
w.uint32(18).fork()
@@ -472,8 +472,8 @@ $root.vector_tile = (function() {
472472
/**
473473
* Encodes the specified Feature, length delimited.
474474
* @param {vector_tile.Tile.Feature|Object} message Feature or plain object to encode
475-
* @param {Writer} [writer] Writer to encode to
476-
* @returns {Writer} Writer
475+
* @param {$protobuf.Writer} [writer] Writer to encode to
476+
* @returns {$protobuf.Writer} Writer
477477
*/
478478
Feature.encodeDelimited = function encodeDelimited(message, writer) {
479479
return this.encode(message, writer).ldelim();
@@ -482,7 +482,7 @@ $root.vector_tile = (function() {
482482
/**
483483
* Decodes a Feature from the specified reader or buffer.
484484
* @function
485-
* @param {Reader|Uint8Array} readerOrBuffer Reader or buffer to decode from
485+
* @param {$protobuf.Reader|Uint8Array} readerOrBuffer Reader or buffer to decode from
486486
* @param {number} [length] Message length if known beforehand
487487
* @returns {vector_tile.Tile.Feature} Feature
488488
*/
@@ -533,7 +533,7 @@ $root.vector_tile = (function() {
533533

534534
/**
535535
* Decodes a Feature from the specified reader or buffer, length delimited.
536-
* @param {Reader|Uint8Array} readerOrBuffer Reader or buffer to decode from
536+
* @param {$protobuf.Reader|Uint8Array} readerOrBuffer Reader or buffer to decode from
537537
* @returns {vector_tile.Tile.Feature} Feature
538538
*/
539539
Feature.decodeDelimited = function decodeDelimited(readerOrBuffer) {
@@ -659,8 +659,8 @@ $root.vector_tile = (function() {
659659
* Encodes the specified Layer.
660660
* @function
661661
* @param {vector_tile.Tile.Layer|Object} message Layer or plain object to encode
662-
* @param {Writer} [writer] Writer to encode to
663-
* @returns {Writer} Writer
662+
* @param {$protobuf.Writer} [writer] Writer to encode to
663+
* @returns {$protobuf.Writer} Writer
664664
*/
665665
Layer.encode = (function() {
666666
/* eslint-disable */
@@ -690,8 +690,8 @@ $root.vector_tile = (function() {
690690
/**
691691
* Encodes the specified Layer, length delimited.
692692
* @param {vector_tile.Tile.Layer|Object} message Layer or plain object to encode
693-
* @param {Writer} [writer] Writer to encode to
694-
* @returns {Writer} Writer
693+
* @param {$protobuf.Writer} [writer] Writer to encode to
694+
* @returns {$protobuf.Writer} Writer
695695
*/
696696
Layer.encodeDelimited = function encodeDelimited(message, writer) {
697697
return this.encode(message, writer).ldelim();
@@ -700,7 +700,7 @@ $root.vector_tile = (function() {
700700
/**
701701
* Decodes a Layer from the specified reader or buffer.
702702
* @function
703-
* @param {Reader|Uint8Array} readerOrBuffer Reader or buffer to decode from
703+
* @param {$protobuf.Reader|Uint8Array} readerOrBuffer Reader or buffer to decode from
704704
* @param {number} [length] Message length if known beforehand
705705
* @returns {vector_tile.Tile.Layer} Layer
706706
*/
@@ -748,7 +748,7 @@ $root.vector_tile = (function() {
748748

749749
/**
750750
* Decodes a Layer from the specified reader or buffer, length delimited.
751-
* @param {Reader|Uint8Array} readerOrBuffer Reader or buffer to decode from
751+
* @param {$protobuf.Reader|Uint8Array} readerOrBuffer Reader or buffer to decode from
752752
* @returns {vector_tile.Tile.Layer} Layer
753753
*/
754754
Layer.decodeDelimited = function decodeDelimited(readerOrBuffer) {

0 commit comments

Comments
 (0)