Add a typescript declaration file.
This covers most of the API that is documented in the README, though I
see that there are some things exposed in `capnp.js` but not documented
-- the declaration file does not currently cover those.
This is designed to work with the output of:
https://github.com/zenhack/capnpc-node-typescript
...which is nearing completion.
This commit is contained in:
1 parent
544bf09271
commit
6eb94df293
2 files changed
+36
No files matched your search
@@ -19,6 +19,7 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"main": "src/node-capnp/capnp.js",
|
"main": "src/node-capnp/capnp.js",
|
||||||
|
"types": "src/node-capnp/capnp.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"install": "node ./build.js",
|
"install": "node ./build.js",
|
||||||
"test": "node src/node-capnp/capnp-test.js"
|
"test": "node src/node-capnp/capnp-test.js"
|
||||||
|
|||||||
Vendored
+35
@@ -0,0 +1,35 @@
|
|||||||
|
declare module Capnp {
|
||||||
|
type Id = string;
|
||||||
|
|
||||||
|
abstract class StructSchema<Builder, Reader> {
|
||||||
|
typeId: Id;
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class InterfaceSchema<Server, Client> {
|
||||||
|
typeId: Id;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface AnyServer {
|
||||||
|
close?: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface AnyClient {
|
||||||
|
close(): void;
|
||||||
|
closed: boolean;
|
||||||
|
castAs<Server, Client>(schema: InterfaceSchema<Server, Client>): Client;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Capability: {
|
||||||
|
new<Server, Client>(server: Server, schema: InterfaceSchema<Server, Client>): Client;
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class Connection {
|
||||||
|
restore<Server, Client>(exportName: string, type: InterfaceSchema<Server, Client>): Client;
|
||||||
|
close(): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
function parse<Builder, Reader>(type: StructSchema<Builder, Reader>, buffer: Buffer): Reader;
|
||||||
|
function serialize<Builder, Reader>(type: StructSchema<Builder, Reader>, reader: Reader): Buffer;
|
||||||
|
function connect(addr: string): Connection;
|
||||||
|
}
|
||||||
|
export default Capnp;
|
||||||
Reference in new issue
Block a user