dwv 0.35.0-beta.8 → 0.35.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dwv",
3
- "version": "0.35.0-beta.8",
3
+ "version": "0.35.0",
4
4
  "description": "DICOM Web Viewer.",
5
5
  "keywords": [
6
6
  "DICOM",
@@ -12,10 +12,17 @@
12
12
  "homepage": "https://ivmartel.github.io/dwv/",
13
13
  "repository": {
14
14
  "type": "git",
15
- "url": "git://github.com/ivmartel/dwv.git"
15
+ "url": "https://github.com/ivmartel/dwv.git"
16
+ },
17
+ "type": "module",
18
+ "sideEffects": false,
19
+ "main": "./dist/dwv.min.js",
20
+ "types": "./dist/dwv.d.ts",
21
+ "exports": {
22
+ "types": "./dist/dwv.d.ts",
23
+ "node": "./dist/dwv.node.min.js",
24
+ "default": "./dist/dwv.min.js"
16
25
  },
17
- "main": "dist/dwv.min.js",
18
- "types": "dist/dwv.d.ts",
19
26
  "engines": {
20
27
  "node": ">= 14.0.0"
21
28
  },
@@ -24,23 +31,23 @@
24
31
  ],
25
32
  "dependencies": {
26
33
  "jszip": "^3.10.1",
27
- "konva": "~9.3.16",
34
+ "konva": "~9.3.20",
28
35
  "magic-wand-tool": "~1.1.7"
29
36
  },
30
37
  "devDependencies": {
31
- "@babel/core": "^7.26.0",
32
- "@babel/preset-env": "^7.26.0",
33
- "@microsoft/api-extractor": "^7.47.11",
34
- "@eslint/js": "^9.14.0",
35
- "@stylistic/eslint-plugin-js": "^2.12.0",
36
- "babel-loader": "^9.2.1",
38
+ "@babel/core": "^7.27.4",
39
+ "@babel/preset-env": "^7.27.2",
40
+ "@eslint/js": "^9.29.0",
41
+ "@microsoft/api-extractor": "^7.52.8",
42
+ "@stylistic/eslint-plugin": "^4.4.1",
43
+ "babel-loader": "^10.0.0",
37
44
  "babel-plugin-istanbul": "^7.0.0",
38
45
  "benchmark": "^2.1.4",
39
46
  "clean-jsdoc-theme": "^4.3.0",
40
- "eslint": "^9.14.0",
41
- "eslint-plugin-jsdoc": "^50.3.1",
47
+ "eslint": "^9.29.0",
48
+ "eslint-plugin-jsdoc": "^51.2.3",
42
49
  "github-release-notes": "0.17.2",
43
- "globals": "^15.12.0",
50
+ "globals": "^16.2.0",
44
51
  "html-webpack-plugin": "^5.6.3",
45
52
  "jsdoc": "^4.0.4",
46
53
  "karma": "^6.4.4",
@@ -50,20 +57,23 @@
50
57
  "karma-qunit": "^4.2.1",
51
58
  "karma-sourcemap-loader": "^0.4.0",
52
59
  "karma-webpack": "^5.0.1",
53
- "qunit": "^2.23.1",
54
- "typescript": "~5.4.5",
55
- "webpack": "^5.97.1",
56
- "webpack-cli": "^5.1.4",
57
- "webpack-dev-server": "^5.1.0",
60
+ "qunit": "^2.24.1",
61
+ "typescript": "~5.6.3",
62
+ "webpack": "^5.99.9",
63
+ "webpack-cli": "^6.0.1",
64
+ "webpack-dev-server": "^5.2.2",
58
65
  "webpack-merge": "^6.0.1"
59
66
  },
