dwv 0.30.1 → 0.30.5

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/changelog.md CHANGED
@@ -1,5 +1,49 @@
1
1
  # Changelog
2
2
 
3
+ ## [v0.30.5](https://github.com/ivmartel/dwv/releases/tag/v0.30.5) - 16/12/2021
4
+
5
+ ### Fixed
6
+
7
+ - Allow to play multi-frame data [#1064](https://github.com/ivmartel/dwv/issues/1064)
8
+ - Allow scroll for multi-frame data [#1063](https://github.com/ivmartel/dwv/issues/1063)
9
+ - Stop worker if no tasks left [#1062](https://github.com/ivmartel/dwv/issues/1062)
10
+
11
+ ---
12
+
13
+ ## [v0.30.4](https://github.com/ivmartel/dwv/releases/tag/v0.30.4) - 10/12/2021
14
+
15
+ ### Fixed
16
+
17
+ - Load i18next plugins as modules [#1057](https://github.com/ivmartel/dwv/issues/1057)
18
+ - Update overlays after event data change [#1056](https://github.com/ivmartel/dwv/issues/1056)
19
+
20
+ ### Dependencies
21
+
22
+ - Replace i18next-xhr-backend with i18next-http-backend [#1049](https://github.com/ivmartel/dwv/issues/1049)
23
+
24
+ ---
25
+
26
+ ## [v0.30.3](https://github.com/ivmartel/dwv/releases/tag/v0.30.3) - 09/12/2021
27
+
28
+ ### Fixed
29
+
30
+ - y.Group is not a constructor [#1055](https://github.com/ivmartel/dwv/issues/1055)
31
+
32
+ ---
33
+
34
+ ## [v0.30.2](https://github.com/ivmartel/dwv/releases/tag/v0.30.2) - 07/12/2021
35
+
36
+ ### Added
37
+
38
+ - Add browserlist to package.json [#1052](https://github.com/ivmartel/dwv/issues/1052)
39
+ - Add engines to package.json [#1050](https://github.com/ivmartel/dwv/issues/1050)
40
+
41
+ ### Fixed
42
+
43
+ - require() of ES modules is not supported [#1045](https://github.com/ivmartel/dwv/issues/1045)
44
+
45
+ ---
46
+
3
47
  ## [v0.30.1](https://github.com/ivmartel/dwv/releases/tag/v0.30.1) - 03/12/2021
4
48
 
5
49
  ### Fixed
package/dist/dwv.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! dwv 0.30.1 2021-12-03 15:19:33 */
1
+ /*! dwv 0.30.5 2021-12-16 11:23:07 */
2
2
  // Inspired from umdjs
3
3
  // See https://github.com/umdjs/umd/blob/master/templates/returnExports.js
4
4
  (function (root, factory) {
@@ -6,7 +6,7 @@
6
6
  // AMD. Register as an anonymous module.
7
7
  define([
8
8
  'i18next',
9
- 'i18next-xhr-backend',
9
+ 'i18next-http-backend',
10
10
  'i18next-browser-languagedetector',
11
11
  'jszip',
12
12
  'konva',
@@ -17,21 +17,20 @@
17
17
  // only CommonJS-like environments that support module.exports,
18
18
  // like Node.
19
19
 
20
- // i18next-xhr-backend: requires XMlHttpRequest
21
20
  // Konva: requires 'canvas'
22
21
  module.exports = factory(
23
22
  require('i18next'),
24
- require('i18next-xhr-backend'),
23
+ require('i18next-http-backend'),
25
24
  require('i18next-browser-languagedetector'),
26
25
  require('jszip'),
27
- require('konva'),
26
+ require('konva/cmj'),
28
27
  require('magic-wand-tool')
29
28
  );
30
29
  } else {
31
30
  // Browser globals (root is window)
32
31
  root.dwv = factory(
33
32
  root.i18next,
34
- root.i18nextXHRBackend,
33
+ root.i18nextHttpBackend,
35
34
  root.i18nextBrowserLanguageDetector,
36
35
  root.JSZip,
37
36
  root.Konva,
@@ -40,7 +39,7 @@
40
39
  }
41
40
  }(this, function (
42
41
  i18next,
43
- i18nextXHRBackend,
42
+ i18nextHttpBackend,
44
43
  i18nextBrowserLanguageDetector,
45
44
  JSZip,
46
45
  Konva,
@@ -49,20 +48,27 @@
49
48
  // similar to what browserify does but reversed
50
49
  // https://www.contentful.com/blog/2017/01/17/the-global-object-in-javascript/
51
50
  var window = typeof window !== 'undefined' ?
52
- window : typeof self !== 'undefined' ?
53
- self : typeof global !== 'undefined' ?
54
- global : {};
55
-
56
- // latest i18next (>v17) does not export default
57
- // see #862 and https://github.com/i18next/i18next/commit/7c6c235
58
- if (typeof i18next !== 'undefined' &&
59
- typeof i18next.t === 'undefined') {
51
+ window : typeof self !== 'undefined' ?
52
+ self : typeof global !== 'undefined' ?
53
+ global : {};
54
+
55
+ // if it has a default, treat it as ESM
56
+ var isEsmModule = function (mod) {
57
+ return typeof mod !== 'undefined' &&
58
+ typeof mod.default !== 'undefined';
59
+ }
60
+ // i18next (>v17) comes as a module, see #862
61
+ if (isEsmModule(i18next)) {
60
62
  i18next = i18next.default;
61
63
  }
62
-
64
+ if (isEsmModule(i18nextHttpBackend)) {
65
+ i18nextHttpBackend = i18nextHttpBackend.default;
66
+ }
67
+ if (isEsmModule(i18nextBrowserLanguageDetector)) {
68
+ i18nextBrowserLanguageDetector = i18nextBrowserLanguageDetector.default;
69
+ }
63
70
  // Konva (>=v8) comes as a module, see #1044
64
- if (typeof Konva !== 'undefined' &&
65
- typeof Konva.Group === 'undefined') {
71
+ if (isEsmModule(Konva)) {
66
72
  Konva = Konva.default;
67
73
  }
68
74
 
@@ -2807,7 +2813,8 @@ dwv.ctrl.ViewController = function (view) {
2807
2813
  /**
2808
2814
  * Can the data be scrolled?
2809
2815
  *
2810
- * @returns {boolean} True if the data has a third dimension greater than one.
2816
+ * @returns {boolean} True if the data has either the third dimension
2817
+ * or above greater than one.
2811
2818
  */
2812
2819
  this.canScroll = function () {
2813
2820
  return view.getImage().canScroll(view.getOrientation());
@@ -2953,22 +2960,36 @@ dwv.ctrl.ViewController = function (view) {
2953
2960
  * Scroll play: loop through all slices.
2954
2961
  */
2955
2962
  this.play = function () {
2963
+ // ensure data is scrollable: dim >= 3
2956
2964
  if (!this.canScroll()) {
2957
2965
  return;
2958
2966
  }
2959
2967
  if (playerID === null) {
2968
+ var image = view.getImage();
2960
2969
  var recommendedDisplayFrameRate =
2961
- view.getImage().getMeta().RecommendedDisplayFrameRate;
2970
+ image.getMeta().RecommendedDisplayFrameRate;
2962
2971
  var milliseconds = view.getPlaybackMilliseconds(
2963
2972
  recommendedDisplayFrameRate);
2973
+ var size = image.getGeometry().getSize();
2974
+ var canScroll3D = size.canScroll3D();
2964
2975
 
2965
2976
  playerID = setInterval(function () {
2977
+ var canDoMore = false;
2978
+ if (canScroll3D) {
2979
+ canDoMore = self.incrementScrollIndex();
2980
+ } else {
2981
+ canDoMore = self.incrementIndex(3);
2982
+ }
2966
2983
  // end of scroll, loop back
2967
- if (!self.incrementScrollIndex()) {
2984
+ if (!canDoMore) {
2968
2985
  var pos1 = self.getCurrentIndex();
2969
2986
  var values = pos1.getValues();
2970
2987
  var orientation = view.getOrientation();
2971
- values[orientation.getThirdColMajorDirection()] = 0;
2988
+ if (canScroll3D) {
2989
+ values[orientation.getThirdColMajorDirection()] = 0;
2990
+ } else {
2991
+ values[3] = 0;
2992
+ }
2972
2993
  var index = new dwv.math.Index(values);
2973
2994
  var geometry = view.getImage().getGeometry();
2974
2995
  self.setCurrentPosition(geometry.indexToWorld(index));
@@ -4398,7 +4419,7 @@ dwv.dicom = dwv.dicom || {};
4398
4419
  * @returns {string} The version of the library.
4399
4420
  */
4400
4421
  dwv.getVersion = function () {
4401
- return '0.30.1';
4422
+ return '0.30.5';
4402
4423
  };
4403
4424
 
4404
4425
  /**
@@ -17737,13 +17758,12 @@ dwv.image.Size.prototype.moreThanOne = function (dimension) {
17737
17758
  };
17738
17759
 
17739
17760
  /**
17740
- * Check if the third direction of an orientation matrix has a size
17741
- * of more than one.
17761
+ * Check if the associated data is scrollable in 3D.
17742
17762
  *
17743
17763
  * @param {dwv.math.Matrix33} viewOrientation The orientation matrix.
17744
17764
  * @returns {boolean} True if scrollable.
17745
17765
  */
17746
- dwv.image.Size.prototype.canScroll = function (viewOrientation) {
17766
+ dwv.image.Size.prototype.canScroll3D = function (viewOrientation) {
17747
17767
  var dimension = 2;
17748
17768
  if (typeof viewOrientation !== 'undefined') {
17749
17769
  dimension = viewOrientation.getThirdColMajorDirection();
@@ -17751,6 +17771,22 @@ dwv.image.Size.prototype.canScroll = function (viewOrientation) {
17751
17771
  return this.moreThanOne(dimension);
17752
17772
  };
17753
17773
 
17774
+ /**
17775
+ * Check if the associated data is scrollable: either in 3D or
17776
+ * in other directions.
17777
+ *
17778
+ * @param {dwv.math.Matrix33} viewOrientation The orientation matrix.
17779
+ * @returns {boolean} True if scrollable.
17780
+ */
17781
+ dwv.image.Size.prototype.canScroll = function (viewOrientation) {
17782
+ var canScroll = this.canScroll3D(viewOrientation);
17783
+ // check possible other dimensions
17784
+ for (var i = 3; i < this.length(); ++i) {
17785
+ canScroll = canScroll || this.moreThanOne(i);
17786
+ }
17787
+ return canScroll;
17788
+ };
17789
+
17754
17790
  /**
17755
17791
  * Get the size of a given dimension.
17756
17792
  *
@@ -31006,9 +31042,9 @@ dwv.tool.Scroll = function (app) {
31006
31042
  if (xMove && imageSize.moreThanOne(3)) {
31007
31043
  // update view controller
31008
31044
  if (diffX > 0) {
31009
- viewController.decrementIndex(3);
31010
- } else {
31011
31045
  viewController.incrementIndex(3);
31046
+ } else {
31047
+ viewController.decrementIndex(3);
31012
31048
  }
31013
31049
  }
31014
31050
 
@@ -32351,12 +32387,12 @@ var dwv = dwv || {};
32351
32387
  */
32352
32388
  var i18next = i18next || {};
32353
32389
  /**
32354
- * The i18nextXHRBackend namespace.
32390
+ * The i18nextHttpBackend namespace.
32355
32391
  *
32356
- * @external i18nextXHRBackend
32357
- * @see https://github.com/i18next/i18next-xhr-backend
32392
+ * @external i18nextHttpBackend
32393
+ * @see https://github.com/i18next/i18next-http-backend
32358
32394
  */
32359
- var i18nextXHRBackend = i18nextXHRBackend || {};
32395
+ var i18nextHttpBackend = i18nextHttpBackend || {};
32360
32396
  /**
32361
32397
  * The i18nextBrowserLanguageDetector namespace.
32362
32398
  *
@@ -32390,8 +32426,8 @@ dwv.i18nInitialise = function (language, localesPath) {
32390
32426
  load: 'languageOnly',
32391
32427
  backend: {loadPath: lpath + '/locales/{{lng}}/{{ns}}.json'}
32392
32428
  };
32393
- // use the XHR backend to get translation files
32394
- var i18n = i18next.use(i18nextXHRBackend);
32429
+ // use the HTTP backend to get translation files
32430
+ var i18n = i18next.use(i18nextHttpBackend);
32395
32431
  // use browser language or the specified one
32396
32432
  if (lng === 'auto') {
32397
32433
  i18n.use(i18nextBrowserLanguageDetector);
@@ -34031,6 +34067,8 @@ dwv.utils.ThreadPool = function (poolSize) {
34031
34067
  // use input thread to run the waiting task
34032
34068
  workerThread.run(workerTask);
34033
34069
  } else {
34070
+ // stop the worker
34071
+ workerThread.stop();
34034
34072
  // no task to run, add to free list
34035
34073
  freeThreads.push(workerThread);
34036
34074
  // remove from running list