diva.js 6.0.1 → 7.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (133) hide show
  1. package/.clang-format +7 -0
  2. package/.github/workflows/npm-publish.yml +45 -0
  3. package/LICENSE +55 -0
  4. package/Makefile +75 -0
  5. package/README.md +15 -108
  6. package/elm.json +32 -0
  7. package/package.json +12 -59
  8. package/review/elm.json +52 -0
  9. package/review/src/ReviewConfig.elm +87 -0
  10. package/scripts/elm-esm.sh +40 -0
  11. package/scripts/minify-css.mjs +31 -0
  12. package/src/Filters.elm +1044 -0
  13. package/src/Main.elm +1217 -0
  14. package/src/Model.elm +213 -0
  15. package/src/Msg.elm +59 -0
  16. package/src/Utilities.elm +46 -0
  17. package/src/View/CollectionExplorer.elm +172 -0
  18. package/src/View/Helpers.elm +86 -0
  19. package/src/View/HtmlRenderer.elm +136 -0
  20. package/src/View/Icons.elm +159 -0
  21. package/src/View/ManifestInfoModal.elm +363 -0
  22. package/src/View/PageViewModal.elm +1046 -0
  23. package/src/View/Sidebar.elm +786 -0
  24. package/src/View/Toolbar.elm +189 -0
  25. package/src/View.elm +244 -0
  26. package/src/diva.ts +802 -0
  27. package/src/filters.ts +1843 -0
  28. package/src/styles/app.css +328 -0
  29. package/src/styles/collection.css +75 -0
  30. package/src/styles/modal.css +388 -0
  31. package/src/styles/sidebar.css +215 -0
  32. package/src/styles/theme.css +39 -0
  33. package/src/styles/toolbar.css +154 -0
  34. package/src/viewer-element.ts +1307 -0
  35. package/testing/index.html +52 -0
  36. package/testing/testing.html +231 -0
  37. package/tsconfig.json +12 -0
  38. package/AUTHORS +0 -22
  39. package/_site/diva.iml +0 -11
  40. package/build/diva.css +0 -554
  41. package/build/diva.css.map +0 -1
  42. package/build/diva.js +0 -9
  43. package/build/diva.js.map +0 -1
  44. package/build/plugins/download.js +0 -2
  45. package/build/plugins/download.js.map +0 -1
  46. package/build/plugins/manipulation.js +0 -2
  47. package/build/plugins/manipulation.js.map +0 -1
  48. package/build/plugins/metadata.js +0 -2
  49. package/build/plugins/metadata.js.map +0 -1
  50. package/diva.iml +0 -11
  51. package/index.html +0 -28
  52. package/karma.conf.js +0 -87
  53. package/source/css/_mixins.scss +0 -43
  54. package/source/css/_variables.scss +0 -50
  55. package/source/css/_viewer.scss +0 -462
  56. package/source/css/diva.scss +0 -15
  57. package/source/css/plugins/_manipulation.scss +0 -228
  58. package/source/css/plugins/_metadata.scss +0 -31
  59. package/source/img/adjust.svg +0 -11
  60. package/source/img/book-view.svg +0 -6
  61. package/source/img/close.svg +0 -6
  62. package/source/img/download.svg +0 -6
  63. package/source/img/from-fullscreen.svg +0 -8
  64. package/source/img/grid-fewer.svg +0 -6
  65. package/source/img/grid-more.svg +0 -6
  66. package/source/img/grid-view.svg +0 -6
  67. package/source/img/link.svg +0 -6
  68. package/source/img/metadata.svg +0 -9
  69. package/source/img/page-view.svg +0 -6
  70. package/source/img/to-fullscreen.svg +0 -11
  71. package/source/img/zoom-in.svg +0 -6
  72. package/source/img/zoom-out.svg +0 -7
  73. package/source/js/composite-image.js +0 -174
  74. package/source/js/diva-global.js +0 -7
  75. package/source/js/diva.js +0 -1543
  76. package/source/js/document-handler.js +0 -180
  77. package/source/js/document-layout.js +0 -286
  78. package/source/js/exceptions.js +0 -26
  79. package/source/js/gesture-events.js +0 -190
  80. package/source/js/grid-handler.js +0 -122
  81. package/source/js/iiif-source-adapter.js +0 -63
  82. package/source/js/image-cache.js +0 -113
  83. package/source/js/image-manifest.js +0 -157
  84. package/source/js/image-request-handler.js +0 -76
  85. package/source/js/interpolate-animation.js +0 -122
  86. package/source/js/page-layouts/book-layout.js +0 -161
  87. package/source/js/page-layouts/grid-layout.js +0 -97
  88. package/source/js/page-layouts/index.js +0 -38
  89. package/source/js/page-layouts/page-dimensions.js +0 -9
  90. package/source/js/page-layouts/singles-layout.js +0 -27
  91. package/source/js/page-overlay-manager.js +0 -102
  92. package/source/js/page-tools-overlay.js +0 -95
  93. package/source/js/parse-iiif-manifest.js +0 -302
  94. package/source/js/plugins/_filters.js +0 -679
  95. package/source/js/plugins/download.js +0 -83
  96. package/source/js/plugins/manipulation.js +0 -837
  97. package/source/js/plugins/metadata.js +0 -190
  98. package/source/js/renderer.js +0 -584
  99. package/source/js/settings-view.js +0 -30
  100. package/source/js/tile-coverage-map.js +0 -25
  101. package/source/js/toolbar.js +0 -572
  102. package/source/js/utils/dragscroll.js +0 -106
  103. package/source/js/utils/elt.js +0 -94
  104. package/source/js/utils/events.js +0 -190
  105. package/source/js/utils/get-scrollbar-width.js +0 -29
  106. package/source/js/utils/hash-params.js +0 -86
  107. package/source/js/utils/parse-label-value.js +0 -34
  108. package/source/js/utils/vanilla.kinetic.js +0 -527
  109. package/source/js/validation-runner.js +0 -177
  110. package/source/js/viewer-core.js +0 -1505
  111. package/source/js/viewport.js +0 -143
  112. package/test/_setup.js +0 -13
  113. package/test/composite-image_test.js +0 -94
  114. package/test/diva_test.js +0 -43
  115. package/test/hash-params_test.js +0 -221
  116. package/test/image-cache_test.js +0 -106
  117. package/test/main.js +0 -6
  118. package/test/manifests/beromunsterManifest.json +0 -15514
  119. package/test/manifests/iiifv2.json +0 -11032
  120. package/test/manifests/iiifv2pages.json +0 -30437
  121. package/test/manifests/iiifv3.json +0 -10965
  122. package/test/navigation_test.js +0 -355
  123. package/test/parse-iiif-manifest_test.js +0 -68
  124. package/test/public_test.js +0 -881
  125. package/test/settings_test.js +0 -487
  126. package/test/utils/book-layout_test.js +0 -148
  127. package/test/utils/elt_test.js +0 -102
  128. package/test/utils/events_test.js +0 -245
  129. package/test/utils/hash-params_test.js +0 -79
  130. package/test/utils/parse-label-value_test.js +0 -45
  131. package/test/z_plugins_test.js +0 -180
  132. package/webpack.config.js +0 -58
  133. package/webpack.config.test.js +0 -45
