@ivmartel/dwv-react 0.0.0-stage → 0.11.0

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.
package/README.md CHANGED
@@ -1,3 +1,88 @@
1
- # Temporary Holding Version
1
+ # dwv-react
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Medical viewer using [DWV](https://github.com/ivmartel/dwv) (DICOM Web Viewer) and [React](https://reactjs.org/).
4
+
5
+ All coding/implementation contributions and comments are welcome. Releases should be ready for deployment otherwise download the code and install dependencies with a `yarn` or `npm` `install`.
6
+
7
+ dwv-react is not certified for diagnostic use. Released under GNU GPL-3.0 license (see [license.txt](license.txt)).
8
+
9
+ [![Node.js CI](https://github.com/ivmartel/dwv-react/actions/workflows/nodejs-ci.yml/badge.svg)](https://github.com/ivmartel/dwv-react/actions/workflows/nodejs-ci.yml)
10
+
11
+ ## Available Scripts
12
+
13
+ - `install`: install dependencies
14
+ - `dev`: serve with hot reload at localhost:5173
15
+ - `lint`: lint the code with [ESLint](https://eslint.org/)
16
+ - `test`: run unit tests (watch mode)
17
+ - `test-ci`: run unit tests once with coverage
18
+ - `build`: build the demo for production
19
+ - `build-trunk`: build the demo in development mode for the `/dwv-react/demo/trunk` base path
20
+ - `build-stable`: build the demo for production for the `/dwv-react/demo/stable` base path
21
+ - `preview`: serve the demo build locally
22
+ - `build-lib`: build the library (to `dist/dwv-react-lib/`)
23
+
24
+ Unit tests use [Vitest](https://vitest.dev/) and [React Testing Library](https://testing-library.com/docs/react-testing-library/intro/).
25
+
26
+ This project uses [Vite](https://vite.dev/) and [Yarn](https://yarnpkg.com/) (enable it with `corepack enable`).
27
+
28
+ ## Steps to run the viewer from scratch
29
+
30
+ ```sh
31
+ # get the code
32
+ git clone https://github.com/ivmartel/dwv-react.git
33
+
34
+ # move to its folder
35
+ cd dwv-react
36
+
37
+ # install dependencies
38
+ yarn install
39
+
40
+ # call the dev script to launch the viewer on a local server
41
+ yarn run dev
42
+ ```
43
+
44
+ You can now open a browser at http://localhost:5173 and enjoy!
45
+
46
+ ## Use as a library
47
+
48
+ ```sh
49
+ yarn add @ivmartel/dwv-react react react-dom @mui/material @mui/icons-material @emotion/react @emotion/styled
50
+ ```
51
+
52
+ ```jsx
53
+ import { DwvViewer } from '@ivmartel/dwv-react';
54
+ import '@ivmartel/dwv-react/style.css';
55
+
56
+ // the viewer fills its container: give it a height
57
+ <div style={{height: '100vh'}}>
58
+ <DwvViewer uri="https://www.demo.com/index.html?input=file.dcm" />
59
+ </div>
60
+ ```
61
+
62
+ Properties: `uri`, `urls` (white space separated), `loadFromWindowLocation` and `showLegend`.
63
+ Each viewer creates its own state: several viewers can be used on the same page.
64
+ The viewer uses the MUI theme of the application if there is one
65
+ (the side panel uses an optional `background.surfaceContainer` palette token).
66
+
67
+ With Vite, add the workers plugin (see below) to the application config:
68
+
69
+ ```js
70
+ import { dwvWorkers } from '@ivmartel/dwv-react/vite-plugin';
71
+
72
+ export default defineConfig({ plugins: [react(), dwvWorkers()] });
73
+ ```
74
+
75
+ The package is released under GPL-3.0, as dwv.
76
+
77
+ ## DWVs' Web workers
78
+ dwv loads its web workers at runtime from `assets/workers/` relative to the page base URI.
79
+ They are not bundled automatically: the `dwvWorkers` Vite plugin (`plugins/dwvWorkers.js`) serves them
80
+ from the dwv package (`node_modules/dwv/dist/assets/workers`) in dev and copies them to
81
+ `assets/workers/` in the build output (`dist/dwv-react-app/assets/workers` for the demo), so they
82
+ always match the installed dwv version. Its `workersDir` option sets another source folder
83
+ (for ex. `dwvWorkers({workersDir: 'path/to/workers'})`).
84
+ An application embedding the viewer needs to serve them the same way: with Vite, use the
85
+ plugin (`@ivmartel/dwv-react/vite-plugin`), otherwise copy `node_modules/dwv/dist/assets/workers` to
86
+ `assets/workers/` next to the page. Since the path is relative to the page base URI, a page
87
+ at a nested route (for ex. `/app/viewer/123`) needs a `<base href>` pointing to where the
88
+ workers are served.