diff --git a/javascript/net/grpc/web/grpc_generator.cc b/javascript/net/grpc/web/grpc_generator.cc index 9811f3a..29e253a 100644 --- a/javascript/net/grpc/web/grpc_generator.cc +++ b/javascript/net/grpc/web/grpc_generator.cc @@ -1027,8 +1027,11 @@ void PrintMethodDescriptorFile(Printer* printer, printer->Print( vars, "/**\n" - " * @fileoverview gRPC-Web generated MethodDescriptors for $package$\n" - " * @enhanceable\n" + " * @fileoverview gRPC-Web generated MethodDescriptors for $package$\n"); + if (vars["plugins"].empty()) { + printer->Print(" * @enhanceable\n"); + } + printer->Print( " * @public\n" " */\n\n" "// GENERATED CODE -- DO NOT EDIT!\n\n\n" @@ -1038,6 +1041,11 @@ void PrintMethodDescriptorFile(Printer* printer, printer->Print(vars, "goog.provide('proto.$package_dot$$class_name$.$" "method_name$MethodDescriptor');\n\n"); + if (!vars["plugins"].empty()) { + printer->Print(vars, + "goog.require('$plugins$.$package_dot$$class_name$.$" + "method_name$MethodDescriptor');\n"); + } printer->Print(vars, "goog.require('grpc.web.MethodDescriptor');\n"); printer->Print(vars, "goog.require('grpc.web.MethodType');\n"); printer->Print(vars, "goog.require('$in_type$');\n"); @@ -1507,6 +1515,7 @@ class GeneratorOptions { string OutputFile(const string& proto_file) const; string mode() const { return mode_; } + string plugins() const { return plugins_; } ImportStyle import_style() const { return import_style_; } bool generate_dts() const { return generate_dts_; } bool generate_closure_es6() const { return generate_closure_es6_; } @@ -1516,6 +1525,7 @@ class GeneratorOptions { private: string file_name_; string mode_; + string plugins_; ImportStyle import_style_; bool generate_dts_; bool generate_closure_es6_; @@ -1526,6 +1536,7 @@ class GeneratorOptions { GeneratorOptions::GeneratorOptions() : file_name_(""), mode_(""), + plugins_(""), import_style_(ImportStyle::CLOSURE), generate_dts_(false), generate_closure_es6_(false), @@ -1566,6 +1577,8 @@ bool GeneratorOptions::ParseFromOptions( } } else if ("multiple_files" == option.first) { multiple_files_ = "True" == option.second; + } else if ("plugins" == option.first) { + plugins_ = option.second; } else if ("goog_promise" == option.first) { goog_promise_ = "True" == option.second; } else { @@ -1620,6 +1633,7 @@ class GrpcCodeGenerator : public CodeGenerator { vars["package"] = package; vars["package_dot"] = package.empty() ? "" : package + '.'; vars["promise"] = "Promise"; + vars["plugins"] = generator_options.plugins(); if ("binary" == generator_options.mode()) { vars["mode"] = GetModeVar(Mode::OP); diff --git a/javascript/net/grpc/web/streambodyclientreadablestream.js b/javascript/net/grpc/web/streambodyclientreadablestream.js index a2ecf38..f8b5c93 100644 --- a/javascript/net/grpc/web/streambodyclientreadablestream.js +++ b/javascript/net/grpc/web/streambodyclientreadablestream.js @@ -139,8 +139,8 @@ class StreamBodyClientReadableStream { const responseMessage = this.grpcResponseDeserializeFn_(response); const grpcStatus = StatusCode.fromHttpStatus(this.xhr_.getStatus()); if (grpcStatus == StatusCode.OK) { - this.sendDataCallbacks_(responseMessage); this.sendMetadataCallbacks_(this.readHeaders_()); + this.sendDataCallbacks_(responseMessage); } else { this.sendErrorCallbacks_( /** @type {!GrpcWebError} */ ({