package/.clang-format ADDED
@@ -0,0 +1,7 @@
1
+ BasedOnStyle: None
2
+ Language: JavaScript
3
+ IndentWidth: 4
4
+ TabWidth: 4
5
+ UseTab: Never
6
+ ColumnLimit: 0
7
+ BreakBeforeBraces: Allman
@@ -0,0 +1,45 @@
1
+ name: Publish to NPM
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - 'v*'
7
+
8
+ permissions:
9
+ contents: read
10
+ id-token: write
11
+
12
+ jobs:
13
+ publish:
14
+ runs-on: ubuntu-latest
15
+ environment: npm
16
+ steps:
17
+ - name: Checkout repository
18
+ uses: actions/checkout@v6
19
+
20
+ - name: Setup Node.js
21
+ uses: actions/setup-node@v6
22
+ with:
23
+ node-version: '24'
24
+ registry-url: 'https://registry.npmjs.org'
25
+
26
+ - name: Install dependencies
27
+ run: yarn install
28
+
29
+ - name: Install Elm globally
30
+ run: npm install -g elm
31
+
32
+ - name: Build
33
+ run: make build
34
+
35
+ - name: Verify tag matches package version
36
+ run: |
37
+ PACKAGE_VERSION="$(node -p "require('./package.json').version")"
38
+ TAG_VERSION="${GITHUB_REF_NAME#v}"
39
+ if [ "$PACKAGE_VERSION" != "$TAG_VERSION" ]; then
40
+ echo "Tag version ($TAG_VERSION) does not match package.json version ($PACKAGE_VERSION)." >&2
41
+ exit 1
42
+ fi
43
+
44
+ - name: Publish to NPM
45
+ run: npm publish --provenance
package/LICENSE ADDED
@@ -0,0 +1,55 @@
1
+ MIT License - Diva.js
2
+
3
+ Copyright (c) 2026 Andrew Hankinson, RISM Digital Center
4
+ Copyright (c) 2011-2019, Various Authors. See AUTHORS file.
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
23
+
24
+ ---
25
+
26
+ Additional code has been used and modified from its original.
27
+
28
+ CamanJS: https://github.com/meltingice/CamanJS
29
+
30
+ Copyright (c) 2010-2016, Ryan LeFevre
31
+ All rights reserved.
32
+
33
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
34
+
35
+ * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
36
+ * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
37
+ * Neither the name of Ryan LeFevre nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
38
+
39
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40
+
41
+
42
+ ---
43
+
44
+ OpenSeadragon Filtering: https://github.com/usnistgov/OpenSeadragonFiltering
45
+
46
+ This software was developed at the National Institute of Standards and
47
+ Technology by employees of the Federal Government in the course of
48
+ their official duties. Pursuant to title 17 Section 105 of the United
49
+ States Code this software is not subject to copyright protection and is
50
+ in the public domain. This software is an experimental system. NIST assumes
51
+ no responsibility whatsoever for its use by other parties, and makes no
52
+ guarantees, expressed or implied, about its quality, reliability, or
53
+ any other characteristic. We would appreciate acknowledgement if the
54
+ software is used.
55
+
package/Makefile ADDED
@@ -0,0 +1,75 @@
1
+ SHELL := /bin/sh
2
+
3
+ ELM_SRC := src/Main.elm
4
+ TS_SRC := src/diva.ts
5
+ TS_VE_SRC := src/viewer-element.ts
6
+ TS_FT_SRC := src/filters.ts
7
+ CSS_SRC := $(wildcard src/styles/*.css)
8
+ DIVA_CSS := cache/diva.css
9
+ ELM_OUT := cache/elm.js
10
+ ELM_ESM := cache/elm-esm.js
11
+ DIVA_DEBUG := build/diva.debug.js
12
+ DIVA_JS := build/diva.js
13
+ ELM_ESM_SCRIPT := scripts/elm-esm.sh
14
+ ELM_FLAGS ?= --optimize
15
+ VERSION ?= $(shell node -p "require('./package.json').version")
16
+ RELEASE_PREFIX := diva.js-$(VERSION)
17
+ RELEASE_DIR := release
18
+ RELEASE_TAR := $(RELEASE_DIR)/$(RELEASE_PREFIX).tar.gz
19
+ RELEASE_ZIP := $(RELEASE_DIR)/$(RELEASE_PREFIX).zip
20
+
21
+ .PHONY: all build build-dev clean clean-cache release
22
+
23
+ all: build
24
+
25
+ build: clean-cache $(DIVA_JS)
26
+
27
+ build-dev: ELM_FLAGS = --debug
28
+ build-dev:
29
+ $(MAKE) -B ELM_FLAGS=--debug clean-cache $(DIVA_DEBUG)
30
+
31
+ $(ELM_OUT): $(ELM_SRC)
32
+ mkdir -p build
33
+ elm make $(ELM_FLAGS) $(ELM_SRC) --output=$(ELM_OUT)
34
+
35
+ $(ELM_ESM): $(ELM_OUT) $(ELM_ESM_SCRIPT)
36
+ ./scripts/elm-esm.sh $(ELM_OUT) $(ELM_ESM)
37
+
38
+ $(DIVA_CSS): $(CSS_SRC) scripts/minify-css.mjs
39
+ node ./scripts/minify-css.mjs
40
+
41
+ $(DIVA_DEBUG): $(TS_SRC) $(TS_VE_SRC) $(TS_FT_SRC) $(DIVA_CSS) $(ELM_ESM)
42
+ mkdir -p public
43
+ yarn -s esbuild $(TS_SRC) --bundle --format=iife --platform=browser --target=es2019 --loader:.css=text --outfile=$(DIVA_DEBUG)
44
+
45
+ $(DIVA_JS): $(TS_SRC) $(TS_VE_SRC) $(TS_FT_SRC) $(DIVA_CSS) $(ELM_ESM)
46
+ yarn -s esbuild $(TS_SRC) --bundle --format=iife --platform=browser --target=es2019 --loader:.css=text --minify --drop:console --pure:F2 --pure:F3 --pure:F4 --pure:F5 --pure:F6 --pure:F7 --pure:F8 --pure:F9 --pure:A2 --pure:A3 --pure:A4 --pure:A5 --pure:A6 --pure:A7 --pure:A8 --pure:A9 --outfile=$(DIVA_JS)
47
+ @min="$(DIVA_JS)"; \
48
+ MINIFIED_SIZE=$$(wc -c < "$$min"); \
49
+ GZIPPED_SIZE=$$(gzip -c "$$min" | wc -c); \
50
+ MINIFIED_HR=$$(numfmt --to=iec-i --suffix=B "$$MINIFIED_SIZE"); \
51
+ GZIPPED_HR=$$(numfmt --to=iec-i --suffix=B "$$GZIPPED_SIZE"); \
52
+ printf "%-18s %10s (%7s) %s\n" "Minified size:" "$$MINIFIED_SIZE bytes" "$$MINIFIED_HR" "$$min"; \
53
+ printf "%-18s %10s (%7s)\n" "Gzipped size:" "$$GZIPPED_SIZE bytes" "$$GZIPPED_HR";
54
+
55
+ clean:
56
+ rm -f $(ELM_OUT) $(ELM_ESM) $(DIVA_JS) $(DIVA_DEBUG) $(DIVA_CSS) build/diva.css build/diva.min.css
57
+
58
+ clean-cache:
59
+ rm -f cache/*
60
+
61
+ release: clean build build-dev
62
+ mkdir -p $(RELEASE_DIR)
63
+ @LICENSE_FILE=$$(ls LICENSE* 2>/dev/null | head -n 1); \
64
+ if [ -z "$$LICENSE_FILE" ]; then \
65
+ echo "Error: no LICENSE file found in project root."; \
66
+ exit 1; \
67
+ fi; \
68
+ tar -czf "$(RELEASE_TAR)" build README.md "$$LICENSE_FILE"; \
69
+ zip -rq "$(RELEASE_ZIP)" build README.md "$$LICENSE_FILE"; \
70
+ echo "Created $(RELEASE_TAR)"; \
71
+ echo "Created $(RELEASE_ZIP)"
72
+
73
+ publish: clean build
74
+ cp -r build .
75
+ npm publish
package/README.md CHANGED
@@ -1,117 +1,24 @@
1
- <p align="center">
2
- <a href="http://ddmal.github.io/diva.js">
3
- <img width="382" height="191" src="https://github.com/DDMAL/diva.js/wiki/img/diva-logo-sm.png" />
4
- </a>
5
- </p>
1
+ # Diva.js
6
2
 
7
- Diva.js [![Build Status](https://travis-ci.org/DDMAL/diva.js.svg?branch=master)](http://travis-ci.org/DDMAL/diva.js)
8
- =========================================
3
+ Version 7.2.2
9
4
 
10
- Diva.js (Document Image Viewer with AJAX) is a JavaScript book image viewer designed to present multi-page documents at multiple resolutions.
5
+ ## Build
11
6
 
12
- Version 6.0 contains many new features and improvements:
13
-
14
- - **Compatibility with IIIF Presentation API version 2.1 and 3**.
15
- - **Small footprint, zero dependencies**. Can be deployed with just a JavaScript and a CSS file.
16
- - **Rewritten in ES6** for compatibility with the new JavaScript module system.
17
- - **New plugins**: Metadata, Image Manipulation
18
-
19
- ## Overview
20
-
21
- There are two components to a functioning Diva system:
22
-
23
- 1. **[A IIIF Manifest](https://iiif.io/)** that will be displayed.
24
- 2. **The Diva.js plugin.** The embedded web application that displays the images in a browser.
25
-
26
- ### Details
27
-
28
- #### Using IIIF
29
- Diva.js is an image viewer compatible with IIIF Presentation API versions [2](http://iiif.io/api/presentation/2.0/) and [3](http://iiif.io/api/presentation/3.0/). Simply supply the path to a valid IIIF Manifest and Diva will display the document as described by the metadata (see [Installing](#installing)).
30
-
31
- ## Installing
32
-
33
- ### From a CDN (hosted)
34
-
35
- If you prefer to use a hosted version of Diva, copy and paste the following into the `<head>` of any webpage to include all the files necessary to use Diva.js.
36
- ```html
37
- <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/diva.js/6.0.0/css/diva.css" />
38
- <script src="//cdnjs.cloudflare.com/ajax/libs/diva.js/6.0.0/js/diva.js"></script>
39
- ```
40
- ### Locally (release package)
41
-
42
- Download the [latest release](https://github.com/DDMAL/diva.js/releases) of Diva. In the `diva.js` directory you can find a pre-compiled version. The `build` directory contains the files necessary to use Diva. Simply include `build/diva.css` and `build/diva.js` in the `<head>` of your webpage, as shown in the HTML source of the example [index page](https://github.com/DDMAL/diva.js/blob/develop/index.html).
43
-
44
- ### From npm
45
-
46
- You can also run `npm install diva.js` in order to install Diva as a node package. Then, Diva will be located under `node_modules/diva.js/`, and you can access the `build` directory the same as above.
47
-
48
- ## Basic setup
49
- ### HTML
50
- After including the necessary files, the most basic Diva viewer is instantiated with one (IIIF) required parameter and several optional settings parameters. Diva must target a parent div, in this case diva-wrapper:
51
- ```html
52
- <div id="diva-wrapper"></div>
53
-
54
- <script>
55
- let diva = new Diva('diva-wrapper', {
56
- objectData: "http://www.example.com/manifest.json"
57
- // possible settings
58
- });
59
- </script>
60
- ```
61
- * `objectData`: The URL (absolute or relative) to the document's `.json` file, or a IIIF Manifest
62
-
63
- The `diva-wrapper` selector points to a `div` element within which the document viewer will appear.
64
-
65
- ### JavaScript
66
- If you wish to include the Diva viewer component into your own JavaScript app, this can be done easily by just importing Diva beforehand.
67
- ```javascript
68
- import Diva from './path/to/source/diva.js';
69
-
70
- let diva = new Diva('diva-wrapper', {
71
- objectData: "http://www.example.com/manifest.json"
72
- // possible settings
73
- });
7
+ ```sh
8
+ make build
74
9
  ```
75
10
 
76
- There are a large number of settings that can be enabled/disabled for this Diva instance. See [Settings](https://github.com/DDMAL/diva.js/wiki/Settings) for a comprehensive list.
77
-
78
- See [Installation](https://github.com/DDMAL/diva.js/wiki/Installation) for full instructions.
79
-
80
- ## Building from source
81
-
82
- If you wish to install from source, first you must install [node.js and npm](https://nodejs.org/en/). Then, check out the code from [our GitHub repository](http://github.com/DDMAL/diva.js). Once you've obtained the code, change to the project directory and run `npm install` to fetch all development dependencies.
11
+ ## Run
83
12
 
84
- The full installation gives you access to the un-minified JavaScript source, the plugins, the documentation, and our unit-tests.
85
-
86
- ```javascript
87
- npm run develop // Runs a server at localhost:9001 and automatically builds and reloads upon changes
88
- npm run build:develop // Compiles the Javascript and SASS source and places it in the build/ directory
89
- npm run lint // Lints the Javascript source with JSHint
90
- npm test // Runs the unit tests and outputs a report to the console
91
- npm run build:production // Builds the release package
13
+ ```sh
14
+ python3 -m http.server 8000
92
15
  ```
93
16
 
94
- Run `npm run develop` and navigate to [http://localhost:9001](http://localhost:9001) in your web browser to see a basic Diva instance.
95
-
96
- See [Installation](https://github.com/DDMAL/diva.js/wiki/Installation) for more information.
97
-
98
- ## Getting help
99
-
100
- Help for Diva.js is available through this repository's [wiki](https://github.com/DDMAL/diva.js/wiki), in the form of code documentation, installation instructions and usage tips. You can also [submit an issue](https://github.com/DDMAL/diva.js/issues)!
101
-
102
- ## Cross-site Requests
103
-
104
- You may receive an error that looks something like this:
105
-
106
- ```
107
- XMLHttpRequest cannot load http://example.com/demo/imagefiles.json. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8000' is therefore not allowed access.
108
- ```
109
-
110
- This is a security precaution that all browsers use to prevent cross-site request forgeries. If you receive this message it is because your `objectData` parameter and the server used to serve the Diva page are not at the same server address.
111
-
112
- To fix this you must ensure that the Diva HTML page, and the location pointed to by the `objectData` page are being served by the same server, or you must create an exception using the `Access-Control-Allow-Origin` header on your server to explicitly white-list the `objectData` location.
113
-
114
- Let Us Know
115
- -----------
17
+ Open http://localhost:8000 in a browser.
116
18
 
117
- We're developing Diva.js as part of our research in [Distributed Digital Music Libraries](http://ddmal.music.mcgill.ca). If you use it in your project, it would be great if you could [let us know](mailto:andrew.hankinson@mail.mcgill.ca).
19
+ ## Notes
20
+ - Build output is a single `build/diva.js` bundle (Elm + TS) plus the OpenSeadragon CDN script. A debug build is available as `build/diva.debug.js`.
21
+ - Initialize the viewer in `public/index.html` with `new Diva("diva-wrapper", { objectData, acceptHeaders })`.
22
+ - `src/viewer-element.ts` defines the `osd-viewer` custom element used by the Elm view.
23
+ - `src/diva.ts` owns the Elm ports and the filter preview OpenSeadragon instance.
24
+ - `make clean` removes generated artifacts in `build/` and `public/`.
package/elm.json ADDED
@@ -0,0 +1,32 @@
1
+ {
2
+ "type": "application",
3
+ "source-directories": [
4
+ "src"
5
+ ],
6
+ "elm-version": "0.19.1",
7
+ "dependencies": {
8
+ "direct": {
9
+ "elm/browser": "1.0.2",
10
+ "elm/core": "1.0.5",
11
+ "elm/html": "1.0.1",
12
+ "elm/http": "2.0.0",
13
+ "elm/json": "1.1.4",
14
+ "elm/svg": "1.0.1",
15
+ "hecrj/html-parser": "2.4.0",
16
+ "rism-digital/elm-iiif": "1.0.3"
17
+ },
18
+ "indirect": {
19
+ "elm/bytes": "1.0.8",
20
+ "elm/file": "1.0.5",
21
+ "elm/parser": "1.1.0",
22
+ "elm/time": "1.0.0",
23
+ "elm/url": "1.0.0",
24
+ "elm/virtual-dom": "1.0.5",
25
+ "rtfeldman/elm-hex": "1.0.0"
26
+ }
27
+ },
28
+ "test-dependencies": {
29
+ "direct": {},
30
+ "indirect": {}
31
+ }
32
+ }
package/package.json CHANGED
@@ -1,69 +1,22 @@
1
1
  {
2
2
  "name": "diva.js",
3
- "version": "6.0.1",
4
- "description": "Diva.js",
5
- "main": "build/js/diva.js",
6
- "scripts": {
7
- "test": "npm run build:production && karma start",
8
- "lint": "jshint --reporter=node_modules/jshint-stylish source/js test",
9
- "develop": "webpack-dev-server",
10
- "build:develop": "webpack --progress",
11
- "build:production": "NODE_ENV=production webpack --progress"
12
- },
3
+ "version": "7.2.3",
4
+ "license": "MIT",
13
5
  "repository": {
14
6
  "type": "git",
15
7
  "url": "git+https://github.com/DDMAL/diva.js.git"
16
8
  },
17
- "author": "",
18
- "license": "ISC",
19
- "bugs": {
20
- "url": "https://github.com/DDMAL/diva.js/issues"
21
- },
22
- "homepage": "https://github.com/DDMAL/diva.js#readme",
23
- "dependencies": {
24
- "array.prototype.fill": "^1.0.2",
25
- "extend": "^3.0.2",
26
- "lodash": ">=4.17.11",
27
- "url-search-params": "^1.0.2",
28
- "whatwg-fetch": "^2.0.4"
9
+ "scripts": {
10
+ "format": "find src -name \"*.ts\" -print0 | xargs -0 clang-format -i",
11
+ "develop": "chokidar \"src/**/*\" \"scripts/elm-esm.sh\" \"Makefile\" -c \"make build-dev\"",
12
+ "publish": "npm publish"
29
13
  },