60
67
  "scripts": {
61
- "start": "webpack serve --config webpack.dev.js",
62
- "pack": "webpack --config webpack.prod.js",
68
+ "start": "webpack serve --config config/webpack.dev.js",
69
+ "pack": "webpack --config config/webpack.prod.js",
70
+ "pack-node": "webpack --config config/webpack.node.js",
63
71
  "build": "yarn run pack && yarn run types && yarn run api",
64
- "lint": "eslint -c 'eslint.config-full.mjs' 'src/**/*.js' 'tests/**/*.js' '*.js'",
65
- "test": "karma start ./karma.conf.js",
66
- "test-ci": "karma start ./karma.conf.js --browsers ChromeHeadless --reporters progress,coverage,json --single-run",
72
+ "build-all": "yarn run build && yarn run pack-node",
73
+ "build-demo": "webpack --config config/webpack.demo.js",
74
+ "lint": "eslint -c config/eslint.config-full.js 'src/**/*.js' 'tests/**/*.js' '*.js'",
75
+ "test": "karma start karma.conf.js",
76
+ "test-ci": "karma start karma.conf.js --browsers ChromeHeadless --reporters progress,coverage,json --single-run",
67
77
  "doc": "jsdoc -c resources/doc/jsdoc.conf.json",
68
78
  "gren": "gren",
69
79
  "types": "tsc -p resources/api/tsconfig.json",
package/readme.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # DWV
2
2
 
3
- DWV (DICOM Web Viewer) is an open source zero footprint medical image viewer library. It uses _only_ javascript and HTML5 technologies, meaning that it can be run on any platform that provides a modern browser (laptop, tablet, phone and even modern TVs). It can load local or remote data in DICOM format (the standard for medical imaging data such as MR, CT, Echo, Mammo, NM...) and provides standard tools for its manipulation such as contrast, zoom, drag, possibility to draw regions on top of the image and imaging filters such as threshold and sharpening.
3
+ DWV (DICOM Web Viewer) is an open source zero footprint medical image viewer library. It uses _only_ javascript and HTML5 technologies, meaning that it can be run on any platform that provides a modern browser (laptop, tablet, phone and even modern TVs). It can load local or remote data in DICOM format (the standard for medical imaging data such as MR, CT, Echo, Mammo, NM...) and provides standard tools for its manipulation such as scroll, contrast, zoom, pan, MPR, annotation and imaging filters such as threshold and sharpening.
4
4
 
5
5
  [![Node.js CI](https://github.com/ivmartel/dwv/actions/workflows/nodejs-ci.yml/badge.svg)](https://github.com/ivmartel/dwv/actions/workflows/nodejs-ci.yml) [![npm](https://img.shields.io/npm/v/dwv.svg)](https://www.npmjs.com/package/dwv)
6
6
  [![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=VQWYY8ZS75H3E&currency_code=EUR&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted)
@@ -1,23 +0,0 @@
1
- /**
2
- * RLE decoder worker.
3
- */
4
- // Do not warn if these variables were not defined before.
5
- /* global importScripts */
6
-
7
- importScripts('rle.js');
8
-
9
- self.addEventListener('message', function (event) {
10
-
11
- // decode DICOM buffer
12
- // eslint-disable-next-line no-undef
13
- var decoder = new dwvdecoder.RleDecoder();
14
- // post decoded data
15
- self.postMessage([decoder.decode(
16
- event.data.buffer,
17
- event.data.meta.bitsAllocated,
18
- event.data.meta.isSigned,
19
- event.data.meta.sliceSize,
20
- event.data.meta.samplesPerPixel,
21
- event.data.meta.planarConfiguration)]);
22
-
23
- }, false);
@@ -1,129 +0,0 @@
1
- // namespaces
2
- // (do not use dwv since it is the exported module name)
3
- var dwvdecoder = dwvdecoder || {};
4
-
5
- /**
6
- * RLE (Run-length encoding) decoder class.
7
- * @constructor
8
- */
9
- dwvdecoder.RleDecoder = function () {};
10
-
11
- /**
12
- * Decode a RLE buffer.
13
- * @param {Array} buffer The buffer to decode.
14
- * @param {Number} bitsAllocated The bits allocated per element in the buffer.
15
- * @param {Boolean} isSigned Is the data signed.
16
- * @param {Number} sliceSize The size of a slice
17
- (number of rows per number of columns).
18
- * @param {Number} samplesPerPixel The number of samples per pixel (3 for RGB).
19
- * @param {Number} planarConfiguration The planar configuration.
20
- * @returns The decoded buffer.
21
- * @see http://dicom.nema.org/dicom/2013/output/chtml/part05/sect_G.3.html
22
- */
23
- dwvdecoder.RleDecoder.prototype.decode = function (buffer,
24
- bitsAllocated, isSigned, sliceSize, samplesPerPixel, planarConfiguration) {
25
-
26
- // bytes per element
27
- var bpe = bitsAllocated / 8;
28
-
29
- // input
30
- var inputDataView = new DataView(buffer.buffer, buffer.byteOffset);
31
- var inputArray = new Int8Array(buffer.buffer, buffer.byteOffset);
32
- // output
33
- var outputBuffer = new ArrayBuffer(sliceSize * samplesPerPixel * bpe);
34
- var outputArray = new Int8Array(outputBuffer);
35
-
36
- // first value of the RLE header is the number of segments
37
- var numberOfSegments = inputDataView.getInt32(0, true);
38
-
39
- // index increment in output array
40
- var outputIndexIncrement = 1;
41
- var incrementFactor = 1;
42
- if (samplesPerPixel !== 1 && planarConfiguration === 0) {
43
- incrementFactor *= samplesPerPixel;
44
- }
45
- if (bpe !== 1) {
46
- incrementFactor *= bpe;
47
- }
48
- outputIndexIncrement *= incrementFactor;
49
-
50
- // loop on segments
51
- var outputIndex = 0;
52
- var inputIndex = 0;
53
- var remainder = 0;
54
- var maxOutputIndex = 0;
55
- var groupOutputIndex = 0;
56
- for (var segment = 0; segment < numberOfSegments; ++segment) {
57
- // handle special cases:
58
- // - more than one sample per pixel: one segment per channel
59
- // - 16bits: sort high and low bytes
60
- if (incrementFactor !== 1) {
61
- remainder = segment % incrementFactor;
62
- if (remainder === 0) {
63
- groupOutputIndex = maxOutputIndex;
64
- }
65
- outputIndex = groupOutputIndex + remainder;
66
- // 16bits data
67
- if (bpe === 2) {
68
- outputIndex += (remainder % bpe ? -1 : 1);
69
- }
70
- }
71
-
72
- // RLE header: list of segment sizes
73
- var segmentStartIndex = inputDataView.getInt32((segment + 1) * 4, true);
74
- var nextSegmentStartIndex = inputDataView.getInt32((segment + 2) * 4, true);
75
- if (segment === numberOfSegments - 1 || nextSegmentStartIndex === 0) {
76
- nextSegmentStartIndex = buffer.length;
77
- }
78
- // decode segment
79
- inputIndex = segmentStartIndex;
80
- var count = 0;
81
- while (inputIndex < nextSegmentStartIndex) {
82
- // get the count value
83
- count = inputArray[inputIndex];
84
- ++inputIndex;
85
- // store according to count
86
- if (count >= 0 && count <= 127) {
87
- // output the next count+1 bytes literally
88
- for (var i = 0; i < count + 1; ++i) {
89
- // store
90
- outputArray[outputIndex] = inputArray[inputIndex];
91
- // increment indexes
92
- ++inputIndex;
93
- outputIndex += outputIndexIncrement;
94
- }
95
- } else if (count <= -1 && count >= -127) {
96
- // output the next byte -count+1 times
97
- var value = inputArray[inputIndex];
98
- ++inputIndex;
99
- for (var j = 0; j < -count + 1; ++j) {
100
- // store
101
- outputArray[outputIndex] = value;
102
- // increment index
103
- outputIndex += outputIndexIncrement;
104
- }
105
- }
106
- }
107
-
108
- if (outputIndex > maxOutputIndex) {
109
- maxOutputIndex = outputIndex;
110
- }
111
- }
112
-
113
- var decodedBuffer = null;
114
- if (bitsAllocated === 8) {
115
- if (isSigned) {
116
- decodedBuffer = new Int8Array(outputBuffer);
117
- } else {
118
- decodedBuffer = new Uint8Array(outputBuffer);
119
- }
120
- } else if (bitsAllocated === 16) {
121
- if (isSigned) {
122
- decodedBuffer = new Int16Array(outputBuffer);
123
- } else {
124
- decodedBuffer = new Uint16Array(outputBuffer);
125
- }
126
- }
127
-
128
- return decodedBuffer;
129
- };
@@ -1,185 +0,0 @@
1
- /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
- /* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
3
- /* Copyright 2012 Mozilla Foundation
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
-
18
- 'use strict';
19
-
20
- /* This class implements the QM Coder decoding as defined in
21
- * JPEG 2000 Part I Final Committee Draft Version 1.0
22
- * Annex C.3 Arithmetic decoding procedure
23
- * available at http://www.jpeg.org/public/fcd15444-1.pdf
24
- *
25
- * The arithmetic decoder is used in conjunction with context models to decode
26
- * JPEG2000 and JBIG2 streams.
27
- */
28
- var ArithmeticDecoder = (function ArithmeticDecoderClosure() {
29
- // Table C-2
30
- var QeTable = [
31
- {qe: 0x5601, nmps: 1, nlps: 1, switchFlag: 1},
32
- {qe: 0x3401, nmps: 2, nlps: 6, switchFlag: 0},
33
- {qe: 0x1801, nmps: 3, nlps: 9, switchFlag: 0},
34
- {qe: 0x0AC1, nmps: 4, nlps: 12, switchFlag: 0},
35
- {qe: 0x0521, nmps: 5, nlps: 29, switchFlag: 0},
36
- {qe: 0x0221, nmps: 38, nlps: 33, switchFlag: 0},
37
- {qe: 0x5601, nmps: 7, nlps: 6, switchFlag: 1},
38
- {qe: 0x5401, nmps: 8, nlps: 14, switchFlag: 0},
39
- {qe: 0x4801, nmps: 9, nlps: 14, switchFlag: 0},
40
- {qe: 0x3801, nmps: 10, nlps: 14, switchFlag: 0},
41
- {qe: 0x3001, nmps: 11, nlps: 17, switchFlag: 0},
42
- {qe: 0x2401, nmps: 12, nlps: 18, switchFlag: 0},
43
- {qe: 0x1C01, nmps: 13, nlps: 20, switchFlag: 0},
44
- {qe: 0x1601, nmps: 29, nlps: 21, switchFlag: 0},
45
- {qe: 0x5601, nmps: 15, nlps: 14, switchFlag: 1},
46
- {qe: 0x5401, nmps: 16, nlps: 14, switchFlag: 0},
47
- {qe: 0x5101, nmps: 17, nlps: 15, switchFlag: 0},
48
- {qe: 0x4801, nmps: 18, nlps: 16, switchFlag: 0},
49
- {qe: 0x3801, nmps: 19, nlps: 17, switchFlag: 0},
50
- {qe: 0x3401, nmps: 20, nlps: 18, switchFlag: 0},
51
- {qe: 0x3001, nmps: 21, nlps: 19, switchFlag: 0},
52
- {qe: 0x2801, nmps: 22, nlps: 19, switchFlag: 0},
53
- {qe: 0x2401, nmps: 23, nlps: 20, switchFlag: 0},
54
- {qe: 0x2201, nmps: 24, nlps: 21, switchFlag: 0},
55
- {qe: 0x1C01, nmps: 25, nlps: 22, switchFlag: 0},
56
- {qe: 0x1801, nmps: 26, nlps: 23, switchFlag: 0},
57
- {qe: 0x1601, nmps: 27, nlps: 24, switchFlag: 0},
58
- {qe: 0x1401, nmps: 28, nlps: 25, switchFlag: 0},
59
- {qe: 0x1201, nmps: 29, nlps: 26, switchFlag: 0},
60
- {qe: 0x1101, nmps: 30, nlps: 27, switchFlag: 0},
61
- {qe: 0x0AC1, nmps: 31, nlps: 28, switchFlag: 0},
62
- {qe: 0x09C1, nmps: 32, nlps: 29, switchFlag: 0},
63
- {qe: 0x08A1, nmps: 33, nlps: 30, switchFlag: 0},
64
- {qe: 0x0521, nmps: 34, nlps: 31, switchFlag: 0},
65
- {qe: 0x0441, nmps: 35, nlps: 32, switchFlag: 0},
66
- {qe: 0x02A1, nmps: 36, nlps: 33, switchFlag: 0},
67
- {qe: 0x0221, nmps: 37, nlps: 34, switchFlag: 0},
68
- {qe: 0x0141, nmps: 38, nlps: 35, switchFlag: 0},
69
- {qe: 0x0111, nmps: 39, nlps: 36, switchFlag: 0},
70
- {qe: 0x0085, nmps: 40, nlps: 37, switchFlag: 0},
71
- {qe: 0x0049, nmps: 41, nlps: 38, switchFlag: 0},
72
- {qe: 0x0025, nmps: 42, nlps: 39, switchFlag: 0},
73
- {qe: 0x0015, nmps: 43, nlps: 40, switchFlag: 0},
74
- {qe: 0x0009, nmps: 44, nlps: 41, switchFlag: 0},
75
- {qe: 0x0005, nmps: 45, nlps: 42, switchFlag: 0},
76
- {qe: 0x0001, nmps: 45, nlps: 43, switchFlag: 0},
77
- {qe: 0x5601, nmps: 46, nlps: 46, switchFlag: 0}
78
- ];
79
-
80
- // C.3.5 Initialisation of the decoder (INITDEC)
81
- function ArithmeticDecoder(data, start, end) {
82
- this.data = data;
83
- this.bp = start;
84
- this.dataEnd = end;
85
-
86
- this.chigh = data[start];
87
- this.clow = 0;
88
-
89
- this.byteIn();
90
-
91
- this.chigh = ((this.chigh << 7) & 0xFFFF) | ((this.clow >> 9) & 0x7F);
92
- this.clow = (this.clow << 7) & 0xFFFF;
93
- this.ct -= 7;
94
- this.a = 0x8000;
95
- }
96
-
97
- ArithmeticDecoder.prototype = {
98
- // C.3.4 Compressed data input (BYTEIN)
99
- byteIn: function ArithmeticDecoder_byteIn() {
100
- var data = this.data;
101
- var bp = this.bp;
102
- if (data[bp] === 0xFF) {
103
- var b1 = data[bp + 1];
104
- if (b1 > 0x8F) {
105
- this.clow += 0xFF00;
106
- this.ct = 8;
107
- } else {
108
- bp++;
109
- this.clow += (data[bp] << 9);
110
- this.ct = 7;
111
- this.bp = bp;
112
- }
113
- } else {
114
- bp++;
115
- this.clow += bp < this.dataEnd ? (data[bp] << 8) : 0xFF00;
116
- this.ct = 8;
117
- this.bp = bp;
118
- }
119
- if (this.clow > 0xFFFF) {
120
- this.chigh += (this.clow >> 16);
121
- this.clow &= 0xFFFF;
122
- }
123
- },
124
- // C.3.2 Decoding a decision (DECODE)
125
- readBit: function ArithmeticDecoder_readBit(contexts, pos) {
126
- // contexts are packed into 1 byte:
127
- // highest 7 bits carry cx.index, lowest bit carries cx.mps
128
- var cx_index = contexts[pos] >> 1, cx_mps = contexts[pos] & 1;
129
- var qeTableIcx = QeTable[cx_index];
130
- var qeIcx = qeTableIcx.qe;
131
- var d;
132
- var a = this.a - qeIcx;
133
-
134
- if (this.chigh < qeIcx) {
135
- // exchangeLps
136
- if (a < qeIcx) {
137
- a = qeIcx;
138
- d = cx_mps;
139
- cx_index = qeTableIcx.nmps;
140
- } else {
141
- a = qeIcx;
142
- d = 1 ^ cx_mps;
143
- if (qeTableIcx.switchFlag === 1) {
144
- cx_mps = d;
145
- }
146
- cx_index = qeTableIcx.nlps;
147
- }
148
- } else {
149
- this.chigh -= qeIcx;
150
- if ((a & 0x8000) !== 0) {
151
- this.a = a;
152
- return cx_mps;
153
- }
154
- // exchangeMps
155
- if (a < qeIcx) {
156
- d = 1 ^ cx_mps;
157
- if (qeTableIcx.switchFlag === 1) {
158
- cx_mps = d;
159
- }
160
- cx_index = qeTableIcx.nlps;
161
- } else {
162
- d = cx_mps;
163
- cx_index = qeTableIcx.nmps;
164
- }
165
- }
166
- // C.3.3 renormD;
167
- do {
168
- if (this.ct === 0) {
169
- this.byteIn();
170
- }
171
-
172
- a <<= 1;
173
- this.chigh = ((this.chigh << 1) & 0xFFFF) | ((this.clow >> 15) & 1);
174
- this.clow = (this.clow << 1) & 0xFFFF;
175
- this.ct--;
176
- } while ((a & 0x8000) === 0);
177
- this.a = a;
178
-
179
- contexts[pos] = cx_index << 1 | cx_mps;
180
- return d;
181
- }
182
- };
183
-
184
- return ArithmeticDecoder;
185
- })();
@@ -1,18 +0,0 @@
1
- /**
2
- * JPEG 2000 decoder worker.
3
- */
4
- // Do not warn if these variables were not defined before.
5
- /* global importScripts, JpxImage */
6
-
7
- importScripts('jpx.js', 'util.js', 'arithmetic_decoder.js');
8
-
9
- self.addEventListener('message', function (event) {
10
-
11
- // decode DICOM buffer
12
- var decoder = new JpxImage();
13
- decoder.parse(event.data.buffer);
14
- // post decoded data
15
- var res = decoder.tiles[0].items;
16
- self.postMessage([res]);
17
-
18
- }, false);
@@ -1,18 +0,0 @@
1
- /**
2
- * JPEG Baseline decoder worker.
3
- */
4
- // Do not warn if these variables were not defined before.
5
- /* global importScripts, JpegImage */
6
-
7
- importScripts('jpg.js');
8
-
9
- self.addEventListener('message', function (event) {
10
-
11
- // decode DICOM buffer
12
- var decoder = new JpegImage();
13
- decoder.parse(event.data.buffer);
14
- // post decoded data
15
- var res = decoder.getData(decoder.width, decoder.height);
16
- self.postMessage([res]);
17
-
18
- }, false);