-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Other: Added infrastructure for TypeScript support of extensions
- Loading branch information
Showing
10 changed files
with
187 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
protobufjs/ext/descriptor | ||
========================= | ||
|
||
Experimental [protobuf.js](https://github.com/dcodeIO/protobuf.js) extension for interoperability with descriptor.proto types. | ||
|
||
Usage | ||
----- | ||
|
||
```js | ||
var protobuf = require("protobufjs"), | ||
descriptor = require("protobufjs/ext/descriptor"); | ||
|
||
var descriptor = ...; // either a FieldDescriptorSet buffer or JSON object | ||
var root = protobuf.Root.fromDescriptor(descriptor); | ||
var rootDescriptor = root.toDescriptor("proto3"); | ||
``` | ||
|
||
API | ||
--- | ||
|
||
The extension adds `.fromDescriptor(descriptor[, syntax])` and `#toDescriptor([syntax])` methods to reflection objects and exports the internally used `Root` instance that contains the types present in descriptor.proto. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
import * as $protobuf from "../.."; | ||
|
||
declare const descriptor: $protobuf.Root; | ||
|
||
interface IFileDescriptorSet { | ||
file: IFileDescriptorProto[]; | ||
} | ||
|
||
interface IFileDescriptorProto { | ||
name?: string; | ||
package?: string; | ||
dependency?: any; | ||
publicDependency?: any; | ||
weakDependency?: any; | ||
messageType?: IDescriptorProto[]; | ||
enumType?: IEnumDescriptorProto[]; | ||
service?: IServiceDescriptorProto[]; | ||
extension?: IFieldDescriptorProto[]; | ||
options?: any; | ||
sourceCodeInfo?: any; | ||
syntax?: string; | ||
} | ||
|
||
interface IDescriptorProto { | ||
name?: string; | ||
field?: IFieldDescriptorProto[]; | ||
extension?: IFieldDescriptorProto[]; | ||
nestedType?: IDescriptorProto[]; | ||
enumType?: IEnumDescriptorProto[]; | ||
extensionRange?: IExtensionRange[]; | ||
oneofDecl?: IOneofDescriptorProto[]; | ||
options?: IMessageOptions; | ||
reservedRange?: IReservedRange[]; | ||
reservedName?: string[]; | ||
} | ||
|
||
interface IMessageOptions { | ||
mapEntry?: any; | ||
} | ||
|
||
interface IExtensionRange { | ||
start?: number; | ||
end?: number; | ||
} | ||
|
||
interface IReservedRange { | ||
start?: number; | ||
end?: number; | ||
} | ||
|
||
interface IFieldDescriptorProto { | ||
name?: string; | ||
number?: number; | ||
label?: IFieldDescriptorProto_Label; | ||
type?: IFieldDescriptorProto_Type; | ||
typeName?: string; | ||
extendee?: string; | ||
defaultValue?: any; | ||
oneofIndex?: number; | ||
jsonName?: any; | ||
options?: IFieldOptions; | ||
} | ||
|
||
type IFieldDescriptorProto_Label = number; | ||
|
||
type IFieldDescriptorProto_Type = number; | ||
|
||
interface IFieldOptions { | ||
packed?: boolean; | ||
} | ||
|
||
interface IEnumDescriptorProto { | ||
name?: string; | ||
value?: IEnumValueDescriptorProto[]; | ||
options?: IEnumOptions; | ||
} | ||
|
||
interface IEnumValueDescriptorProto { | ||
name?: string; | ||
number?: number; | ||
options?: any; | ||
} | ||
|
||
interface IEnumOptions { | ||
allowAlias?: boolean; | ||
} | ||
|
||
interface IOneofDescriptorProto { | ||
name?: string; | ||
options?: any; | ||
} | ||
|
||
interface IServiceDescriptorProto { | ||
name?: string; | ||
method?: IMethodDescriptorProto[]; | ||
options?: any; | ||
} | ||
|
||
interface IMethodDescriptorProto { | ||
name?: string; | ||
inputType?: string; | ||
outputType?: string; | ||
options?: any; | ||
clientStreaming?: boolean; | ||
serverStreaming?: boolean; | ||
} | ||
|
||
export = descriptor; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.