| Total Complexity | 166 |
| Complexity/F | 1.71 |
| Lines of Code | 733 |
| Function Count | 97 |
| Duplicated Lines | 12 |
| Ratio | 1.64 % |
| Changes | 0 | ||
Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
Complex classes like src/ohif/12.bundle.2984165d3050cb4e5079.js 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__) { |
||
| 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) { |
|
| 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)) { |
||
| 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)) { |
||
| 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)) { |
||
| 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)) { |
||
| 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)) { |
||
| 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)) { |
||
| 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)) { |
||
| 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)) { |
||
| 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)) { |
||
| 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)) { |
||
| 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)) { |
||
| 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)) { |
||
| 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) { |
|
| 119 | if (!(props[propName] instanceof Uint32Array || props[propName] instanceof Uint16Array || props[propName] instanceof Uint8Array || props[propName] instanceof Uint8ClampedArray)) { |
||
| 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); |
||
| 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); } |
||
| 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; } |
||
| 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; } |
||
| 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); } } |
||
| 146 | |||
| 147 | function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } |
||
| 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; } |
||
| 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); } |
||
| 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() { |
||
| 192 | var _this$state, pdf, scale, currentPageIndex, context, page, viewport, renderContext, textContent; |
||
| 193 | |||
| 194 | return regeneratorRuntime.wrap(function _callee$(_context) { |
||
| 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; |
||
| 199 | context = _this.canvas.getContext('2d'); |
||
| 200 | _context.next = 4; |
||
| 201 | return pdf.getPage(currentPageIndex); |
||
| 202 | |||
| 203 | case 4: |
||
| 204 | page = _context.sent; |
||
| 205 | viewport = page.getViewport({ |
||
| 206 | scale: scale |
||
| 207 | }); |
||
| 208 | _this.canvas.height = viewport.height; |
||
| 209 | _this.canvas.width = viewport.width; |
||
| 210 | renderContext = { |
||
| 211 | canvasContext: context, |
||
| 212 | viewport: viewport |
||
| 213 | }; |
||
| 214 | _context.next = 11; |
||
| 215 | return page.render(renderContext); |
||
| 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, |
||
| 228 | container: _this.textLayer, |
||
| 229 | viewport: viewport, |
||
| 230 | textDivs: [] |
||
| 231 | }); |
||
| 232 | |||
| 233 | case 18: |
||
| 234 | case "end": |
||
| 235 | return _context.stop(); |
||
| 236 | } |
||
| 237 | } |
||
| 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], { |
||
| 258 | type: 'application/pdf' |
||
| 259 | }); |
||
| 260 | var fileURL = URL.createObjectURL(PDF); |
||
| 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) { |
||
| 270 | var _this$state2, currentPageIndex, pdf, newPageIndex, action; |
||
| 271 | |||
| 272 | return regeneratorRuntime.wrap(function _callee2$(_context2) { |
||
| 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; |
||
| 277 | newPageIndex = currentPageIndex; |
||
| 278 | action = event.target.getAttribute('data-pager'); |
||
| 279 | |||
| 280 | if (!(action === 'prev')) { |
||
| 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; |
||
| 294 | |||
| 295 | if (currentPageIndex < 0) { |
||
| 296 | newPageIndex = 0; |
||
| 297 | } |
||
| 298 | |||
| 299 | case 8: |
||
| 300 | if (!(action === 'next')) { |
||
| 301 | _context2.next = 13; |
||
| 302 | break; |
||
| 303 | } |
||
| 304 | |||
| 305 | if (!(currentPageIndex === pdf.numPages - 1)) { |
||
| 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; |
||
| 317 | } |
||
| 318 | |||
| 319 | case 13: |
||
| 320 | _this.setState(function (state) { |
||
| 321 | return _objectSpread({}, state, { |
||
| 322 | currentPageIndex: newPageIndex |
||
| 323 | }); |
||
| 324 | }); |
||
| 325 | |||
| 326 | case 14: |
||
| 327 | case "end": |
||
| 328 | return _context2.stop(); |
||
| 329 | } |
||
| 330 | } |
||
| 331 | }, _callee2); |
||
| 332 | })); |
||
| 333 | |||
| 334 | return function (_x) { |
||
| 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'); |
||
| 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() { |
||
| 416 | var _this2 = this; |
||
| 417 | |||
| 418 | var dataSet, fileURL, pdf; |
||
| 419 | return regeneratorRuntime.wrap(function _callee3$(_context3) { |
||
| 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); |
||
| 425 | this.setState(function (state) { |
||
| 426 | return _objectSpread({}, state, { |
||
| 427 | fileURL: fileURL |
||
| 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; |
||
| 438 | |||
| 439 | case 6: |
||
| 440 | pdf = _context3.sent; |
||
| 441 | this.setState(function (state) { |
||
| 442 | return _objectSpread({}, state, { |
||
| 443 | pdf: pdf |
||
| 444 | }); |
||
| 445 | }, function () { |
||
| 446 | return _this2.updatePDFCanvas(); |
||
| 447 | }); |
||
| 448 | |||
| 449 | case 8: |
||
| 450 | case "end": |
||
| 451 | return _context3.stop(); |
||
| 452 | } |
||
| 453 | } |
||
| 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); } |
||
| 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); } } |
||
| 558 | |||
| 559 | function OHIFDicomPDFViewport_createClass(Constructor, protoProps, staticProps) { if (protoProps) OHIFDicomPDFViewport_defineProperties(Constructor.prototype, protoProps); if (staticProps) OHIFDicomPDFViewport_defineProperties(Constructor, staticProps); return Constructor; } |
||
| 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); } |
||
| 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; } |
||
| 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); } |
||
| 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); } |
||
| 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++) { |
||
| 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()'); |
||
| 655 | } |
||
| 656 | }, { |
||
| 657 | key: "destroy", |
||
| 658 | value: function destroy() { |
||
| 659 | console.log('DicomPDFViewport destroy()'); |
||
| 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) { |
||
| 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); |
||
| 702 | |||
| 703 | /***/ }), |
||
| 704 | |||
| 705 | /***/ 994: |
||
| 706 | /***/ (function(module, exports) { |
||
| 707 | |||
| 708 | /* (ignored) */ |
||
| 709 | |||
| 710 | /***/ }), |
||
| 711 | |||
| 712 | /***/ 995: |
||
| 713 | /***/ (function(module, exports) { |
||
| 714 | |||
| 715 | /* (ignored) */ |
||
| 716 | |||
| 717 | /***/ }), |
||
| 718 | |||
| 719 | /***/ 996: |
||
| 720 | /***/ (function(module, exports) { |
||
| 721 | |||
| 722 | /* (ignored) */ |
||
| 723 | |||
| 724 | /***/ }), |
||
| 725 | |||
| 726 | /***/ 997: |
||
| 727 | /***/ (function(module, exports) { |
||
| 728 | |||
| 729 | /* (ignored) */ |
||
| 730 | |||
| 731 | /***/ }) |
||
| 732 | |||
| 733 | }]); |
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.