Developing

Diva.js is built from two main pieces: an Elm application that manages state and UI, and a TypeScript layer that provides the custom OpenSeadragon viewer element, the filter implementations, and bridges Elm ports to the browser.

Architecture Overview

Key source files:

Key Technologies

elm-iiif

At the core of the manifest parsing is the elm-iiif package. This was built specifically for the new version of Diva.js, but has been released as a separate package so that others can use it.

By building type-safe JSON decoders, it is less likely that non-compliant manifests will produce undefined behaviour. Most likely, a manifest that does not conform to the standard will fail to parse, and will refuse to load in the viewer. Some leeway is built in, but for the most part, IIIF response parsing is very strict in Diva.js.

The elm-iiif package also contains parsers and helpers for working with IIIF Image API URLs. For example, it contains type-safe constructors for the various parameters that can make up a IIIF Image API URL, and will use these values to build valid Image API URLs.

More information can be found on the Elm packages site.

Development Setup

Prerequisites:

Install dependencies:

yarn install

The Elm dependencies (in elm.json) will automatically install when the package is built the first time.

Building

The production bundle can be built with Make.

make clean && make build

This command will create the build/diva.js file, which is minified and stripped of any debugging information.

We also ship a debug build that can help track down integration problems.

make build-dev

This command will create build/diva.debug.js, which you can load in place of diva.js. It will give you access to the Elm “time travel debugger” to see the internal state of the application.

You can also watch for changes and re-build the debug build as you develop.

yarn run develop

It is probably helpful to run a local web server as you develop. (There is no hot reloading in place, so you have to refresh manually.)

python3 -m http.server 8000

Then open:

Formatting

We have a thing with using Allman style in the TypeScript files. To reformat the TypeScript, use clang-format. This can be invoked with yarn:

yarn run format

There is an elm-review configuration, which should be checked for any violations:

elm-review

Releases

Release builds will build both the production and debug versions, as well as build tar.gz and zip files for GitHub.

make release