@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 +87 -2
- package/dist/dwv-react-lib/index.js +1416 -0
- package/dist/dwv-react-lib/index.js.map +1 -0
- package/dist/dwv-react-lib/style.css +2 -0
- package/license.txt +674 -0
- package/package.json +92 -4
- package/plugins/dwvWorkers.js +70 -0
package/package.json
CHANGED
|
@@ -1,6 +1,94 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ivmartel/dwv-react",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.11.0",
|
|
4
|
+
"description": "Medical viewer React component using DWV (DICOM Web Viewer).",
|
|
5
|
+
"author": "ivmartel",
|
|
6
|
+
"license": "GPL-3.0",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"dicom",
|
|
9
|
+
"medical",
|
|
10
|
+
"imaging",
|
|
11
|
+
"viewer",
|
|
12
|
+
"dwv",
|
|
13
|
+
"react",
|
|
14
|
+
"mui"
|
|
15
|
+
],
|
|
16
|
+
"homepage": "https://github.com/ivmartel/dwv-react#readme",
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git+https://github.com/ivmartel/dwv-react.git"
|
|
20
|
+
},
|
|
21
|
+
"bugs": {
|
|
22
|
+
"url": "https://github.com/ivmartel/dwv-react/issues"
|
|
23
|
+
},
|
|
24
|
+
"type": "module",
|
|
25
|
+
"module": "./dist/dwv-react-lib/index.js",
|
|
26
|
+
"exports": {
|
|
27
|
+
".": "./dist/dwv-react-lib/index.js",
|
|
28
|
+
"./style.css": "./dist/dwv-react-lib/style.css",
|
|
29
|
+
"./vite-plugin": "./plugins/dwvWorkers.js"
|
|
30
|
+
},
|
|
31
|
+
"files": [
|
|
32
|
+
"dist/dwv-react-lib/**",
|
|
33
|
+
"plugins/dwvWorkers.js"
|
|
34
|
+
],
|
|
35
|
+
"sideEffects": [
|
|
36
|
+
"**/*.css"
|
|
37
|
+
],
|
|
38
|
+
"publishConfig": {
|
|
39
|
+
"access": "public"
|
|
40
|
+
},
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"dwv": "0.37.0"
|
|
43
|
+
},
|
|
44
|
+
"peerDependencies": {
|
|
45
|
+
"@emotion/react": "^11.0.0",
|
|
46
|
+
"@emotion/styled": "^11.0.0",
|
|
47
|
+
"@mui/icons-material": "^9.0.0",
|
|
48
|
+
"@mui/material": "^9.0.0",
|
|
49
|
+
"react": "^19.0.0",
|
|
50
|
+
"react-dom": "^19.0.0"
|
|
51
|
+
},
|
|
52
|
+
"devDependencies": {
|
|
53
|
+
"@emotion/react": "^11.14.0",
|
|
54
|
+
"@emotion/styled": "^11.14.1",
|
|
55
|
+
"@eslint/js": "^10.0.1",
|
|
56
|
+
"@mui/icons-material": "^9.5.0",
|
|
57
|
+
"@mui/material": "^9.5.0",
|
|
58
|
+
"@napi-rs/canvas": "^1.0.13",
|
|
59
|
+
"@testing-library/dom": "^10.4.2",
|
|
60
|
+
"@testing-library/jest-dom": "^8.0.0",
|
|
61
|
+
"@testing-library/react": "^16.3.3",
|
|
62
|
+
"@types/react": "^19.3.0",
|
|
63
|
+
"@vitejs/plugin-react": "^6.3.0",
|
|
64
|
+
"@vitest/coverage-v8": "^5.1.1",
|
|
65
|
+
"eslint": "^10.15.0",
|
|
66
|
+
"eslint-plugin-react-hooks": "^7.1.1",
|
|
67
|
+
"globals": "^17.14.0",
|
|
68
|
+
"jsdom": "^31.0.1",
|
|
69
|
+
"react": "^19.3.1",
|
|
70
|
+
"react-dom": "^19.3.1",
|
|
71
|
+
"vite": "^8.3.8",
|
|
72
|
+
"vite-plugin-pwa": "^2.0.0",
|
|
73
|
+
"vitest": "^5.1.1"
|
|
74
|
+
},
|
|
75
|
+
"scripts": {
|
|
76
|
+
"dev": "vite",
|
|
77
|
+
"build": "vite build",
|
|
78
|
+
"build-trunk": "vite build --mode development --base /dwv-react/demo/trunk",
|
|
79
|
+
"build-stable": "vite build --mode production --base /dwv-react/demo/stable",
|
|
80
|
+
"build-lib": "vite build --config vite.lib.config.js",
|
|
81
|
+
"prepack": "yarn build-lib",
|
|
82
|
+
"preview": "vite preview",
|
|
83
|
+
"lint": "eslint .",
|
|
84
|
+
"test": "vitest",
|
|
85
|
+
"test-ci": "vitest run --coverage"
|
|
86
|
+
},
|
|
87
|
+
"browserslist": [
|
|
88
|
+
">0.2%",
|
|
89
|
+
"not dead",
|
|
90
|
+
"not ie <= 11",
|
|
91
|
+
"not op_mini all"
|
|
92
|
+
],
|
|
93
|
+
"packageManager": "yarn@4.18.0"
|
|
94
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// Vite plugin providing the dwv web workers.
|
|
2
|
+
//
|
|
3
|
+
// dwv loads its workers from 'assets/workers/' relative to the page base url
|
|
4
|
+
// (document.baseURI). Vite does not pick them up from the dwv bundle: this
|
|
5
|
+
// plugin serves them with the dev server and adds them to the build output.
|
|
6
|
+
import { readdirSync, readFileSync } from 'node:fs';
|
|
7
|
+
import { createRequire } from 'node:module';
|
|
8
|
+
import path from 'node:path';
|
|
9
|
+
|
|
10
|
+
const WORKERS_PATH = 'assets/workers/';
|
|
11
|
+
|
|
12
|
+
const CONTENT_TYPES = {
|
|
13
|
+
'.js': 'text/javascript',
|
|
14
|
+
'.map': 'application/json'
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Get the folder of the dwv workers: the dwv version used by dwv-react.
|
|
19
|
+
*
|
|
20
|
+
* @returns {string} The folder path.
|
|
21
|
+
*/
|
|
22
|
+
export function getDwvWorkersDir() {
|
|
23
|
+
const require = createRequire(import.meta.url);
|
|
24
|
+
// the dwv package does not export its package.json:
|
|
25
|
+
// resolve its main file, in the 'dist' folder
|
|
26
|
+
const dwvDist = path.dirname(require.resolve('dwv'));
|
|
27
|
+
return path.join(dwvDist, WORKERS_PATH);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Vite plugin serving the dwv web workers in dev and adding them
|
|
32
|
+
* to the build output, in 'assets/workers/'.
|
|
33
|
+
*
|
|
34
|
+
* @param {object} [options] The plugin options.
|
|
35
|
+
* @param {string} [options.workersDir] The dwv workers folder,
|
|
36
|
+
* defaults to the one of the dwv package used by dwv-react.
|
|
37
|
+
* @returns {import('vite').Plugin} The Vite plugin.
|
|
38
|
+
*/
|
|
39
|
+
export function dwvWorkers(options = {}) {
|
|
40
|
+
const workersDir = options.workersDir ?? getDwvWorkersDir();
|
|
41
|
+
const fileNames = readdirSync(workersDir)
|
|
42
|
+
.filter((name) => Object.hasOwn(CONTENT_TYPES, path.extname(name)));
|
|
43
|
+
|
|
44
|
+
return {
|
|
45
|
+
name: 'dwv-workers',
|
|
46
|
+
configureServer(server) {
|
|
47
|
+
server.middlewares.use((req, res, next) => {
|
|
48
|
+
// the page can be at any path: match the end of the url path
|
|
49
|
+
const urlPath = (req.url ?? '').split(/[?#]/)[0];
|
|
50
|
+
const fileName = fileNames.find(
|
|
51
|
+
(name) => urlPath.endsWith('/' + WORKERS_PATH + name));
|
|
52
|
+
if (!fileName) {
|
|
53
|
+
next();
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
res.setHeader('Content-Type', CONTENT_TYPES[path.extname(fileName)]);
|
|
57
|
+
res.end(readFileSync(path.join(workersDir, fileName)));
|
|
58
|
+
});
|
|
59
|
+
},
|
|
60
|
+
generateBundle() {
|
|
61
|
+
for (const name of fileNames) {
|
|
62
|
+
this.emitFile({
|
|
63
|
+
type: 'asset',
|
|
64
|
+
fileName: WORKERS_PATH + name,
|
|
65
|
+
source: readFileSync(path.join(workersDir, name))
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
}
|