1 | # [Loom.js](https://loomx.io) [![Build Status](https://travis-ci.org/loomnetwork/loom-js.svg?branch=master)](https://travis-ci.org/loomnetwork/loom-js)
|
2 |
|
3 | JS library for building browser apps & NodeJS services that interact with Loom DAppChains.
|
4 |
|
5 | ## Install
|
6 |
|
7 | ### NodeJS
|
8 |
|
9 | ```
|
10 | # NPM
|
11 | npm install loom-js
|
12 | # Yarn
|
13 | yarn add loom-js
|
14 | ```
|
15 |
|
16 | ### Browser
|
17 |
|
18 | ```html
|
19 | <script src="https://cdn.jsdelivr.net/npm/loom-js@1.15.0/dist/loom.umd.js"></script>
|
20 | ```
|
21 |
|
22 | ## Development
|
23 |
|
24 | ```shell
|
25 | # build for Node
|
26 | yarn build
|
27 | # build for Browser
|
28 | yarn build:browser
|
29 | # build for Node while targeting ES2017 (more readable than ES5)
|
30 | yarn build:dev
|
31 | # run unit tests on Node & Browser
|
32 | yarn test
|
33 | # auto-format source files
|
34 | yarn format
|
35 | # run unit tests in Node
|
36 | yarn test:node
|
37 | # run unit tests in Electon
|
38 | yarn test:browser
|
39 | # run e2e test in Node (local DAppChain node must be running first)
|
40 | yarn e2e:node
|
41 | # run e2e test in Electron (local DAppChain node must be running first)
|
42 | yarn e2e:browser
|
43 | ```
|
44 |
|
45 | The e2e test environment can be configured by changing `.env.test` (see `.env.test.example` for
|
46 | default values).
|
47 |
|
48 | ### Debugging
|
49 |
|
50 | To debug loom-js while using it another project:
|
51 | 1. Clone the Git repo from https://github.com/loomnetwork/loom-js
|
52 | 2. Inside the loom-js repo run:
|
53 | ```bash
|
54 | yarn link
|
55 | yarn build:dev
|
56 | ```
|
57 | 3. In your project repo run `yarn link loom-js`.
|
58 | 4. Debug your project normally.
|
59 |
|
60 | `yarn build:dev` will compile the TypeScript source to target ES2017, which requires a lot less
|
61 | transformation of async/await constructs than the ES5 code released on NPM.
|
62 |
|
63 | ### Regenerating Protobufs
|
64 |
|
65 | Whenever you change `src/proto/loom.proto`, or `src/tests/tests.proto` you will need to regenerate
|
66 | the corresponding `*_pb.js` by running:
|
67 |
|
68 | ```shell
|
69 | yarn proto
|
70 | ```
|
71 |
|
72 | The shell must be able to locate the `protoc` binary, which can be obtained from https://github.com/google/protobuf/releases
|
73 |
|
74 | ## License
|
75 |
|
76 | BSD 3-Clause, see `LICENSE` file for details.
|