28 Commits
Author SHA1 Message Date
Kenton Varda 18c54885f4 Merge pull request #71 from orblivion/patch-1
Suggest libcapnp-dev instead of capnproto-dev
2021-10-05 19:28:50 -05:00
Daniel Krol 644e5e4a4d Suggest libcapnp-dev instead of capnproto-dev
https://github.com/capnproto/node-capnp/issues/25

I don't see capnproto-dev in Debian Buster either.
2021-10-04 21:38:23 -04:00
Kenton Varda ca17e686f2 Port to Node 14. 2021-09-04 12:06:22 -05:00
Kenton Varda a2ed298d34 Merge pull request #68 from zenhack/module-stubs
Add .capnp.js stubs generated by capnpc-node-typescript.
2020-12-16 21:52:36 -06:00
Kenton Varda 8509161f7c Merge pull request #67 from zenhack/typescript-decl-fix
Small fix in the typescript declarations, and add some comments.
2020-12-14 16:53:50 -06:00
Ian Denhardt b88ab5a305 Add .capnp.js stubs generated by capnpc-node-typescript.
Per discussion in #62, this allows importing modules to use "normal"
imports, which is important for typescript since it doesn't understand
`capnp.importSystem()` and friends.

We could also merge in the type declarations themselves, but that isn't
strictly necessary, since typescript is built around being able to
supply your own stubs for other libraries. I may do something in that
vein in a follow-on pr, but I want to think a bit about how this
will all fit together.
2020-12-12 02:29:24 -05:00
Ian Denhardt ac4c2574a6 ts declarations: Add comments describing how the type parameters work. 2020-12-12 02:00:08 -05:00
Ian Denhardt 0ba69aec95 Fix a mistake in the type declaration file.
The argument to serialize() should be a builder, not a reader.
2020-12-12 01:54:15 -05:00
Kenton Varda 7ef8da3d79 Merge pull request #66 from zenhack/gitignore-capnp.node
Add capnp.node to .gitignore
2020-12-07 13:39:16 -06:00
Ian Denhardt 0e9376071e Add capnp.node to .gitignore 2020-12-07 10:42:43 -05:00
Kenton Varda d75642d0e8 Merge pull request #62 from zenhack/typescript-declaration-file
Add a typescript declaration file.
2020-11-30 16:05:15 -06:00
Ian Denhardt 6eb94df293 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.
2020-10-28 16:30:22 -04:00
Kenton Varda 544bf09271 Merge pull request #60 from ocdtrekkie/patch-1
Readme typos
2020-06-08 09:53:11 -05:00
Jacob Weisz b45f75c8f9 Readme typos 2020-06-08 07:38:12 -05:00
Kenton Varda 752d3cdffd Merge pull request #59 from zenhack/null-handle-cleanup
More defensive/sensible handling of a case that probably can't happen.
2020-05-11 10:03:05 -05:00
Ian Denhardt 0371c68bcd More defensive/sensible handling of a case that probably can't happen.
I found this by running clang-analyzer. With the previous version of the
code, if `handler` is null, then we assign `self = nullptr` and then
immediately call a method on it.

I'm pretty sure this can't actually happen -- I don't think
`uv_timer_start` will ever pass nullptr to the callback -- but the logic
is obviously bogus so let's replace it with something defensive.
2020-05-09 23:56:19 -04:00
Kenton Varda ae6f591602 Merge pull request #58 from zenhack/version-bump
Bump version in package.json
2020-03-24 13:03:16 -05:00
Ian Denhardt 81aeebf181 Bump version in package.json
I just published this to the npm registry, we should probably update the
version in the git repo too.

It seems to work on node 12, though node 10 is still failing. I actually
*can* reproduce the failures locally if:

- I start a fresh npm project and do `npm install
  `/path/to/node-canpnp/src`
- The working directory for `node-capnp` is clean.

I may try to troubleshoot this more later. Perhaps we should unpublish,
but having a version that works on node 12 is possibly an improvement,
so maybe not...

Npm insisted that 0.4.0 already existed and was refusing to re-publish
it (I assume there was a deleted failed attempt), so I had to bump the
version to get it to work.
2020-03-23 16:01:04 -04:00
Kenton Varda 0cc5054ea2 Merge branch 'node8' into node10 2020-03-14 18:24:46 -05:00
Kenton Varda cdda439e4a Merge pull request #57 from redsift/node12
Node12 support
2020-03-14 17:25:45 -05:00
Kenton Varda 932e589f36 Merge pull request #55 from zenhack/exception-docs
Document how exceptions work.
2020-01-08 17:50:15 -06:00
Ian Denhardt 46fd0a8b6e Document how exceptions work.
Fixes #53.
2020-01-08 17:53:10 -05:00
Kenton Varda 5e8c4c0b1b Merge pull request #51 from redsift/fix/build
Fix the build process.
2020-01-07 10:56:44 -06:00
Deepak Prabhakara 7ab91af445 pipe stdout and stderr from child process so we can see the logs 2019-12-22 23:32:31 +00:00
Deepak Prabhakara 05644ec31b v8 and nan compilation fixes for node12 2019-12-22 23:26:49 +00:00
Christos Vontas 28de5052c0 Merge pull request #1 from redsift/fix/build
afterBuild needs to run after all IO has finished
2019-12-11 13:50:24 +00:00
Christos Vontas c720781a5f afterBuild needs to run after all IO has finished 2019-12-11 13:42:05 +00:00
Kenton Varda eae9c1c54b Update for Node 10. 2019-01-07 13:44:26 -08:00
12 changed files with 392 additions and 210 deletions

No files matched your search

+38 -3
View File
@@ -47,11 +47,11 @@ you must have development headers for Cap'n Proto and Node.js installed, along
with the `node-gyp` tool and a GCC new enough for Cap'n Proto (at least 4.7).
On Debian/Ubuntu, you can install these like so:
sudo apt-get install nodejs-dev nodejs-legacy capnproto-dev g++
sudo apt-get install nodejs-dev nodejs-legacy libcapnp-dev g++
### Form source
### From source
git clone git://github.com/kenton/node-capnp.git
git clone git://github.com/capnproto/node-capnp.git
cd node-capnp
npm install
@@ -118,6 +118,25 @@ we copied.)
// object containing the results by name.
promise.then(function(response) {
console.log(response.namedResult);
})
// If the remote object throws an rpc exception, the promise will be
// rejected. The error returned will have a property `kjType`, which
// will be a string representation of the exception's `type` field.
.catch(function(error) {
switch(error.kjType) {
case 'failed':
console.log("A generic problem occurred:", error.message);
break;
case 'overloaded':
console.log("Resource overload on the remote end:", error.message);
break;
case 'disconnected':
// ...
break;
case 'unimplemented':
// ...
break;
}
});
### Pipelining
@@ -196,6 +215,22 @@ then use that:
In this case, the library only wraps `myFoo` as a capability once, and then
calls `close()` once all copies of that reference have been dropped.
If one of your methods throws an exception, or returns a promise which
is subsequently rejected, it will be converted to a capnproto rpc
exception. If the exception has a `kjType` property, that will be used
for the exception's `type` field, otherwise the type will be `failed`.
var myBar = {
bar: function(foo) {
if(!bazAvailable()) {
var err = new Error("The baz is busy; try again later.");
err.kjType = 'overloaded';
throw(err);
}
// ...
}
}
### Exporting a bootstrap capability
// Connect to another server and export `myFoo` as a bootstrap capability.
+1
View File
@@ -0,0 +1 @@
capnp.node
+7 -3
View File
@@ -72,10 +72,13 @@ if (!force) {
// Build it
function build() {
cp.spawn(
var sp = cp.spawn(
process.platform === 'win32' ? 'node-gyp.cmd' : 'node-gyp',
['rebuild'].concat(args),
{customFds: [0, 1, 2]})
{customFds: [0, 1, 2]});
sp
.on('close', function(){ afterBuild(); })
.on('exit', function(err) {
if (err) {
if (err === 127) {
@@ -88,8 +91,9 @@ function build() {
}
return process.exit(err);
}
afterBuild();
});
sp.stdout.pipe(process.stdout);
sp.stderr.pipe(process.stderr);
}
// Move it to expected location
+1
View File
@@ -0,0 +1 @@
module.exports = require("capnp").importSystem("capnp/c++.capnp");
+7 -4
View File
@@ -1,8 +1,11 @@
{
"name": "capnp",
"version": "0.3.1",
"version": "0.5.0",
"description": "A wrapper for the C++ Cap'n Proto library",
"keywords": [ "capnproto", "serialization" ],
"keywords": [
"capnproto",
"serialization"
],
"homepage": "http://capnproto.org",
"author": {
"name": "Kenton Varda",
@@ -15,8 +18,8 @@
"email": "jparyani@gmail.com"
}
],
"main": "src/node-capnp/capnp.js",
"types": "src/node-capnp/capnp.d.ts",
"scripts": {
"install": "node ./build.js",
"test": "node src/node-capnp/capnp-test.js"
@@ -26,7 +29,7 @@
"url": "git://github.com/kentonv/node-capnp.git"
},
"engines": {
"node": ">=8.0"
"node": ">=10.0"
},
"license": "MIT"
}
+1
View File
@@ -0,0 +1 @@
module.exports = require("capnp").importSystem("capnp/persistent.capnp");
+1
View File
@@ -0,0 +1 @@
module.exports = require("capnp").importSystem("capnp/rpc-twoparty.capnp");
+1
View File
@@ -0,0 +1 @@
module.exports = require("capnp").importSystem("capnp/rpc.capnp");
+1
View File
@@ -0,0 +1 @@
module.exports = require("capnp").importSystem("capnp/schema.capnp");
+288 -200
View File
File diff suppressed because it is too large. Load diff
+45
View File
@@ -0,0 +1,45 @@
declare module Capnp {
type Id = string;
abstract class StructSchema<Builder, Reader> {
// A schema for a struct type. The `Builder` parameter is what users of
// the library specify in order to create a value; it may be missing fields,
// which will be filled in with defaults. A `Reader` is what is is returned
// when parsing a value, and is guaranteed to have all known fields set.
typeId: Id;
}
abstract class InterfaceSchema<Server, Client> {
// A schema for an interface type. Similarly to `StructSchema`, the `Server`
// and `Client` parameters represent objects which may have missing
// methods (for servers), and ones which do not (for clients, though calling
// the method may still throw unimplemented).
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>, builder: Builder): Buffer;
function connect(addr: string): Connection;
}
export default Capnp;
+1
View File
@@ -0,0 +1 @@
module.exports = require("capnp").importSystem("capnp/stream.capnp");