30
14
  "devDependencies": {
31
- "babel-core": "^6.21.0",
32
- "babel-loader": "^8.0.0",
33
- "babel-preset-env": "^1.7.0",
34
- "babel-register": "^6.18.0",
35
- "chai": "^4.1.2",
36
- "clean-webpack-plugin": "^0.1.19",
37
- "connect": "^3.5.0",
38
- "copy-webpack-plugin": "^4.5.2",
39
- "css-loader": "^1.0.0",
40
- "debug": "^3.1.0",
41
- "del": "^3.0.0",
42
- "es6-promise": "^4.2.4",
43
- "istanbul-instrumenter-loader": "^3.0.1",
44
- "jshint": "^2.9.6",
45
- "jshint-stylish": "^2.2.1",
46
- "karma": "^4.0.1",
47
- "karma-babel-preprocessor": "^7.0.0",
48
- "karma-chrome-launcher": "^2.2.0",
49
- "karma-coverage-istanbul-reporter": "^2.0.2",
50
- "karma-mocha": "^1.3.0",
51
- "karma-mocha-reporter": "^2.2.5",
52
- "karma-webpack": "^3.0.0",
53
- "lodash.maxby": "^4.6.0",
54
- "mini-css-extract-plugin": "^0.4.2",
55
- "mocha": "^5.2.0",
56
- "node-sass": "^4.9.3",
57
- "postcss-loader": "^3.0.0",
58
- "puppeteer": "^1.7.0",
59
- "sass-loader": "^7.1.0",
60
- "style-loader": "^0.23.0",
61
- "webpack": "^4.17.1",
62
- "webpack-cli": "^3.1.0",
63
- "webpack-dev-server": ">=3.1.11"
64
- },
65
- "divaOptions": {
66
- "mainEntry": "diva.js",
67
- "mainVarName": "Diva"
15
+ "@types/openseadragon": "^5.0.2",
16
+ "chokidar-cli": "^3.0.0",
17
+ "concurrently": "^9.2.1",
18
+ "esbuild": "^0.28.1",
19
+ "lightningcss": "^1.31.1",
20
+ "typescript": "^5.9.3"
68
21
  }
