diff --git a/cli/targets/static.js b/cli/targets/static.js index d44be23c1..0c938b0ab 100644 --- a/cli/targets/static.js +++ b/cli/targets/static.js @@ -172,12 +172,9 @@ var shortVars = { function beautifyCode(code) { // Add semicolons code = UglifyJS.minify(code, { - fromString: true, compress: false, mangle: false, - output: { - beautify: true - } + output: { beautify: true } }).code; // Properly beautify var ast = espree.parse(code); @@ -653,11 +650,11 @@ function buildService(ref, service) { "@returns {undefined}", "@variation 1" ]); - push(escapeName(service.name) + ".prototype" + util.safeProp(lcName) + " = function " + escapeName(lcName) + "(request, callback) {"); + push("Object.defineProperty(" + 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("};"); + push("}, \"name\", { value: " + JSON.stringify(method.name) + " });"); if (config.comments) push(""); pushComment([ diff --git a/dist/light/protobuf.js b/dist/light/protobuf.js index 22a62d87f..560d1373c 100644 --- a/dist/light/protobuf.js +++ b/dist/light/protobuf.js @@ -1,6 +1,6 @@ /*! * protobuf.js v6.8.7 (c) 2016, daniel wirtz - * compiled wed, 16 may 2018 11:23:03 utc + * compiled fri, 18 may 2018 08:55:41 utc * licensed under the bsd-3-clause license * see: https://github.com/dcodeio/protobuf.js for details */ diff --git a/dist/light/protobuf.min.js b/dist/light/protobuf.min.js index e1722e118..e7f29a72a 100644 --- a/dist/light/protobuf.min.js +++ b/dist/light/protobuf.min.js @@ -1,6 +1,6 @@ /*! * protobuf.js v6.8.7 (c) 2016, daniel wirtz - * compiled wed, 16 may 2018 11:23:04 utc + * compiled fri, 18 may 2018 08:55:42 utc * licensed under the bsd-3-clause license * see: https://github.com/dcodeio/protobuf.js for details */ diff --git a/dist/minimal/protobuf.js b/dist/minimal/protobuf.js index c263d66a2..40e93b85a 100644 --- a/dist/minimal/protobuf.js +++ b/dist/minimal/protobuf.js @@ -1,6 +1,6 @@ /*! * protobuf.js v6.8.7 (c) 2016, daniel wirtz - * compiled wed, 16 may 2018 11:23:03 utc + * compiled fri, 18 may 2018 08:55:41 utc * licensed under the bsd-3-clause license * see: https://github.com/dcodeio/protobuf.js for details */ diff --git a/dist/minimal/protobuf.min.js b/dist/minimal/protobuf.min.js index 4a083c7ef..6bc126256 100644 --- a/dist/minimal/protobuf.min.js +++ b/dist/minimal/protobuf.min.js @@ -1,6 +1,6 @@ /*! * protobuf.js v6.8.7 (c) 2016, daniel wirtz - * compiled wed, 16 may 2018 11:23:04 utc + * compiled fri, 18 may 2018 08:55:42 utc * licensed under the bsd-3-clause license * see: https://github.com/dcodeio/protobuf.js for details */ diff --git a/dist/protobuf.js b/dist/protobuf.js index d49a382b6..993a966db 100644 --- a/dist/protobuf.js +++ b/dist/protobuf.js @@ -1,6 +1,6 @@ /*! * protobuf.js v6.8.7 (c) 2016, daniel wirtz - * compiled wed, 16 may 2018 11:23:03 utc + * compiled fri, 18 may 2018 08:55:41 utc * licensed under the bsd-3-clause license * see: https://github.com/dcodeio/protobuf.js for details */ diff --git a/dist/protobuf.min.js b/dist/protobuf.min.js index 401176891..d94c0f885 100644 --- a/dist/protobuf.min.js +++ b/dist/protobuf.min.js @@ -1,6 +1,6 @@ /*! * protobuf.js v6.8.7 (c) 2016, daniel wirtz - * compiled wed, 16 may 2018 11:23:04 utc + * compiled fri, 18 may 2018 08:55:42 utc * licensed under the bsd-3-clause license * see: https://github.com/dcodeio/protobuf.js for details */ diff --git a/google/protobuf/field_mask.json b/google/protobuf/field_mask.json deleted file mode 100644 index 8c887f8c7..000000000 --- a/google/protobuf/field_mask.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "nested": { - "google": { - "nested": { - "protobuf": { - "nested": { - "FieldMask": { - "fields": { - "paths": { - "rule": "repeated", - "type": "string", - "id": 1 - } - } - } - } - } - } - } - } -} \ No newline at end of file diff --git a/google/protobuf/field_mask.proto b/google/protobuf/field_mask.proto deleted file mode 100644 index 43c64bc3f..000000000 --- a/google/protobuf/field_mask.proto +++ /dev/null @@ -1,7 +0,0 @@ -syntax = "proto3"; - -package google.protobuf; - -message FieldMask { - repeated string paths = 1; -} diff --git a/scripts/gencommons.js b/scripts/gencommons.js index 79e3faaa2..b1eecc426 100644 --- a/scripts/gencommons.js +++ b/scripts/gencommons.js @@ -4,7 +4,6 @@ var pbjs = require("../cli/pbjs"); [ "google/protobuf/api.proto", "google/protobuf/descriptor.proto", - "google/protobuf/field_mask.proto", "google/protobuf/source_context.proto", "google/protobuf/type.proto", diff --git a/tests/data/convert.js b/tests/data/convert.js index 90cd4e844..592ccf180 100644 --- a/tests/data/convert.js +++ b/tests/data/convert.js @@ -482,7 +482,13 @@ $root.Message = (function() { object.uint64Val = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; } else object.uint64Val = options.longs === String ? "0" : 0; - object.bytesVal = options.bytes === String ? "" : []; + if (options.bytes === String) + object.bytesVal = ""; + else { + object.bytesVal = []; + if (options.bytes !== Array) + object.bytesVal = $util.newBuffer(object.bytesVal); + } object.enumVal = options.enums === String ? "ONE" : 1; } if (message.stringVal != null && message.hasOwnProperty("stringVal")) diff --git a/tests/data/rpc-es6.js b/tests/data/rpc-es6.js index 4103a287b..36377302b 100644 --- a/tests/data/rpc-es6.js +++ b/tests/data/rpc-es6.js @@ -58,9 +58,9 @@ export const MyService = $root.MyService = (() => { * @returns {undefined} * @variation 1 */ - MyService.prototype.myMethod = function myMethod(request, callback) { + Object.defineProperty(MyService.prototype.myMethod = function myMethod(request, callback) { return this.rpcCall(myMethod, $root.MyRequest, $root.MyResponse, request, callback); - }; + }, "name", { value: "MyMethod" }); /** * Calls MyMethod. diff --git a/tests/data/rpc-reserved.js b/tests/data/rpc-reserved.js index efee206b7..3f04feb0b 100644 --- a/tests/data/rpc-reserved.js +++ b/tests/data/rpc-reserved.js @@ -60,9 +60,9 @@ $root.MyService = (function() { * @returns {undefined} * @variation 1 */ - MyService.prototype["delete"] = function delete_(request, callback) { + Object.defineProperty(MyService.prototype["delete"] = function delete_(request, callback) { return this.rpcCall(delete_, $root.MyRequest, $root.MyResponse, request, callback); - }; + }, "name", { value: "Delete" }); /** * Calls Delete. diff --git a/tests/data/rpc.js b/tests/data/rpc.js index 14235e958..de99b6439 100644 --- a/tests/data/rpc.js +++ b/tests/data/rpc.js @@ -60,9 +60,9 @@ $root.MyService = (function() { * @returns {undefined} * @variation 1 */ - MyService.prototype.myMethod = function myMethod(request, callback) { + Object.defineProperty(MyService.prototype.myMethod = function myMethod(request, callback) { return this.rpcCall(myMethod, $root.MyRequest, $root.MyResponse, request, callback); - }; + }, "name", { value: "MyMethod" }); /** * Calls MyMethod. diff --git a/tests/data/test.js b/tests/data/test.js index 5ca0f7009..f3fc8243f 100644 --- a/tests/data/test.js +++ b/tests/data/test.js @@ -3550,11 +3550,17 @@ $root.jspb = (function() { object.intField = options.longs === String ? "11" : 11; object.enumField = options.enums === String ? "E1" : 13; object.emptyField = ""; - object.bytesField = options.bytes === String ? "moo" : [ - 109, - 111, - 111 - ]; + if (options.bytes === String) + object.bytesField = "moo"; + else { + object.bytesField = [ + 109, + 111, + 111 + ]; + if (options.bytes !== Array) + object.bytesField = $util.newBuffer(object.bytesField); + } } if (message.stringField != null && message.hasOwnProperty("stringField")) object.stringField = message.stringField; @@ -4285,7 +4291,13 @@ $root.jspb = (function() { if (options.defaults) { object.str = ""; object.simple1 = null; - object.bytesField = options.bytes === String ? "" : []; + if (options.bytes === String) + object.bytesField = ""; + else { + object.bytesField = []; + if (options.bytes !== Array) + object.bytesField = $util.newBuffer(object.bytesField); + } object.unused = ""; object[".jspb.test.CloneExtension.extField"] = null; } @@ -6709,7 +6721,13 @@ $root.jspb = (function() { var object = {}; if (options.defaults) { object.value = 0; - object.data = options.bytes === String ? "" : []; + if (options.bytes === String) + object.data = ""; + else { + object.data = []; + if (options.bytes !== Array) + object.data = $util.newBuffer(object.data); + } } if (message.value != null && message.hasOwnProperty("value")) object.value = message.value; @@ -14604,7 +14622,13 @@ $root.google = (function() { } else object.negativeIntValue = options.longs === String ? "0" : 0; object.doubleValue = 0; - object.stringValue = options.bytes === String ? "" : []; + if (options.bytes === String) + object.stringValue = ""; + else { + object.stringValue = []; + if (options.bytes !== Array) + object.stringValue = $util.newBuffer(object.stringValue); + } object.aggregateValue = ""; } if (message.name && message.name.length) {