Skip to content

Commit

Permalink
Updated CONTRIBUTING
Browse files Browse the repository at this point in the history
Plus a few fixed h/t linter
  • Loading branch information
elsehow committed Dec 13, 2016
1 parent 1ac4aa1 commit 7eadccb
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 18 deletions.
47 changes: 37 additions & 10 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
## Contributing
# Contributing

Thank you for contributing!

The source is organized like this:

```
/dist # Distributables
/build # Intermediate build files
/src # JS source files
/native # C source files for curve25519
/protos # Protobuf definitions
/test # Tests
```
## Getting started

To compile curve25519 from C souce files in `/native`, install
[emscripten](https://kripken.github.io/emscripten-site/docs/getting_started/downloads.html).
Expand All @@ -32,6 +24,26 @@ then set the appropriate envirionment variables to run the tests:
SAUCE_USERNAME="your-sauce-username" SAUCE_ACCESS_KEY="your-sauce-key" grunt test
```

## Code structure

The source is organized like this:

```
/dist # Distributables
/build # Intermediate build files
/src # JS source files
/native # C source files for curve25519
/protos # Protobuf definitions
/test # Tests
```

The main app entrypoint is `src/main.js`. This is what the caller would require in node, or bundle in browserify (though see note below, Node/browser polyfills).

The main test entrypoint is `test/main.js`.
`test/index.html` compiles everything we need for our tests in the browser.

You can run these by serving the project root and visiting /test (e.g. http://localhost:8000/test).


## Node/browser polyfills

Expand All @@ -41,3 +53,18 @@ Just search the source for:
```js
// BROWSER POLYFILL
```

to see where they are used.

The file with *all* the polyfills is `src/node_polyfills.js`

We ignore this file when we do our browserify build for testing.

**NOTE/QUESTION**.
Ignoring the polyfill in our test browserify build certainly makes the tests pass, but a caller who downloads the stuff from npm, tries to `require` our package and browserify it for themelves, will be in for a nasty surprise. Lots of native gunk will show up in their browserify errors, and they will probably be confused and walk away. So, how should we make the browser-side require more seamless? Can we have people require a browserified build we produce?


## TODO
- Integrate native test into grunt test routine
- Travis builds for node?
- Fix native bundling issue, mentioned above
13 changes: 7 additions & 6 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
var child_process = require('child_process');
var util = require('util');

// browserify should ignore the native polyfills
var browserifyOpts = {
exclude: ['src/node_polyfills.js'],
};

module.exports = function(grunt) {
'use strict';

Expand All @@ -10,16 +15,12 @@ module.exports = function(grunt) {
legacy: {
src: 'src/main_window.js',
dest: 'dist/libsignal.js',
options: {
exclude: ['src/node_polyfills.js'],
}
options: browserifyOpts
},
test: {
src: 'test/main.js',
dest: 'build/test_main.js',
options: {
exclude: ['src/node_polyfills.js'],
}
options: browserifyOpts
}
},
concat: {
Expand Down
4 changes: 2 additions & 2 deletions src/curve25519_worker_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function workerRoutine () {
self.postMessage({ id: e.data.id, error: error.message });
});
};
};
}


function Curve25519Worker() {
Expand All @@ -22,7 +22,7 @@ function Curve25519Worker() {
try {
var work = require('webworkify');
this.worker = work(function (self) {
workerRoutine()
workerRoutine();
});
} catch (e) {
var Worker = require('./node_polyfills.js').Worker;
Expand Down

0 comments on commit 7eadccb

Please sign in to comment.