This is the stencila
package for Node.js. It uses Neon
to expose functionality implemented in the Stencila Rust library to Node.js. The main use of this package is to provide core functionality to the Electron-based Stencila Desktop application.
npm install stencila
import * as stencila from 'stencila'
See the in-code doc comment and the tests for more examples of usage. See the Neon docs for advice on using in Electron apps.
Given this package is a set of bindings to the Stencila Rust library you'll need to have Rust installed to build it. Then, get started by cloning this repository, installing dependencies and building the package:
git clone git@github.com:stencila/stencila
cd stencila/node
make setup build
Please run formatting, linting and testing before contributing code e.g.
make format lint test
There are tests in src/*.test.ts
files. Note that most of these tests are aimed at picking up regressions in the API of this package, and not of the correctness of the wrapped Rust code for which tests exists in ../rust
.
This project was bootstrapped by create-neon. Its directory structure is something like:
node/
├── Cargo.toml
├── README.md
├── index.node
├── package.json
├── src/
| └── lib.rs
| └── index.ts
| └── *.rs
| └── *.ts
| └── *.test.ts
The index.node
file is a Node addon—i.e., a binary Node module—generated by building the project. Under the hood, a Node addon is a dynamically-linked shared object. The "build"
script produces this file by copying it from within the ../target/
directory, which is where the Rust build produces the shared object.
To learn more about Neon, see the Neon documentation. To learn more about Rust, see the Rust documentation. To learn more about Node, see the Node documentation.