-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: get the official "addressbook" example working in JS (#56)
This introduces capnpc-js, and a new js-examples package that should be prominent within the repo, and have minimal dependencies to serve as a reference. It doubles as a full integration test of the system (although it's a little light on validation, as is the original in the C++ repo).
- Loading branch information
1 parent
e57ae0d
commit 952b21d
Showing
33 changed files
with
877 additions
and
138 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
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,12 @@ | ||
#! /usr/bin/env bash | ||
# | ||
# Installs capnproto from a release tarball (because the versions in apt is too old) | ||
|
||
set -exuo pipefail | ||
|
||
curl -O https://capnproto.org/capnproto-c++-0.6.1.tar.gz | ||
tar zxf capnproto-c++-0.6.1.tar.gz | ||
cd capnproto-c++-0.6.1 | ||
./configure --prefix=$HOME/opt | ||
make -j6 | ||
make install |
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,10 @@ | ||
{ | ||
"compilerOptions": { | ||
"outDir": "../../packages/capnpc-js/lib-test", | ||
"rootDir": "../../packages/capnpc-js/test" | ||
}, | ||
"extends": "../tsconfig-base", | ||
"include": [ | ||
"../../packages/capnpc-js/test/**/*.ts" | ||
] | ||
} |
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,11 @@ | ||
{ | ||
"compilerOptions": { | ||
"declaration": true, | ||
"outDir": "../../packages/capnpc-js/lib", | ||
"rootDir": "../../packages/capnpc-js/src" | ||
}, | ||
"extends": "../tsconfig-base", | ||
"include": [ | ||
"../../packages/capnpc-js/src/**/*.ts" | ||
] | ||
} |
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,3 @@ | ||
Example of using `capnp-ts` in a JavaScript project. This is just a JavaScript version of [the official C++ samples](https://github.com/capnproto/capnproto/tree/master/c%2B%2B/samples) | ||
|
||
See `test.sh` for how to run them. |
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,52 @@ | ||
# Copyright (c) 2013-2014 Sandstorm Development Group, Inc. and contributors | ||
# Licensed under the MIT License: | ||
# | ||
# Permission is hereby granted, free of charge, to any person obtaining a copy | ||
# of this software and associated documentation files (the "Software"), to deal | ||
# in the Software without restriction, including without limitation the rights | ||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
# copies of the Software, and to permit persons to whom the Software is | ||
# furnished to do so, subject to the following conditions: | ||
# | ||
# The above copyright notice and this permission notice shall be included in | ||
# all copies or substantial portions of the Software. | ||
# | ||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
# THE SOFTWARE. | ||
|
||
@0xef1b5abe02e1f8d4; | ||
|
||
struct Person { | ||
id @0 :UInt32; | ||
name @1 :Text; | ||
email @2 :Text; | ||
phones @3 :List(PhoneNumber); | ||
|
||
struct PhoneNumber { | ||
number @0 :Text; | ||
type @1 :Type; | ||
|
||
enum Type { | ||
mobile @0; | ||
home @1; | ||
work @2; | ||
} | ||
} | ||
|
||
employment :union { | ||
unemployed @4 :Void; | ||
employer @5 :Text; | ||
school @6 :Text; | ||
selfEmployed @7 :Void; | ||
# We assume that a person is only one of these. | ||
} | ||
} | ||
|
||
struct AddressBook { | ||
people @0 :List(Person); | ||
} |
Oops, something went wrong.