Detalhes do pacote

r2-opds-js

readium5.2kBSD-3-Clause1.0.47

Readium 2 'opds' for NodeJS (TypeScript)

readium, readium2, opds, EPUB

readme (leia-me)

NodeJS / TypeScript Readium-2 "opds" components

NodeJS implementation (written in TypeScript) of OPDS functionality for the Readium2 architecture ( https://github.com/readium/architecture/ ).

License

Build status

NPM David

Changelog

Prerequisites

1) https://nodejs.org NodeJS >= 8, NPM >= 5 (check with command line node --version and npm --version) 2) OPTIONAL: https://yarnpkg.com Yarn >= 1.0 (check with command line yarn --version)

GitHub repository

https://github.com/readium/r2-opds-js

There is no github.io site for this project (no gh-pages branch).

NPM package

https://www.npmjs.com/package/r2-opds-js

Command line install:

npm install r2-opds-js OR yarn add r2-opds-js

...or manually add in your package.json:

  "dependencies": {
    "r2-opds-js": "latest"
  }

The JavaScript code distributed in the NPM package is usable as-is (no transpilation required), as it is automatically-generated from the TypeScript source.

Several ECMAScript flavours are provided out-of-the-box: ES5, ES6-2015, ES7-2016, ES8-2017:

https://unpkg.com/r2-opds-js/dist/