69
22
  }
@@ -0,0 +1,52 @@
1
+ {
2
+ "type": "application",
3
+ "source-directories": [
4
+ "src"
5
+ ],
6
+ "elm-version": "0.19.1",
7
+ "dependencies": {
8
+ "direct": {
9
+ "SiriusStarr/elm-review-no-single-pattern-case": "2.1.2",
10
+ "SiriusStarr/elm-review-no-unsorted": "1.1.8",
11
+ "elm/core": "1.0.5",
12
+ "jfmengels/elm-review": "2.16.4",
13
+ "jfmengels/elm-review-code-style": "1.2.0",
14
+ "jfmengels/elm-review-common": "1.3.5",
15
+ "jfmengels/elm-review-debug": "1.0.8",
16
+ "jfmengels/elm-review-performance": "1.0.2",
17
+ "jfmengels/elm-review-simplify": "2.1.15",
18
+ "jfmengels/elm-review-unused": "1.2.6",
19
+ "sparksp/elm-review-imports": "1.0.2",
20
+ "stil4m/elm-syntax": "7.3.9"
21
+ },
22
+ "indirect": {
23
+ "avh4/elm-fifo": "1.0.4",
24
+ "elm/bytes": "1.0.8",
25
+ "elm/html": "1.0.1",
26
+ "elm/json": "1.1.4",
27
+ "elm/parser": "1.1.0",
28
+ "elm/project-metadata-utils": "1.0.2",
29
+ "elm/random": "1.0.0",
30
+ "elm/regex": "1.0.0",
31
+ "elm/time": "1.0.0",
32
+ "elm/virtual-dom": "1.0.5",
33
+ "elm-community/dict-extra": "2.4.0",
34
+ "elm-community/graph": "6.0.0",
35
+ "elm-community/intdict": "3.1.0",
36
+ "elm-community/list-extra": "8.7.0",
37
+ "elm-community/maybe-extra": "5.3.0",
38
+ "elm-community/result-extra": "2.4.0",
39
+ "elm-community/string-extra": "4.0.1",
40
+ "elm-explorations/test": "2.2.1",
41
+ "pzp1997/assoc-list": "1.0.0",
42
+ "rtfeldman/elm-hex": "1.0.0",
43
+ "stil4m/structured-writer": "1.0.3"
44
+ }
45
+ },
46
+ "test-dependencies": {
47
+ "direct": {
48
+ "elm-explorations/test": "2.2.1"
49
+ },
50
+ "indirect": {}
51
+ }
52
+ }
@@ -0,0 +1,87 @@
1
+ module ReviewConfig exposing (config)
2
+
3
+ {-| Do not rename the ReviewConfig module or the config function, because
4
+ `elm-review` will look for these.
5
+
6
+ To add packages that contain rules, add them to this review project using
7
+
8
+ `elm install author/packagename`
9
+
10
+ when inside the directory containing this file.
11
+
12
+ -}
13
+
14
+ import NoConfusingPrefixOperator
15
+ import NoDebug.Log
16
+ import NoDebug.TodoOrToString
17
+ import NoExposingEverything
18
+ import NoImportingEverything
19
+ import NoInconsistentAliases
20
+ import NoMissingTypeAnnotation
21
+ import NoMissingTypeAnnotationInLetIn
22
+ import NoMissingTypeExpose
23
+ import NoModuleOnExposedNames
24
+ import NoPrematureLetComputation
25
+ import NoSimpleLetBody
26
+ import NoSinglePatternCase
27
+ import NoUnoptimizedRecursion
28
+ import NoUnsortedCases
29
+ import NoUnsortedLetDeclarations
30
+ import NoUnsortedRecords
31
+ import NoUnsortedTopLevelDeclarations
32
+ import NoUnused.CustomTypeConstructorArgs
33
+ import NoUnused.CustomTypeConstructors
34
+ import NoUnused.Dependencies
35
+ import NoUnused.Exports
36
+ import NoUnused.Parameters
37
+ import NoUnused.Patterns
38
+ import NoUnused.Variables
39
+ import Review.Rule as Rule exposing (Rule)
40
+ import Simplify
41
+
42
+
43
+ config : List Rule
44
+ config =
45
+ [ NoConfusingPrefixOperator.rule
46
+ , NoDebug.Log.rule
47
+ , NoDebug.TodoOrToString.rule
48
+ |> Rule.ignoreErrorsForDirectories [ "tests/" ]
49
+ , NoExposingEverything.rule
50
+ , NoImportingEverything.rule []
51
+ , NoMissingTypeAnnotation.rule
52
+ , NoMissingTypeExpose.rule
53
+ , NoSimpleLetBody.rule
54
+ , NoPrematureLetComputation.rule
55
+ , NoUnused.CustomTypeConstructors.rule []
56
+ , NoUnused.CustomTypeConstructorArgs.rule
57
+ , NoUnused.Dependencies.rule
58
+ , NoUnused.Exports.rule
59
+ , NoUnused.Parameters.rule
60
+ , NoUnused.Patterns.rule
61
+ , NoUnused.Variables.rule
62
+ , Simplify.rule Simplify.defaults
63
+ , NoSinglePatternCase.rule NoSinglePatternCase.fixInArgument
64
+
65
+ --, NoUnsortedRecords.rule NoUnsortedRecords.defaults
66
+ , NoUnsortedLetDeclarations.rule
67
+ (NoUnsortedLetDeclarations.sortLetDeclarations
68
+ |> NoUnsortedLetDeclarations.usedInExpressionLast
69
+ |> NoUnsortedLetDeclarations.glueHelpersBefore
70
+ )
71
+ , NoUnsortedCases.rule NoUnsortedCases.defaults
72
+ , NoUnsortedTopLevelDeclarations.rule
73
+ (NoUnsortedTopLevelDeclarations.sortTopLevelDeclarations
74
+ |> NoUnsortedTopLevelDeclarations.portsFirst
75
+ |> NoUnsortedTopLevelDeclarations.exposedOrderWithPrivateLast
76
+ |> NoUnsortedTopLevelDeclarations.alphabetically
77
+ )
78
+ , NoInconsistentAliases.config
79
+ [ ( "Html.Attributes", "HA" )
80
+ , ( "Json.Decode", "Decode" )
81
+ , ( "Json.Encode", "Encode" )
82
+ ]
83
+ |> NoInconsistentAliases.noMissingAliases
84
+ |> NoInconsistentAliases.rule
85
+ , NoModuleOnExposedNames.rule
86
+ , NoUnoptimizedRecursion.rule (NoUnoptimizedRecursion.optOutWithComment "IGNORE TCO")
87
+ ]
@@ -0,0 +1,40 @@
1
+ #!/bin/sh
2
+
3
+ # Converts an Elm build into an ESM module so that it can
4
+ # be imported and used as part of a JS library.
5
+
6
+ set -e
7
+
8
+ INPUT="$1"
9
+ OUTPUT="$2"
10
+
11
+
12
+
13
+ if [ -z "$INPUT" ] || [ -z "$OUTPUT" ]; then
14
+ echo "Usage: scripts/elm-esm.sh <input> <output>" 1>&2
15
+ exit 1
16
+ fi
17
+
18
+ perl -0777 -e '
19
+ my ($input, $output) = @ARGV;
20
+ open my $fh, "<", $input or die "Failed to read $input: $!";
21
+ my $js = do { local $/; <$fh> };
22
+ close $fh;
23
+
24
+ if ($js !~ /^\s*_Platform_export\(([\s\S]*)\);\n?}\(this\)\);/m) {
25
+ die "Could not find Elm export payload.";
26
+ }
27
+ my $elm_exports = $1;
28
+
29
+ my $out = $js;
30
+ $out =~ s/\(function\s*\(scope\)\s*\{$/\/\/ -- $&/m;
31
+ $out =~ s/["'"]use strict["'"];$/\/\/ -- $&/m;
32
+ $out =~ s/function _Platform_export([\s\S]*?)\}\n/\/\*\n$&\n\*\//g;
33
+ $out =~ s/function _Platform_mergeExports([\s\S]*?)\}\n\s*}/\/\*\n$&\n\*\//g;
34
+ $out =~ s/^\s*_Platform_export\(([\s\S]*)\);\n?}\(this\)\);/\/\*\n$&\n\*\//m;
35
+ $out .= "\nexport const Elm = $elm_exports;\n";
36
+
37
+ open my $out_fh, ">", $output or die "Failed to write $output: $!";
38
+ print {$out_fh} $out;
39
+ close $out_fh;
40
+ ' "$INPUT" "$OUTPUT"
@@ -0,0 +1,31 @@
1
+ import fs from "node:fs/promises";
2
+ import path from "node:path";
3
+ import {fileURLToPath} from "node:url";
4
+ import {transform} from "lightningcss";
5
+
6
+ const __filename = fileURLToPath(import.meta.url);
7
+ const __dirname = path.dirname(__filename);
8
+ const rootDir = path.resolve(__dirname, "..");
9
+
10
+ const sources = [
11
+ "src/styles/theme.css",
12
+ "src/styles/app.css",
13
+ "src/styles/sidebar.css",
14
+ "src/styles/toolbar.css",
15
+ "src/styles/modal.css",
16
+ "src/styles/collection.css",
17
+ ];
18
+
19
+ const input = await Promise.all(
20
+ sources.map((file) => fs.readFile(path.join(rootDir, file), "utf8"))
21
+ );
22
+
23
+ const css = input.join("\n");
24
+ const result = transform({
25
+ code: Buffer.from(css),
26
+ minify: true,
27
+ });
28
+
29
+ const outDir = path.join(rootDir, "cache");
30
+ await fs.mkdir(outDir, {recursive: true});
31
+ await fs.writeFile(path.join(outDir, "diva.css"), result.code);