protoc-gen-ts
Advanced tools
Comparing version 0.8.0 to 0.8.1
{ | ||
"name": "protoc-gen-ts", | ||
"description": "Compile protocol buffers descriptors to Typescript.", | ||
"version": "0.8.0", | ||
"version": "0.8.1", | ||
"license": "MIT", | ||
@@ -17,3 +17,3 @@ "author": { | ||
"test": "bazel build //test:codegen //test:codegen_experimental //test/conformance:codegen && node ./scripts/sync_generated_protos.js test && bazel test //test/... --test_output=errors", | ||
"release": "bazel run //:package.publish -- --access public --tag latest --registry https://registry.npmjs.org", | ||
"release": "npm publish --access public --tag latest --registry https://registry.npmjs.org", | ||
"codegen": "node ./scripts/sync_compiler_protos.js && bazel build //src:codegen && node ./scripts/sync_generated_protos.js src/compiler && bazel build //src:compiler && node ./scripts/sync_generated_protos.js src/compiler js" | ||
@@ -20,0 +20,0 @@ }, |
@@ -97,12 +97,2 @@ # Protoc Gen Typescript | ||
## Support | ||
If you find this plugin useful please consider giving us a star to get into open collective. | ||
You can also support me directly by buying me one or two coffee, | ||
<a href="https://www.buymeacoffee.com/thesayyn"> | ||
<img height="40px" src="https://img.buymeacoffee.com/button-api/?text=Buy me a coffee&emoji=🙌&slug=thesayyn&button_colour=FFDD00&font_colour=000000&font_family=Cookie&outline_colour=000000&coffee_colour=ffffff"> | ||
</a> | ||
## Key Differences | ||
@@ -131,3 +121,3 @@ | ||
load("@npm_protoc_gen_ts//:index.bzl", "ts_proto_library") | ||
load("@npm//protoc-gen-ts//:index.bzl", "ts_proto_library") | ||
@@ -160,2 +150,3 @@ ts_proto_library( | ||
- <s>Support `map<TYPE, TYPE>` types as ES `Map`.</s> | ||
- Support grpc-web without any manual intervention. | ||
- Interopability with well knowns. | ||
@@ -188,1 +179,12 @@ | ||
![GitHub Contributors Image](https://contrib.rocks/image?repo=thesayyn/protoc-gen-ts) | ||
## Support | ||
If you find this plugin useful please consider giving us a star to get into open collective. | ||
You can also support me directly by buying us some coffees. | ||
<a href="https://www.buymeacoffee.com/thesayyn"> | ||
<img height="40px" src="https://img.buymeacoffee.com/button-api/?text=Buy me a coffee&emoji=🙌&slug=thesayyn&button_colour=FFDD00&font_colour=000000&font_family=Cookie&outline_colour=000000&coffee_colour=ffffff"> | ||
</a> |
@@ -6,5 +6,5 @@ "use strict"; | ||
* Generated by the protoc-gen-ts. DO NOT EDIT! | ||
* compiler version: 3.17.0 | ||
* source: src/compiler/plugin.proto | ||
* git: https://github.com/thesayyn/protoc-gen-ts | ||
* buymeacoffee: https://www.buymeacoffee.com/thesayyn | ||
* */ | ||
@@ -56,2 +56,18 @@ const dependency_1 = require("./descriptor"); | ||
} | ||
static fromObject(data) { | ||
const message = new Version({}); | ||
if (data.major != null) { | ||
message.major = data.major; | ||
} | ||
if (data.minor != null) { | ||
message.minor = data.minor; | ||
} | ||
if (data.patch != null) { | ||
message.patch = data.patch; | ||
} | ||
if (data.suffix != null) { | ||
message.suffix = data.suffix; | ||
} | ||
return message; | ||
} | ||
toObject() { | ||
@@ -156,2 +172,15 @@ const data = {}; | ||
} | ||
static fromObject(data) { | ||
const message = new CodeGeneratorRequest({ | ||
file_to_generate: data.file_to_generate, | ||
proto_file: data.proto_file.map(item => dependency_1.FileDescriptorProto.fromObject(item)) | ||
}); | ||
if (data.parameter != null) { | ||
message.parameter = data.parameter; | ||
} | ||
if (data.compiler_version != null) { | ||
message.compiler_version = Version.fromObject(data.compiler_version); | ||
} | ||
return message; | ||
} | ||
toObject() { | ||
@@ -246,2 +275,14 @@ const data = { | ||
} | ||
static fromObject(data) { | ||
const message = new CodeGeneratorResponse({ | ||
file: data.file.map(item => CodeGeneratorResponse.File.fromObject(item)) | ||
}); | ||
if (data.error != null) { | ||
message.error = data.error; | ||
} | ||
if (data.supported_features != null) { | ||
message.supported_features = data.supported_features; | ||
} | ||
return message; | ||
} | ||
toObject() { | ||
@@ -347,2 +388,18 @@ const data = { | ||
} | ||
static fromObject(data) { | ||
const message = new File({}); | ||
if (data.name != null) { | ||
message.name = data.name; | ||
} | ||
if (data.insertion_point != null) { | ||
message.insertion_point = data.insertion_point; | ||
} | ||
if (data.content != null) { | ||
message.content = data.content; | ||
} | ||
if (data.generated_code_info != null) { | ||
message.generated_code_info = dependency_1.GeneratedCodeInfo.fromObject(data.generated_code_info); | ||
} | ||
return message; | ||
} | ||
toObject() { | ||
@@ -349,0 +406,0 @@ const data = {}; |
@@ -151,3 +151,3 @@ const descriptor = require("./compiler/descriptor"); | ||
*/ | ||
function isNumber(fieldDescriptor) { | ||
function isNumber(fieldDescriptor) { | ||
switch (fieldDescriptor.type) { | ||
@@ -215,8 +215,8 @@ case descriptor.FieldDescriptorProto.Type.TYPE_DOUBLE: | ||
/** | ||
* @param {descriptor.FieldDescriptorProto} fieldDescriptor | ||
* | ||
* @param {descriptor.FieldDescriptorProto.Type} type | ||
* @see https://github.com/protocolbuffers/protobuf/blob/ef8d418fad8366f9854127eb4338b0757eda9aa3/src/google/protobuf/descriptor.h#L2392 | ||
*/ | ||
function isPackable(fieldDescriptor) { | ||
const type = fieldDescriptor.type | ||
function isTypePackable(type) { | ||
return ( | ||
isRepeated(fieldDescriptor) && | ||
type != descriptor.FieldDescriptorProto.Type.TYPE_STRING && | ||
@@ -229,3 +229,14 @@ type != descriptor.FieldDescriptorProto.Type.TYPE_GROUP && | ||
/** | ||
* @param {descriptor.FieldDescriptorProto} fieldDescriptor | ||
* @see https://github.com/protocolbuffers/protobuf/blob/ef8d418fad8366f9854127eb4338b0757eda9aa3/src/google/protobuf/descriptor.h#L2283 | ||
*/ | ||
function isPackable(fieldDescriptor) { | ||
return ( | ||
isRepeated(fieldDescriptor) && | ||
isTypePackable(fieldDescriptor.type) | ||
); | ||
} | ||
/** | ||
@@ -236,5 +247,3 @@ * @param {descriptor.FileDescriptorProto} rootDescriptor | ||
function isPacked(rootDescriptor, fieldDescriptor) { | ||
if (!isPackable(fieldDescriptor)) { | ||
return false; | ||
} | ||
if (!isPackable(fieldDescriptor)) return false; | ||
const options = fieldDescriptor.options; | ||
@@ -246,5 +255,5 @@ // weirdly the compiler does not send the syntax information | ||
return !options || options.packed == null || options.packed; | ||
} | ||
return options != null && options.packed | ||
} | ||
return (options != null) && options.packed | ||
} | ||
@@ -251,0 +260,0 @@ |
@@ -148,4 +148,3 @@ const plugin = require("./compiler/plugin"); | ||
`source: ${fileDescriptor.name}\n` + | ||
`git: https://github.com/thesayyn/protoc-gen-ts\n` + | ||
`buymeacoffee: https://www.buymeacoffee.com/thesayyn\n` | ||
`git: https://github.com/thesayyn/protoc-gen-ts\n` | ||
); | ||
@@ -152,0 +151,0 @@ |
@@ -248,3 +248,3 @@ const type = require("./type"); | ||
grpcIdentifier, | ||
ts.factory.createIdentifier("requestCallback"), | ||
ts.factory.createIdentifier("sendUnaryData"), | ||
), | ||
@@ -251,0 +251,0 @@ [getRPCOutputType(rootDescriptor, methodDescriptor)], |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
187
296629
13
7469