Passed
Pull Request — dev (#52)
by Salim
17:21
created

DFViewport   F

Complexity

Conditions 32

Size

Total Lines 229
Code Lines 148

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 32
eloc 148
c 0
b 0
f 0
dl 0
loc 229
rs 0

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

Complexity

Complex classes like 12.bundle.2984165d3050cb4e5079.js ➔ DicomPDFViewport often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

1
(window["webpackJsonp"] = window["webpackJsonp"] || []).push([[12],{
2
3
/***/ 1001:
4
/***/ (function(module, exports, __webpack_require__) {
0 ignored issues
show
Unused Code introduced by
The parameter __webpack_require__ is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
Unused Code introduced by
The parameter module is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
Unused Code introduced by
The parameter exports is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
5
6
// extracted by extract-css-chunks-webpack-plugin
7
8
/***/ }),
9
10
/***/ 1008:
11
/***/ (function(module, __webpack_exports__, __webpack_require__) {
12
13
"use strict";
14
__webpack_require__.r(__webpack_exports__);
15
16
// EXTERNAL MODULE: /home/salim/GaelO-Dev/OHIF/Viewers/platform/core/src/index.js + 33 modules
17
var src = __webpack_require__(13);
18
19
// EXTERNAL MODULE: /home/salim/GaelO-Dev/OHIF/Viewers/node_modules/react-redux/es/index.js + 21 modules
20
var es = __webpack_require__(59);
21
22
// EXTERNAL MODULE: /home/salim/GaelO-Dev/OHIF/Viewers/node_modules/react/index.js
23
var react = __webpack_require__(0);
24
var react_default = /*#__PURE__*/__webpack_require__.n(react);
25
26
// EXTERNAL MODULE: /home/salim/GaelO-Dev/OHIF/Viewers/node_modules/prop-types/index.js
27
var prop_types = __webpack_require__(1);
28
var prop_types_default = /*#__PURE__*/__webpack_require__.n(prop_types);
29
30
// CONCATENATED MODULE: /home/salim/GaelO-Dev/OHIF/Viewers/extensions/dicom-pdf/src/OHIFComponentPlugin.js
31
32
33
34
function OHIFComponentPlugin(props) {
35
  return react_default.a.createElement(react_default.a.Fragment, null, props.children);
36
}
37
38
OHIFComponentPlugin.propTypes = {
39
  id: prop_types_default.a.string.isRequired,
40
  init: prop_types_default.a.func.isRequired,
41
  destroy: prop_types_default.a.func.isRequired,
42
  children: prop_types_default.a.node
43
};
44
/* harmony default export */ var src_OHIFComponentPlugin = (OHIFComponentPlugin);
45
// EXTERNAL MODULE: /home/salim/GaelO-Dev/OHIF/Viewers/node_modules/dicom-parser/dist/dicomParser.min.js
46
var dicomParser_min = __webpack_require__(97);
47
var dicomParser_min_default = /*#__PURE__*/__webpack_require__.n(dicomParser_min);
48
49
// EXTERNAL MODULE: /home/salim/GaelO-Dev/OHIF/Viewers/node_modules/pdfjs-dist/build/pdf.js
50
var build_pdf = __webpack_require__(970);
51
var pdf_default = /*#__PURE__*/__webpack_require__.n(build_pdf);
52
53
// CONCATENATED MODULE: /home/salim/GaelO-Dev/OHIF/Viewers/extensions/dicom-pdf/src/TypedArrayProp.js
54
// https://github.com/facebook/prop-types/issues/69
55
var TypedArrayProp = {
56 View Code Duplication
  any: function any(props, propName, componentName) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
57
    var obj = props[propName];
58
59
    if (!(obj instanceof Float64Array || obj instanceof Float32Array || obj instanceof Int32Array || obj instanceof Int16Array || obj instanceof Int8Array || obj instanceof Uint32Array || obj instanceof Uint16Array || obj instanceof Uint8Array || obj instanceof Uint8ClampedArray)) {
0 ignored issues
show
Complexity Best Practice introduced by
There is no return statement if !(obj instanceof Float64...ceof Uint8ClampedArray) is false. Are you sure this is correct? If so, consider adding return; explicitly.

This check looks for functions where a return statement is found in some execution paths, but not in all.

Consider this little piece of code

function isBig(a) {
    if (a > 5000) {
        return "yes";
    }
}

console.log(isBig(5001)); //returns yes
console.log(isBig(42)); //returns undefined

The function isBig will only return a specific value when its parameter is bigger than 5000. In any other case, it will implicitly return undefined.

This behaviour may not be what you had intended. In any case, you can add a return undefined to the other execution path to make the return value explicit.

Loading history...
60
      return new Error('Invalid prop `' + propName + '` supplied to' + ' `' + componentName + '`. Expected a typed array.');
61
    }
62
  },
63
  float64: function float64(props, propName, componentName) {
64
    if (!(props[propName] instanceof Float64Array)) {
0 ignored issues
show
Complexity Best Practice introduced by
There is no return statement if !(props.propName instanceof Float64Array) is false. Are you sure this is correct? If so, consider adding return; explicitly.

This check looks for functions where a return statement is found in some execution paths, but not in all.

Consider this little piece of code

function isBig(a) {
    if (a > 5000) {
        return "yes";
    }
}

console.log(isBig(5001)); //returns yes
console.log(isBig(42)); //returns undefined

The function isBig will only return a specific value when its parameter is bigger than 5000. In any other case, it will implicitly return undefined.

This behaviour may not be what you had intended. In any case, you can add a return undefined to the other execution path to make the return value explicit.

Loading history...
65
      return new Error('Invalid prop `' + propName + '` supplied to' + ' `' + componentName + '`. Expected a Float64Array.');
66
    }
67
  },
68
  float32: function float32(props, propName, componentName) {
69
    if (!(props[propName] instanceof Float32Array)) {
0 ignored issues
show
Complexity Best Practice introduced by
There is no return statement if !(props.propName instanceof Float32Array) is false. Are you sure this is correct? If so, consider adding return; explicitly.

This check looks for functions where a return statement is found in some execution paths, but not in all.

Consider this little piece of code

function isBig(a) {
    if (a > 5000) {
        return "yes";
    }
}

console.log(isBig(5001)); //returns yes
console.log(isBig(42)); //returns undefined

The function isBig will only return a specific value when its parameter is bigger than 5000. In any other case, it will implicitly return undefined.

This behaviour may not be what you had intended. In any case, you can add a return undefined to the other execution path to make the return value explicit.

Loading history...
70
      return new Error('Invalid prop `' + propName + '` supplied to' + ' `' + componentName + '`. Expected a Float32Array.');
71
    }
72
  },
73
  float: function float(props, propName, componentName) {
74
    if (!(props[propName] instanceof Float64Array || props[propName] instanceof Float32Array)) {
0 ignored issues
show
Complexity Best Practice introduced by
There is no return statement if !(props.propName instanc...nstanceof Float32Array) is false. Are you sure this is correct? If so, consider adding return; explicitly.

This check looks for functions where a return statement is found in some execution paths, but not in all.

Consider this little piece of code

function isBig(a) {
    if (a > 5000) {
        return "yes";
    }
}

console.log(isBig(5001)); //returns yes
console.log(isBig(42)); //returns undefined

The function isBig will only return a specific value when its parameter is bigger than 5000. In any other case, it will implicitly return undefined.

This behaviour may not be what you had intended. In any case, you can add a return undefined to the other execution path to make the return value explicit.

Loading history...
75
      return new Error('Invalid prop `' + propName + '` supplied to' + ' `' + componentName + '`. Expected a Float32Array or Float64Array.');
76
    }
77
  },
78
  int32: function int32(props, propName, componentName) {
79
    if (!(props[propName] instanceof Int32Array)) {
0 ignored issues
show
Complexity Best Practice introduced by
There is no return statement if !(props.propName instanceof Int32Array) is false. Are you sure this is correct? If so, consider adding return; explicitly.

This check looks for functions where a return statement is found in some execution paths, but not in all.

Consider this little piece of code

function isBig(a) {
    if (a > 5000) {
        return "yes";
    }
}

console.log(isBig(5001)); //returns yes
console.log(isBig(42)); //returns undefined

The function isBig will only return a specific value when its parameter is bigger than 5000. In any other case, it will implicitly return undefined.

This behaviour may not be what you had intended. In any case, you can add a return undefined to the other execution path to make the return value explicit.

Loading history...
80
      return new Error('Invalid prop `' + propName + '` supplied to' + ' `' + componentName + '`. Expected an Int32Array.');
81
    }
82
  },
83
  int16: function int16(props, propName, componentName) {
84
    if (!(props[propName] instanceof Int16Array)) {
0 ignored issues
show
Complexity Best Practice introduced by
There is no return statement if !(props.propName instanceof Int16Array) is false. Are you sure this is correct? If so, consider adding return; explicitly.

This check looks for functions where a return statement is found in some execution paths, but not in all.

Consider this little piece of code

function isBig(a) {
    if (a > 5000) {
        return "yes";
    }
}

console.log(isBig(5001)); //returns yes
console.log(isBig(42)); //returns undefined

The function isBig will only return a specific value when its parameter is bigger than 5000. In any other case, it will implicitly return undefined.

This behaviour may not be what you had intended. In any case, you can add a return undefined to the other execution path to make the return value explicit.

Loading history...
85
      return new Error('Invalid prop `' + propName + '` supplied to' + ' `' + componentName + '`. Expected an In16Array.');
86
    }
87
  },
88
  int8: function int8(props, propName, componentName) {
89
    if (!(props[propName] instanceof Int8Array)) {
0 ignored issues
show
Complexity Best Practice introduced by
There is no return statement if !(props.propName instanceof Int8Array) is false. Are you sure this is correct? If so, consider adding return; explicitly.

This check looks for functions where a return statement is found in some execution paths, but not in all.

Consider this little piece of code

function isBig(a) {
    if (a > 5000) {
        return "yes";
    }
}

console.log(isBig(5001)); //returns yes
console.log(isBig(42)); //returns undefined

The function isBig will only return a specific value when its parameter is bigger than 5000. In any other case, it will implicitly return undefined.

This behaviour may not be what you had intended. In any case, you can add a return undefined to the other execution path to make the return value explicit.

Loading history...
90
      return new Error('Invalid prop `' + propName + '` supplied to' + ' `' + componentName + '`. Expected an Int8Array.');
91
    }
92
  },
93
  int: function int(props, propName, componentName) {
94
    if (!(props[propName] instanceof Int32Array || props[propName] instanceof Int16Array || props[propName] instanceof Int8Array)) {
0 ignored issues
show
Complexity Best Practice introduced by
There is no return statement if !(props.propName instanc...e instanceof Int8Array) is false. Are you sure this is correct? If so, consider adding return; explicitly.

This check looks for functions where a return statement is found in some execution paths, but not in all.

Consider this little piece of code

function isBig(a) {
    if (a > 5000) {
        return "yes";
    }
}

console.log(isBig(5001)); //returns yes
console.log(isBig(42)); //returns undefined

The function isBig will only return a specific value when its parameter is bigger than 5000. In any other case, it will implicitly return undefined.

This behaviour may not be what you had intended. In any case, you can add a return undefined to the other execution path to make the return value explicit.

Loading history...
95
      return new Error('Invalid prop `' + propName + '` supplied to' + ' `' + componentName + '`. Expected an Int32Array, In16Array, or Int8Array.');
96
    }
97
  },
98
  uint32: function uint32(props, propName, componentName) {
99
    if (!(props[propName] instanceof Uint32Array)) {
0 ignored issues
show
Complexity Best Practice introduced by
There is no return statement if !(props.propName instanceof Uint32Array) is false. Are you sure this is correct? If so, consider adding return; explicitly.

This check looks for functions where a return statement is found in some execution paths, but not in all.

Consider this little piece of code

function isBig(a) {
    if (a > 5000) {
        return "yes";
    }
}

console.log(isBig(5001)); //returns yes
console.log(isBig(42)); //returns undefined

The function isBig will only return a specific value when its parameter is bigger than 5000. In any other case, it will implicitly return undefined.

This behaviour may not be what you had intended. In any case, you can add a return undefined to the other execution path to make the return value explicit.

Loading history...
100
      return new Error('Invalid prop `' + propName + '` supplied to' + ' `' + componentName + '`. Expected a Uint32Array.');
101
    }
102
  },
103
  uint16: function uint16(props, propName, componentName) {
104
    if (!(props[propName] instanceof Uint16Array)) {
0 ignored issues
show
Complexity Best Practice introduced by
There is no return statement if !(props.propName instanceof Uint16Array) is false. Are you sure this is correct? If so, consider adding return; explicitly.

This check looks for functions where a return statement is found in some execution paths, but not in all.

Consider this little piece of code

function isBig(a) {
    if (a > 5000) {
        return "yes";
    }
}

console.log(isBig(5001)); //returns yes
console.log(isBig(42)); //returns undefined

The function isBig will only return a specific value when its parameter is bigger than 5000. In any other case, it will implicitly return undefined.

This behaviour may not be what you had intended. In any case, you can add a return undefined to the other execution path to make the return value explicit.

Loading history...
105
      return new Error('Invalid prop `' + propName + '` supplied to' + ' `' + componentName + '`. Expected a Uint16Array.');
106
    }
107
  },
108
  uint8: function uint8(props, propName, componentName) {
109
    if (!(props[propName] instanceof Uint8Array)) {
0 ignored issues
show
Complexity Best Practice introduced by
There is no return statement if !(props.propName instanceof Uint8Array) is false. Are you sure this is correct? If so, consider adding return; explicitly.

This check looks for functions where a return statement is found in some execution paths, but not in all.

Consider this little piece of code

function isBig(a) {
    if (a > 5000) {
        return "yes";
    }
}

console.log(isBig(5001)); //returns yes
console.log(isBig(42)); //returns undefined

The function isBig will only return a specific value when its parameter is bigger than 5000. In any other case, it will implicitly return undefined.

This behaviour may not be what you had intended. In any case, you can add a return undefined to the other execution path to make the return value explicit.

Loading history...
110
      return new Error('Invalid prop `' + propName + '` supplied to' + ' `' + componentName + '`. Expected a Uint8Array.');
111
    }
112
  },
113
  uint8clamped: function uint8clamped(props, propName, componentName) {
114
    if (!(props[propName] instanceof Uint8ClampedArray)) {
0 ignored issues
show
Complexity Best Practice introduced by
There is no return statement if !(props.propName instanceof Uint8ClampedArray) is false. Are you sure this is correct? If so, consider adding return; explicitly.

This check looks for functions where a return statement is found in some execution paths, but not in all.

Consider this little piece of code

function isBig(a) {
    if (a > 5000) {
        return "yes";
    }
}

console.log(isBig(5001)); //returns yes
console.log(isBig(42)); //returns undefined

The function isBig will only return a specific value when its parameter is bigger than 5000. In any other case, it will implicitly return undefined.

This behaviour may not be what you had intended. In any case, you can add a return undefined to the other execution path to make the return value explicit.

Loading history...
115
      return new Error('Invalid prop `' + propName + '` supplied to' + ' `' + componentName + '`. Expected a Uint8ClampedArray.');
116
    }
117
  },
118 View Code Duplication
  uint: function uint(props, propName, componentName) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
119
    if (!(props[propName] instanceof Uint32Array || props[propName] instanceof Uint16Array || props[propName] instanceof Uint8Array || props[propName] instanceof Uint8ClampedArray)) {
0 ignored issues
show
Complexity Best Practice introduced by
There is no return statement if !(props.propName instanc...ceof Uint8ClampedArray) is false. Are you sure this is correct? If so, consider adding return; explicitly.

This check looks for functions where a return statement is found in some execution paths, but not in all.

Consider this little piece of code

function isBig(a) {
    if (a > 5000) {
        return "yes";
    }
}

console.log(isBig(5001)); //returns yes
console.log(isBig(42)); //returns undefined

The function isBig will only return a specific value when its parameter is bigger than 5000. In any other case, it will implicitly return undefined.

This behaviour may not be what you had intended. In any case, you can add a return undefined to the other execution path to make the return value explicit.

Loading history...
120
      return new Error('Invalid prop `' + propName + '` supplied to' + ' `' + componentName + '`. Expected a Uint32Array, Uint16Array, Uint8Array, or Uint8ClampedArray.');
121
    }
122
  }
123
};
124
125
// EXTERNAL MODULE: /home/salim/GaelO-Dev/OHIF/Viewers/extensions/dicom-pdf/src/DicomPDFViewport.css
126
var src_DicomPDFViewport = __webpack_require__(1001);
0 ignored issues
show
Unused Code introduced by
The variable src_DicomPDFViewport seems to be never used. Consider removing it.
Loading history...
127
128
// EXTERNAL MODULE: /home/salim/GaelO-Dev/OHIF/Viewers/node_modules/pdfjs-dist/build/pdf.worker.entry.js
129
var pdf_worker_entry = __webpack_require__(1002);
130
var pdf_worker_entry_default = /*#__PURE__*/__webpack_require__.n(pdf_worker_entry);
131
132
// CONCATENATED MODULE: /home/salim/GaelO-Dev/OHIF/Viewers/extensions/dicom-pdf/src/DicomPDFViewport.js
133
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
0 ignored issues
show
Bug introduced by
The variable Symbol seems to be never declared. If this is a global, consider adding a /** global: Symbol */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
134
135
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
136
137
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
0 ignored issues
show
Bug introduced by
The variable source is changed as part of the for loop for example by arguments.i != null ? arguments.i: {} on line 137. Only the value of the last iteration will be visible in this function if it is called after the loop.
Loading history...
Best Practice introduced by
Comparing arguments.i to null using the != operator is not safe. Consider using !== instead.
Loading history...
138
139
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
140
141
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
142
143
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
144
145
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
146
147
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
148
149
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
150
151
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
152
153
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
0 ignored issues
show
Coding Style introduced by
Consider using undefined instead of void(0). It is equivalent and more straightforward to read.
Loading history...
154
155
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
156
157
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
158
159
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
160
161
162
163
164
165
166
167
168
169
pdf_default.a.GlobalWorkerOptions.workerSrc = pdf_worker_entry_default.a; // TODO: Should probably use dcmjs for this
170
171
var SOP_CLASS_UIDS = {
172
  ENCAPSULATED_PDF: '1.2.840.10008.5.1.4.1.1.104.1'
173
};
174
175
var DicomPDFViewport_DicomPDFViewport =
176
/*#__PURE__*/
177
function (_Component) {
178
  _inherits(DicomPDFViewport, _Component);
179
180
  function DicomPDFViewport(props) {
181
    var _this;
182
183
    _classCallCheck(this, DicomPDFViewport);
184
185
    _this = _possibleConstructorReturn(this, _getPrototypeOf(DicomPDFViewport).call(this, props));
186
187
    _defineProperty(_assertThisInitialized(_this), "updatePDFCanvas",
188
    /*#__PURE__*/
189
    _asyncToGenerator(
190
    /*#__PURE__*/
191
    regeneratorRuntime.mark(function _callee() {
0 ignored issues
show
Bug introduced by
The variable regeneratorRuntime seems to be never declared. If this is a global, consider adding a /** global: regeneratorRuntime */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
192
      var _this$state, pdf, scale, currentPageIndex, context, page, viewport, renderContext, textContent;
193
194
      return regeneratorRuntime.wrap(function _callee$(_context) {
0 ignored issues
show
Bug introduced by
The variable regeneratorRuntime seems to be never declared. If this is a global, consider adding a /** global: regeneratorRuntime */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
195
        while (1) {
196
          switch (_context.prev = _context.next) {
197
            case 0:
198
              _this$state = _this.state, pdf = _this$state.pdf, scale = _this$state.scale, currentPageIndex = _this$state.currentPageIndex;
0 ignored issues
show
Bug introduced by
The variable _this$state is changed as part of the while loop for example by _this.state on line 198. Only the value of the last iteration will be visible in this function if it is called after the loop.
Loading history...
Comprehensibility introduced by
Usage of the sequence operator is discouraged, since it may lead to obfuscated code.

The sequence or comma operator allows the inclusion of multiple expressions where only is permitted. The result of the sequence is the value of the last expression.

This operator is most often used in for statements.

Used in another places it can make code hard to read, especially when people do not realize it even exists as a seperate operator.

This check looks for usage of the sequence operator in locations where it is not necessary and could be replaced by a series of expressions or statements.

var a,b,c;

a = 1, b = 1,  c= 3;

could just as well be written as:

var a,b,c;

a = 1;
b = 1;
c = 3;

To learn more about the sequence operator, please refer to the MDN.

Loading history...
199
              context = _this.canvas.getContext('2d');
200
              _context.next = 4;
201
              return pdf.getPage(currentPageIndex);
0 ignored issues
show
Bug introduced by
The variable currentPageIndex is changed as part of the while loop for example by _this$state.currentPageIndex on line 198. Only the value of the last iteration will be visible in this function if it is called after the loop.
Loading history...
Bug introduced by
The variable pdf is changed as part of the while loop for example by _this$state.pdf on line 198. Only the value of the last iteration will be visible in this function if it is called after the loop.
Loading history...
202
203
            case 4:
204
              page = _context.sent;
205
              viewport = page.getViewport({
0 ignored issues
show
Bug introduced by
The variable page is changed as part of the while loop for example by _context.sent on line 204. Only the value of the last iteration will be visible in this function if it is called after the loop.
Loading history...
206
                scale: scale
207
              });
208
              _this.canvas.height = viewport.height;
0 ignored issues
show
Bug introduced by
The variable viewport is changed as part of the while loop for example by page.getViewport({Identi...ierNode(scale,false))}) on line 205. Only the value of the last iteration will be visible in this function if it is called after the loop.
Loading history...
209
              _this.canvas.width = viewport.width;
210
              renderContext = {
211
                canvasContext: context,
212
                viewport: viewport
213
              };
214
              _context.next = 11;
215
              return page.render(renderContext);
0 ignored issues
show
Bug introduced by
The variable renderContext is changed as part of the while loop for example by {IdentifierNode(canvasCo...rNode(viewport,false))} on line 210. Only the value of the last iteration will be visible in this function if it is called after the loop.
Loading history...
216
217
            case 11:
218
              _context.next = 13;
219
              return page.getTextContent();
220
221
            case 13:
222
              textContent = _context.sent;
223
              _this.textLayer.innerHTML = '';
224
              _this.textLayer.style.height = viewport.height + 'px';
225
              _this.textLayer.style.width = viewport.width + 'px';
226
              pdf_default.a.renderTextLayer({
227
                textContent: textContent,
0 ignored issues
show
Bug introduced by
The variable textContent is changed as part of the while loop for example by _context.sent on line 222. Only the value of the last iteration will be visible in this function if it is called after the loop.
Loading history...
228
                container: _this.textLayer,
229
                viewport: viewport,
230
                textDivs: []
231
              });
232
233
            case 18:
234
            case "end":
235
              return _context.stop();
236
          }
237
        }
0 ignored issues
show
Best Practice introduced by
There is no return statement in this branch, but you do return something in other branches. Did you maybe miss it? If you do not want to return anything, consider adding return undefined; explicitly.
Loading history...
238
      }, _callee);
239
    })));
240
241
    _defineProperty(_assertThisInitialized(_this), "getPDFFileUrl", function (dataSet, byteArray) {
242
      var pdfByteArray = byteArray;
243
244
      if (dataSet) {
245
        var SOPClassUID = dataSet.string('x00080016');
246
247
        if (SOPClassUID !== SOP_CLASS_UIDS.ENCAPSULATED_PDF) {
248
          throw new Error('This is not a DICOM-encapsulated PDF');
249
        }
250
251
        var fileTag = dataSet.elements.x00420011;
252
        var offset = fileTag.dataOffset;
253
        var remainder = offset + fileTag.length;
254
        pdfByteArray = dataSet.byteArray.slice(offset, remainder);
255
      }
256
257
      var PDF = new Blob([pdfByteArray], {
0 ignored issues
show
Bug introduced by
The variable Blob seems to be never declared. If this is a global, consider adding a /** global: Blob */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
258
        type: 'application/pdf'
259
      });
260
      var fileURL = URL.createObjectURL(PDF);
0 ignored issues
show
Bug introduced by
The variable URL seems to be never declared. If this is a global, consider adding a /** global: URL */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
261
      return fileURL;
262
    });
263
264
    _defineProperty(_assertThisInitialized(_this), "onPageChange",
265
    /*#__PURE__*/
266
    function () {
267
      var _ref2 = _asyncToGenerator(
268
      /*#__PURE__*/
269
      regeneratorRuntime.mark(function _callee2(event) {
0 ignored issues
show
Bug introduced by
The variable regeneratorRuntime seems to be never declared. If this is a global, consider adding a /** global: regeneratorRuntime */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
270
        var _this$state2, currentPageIndex, pdf, newPageIndex, action;
271
272
        return regeneratorRuntime.wrap(function _callee2$(_context2) {
0 ignored issues
show
Bug introduced by
The variable regeneratorRuntime seems to be never declared. If this is a global, consider adding a /** global: regeneratorRuntime */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
273
          while (1) {
274
            switch (_context2.prev = _context2.next) {
275
              case 0:
276
                _this$state2 = _this.state, currentPageIndex = _this$state2.currentPageIndex, pdf = _this$state2.pdf;
0 ignored issues
show
Comprehensibility introduced by
Usage of the sequence operator is discouraged, since it may lead to obfuscated code.

The sequence or comma operator allows the inclusion of multiple expressions where only is permitted. The result of the sequence is the value of the last expression.

This operator is most often used in for statements.

Used in another places it can make code hard to read, especially when people do not realize it even exists as a seperate operator.

This check looks for usage of the sequence operator in locations where it is not necessary and could be replaced by a series of expressions or statements.

var a,b,c;

a = 1, b = 1,  c= 3;

could just as well be written as:

var a,b,c;

a = 1;
b = 1;
c = 3;

To learn more about the sequence operator, please refer to the MDN.

Loading history...
Bug introduced by
The variable _this$state2 is changed as part of the while loop for example by _this.state on line 276. Only the value of the last iteration will be visible in this function if it is called after the loop.
Loading history...
277
                newPageIndex = currentPageIndex;
0 ignored issues
show
Bug introduced by
The variable currentPageIndex is changed as part of the while loop for example by _this$state2.currentPageIndex on line 276. Only the value of the last iteration will be visible in this function if it is called after the loop.
Loading history...
278
                action = event.target.getAttribute('data-pager');
279
280
                if (!(action === 'prev')) {
0 ignored issues
show
Bug introduced by
The variable action is changed as part of the while loop for example by event.target.getAttribute("data-pager") on line 278. Only the value of the last iteration will be visible in this function if it is called after the loop.
Loading history...
281
                  _context2.next = 8;
282
                  break;
283
                }
284
285
                if (!(currentPageIndex === 1)) {
286
                  _context2.next = 6;
287
                  break;
288
                }
289
290
                return _context2.abrupt("return");
291
292
              case 6:
293
                newPageIndex -= 1;
0 ignored issues
show
Comprehensibility Bug introduced by
The variable newPageIndex does not seem to be initialized in case the while loop on line 273 is not entered. Are you sure this can never be the case?
Loading history...
294
295
                if (currentPageIndex < 0) {
0 ignored issues
show
Comprehensibility Bug introduced by
The variable currentPageIndex does not seem to be initialized in case the while loop on line 273 is not entered. Are you sure this can never be the case?
Loading history...
296
                  newPageIndex = 0;
0 ignored issues
show
introduced by
This node falls through to the next case due to this statement. Please add a comment either directly below this line or between the cases to explain.
Loading history...
297
                }
0 ignored issues
show
introduced by
This node falls through to the next case due to this statement. Please add a comment either directly below this line or between the cases to explain.
Loading history...
298
299
              case 8:
300
                if (!(action === 'next')) {
0 ignored issues
show
Comprehensibility Bug introduced by
The variable action does not seem to be initialized in case the while loop on line 273 is not entered. Are you sure this can never be the case?
Loading history...
301
                  _context2.next = 13;
302
                  break;
303
                }
304
305
                if (!(currentPageIndex === pdf.numPages - 1)) {
0 ignored issues
show
Comprehensibility Bug introduced by
The variable pdf does not seem to be initialized in case the while loop on line 273 is not entered. Are you sure this can never be the case?
Loading history...
306
                  _context2.next = 11;
307
                  break;
308
                }
309
310
                return _context2.abrupt("return");
311
312
              case 11:
313
                newPageIndex += 1;
314
315
                if (currentPageIndex > pdf.numPages - 1) {
316
                  newPageIndex = pdf.numPages - 1;
0 ignored issues
show
introduced by
This node falls through to the next case due to this statement. Please add a comment either directly below this line or between the cases to explain.
Loading history...
317
                }
0 ignored issues
show
introduced by
This node falls through to the next case due to this statement. Please add a comment either directly below this line or between the cases to explain.
Loading history...
318
319
              case 13:
320
                _this.setState(function (state) {
321
                  return _objectSpread({}, state, {
322
                    currentPageIndex: newPageIndex
0 ignored issues
show
Comprehensibility Bug introduced by
The variable newPageIndex does not seem to be initialized in case the while loop on line 273 is not entered. Are you sure this can never be the case?
Loading history...
323
                  });
324
                });
325
326
              case 14:
327
              case "end":
328
                return _context2.stop();
329
            }
330
          }
0 ignored issues
show
Best Practice introduced by
There is no return statement in this branch, but you do return something in other branches. Did you maybe miss it? If you do not want to return anything, consider adding return undefined; explicitly.
Loading history...
331
        }, _callee2);
332
      }));
333
334
      return function (_x) {
0 ignored issues
show
Unused Code introduced by
The parameter _x is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
335
        return _ref2.apply(this, arguments);
336
      };
337
    }());
338
339
    _defineProperty(_assertThisInitialized(_this), "onZoomChange", function () {
340
      var newZoomValue = _this.state.scale;
341
      var action = event.target.getAttribute('data-pager');
0 ignored issues
show
Bug introduced by
The variable event seems to be never declared. If this is a global, consider adding a /** global: event */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
342
343
      if (action === '+') {
344
        newZoomValue += 0.25;
345
      }
346
347
      if (action === '-') {
348
        newZoomValue -= 0.25;
349
      }
350
351
      _this.setState(function (state) {
352
        return _objectSpread({}, state, {
353
          scale: newZoomValue
354
        });
355
      });
356
    });
357
358
    _defineProperty(_assertThisInitialized(_this), "parseByteArray", function (byteArray) {
359
      var options = {
360
        untilTag: ''
361
      };
362
      var dataSet;
363
364
      try {
365
        dataSet = dicomParser_min_default.a.parseDicom(byteArray, options);
366
      } catch (error) {
367
        _this.setState(function (state) {
368
          return _objectSpread({}, state, {
369
            error: error
370
          });
371
        });
372
      }
373
374
      return dataSet;
375
    });
376
377
    _defineProperty(_assertThisInitialized(_this), "setViewportActiveHandler", function () {
378
      var _this$props = _this.props,
379
          setViewportActive = _this$props.setViewportActive,
380
          viewportIndex = _this$props.viewportIndex,
381
          activeViewportIndex = _this$props.activeViewportIndex;
382
383
      if (viewportIndex !== activeViewportIndex) {
384
        setViewportActive(viewportIndex);
385
      }
386
    });
387
388
    _defineProperty(_assertThisInitialized(_this), "downloadPDFCanvas", function () {
389
      var fileURL = _this.state.fileURL;
390
      var a = document.createElement('a');
391
      a.href = fileURL;
392
      a.download = fileURL.substr(fileURL.lastIndexOf('/') + 1);
393
      document.body.appendChild(a);
394
      a.click();
395
      document.body.removeChild(a);
396
    });
397
398
    _this.state = {
399
      fileURL: null,
400
      error: null,
401
      currentPageIndex: 1,
402
      pdf: null,
403
      scale: 1
404
    };
405
    _this.canvas = Object(react["createRef"])();
406
    _this.textLayer = Object(react["createRef"])();
407
    return _this;
408
  }
409
410
  _createClass(DicomPDFViewport, [{
411
    key: "componentDidMount",
412
    value: function () {
413
      var _componentDidMount = _asyncToGenerator(
414
      /*#__PURE__*/
415
      regeneratorRuntime.mark(function _callee3() {
0 ignored issues
show
Bug introduced by
The variable regeneratorRuntime seems to be never declared. If this is a global, consider adding a /** global: regeneratorRuntime */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
416
        var _this2 = this;
417
418
        var dataSet, fileURL, pdf;
419
        return regeneratorRuntime.wrap(function _callee3$(_context3) {
0 ignored issues
show
Bug introduced by
The variable regeneratorRuntime seems to be never declared. If this is a global, consider adding a /** global: regeneratorRuntime */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
420
          while (1) {
421
            switch (_context3.prev = _context3.next) {
422
              case 0:
423
                dataSet = this.parseByteArray(this.props.byteArray);
424
                fileURL = this.getPDFFileUrl(dataSet, this.props.byteArray);
0 ignored issues
show
Bug introduced by
The variable dataSet is changed as part of the while loop for example by this.parseByteArray(this.props.byteArray) on line 423. Only the value of the last iteration will be visible in this function if it is called after the loop.
Loading history...
425
                this.setState(function (state) {
426
                  return _objectSpread({}, state, {
427
                    fileURL: fileURL
0 ignored issues
show
Bug introduced by
The variable fileURL is changed as part of the while loop for example by this.getPDFFileUrl(dataSet, this.props.byteArray) on line 424. Only the value of the last iteration will be visible in this function if it is called after the loop.
Loading history...
428
                  });
429
                });
430
431
                if (this.props.useNative) {
432
                  _context3.next = 8;
433
                  break;
434
                }
435
436
                _context3.next = 6;
437
                return pdf_default.a.getDocument(fileURL).promise;
0 ignored issues
show
Bug introduced by
The variable fileURL is changed as part of the while loop for example by this.getPDFFileUrl(dataSet, this.props.byteArray) on line 424. Only the value of the last iteration will be visible in this function if it is called after the loop.
Loading history...
438
439
              case 6:
440
                pdf = _context3.sent;
441
                this.setState(function (state) {
442
                  return _objectSpread({}, state, {
443
                    pdf: pdf
0 ignored issues
show
Bug introduced by
The variable pdf is changed as part of the while loop for example by _context3.sent on line 440. Only the value of the last iteration will be visible in this function if it is called after the loop.
Loading history...
444
                  });
445
                }, function () {
446
                  return _this2.updatePDFCanvas();
447
                });
448
449
              case 8:
450
              case "end":
451
                return _context3.stop();
452
            }
453
          }
0 ignored issues
show
Best Practice introduced by
There is no return statement in this branch, but you do return something in other branches. Did you maybe miss it? If you do not want to return anything, consider adding return undefined; explicitly.
Loading history...
454
        }, _callee3, this);
455
      }));
456
457
      function componentDidMount() {
458
        return _componentDidMount.apply(this, arguments);
459
      }
460
461
      return componentDidMount;
462
    }()
463
  }, {
464
    key: "componentDidUpdate",
465
    value: function componentDidUpdate(prevProps, prevState) {
466
      var _this$state3 = this.state,
467
          currentPageIndex = _this$state3.currentPageIndex,
468
          scale = _this$state3.scale;
469
      var newValidScale = prevState.scale !== scale && scale > 0;
470
      var newValidPageNumber = prevState.currentPageIndex !== currentPageIndex && currentPageIndex > 0;
471
472
      if (newValidScale || newValidPageNumber) {
473
        this.updatePDFCanvas();
474
      }
475
    }
476
  }, {
477
    key: "render",
478
    value: function render() {
479
      var _this3 = this;
480
481
      var _this$state4 = this.state,
482
          fileURL = _this$state4.fileURL,
483
          pdf = _this$state4.pdf,
484
          error = _this$state4.error;
485
      return react_default.a.createElement("div", {
486
        className: 'DicomPDFViewport',
487
        onClick: this.setViewportActiveHandler,
488
        onScroll: this.setViewportActiveHandler,
489
        style: {
490
          width: '100%',
491
          height: '100%'
492
        }
493
      }, !this.props.useNative ? react_default.a.createElement(react_default.a.Fragment, null, react_default.a.createElement("div", {
494
        id: "toolbar"
495
      }, react_default.a.createElement("div", {
496
        id: "pager"
497
      }, pdf && pdf.numPages > 1 && react_default.a.createElement(react_default.a.Fragment, null, react_default.a.createElement("button", {
498
        "data-pager": "prev",
499
        onClick: this.onPageChange
500
      }, "<"), react_default.a.createElement("button", {
501
        "data-pager": "next",
502
        onClick: this.onPageChange
503
      }, ">")), react_default.a.createElement("button", {
504
        "data-pager": "-",
505
        onClick: this.onZoomChange
506
      }, "-"), react_default.a.createElement("button", {
507
        "data-pager": "+",
508
        onClick: this.onZoomChange
509
      }, "+"), react_default.a.createElement("button", {
510
        onClick: this.downloadPDFCanvas
511
      }, "Download"))), react_default.a.createElement("div", {
512
        id: "canvas"
513
      }, react_default.a.createElement("div", {
514
        id: "pdf-canvas-container"
515
      }, react_default.a.createElement("canvas", {
516
        id: "pdf-canvas",
517
        ref: function ref(canvas) {
518
          return _this3.canvas = canvas;
519
        }
520
      }), react_default.a.createElement("div", {
521
        id: "text-layer",
522
        ref: function ref(textLayer) {
523
          return _this3.textLayer = textLayer;
524
        }
525
      })))) : react_default.a.createElement("object", {
526
        "aria-label": "PDF Viewer",
527
        data: fileURL,
528
        type: "application/pdf",
529
        width: "100%",
530
        height: "100%"
531
      }), error && react_default.a.createElement("h2", null, JSON.stringify(error)));
532
    }
533
  }]);
534
535
  return DicomPDFViewport;
536
}(react["Component"]);
537
538
_defineProperty(DicomPDFViewport_DicomPDFViewport, "propTypes", {
539
  byteArray: TypedArrayProp.uint8,
540
  useNative: prop_types_default.a.bool,
541
  viewportData: prop_types_default.a.object,
542
  activeViewportIndex: prop_types_default.a.number,
543
  setViewportActive: prop_types_default.a.func,
544
  viewportIndex: prop_types_default.a.number
545
});
546
547
_defineProperty(DicomPDFViewport_DicomPDFViewport, "defaultProps", {
548
  useNative: false
549
});
550
551
/* harmony default export */ var dicom_pdf_src_DicomPDFViewport = (DicomPDFViewport_DicomPDFViewport);
552
// CONCATENATED MODULE: /home/salim/GaelO-Dev/OHIF/Viewers/extensions/dicom-pdf/src/OHIFDicomPDFViewport.js
553
function OHIFDicomPDFViewport_typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { OHIFDicomPDFViewport_typeof = function _typeof(obj) { return typeof obj; }; } else { OHIFDicomPDFViewport_typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return OHIFDicomPDFViewport_typeof(obj); }
0 ignored issues
show
Bug introduced by
The variable Symbol seems to be never declared. If this is a global, consider adding a /** global: Symbol */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
Comprehensibility introduced by
It seems like you are trying to overwrite a function name here. OHIFDicomPDFViewport_typeof is already defined in line 553 as a function. While this will work, it can be very confusing.
Loading history...
554
555
function OHIFDicomPDFViewport_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
556
557
function OHIFDicomPDFViewport_defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
558
559
function OHIFDicomPDFViewport_createClass(Constructor, protoProps, staticProps) { if (protoProps) OHIFDicomPDFViewport_defineProperties(Constructor.prototype, protoProps); if (staticProps) OHIFDicomPDFViewport_defineProperties(Constructor, staticProps); return Constructor; }
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
560
561
function OHIFDicomPDFViewport_possibleConstructorReturn(self, call) { if (call && (OHIFDicomPDFViewport_typeof(call) === "object" || typeof call === "function")) { return call; } return OHIFDicomPDFViewport_assertThisInitialized(self); }
562
563
function OHIFDicomPDFViewport_getPrototypeOf(o) { OHIFDicomPDFViewport_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return OHIFDicomPDFViewport_getPrototypeOf(o); }
0 ignored issues
show
Comprehensibility introduced by
It seems like you are trying to overwrite a function name here. OHIFDicomPDFViewport_getPrototypeOf is already defined in line 563 as a function. While this will work, it can be very confusing.
Loading history...
564
565
function OHIFDicomPDFViewport_assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
0 ignored issues
show
Coding Style introduced by
Consider using undefined instead of void(0). It is equivalent and more straightforward to read.
Loading history...
566
567
function OHIFDicomPDFViewport_inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) OHIFDicomPDFViewport_setPrototypeOf(subClass, superClass); }
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
568
569
function OHIFDicomPDFViewport_setPrototypeOf(o, p) { OHIFDicomPDFViewport_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return OHIFDicomPDFViewport_setPrototypeOf(o, p); }
0 ignored issues
show
Comprehensibility introduced by
It seems like you are trying to overwrite a function name here. OHIFDicomPDFViewport_setPrototypeOf is already defined in line 569 as a function. While this will work, it can be very confusing.
Loading history...
570
571
function OHIFDicomPDFViewport_defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
572
573
574
575
576
577
578
var DicomLoaderService = src["a" /* default */].utils.DicomLoaderService;
579
580
var OHIFDicomPDFViewport_OHIFDicomPDFViewport =
581
/*#__PURE__*/
582
function (_Component) {
583
  OHIFDicomPDFViewport_inherits(OHIFDicomPDFViewport, _Component);
584
585
  function OHIFDicomPDFViewport() {
586
    var _getPrototypeOf2;
587
588
    var _this;
589
590
    OHIFDicomPDFViewport_classCallCheck(this, OHIFDicomPDFViewport);
591
592
    for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
0 ignored issues
show
Coding Style Best Practice introduced by
Using the Array constructor is generally discouraged. Consider using an array literal instead.
Loading history...
593
      args[_key] = arguments[_key];
594
    }
595
596
    _this = OHIFDicomPDFViewport_possibleConstructorReturn(this, (_getPrototypeOf2 = OHIFDicomPDFViewport_getPrototypeOf(OHIFDicomPDFViewport)).call.apply(_getPrototypeOf2, [this].concat(args)));
597
598
    OHIFDicomPDFViewport_defineProperty(OHIFDicomPDFViewport_assertThisInitialized(_this), "state", {
599
      byteArray: null,
600
      error: null
601
    });
602
603
    return _this;
604
  }
605
606
  OHIFDicomPDFViewport_createClass(OHIFDicomPDFViewport, [{
607
    key: "componentDidMount",
608
    value: function componentDidMount() {
609
      var _this2 = this;
610
611
      var _this$props$viewportD = this.props.viewportData,
612
          displaySet = _this$props$viewportD.displaySet,
613
          studies = _this$props$viewportD.studies;
614
      DicomLoaderService.findDicomDataPromise(displaySet, studies).then(function (data) {
615
        return _this2.setState({
616
          byteArray: new Uint8Array(data)
617
        });
618
      }, function (error) {
619
        _this2.setState({
620
          error: error
621
        });
622
623
        throw new Error(error);
624
      });
625
    }
626
  }, {
627
    key: "render",
628
    value: function render() {
629
      var _this$props = this.props,
630
          setViewportActive = _this$props.setViewportActive,
631
          viewportIndex = _this$props.viewportIndex,
632
          activeViewportIndex = _this$props.activeViewportIndex;
633
      var _this$state = this.state,
634
          byteArray = _this$state.byteArray,
635
          error = _this$state.error;
636
      var id = OHIFDicomPDFViewport.id,
637
          init = OHIFDicomPDFViewport.init,
638
          destroy = OHIFDicomPDFViewport.destroy;
639
      var pluginProps = {
640
        id: id,
641
        init: init,
642
        destroy: destroy
643
      };
644
      return react_default.a.createElement(src_OHIFComponentPlugin, pluginProps, byteArray && react_default.a.createElement(dicom_pdf_src_DicomPDFViewport, {
645
        byteArray: byteArray,
646
        setViewportActive: setViewportActive,
647
        viewportIndex: viewportIndex,
648
        activeViewportIndex: activeViewportIndex
649
      }), error && react_default.a.createElement("h2", null, JSON.stringify(error)));
650
    }
651
  }], [{
652
    key: "init",
653
    value: function init() {
654
      console.log('DicomPDFViewport init()');
0 ignored issues
show
Debugging Code introduced by
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
655
    }
656
  }, {
657
    key: "destroy",
658
    value: function destroy() {
659
      console.log('DicomPDFViewport destroy()');
0 ignored issues
show
Debugging Code introduced by
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
660
    }
661
  }]);
662
663
  return OHIFDicomPDFViewport;
664
}(react["Component"]);
665
666
OHIFDicomPDFViewport_defineProperty(OHIFDicomPDFViewport_OHIFDicomPDFViewport, "propTypes", {
667
  studies: prop_types_default.a.object,
668
  displaySet: prop_types_default.a.object,
669
  viewportIndex: prop_types_default.a.number,
670
  viewportData: prop_types_default.a.object,
671
  activeViewportIndex: prop_types_default.a.number,
672
  setViewportActive: prop_types_default.a.func
673
});
674
675
OHIFDicomPDFViewport_defineProperty(OHIFDicomPDFViewport_OHIFDicomPDFViewport, "id", 'DicomPDFViewportPDF');
676
677
/* harmony default export */ var src_OHIFDicomPDFViewport = (OHIFDicomPDFViewport_OHIFDicomPDFViewport);
678
// CONCATENATED MODULE: /home/salim/GaelO-Dev/OHIF/Viewers/extensions/dicom-pdf/src/ConnectedOHIFDicomPDFViewer.js
679
680
681
682
var _setViewportActive = src["a" /* default */].redux.actions.setViewportActive;
683
684
var mapStateToProps = function mapStateToProps(state, ownProps) {
0 ignored issues
show
Unused Code introduced by
The parameter ownProps is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
685
  var activeViewportIndex = state.viewports.activeViewportIndex;
686
  return {
687
    activeViewportIndex: activeViewportIndex
688
  };
689
};
690
691
var mapDispatchToProps = function mapDispatchToProps(dispatch, ownProps) {
692
  var viewportIndex = ownProps.viewportIndex;
693
  return {
694
    setViewportActive: function setViewportActive() {
695
      dispatch(_setViewportActive(viewportIndex));
696
    }
697
  };
698
};
699
700
var ConnectedOHIFDicomPDFViewer = Object(es["b" /* connect */])(mapStateToProps, mapDispatchToProps)(src_OHIFDicomPDFViewport);
701
/* harmony default export */ var src_ConnectedOHIFDicomPDFViewer = __webpack_exports__["default"] = (ConnectedOHIFDicomPDFViewer);
0 ignored issues
show
Unused Code introduced by
The variable src_ConnectedOHIFDicomPDFViewer seems to be never used. Consider removing it.
Loading history...
702
703
/***/ }),
704
705
/***/ 994:
706
/***/ (function(module, exports) {
0 ignored issues
show
Unused Code introduced by
The parameter module is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
Unused Code introduced by
The parameter exports is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
707
708
/* (ignored) */
709
710
/***/ }),
711
712
/***/ 995:
713
/***/ (function(module, exports) {
0 ignored issues
show
Unused Code introduced by
The parameter exports is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
Unused Code introduced by
The parameter module is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
714
715
/* (ignored) */
716
717
/***/ }),
718
719
/***/ 996:
720
/***/ (function(module, exports) {
0 ignored issues
show
Unused Code introduced by
The parameter module is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
Unused Code introduced by
The parameter exports is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
721
722
/* (ignored) */
723
724
/***/ }),
725
726
/***/ 997:
727
/***/ (function(module, exports) {
0 ignored issues
show
Unused Code introduced by
The parameter exports is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
Unused Code introduced by
The parameter module is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
728
729
/* (ignored) */
730
731
/***/ })
732
733
}]);