UNPKG

3.88 kBMarkdownView Raw
1# NodeJS / TypeScript Readium-2 "LCP" components
2
3NodeJS implementation (written in TypeScript) of LCP modules for the Readium2 architecture ( https://github.com/readium/architecture/ ).
4
5[![License](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](/LICENSE)
6
7## Build status
8
9[![NPM](https://img.shields.io/npm/v/r2-lcp-js.svg)](https://www.npmjs.com/package/r2-lcp-js) [![David](https://david-dm.org/readium/r2-lcp-js/status.svg)](https://david-dm.org/readium/r2-lcp-js)
10
11[Changelog](/CHANGELOG.md)
12
13## Prerequisites
14
151) https://nodejs.org NodeJS >= 8, NPM >= 5 (check with command line `node --version` and `npm --version`)
162) OPTIONAL: https://yarnpkg.com Yarn >= 1.0 (check with command line `yarn --version`)
17
18## GitHub repository
19
20https://github.com/readium/r2-lcp-js
21
22There is no [github.io](https://readium.github.io/r2-lcp-js) site for this project (no [gh-pages](https://github.com/readium/r2-lcp-js/tree/gh-pages) branch).
23
24## NPM package
25
26https://www.npmjs.com/package/r2-lcp-js
27
28Command line install:
29
30`npm install r2-lcp-js`
31OR
32`yarn add r2-lcp-js`
33
34...or manually add in your `package.json`:
35```json
36 "dependencies": {
37 "r2-lcp-js": "latest"
38 }
39```
40
41The JavaScript code distributed in the NPM package is usable as-is (no transpilation required), as it is automatically-generated from the TypeScript source.
42
43Several ECMAScript flavours are provided out-of-the-box: ES5, ES6-2015, ES7-2016, ES8-2017:
44
45https://unpkg.com/r2-lcp-js/dist/
46
47(alternatively, GitHub mirror with semantic-versioning release tags: https://github.com/edrlab/r2-lcp-js-dist/tree/develop/dist/ )
48
49The JavaScript code is not bundled, and it uses `require()` statement for imports (NodeJS style).
50
51More information about NodeJS compatibility:
52
53http://node.green
54
55Note that web-browser Javascript is currently not supported (only NodeJS runtimes).
56
57The type definitions (aka "typings") are included as `*.d.ts` files in `./node_modules/r2-lcp-js/dist/**`, so this package can be used directly in a TypeScript project.
58
59Example usage:
60
61```javascript
62// currently no index file
63// import { * } from "r2-lcp-js";
64
65// ES5 import (assuming node_modules/r2-lcp-js/):
66import { downloadEPUBFromLCPL } from "r2-lcp-js/dist/es5/src/publication-download";
67
68// ... or alternatively using a convenient path alias in the TypeScript config (+ WebPack etc.):
69import { downloadEPUBFromLCPL } from "@r2-lcp-js/publication-download";
70```
71
72## Dependencies
73
74https://david-dm.org/readium/r2-lcp-js
75
76A [package-lock.json](https://github.com/readium/r2-lcp-js/blob/develop/package-lock.json) is provided (modern NPM replacement for `npm-shrinkwrap.json`).
77
78A [yarn.lock](https://github.com/readium/r2-lcp-js/blob/develop/yarn.lock) file is currently *not* provided at the root of the source tree.
79
80## Continuous Integration
81
82TODO (unit tests?)
83https://travis-ci.org/readium/r2-lcp-js
84
85Badge: `[![Travis](https://travis-ci.org/readium/r2-lcp-js.svg?branch=develop)](https://travis-ci.org/readium/r2-lcp-js)`
86
87## Version(s), Git revision(s)
88
89NPM package (latest published):
90
91https://unpkg.com/r2-lcp-js/dist/gitrev.json
92
93Alternatively, GitHub mirror with semantic-versioning release tags:
94
95https://raw.githack.com/edrlab/r2-lcp-js-dist/develop/dist/gitrev.json
96
97## Developer quick start
98
99Command line steps (NPM, but similar with YARN):
100
1011) `cd r2-lcp-js`
1022) `git status` (please ensure there are no local changes, especially in `package-lock.json` and the dependency versions in `package.json`)
1033) `rm -rf node_modules` (to start from a clean slate)
1044) `npm install`, or alternatively `npm ci` (both commands initialize the `node_modules` tree of package dependencies, based on the strict `package-lock.json` definition)
1055) `npm run build:all` (invoke the main build script: clean, lint, compile)
1066) `ls dist` (that's the build output which gets published as NPM package)
107
108## Documentation
109
110TODO