(alternatively, GitHub mirror with semantic-versioning release tags: https://github.com/edrlab/r2-opds-js-dist/tree/develop/dist/ )

The JavaScript code is not bundled, and it uses require() statement for imports (NodeJS style).

More information about NodeJS compatibility:

http://node.green

Note that web-browser Javascript is currently not supported (only NodeJS runtimes).

The type definitions (aka "typings") are included as *.d.ts files in ./node_modules/r2-opds-js/dist/**, so this package can be used directly in a TypeScript project.

Dependencies

https://david-dm.org/readium/r2-opds-js

A package-lock.json is provided (modern NPM replacement for npm-shrinkwrap.json).

A yarn.lock file is currently not provided at the root of the source tree.

Continuous Integration

TODO (unit tests?) https://travis-ci.org/readium/r2-opds-js

Badge: [![Travis](https://travis-ci.org/readium/r2-opds-js.svg?branch=develop)](https://travis-ci.org/readium/r2-opds-js)

Version(s), Git revision(s)

NPM package (latest published):

https://unpkg.com/r2-opds-js/dist/gitrev.json

Alternatively, GitHub mirror with semantic-versioning release tags:

https://raw.githack.com/edrlab/r2-opds-js-dist/develop/dist/gitrev.json

Developer quick start

Command line steps (NPM, but similar with YARN):

1) cd r2-opds-js 2) git status (please ensure there are no local changes, especially in package-lock.json and the dependency versions in package.json) 3) rm -rf node_modules (to start from a clean slate) 4) npm install, or alternatively npm ci (both commands initialize the node_modules tree of package dependencies, based on the strict package-lock.json definition) 5) npm run build:all (invoke the main build script: clean, lint, compile) 6) ls dist (that's the build output which gets published as NPM package)

Documentation

(de)serialization / (un)marshalling of JSON and XML

Due to the "factory" registration pattern in the TA-JSON library dependency (and its corresponding XML fork/adaptation), the functions initGlobalConverters_GENERIC() and initGlobalConverters_OPDS() must be called before invoking the actual OPDS1/2 parsers.

https://github.com/readium/r2-opds-js/blob/develop/src/opds/init-globals.ts

// npm install r2-opds-js
// "@opds" is a dist path alias, for example EcmaScript6/ES2015 'node_modules/r2-opds-js/dist/es6-es2015/src/opds/'
import { initGlobalConverters_GENERIC, initGlobalConverters_OPDS } from "@opds/init-globals";

initGlobalConverters_GENERIC();
initGlobalConverters_OPDS();

OPDS 1

The XML (Atom) markup of an OPDS1 "feed" (or "entry") can be loaded/parsed into an in-memory data model.

https://github.com/readium/r2-opds-js/tree/develop/src/opds/opds1

// npm install xmldom
import * as xmldom from "xmldom";

// npm install r2-utils-js
// "@utils" is a dist path alias, for example EcmaScript6/ES2015 'node_modules/r2-utils-js/dist/es6-es2015/src/_utils/'
import { XML } from "@utils/xml-js-mapper";

// npm install r2-opds-js
// "@opds" is a dist path alias, for example EcmaScript6/ES2015 'node_modules/r2-opds-js/dist/es6-es2015/src/opds/'
import { OPDS } from "@opds/opds1/opds";
import { Entry } from "@opds/opds1/opds-entry";

const xmlDom = new xmldom.DOMParser().parseFromString(xmlStr);
if (!xmlDom || !xmlDom.documentElement) {
    return;
}
const isEntry = xmlDom.documentElement.localName === "entry";
if (isEntry) {
    let opds1Entry = XML.deserialize<Entry>(xmlDom, Entry);
    // ...
} else {
    let opds1Feed = XML.deserialize<OPDS>(xmlDom, OPDS);
    // ...
}

OPDS 2

The JSON serialization of an OPDS2 "feed" (or "publication") can be loaded/parsed into an in-memory data model.

https://github.com/readium/r2-opds-js/tree/develop/src/opds/opds2

import { TaJsonDeserialize, TaJsonSerialize } from "@r2-lcp-js/serializable";

// npm install r2-opds-js
// "@opds" is a dist path alias, for example EcmaScript6/ES2015 'node_modules/r2-opds-js/dist/es6-es2015/src/opds/'
import { OPDSFeed } from "@opds/opds2/opds2";
import { OPDSPublication } from "@opds/opds2/opds2-publication";

// feed
var opds2Feed: OPDSFeed;
const opds2Feed_JSON = TaJsonSerialize(opds2Feed);
// ...and the reverse:
opds2Feed = TaJsonDeserialize<OPDSFeed>(opds2Feed_JSON, OPDSFeed);

// publication
var opds2Publication: OPDSPublication;
const opds2Publication_JSON = TaJsonSerialize(opds2Publication);
// ...and the reverse:
opds2Publication = TaJsonDeserialize<OPDSPublication>(opds2Publication_JSON, OPDSPublication);

OPDS 1 - OPDS 2 Converter

An OPDS1 "feed" (or "entry") can be converted into an OPDS2 representation.

https://github.com/readium/r2-opds-js/blob/develop/src/opds/converter.ts

// npm install xmldom
import * as xmldom from "xmldom";

// npm install r2-utils-js
// "@utils" is a dist path alias, for example EcmaScript6/ES2015 'node_modules/r2-utils-js/dist/es6-es2015/src/_utils/'
import { XML } from "@utils/xml-js-mapper";

// npm install r2-opds-js
// "@opds" is a dist path alias, for example EcmaScript6/ES2015 'node_modules/r2-opds-js/dist/es6-es2015/src/opds/'
import { OPDS } from "@opds/opds1/opds";
import { Entry } from "@opds/opds1/opds-entry";
import { OPDSFeed } from "@opds/opds2/opds2";
import { OPDSPublication } from "@opds/opds2/opds2-publication";
import { convertOpds1ToOpds2, convertOpds1ToOpds2_EntryToPublication } from "@opds/converter";

const xmlDom = new xmldom.DOMParser().parseFromString(xmlStr);
if (!xmlDom || !xmlDom.documentElement) {
    return;
}
const isEntry = xmlDom.documentElement.localName === "entry";
if (isEntry) {
    let opds1Entry = XML.deserialize<Entry>(xmlDom, Entry);

    let opds2Publication: OPDSPublication = convertOpds1ToOpds2_EntryToPublication(opds1Entry);
    // ...
} else {
    let opds1Feed = XML.deserialize<OPDS>(xmlDom, OPDS);

    var opds2Feed: OPDSFeed = convertOpds1ToOpds2(opds1Feed);
    // ...
}

changelog (log de mudanças)

Next

Git diff:

Changes:

  • TODO

1.0.47

Build environment: NodeJS 22.14.0, NPM 11.4.2

Changes:

  • NPM package updates

Git revision info:

Git commit history:

Git diff:

1.0.46

Build environment: NodeJS 22.12.0, NPM 11.0.0

Changes:

  • NPM package updates
  • Updated Flox/Nix (dev)

Git revision info:

Git commit history:

Git diff:

1.0.45

Build environment: NodeJS 22.11.0, NPM 11.0.0

Changes:

  • NPM package updates
  • Flox/Nix support (dev)

Git revision info:

Git commit history:

Git diff:

1.0.44

Build environment: NodeJS 20.17.0, NPM 10.8.3

Changes:

  • NPM package updates

Git revision info:

Git commit history:

Git diff:

1.0.43

Build environment: NodeJS 20.10.0, NPM 10.2.5

Changes:

  • NPM package updates

Git revision info:

Git commit history:

Git diff:

1.0.42

Build environment: NodeJS 18.16.0, NPM 9.8.0

Changes:

  • NPM package updates
  • added OPDS JSON test for accessibility metadata roundtrip

Git revision info:

Git commit history:

Git diff:

1.0.41

Build environment: NodeJS 18.14.2, NPM 9.5.1

Changes:

  • NPM package updates

Git revision info:

Git commit history:

Git diff:

1.0.40

Build environment: NodeJS 18.12.1, NPM 9.1.1

Changes:

  • NPM package updates

Git revision info:

Git commit history:

Git diff:

1.0.39

Build environment: NodeJS 16.13.1, NPM 8.3.0

Changes:

  • NPM package updates
  • Added Atom "summary" namespaced property name

Git revision info:

Git commit history:

Git diff:

1.0.38

Build environment: NodeJS 16.13.0, NPM 8.1.3

Changes:

  • NPM package updates (Node 16 + NPM 8)
  • TSLint to ESLint migration
  • Fixed OPDS 1 to OPDS 2 Entry Title conversion (Summary field extra untyped JSON property)

Git revision info:

Git commit history:

Git diff:

1.0.37

Build environment: NodeJS 14.18.1, NPM 6.14.15

Changes:

  • NPM package updates
  • NodeJS v14 minimum requirement

Git revision info:

Git commit history:

Git diff:

1.0.36

Build environment: NodeJS 14.17.5, NPM 6.14.14

Changes:

  • NPM updates

Git revision info:

Git commit history:

Git diff:

1.0.35

Build environment: NodeJS 14.16.1, NPM 6.14.13

Changes:

  • Fixed OPDS content / summary and other type'd content (title, subtitle)

Git revision info:

Git commit history:

Git diff:

1.0.34

Build environment: NodeJS 14.16.1, NPM 6.14.13

Changes:

  • NPM package updates

Git revision info:

Git commit history:

Git diff:

1.0.33

Build environment: NodeJS 14.15.4, NPM 6.14.11

Changes:

  • NPM package updates
  • Added support for the image property of "catalog entry" (in addition to the images array of links), reusing the OPDSPublication object type

Git revision info:

Git commit history:

Git diff:

1.0.32

Build environment: NodeJS 14.15.1, NPM 6.14.10

Changes:

  • Fixed regression bug from 1.0.28 (OPDS link holds/copies/etc.)
  • NPM package updates
  • Added missing support for OPDS 1 XML LCP Hashed Passphrase conversion to OPDS 2 JSON (custom Link Properties)
  • Added unit tests for the above

Git revision info:

Git commit history:

Git diff:

1.0.31

Build environment: NodeJS 14.15.1, NPM 6.14.9

Changes:

  • NPM package updates (including fixed TA-JSON for class inheritance hierarchy and custom additional JSON properties)
  • Added missing support for Number type converter in XML deserialization
  • Added unit tests for the above

Git revision info:

Git commit history:

Git diff:

1.0.30

Build environment: NodeJS 14.15.1, NPM 6.14.9

Changes:

  • Minor NPM package updates
  • Support for OPDS Availability Status in addition to State (because legacy / incorrect feeds)

Git revision info:

Git commit history:

Git diff:

1.0.29

Build environment: NodeJS 14.15.0, NPM 6.14.9

Changes:

  • Added missing TypeScript files (see previous version 1.0.28)

Git revision info:

Git commit history:

Git diff:

1.0.28

Build environment: NodeJS 14.15.0, NPM 6.14.9

Changes:

  • NPM package updates
  • Added support for OPDS1 'availability', 'holds' and 'copies', and conversion to OPDS2

Git revision info:

Git commit history:

Git diff:

1.0.27

Build environment: NodeJS 12.18.2, NPM 6.14.5

Changes:

  • NPM package updates
  • TypeScript const enum safeguard (isolated modules)

Git revision info:

Git commit history:

Git diff:

1.0.26

Build environment: NodeJS 12.18.1, NPM 6.14.5

Changes:

  • NPM package updates

Git revision info:

Git commit history:

Git diff:

1.0.25

Build environment: NodeJS 12.16.3, NPM 6.14.5

Changes:

  • NPM package updates

Git revision info:

Git commit history:

Git diff:

1.0.24

Build environment: NodeJS 12.16.1, NPM 6.14.4

Changes:

  • NPM package updates
  • CSON 2 JSON script fix

Git revision info:

Git commit history:

Git diff:

1.0.23

Build environment: NodeJS 12.16.1, NPM 6.14.4

Changes:

  • NPM package updates

Git revision info:

Git commit history:

Git diff:

1.0.22

Build environment: NodeJS 12.15.0, NPM 6.13.7

Changes:

  • NPM package updates

Git revision info:

Git commit history:

Git diff:

1.0.21

Build environment: NodeJS 12.13.0, NPM 6.13.0

Changes:

  • Fixed OPDS1-2 converter to duck-type publication vs. navigation feed (image thumbnails and authors)

Git revision info:

Git commit history:

Git diff:

1.0.20

Build environment: NodeJS 12.13.0, NPM 6.13.0

Changes:

  • NPM package updates
  • TAJSON now parses/generates arbitrary JSON properties with typed object

Git revision info:

Git commit history:

Git diff:

1.0.19

Build environment: NodeJS 12.13.0, NPM 6.13.0

Changes:

  • NPM package updates
  • fix: duck-type navigation vs. publications OPDS feed
  • workaround: monkey-patch erroneous OPDS 1 rel URI (cover image thumbnail)
  • fix: OPDS entry type (x)html for Title, SubTitle, Summary, Content with correct XML namespace normalization (Atom removal)

Git revision info:

Git commit history:

Git diff:

1.0.18

Build environment: NodeJS 12.13.0, NPM 6.12.0

Changes:

  • OPDS converter 1 > 2 support for ThrCount (numberOfItems)

Git revision info:

Git commit history:

Git diff:

1.0.17

Build environment: NodeJS 12.13.0, NPM 6.12.0

Changes:

  • NPM updates

Git revision info:

Git commit history:

Git diff:

1.0.16

Build environment: NodeJS 10.16.3, NPM 6.12.0

Changes:

  • NPM updates (including NodeJS v12 for Electron v6)

Git revision info:

Git commit history:

Git diff:

1.0.15

Build environment: NodeJS 10.16.3, NPM 6.11.3

Changes:

  • OPDS support for "journals" online HTML publication entries (no EPUB acquisition link)

Git revision info:

Git commit history:

Git diff:

1.0.14

Build environment: NodeJS 10.16.3, NPM 6.11.3

Changes:

  • NPM updates
  • OPDS JSON Schema uri-reference validator was failing on space characters (but not unicode chars)
  • OPDS v1-v2 converter auto-fixes incorrect JPEG content type
  • OPDS support for x-stanza image mime type
  • OPDS parser adds link rel acquisition when missing, inferred from EPUB link type

Git revision info:

Git commit history:

Git diff:

1.0.13

Build environment: NodeJS 10.16.3, NPM 6.11.3

Changes:

  • NPM updates
  • TypeScript sort imports

Git revision info:

Git commit history:

Git diff:

1.0.12

Build environment: NodeJS 10.16.3, NPM 6.11.3

Changes:

  • NPM updates

Git revision info:

Git commit history:

Git diff:

1.0.11

Build environment: NodeJS 10.16.0, NPM 6.10.2

Changes:

  • NPM updates

Git revision info:

Git commit history:

Git diff:

1.0.10

Build environment: NodeJS 10.16.0, NPM 6.9.0

Changes:

  • NPM updates (notably: Ava unit testing)

Git revision info:

Git commit history:

Git diff:

1.0.9

Build environment: NodeJS 10.15.3, NPM 6.9.0

Changes:

  • NPM updates

Git revision info:

Git commit history:

Git diff:

1.0.8

Build environment: NodeJS 8.15.1, NPM 6.4.1

Changes:

  • NPM updates

Git revision info:

Git commit history:

Git diff:

1.0.7

Build environment: NodeJS 8.15.1, NPM 6.4.1

Changes:

  • NPM updates
  • JSON Schema reference updates
  • NodeTS (TypeScript) unit test runner

Git revision info:

Git commit history:

Git diff:

1.0.6

Build environment: NodeJS 8.14.1, NPM 6.4.1

Changes:

  • NPM updates
  • Significant unit test updates, handling of union/polymorph types with special (de)serialization rules, and OPDS feed crawler.

Git revision info:

Git commit history:

Git diff:

1.0.5

Build environment: NodeJS 8.14.1, NPM 6.4.1

Changes:

  • Reviewed and annotated the data models based on the most current JSON Schema (significant unit test updates to match)
  • Minor NPM updates

Git revision info:

Git commit history:

Git diff:

1.0.4

Build environment: NodeJS 8.14.1, NPM 6.4.1

Changes:

  • Updated documentation (minor)
  • NPM 6.5.* has regression bugs for global package installs, so revert back to NPM 6.4.1 (which is officially shipped with the NodeJS installer).

Git revision info:

Git commit history:

Git diff:

1.0.3

Build environment: NodeJS 8.14.0, NPM 6.5.0

Changes:

  • NPM updates

Git revision info:

Git commit history:

Git diff:

1.0.2

Build environment: NodeJS 8.14.0, NPM 6.5.0

Changes:

  • NPM updates (r2-xxx-js)

Git revision info:

Git commit history:

Git diff:

1.0.1

Build environment: NodeJS 8.14.0, NPM 6.5.0

Changes:

  • NPM updates (minor)
  • Replaced deprecated RawGit URLs
  • Improved Ava unit test setup
  • Removed unnecessary TypeScript import aliases

Git revision info:

Git commit history:

Git diff:

1.0.0

Build environment: NodeJS 8.14.0, NPM 6.5.0

Changes:

  • NPM updates (minor)
  • README info
  • VisualStudio code tweaks (developer workflow)
  • Semantic versioning bump 1.. (3-digit style now, "-alphaX" suffix caused issues with NPM tooling: updates, lockfile, etc.)

Git revision info:

Git commit history:

Git diff:

1.0.0-alpha.7

Build environment: NodeJS 8.12.0, NPM 6.4.1

Changes:

  • NPM updates (minor corrections)

Git revision info:

Git commit history:

Git diff:

1.0.0-alpha.6

Build environment: NodeJS 8.12.0, NPM 6.4.1

Changes:

  • NPM updates (minor)
  • Git revision JSON info now includes NodeJS and NPM version (build environment)
  • OPDS v1 to v2 converter now exposes Entry-compatible function

Git revision info:

Git commit history:

Git diff:

1.0.0-alpha.5

Changes:

  • Dependency "ta-json" GitHub semver dependency becomes "ta-json-x" NPM package (fixes https://github.com/readium/r2-testapp-js/issues/10 )
  • Removed TypeScript linter warning message (checks for no unused variables)
  • NPM updates related to the Node TypeScript typings

Git revision info:

Git commit history:

Git diff:

1.0.0-alpha.4

Changes:

  • OPDS converter XML to JSON: empty language ignored.
  • npm updates (external dependencies)

Git revision info:

Git commit history:

Git diff:

1.0.0-alpha.3

Changes:

  • correct version in package-lock.json

Git revision info:

Git commit history:

Git diff:

1.0.0-alpha.2

Changes (NPM updates):

  • @types/node
  • r2-utils-js
  • r2-shared-js

Git revision info:

Git commit history:

Git diff:

1.0.0-alpha.1

Changes:

  • initial NPM publish

Git revision info:

Git commit history:

Git diff:

  • initial NPM publish