diff --git a/.webpack/rules/stylusToJavaScript.js b/.webpack/rules/stylusToJavaScript.js new file mode 100644 index 00000000000..1d83f95281e --- /dev/null +++ b/.webpack/rules/stylusToJavaScript.js @@ -0,0 +1,10 @@ +const stylusToJavaScript = { + test: /\.styl$/, + use: [ + { loader: 'style-loader' }, // 3. Style nodes from JS Strings + { loader: 'css-loader' }, // 2. CSS to CommonJS + { loader: 'stylus-loader' }, // 1. Stylus to CSS + ], +}; + +module.exports = stylusToJavaScript; diff --git a/.webpack/webpack.base.js b/.webpack/webpack.base.js index 004c73ece8e..6efedd0d2cd 100644 --- a/.webpack/webpack.base.js +++ b/.webpack/webpack.base.js @@ -18,6 +18,7 @@ const loadShadersRule = require('./rules/loadShaders.js'); const loadWebWorkersRule = require('./rules/loadWebWorkers.js'); const transpileJavaScriptRule = require('./rules/transpileJavaScript.js'); const cssToJavaScript = require('./rules/cssToJavaScript.js'); +const stylusToJavaScript = require('./rules/stylusToJavaScript.js'); // ~~ ENV VARS const NODE_ENV = process.env.NODE_ENV; @@ -112,6 +113,9 @@ module.exports = (env, argv, { SRC_DIR, ENTRY }) => { }, }, cssToJavaScript, + // Note: Only uncomment the following if you are using the old style of stylus in v2 + // Also you need to uncomment this platform/app/.webpack/rules/extractStyleChunks.js + // stylusToJavaScript, { test: /\.wasm/, type: 'asset/resource', diff --git a/extensions/cornerstone/src/services/SegmentationService/SegmentationService.ts b/extensions/cornerstone/src/services/SegmentationService/SegmentationService.ts index 50e2d2c3c16..eda99b7b2f4 100644 --- a/extensions/cornerstone/src/services/SegmentationService/SegmentationService.ts +++ b/extensions/cornerstone/src/services/SegmentationService/SegmentationService.ts @@ -189,7 +189,7 @@ class SegmentationService extends PubSubService { ); } - if (active !== undefined) { + if (active === true) { this._setActiveSegment(segmentationId, segmentIndex, suppressEvents); } @@ -399,6 +399,23 @@ class SegmentationService extends PubSubService { return segmentations && segmentations.map(m => this.segmentations[Object.keys(m)[0]]); } + public getActiveSegmentation(): Segmentation { + const segmentations = this.getSegmentations(); + + return segmentations.find(segmentation => segmentation.isActive); + } + + public getActiveSegment() { + const activeSegmentation = this.getActiveSegmentation(); + const { activeSegmentIndex, segments } = activeSegmentation; + + if (activeSegmentIndex === null) { + return; + } + + return segments[activeSegmentIndex]; + } + /** * Get specific segmentation by its id. * diff --git a/extensions/cornerstone/src/utils/stackSync/toggleStackImageSync.ts b/extensions/cornerstone/src/utils/stackSync/toggleStackImageSync.ts index 65ce12ea8ec..d18768f38b4 100644 --- a/extensions/cornerstone/src/utils/stackSync/toggleStackImageSync.ts +++ b/extensions/cornerstone/src/utils/stackSync/toggleStackImageSync.ts @@ -12,7 +12,8 @@ export default function toggleStackImageSync({ const { syncGroupService, viewportGridService, displaySetService, cornerstoneViewportService } = servicesManager.services; - const viewports = providedViewports || getReconstructableStackViewports(viewportGridService, displaySetService); + const viewports = + providedViewports || getReconstructableStackViewports(viewportGridService, displaySetService); // create synchronization group and add the viewports to it. viewports.forEach(gridViewport => { @@ -46,7 +47,7 @@ function disableSync(syncName, servicesManager) { syncName ); }); -}; +} /** * Gets the consistent spacing stack viewport types, which are the ones which @@ -77,4 +78,4 @@ function getReconstructableStackViewports(viewportGridService, displaySetService } }); return viewports; -}; +} diff --git a/modes/longitudinal/src/index.js b/modes/longitudinal/src/index.js index c12219c274d..25397a2cf74 100644 --- a/modes/longitudinal/src/index.js +++ b/modes/longitudinal/src/index.js @@ -40,7 +40,7 @@ const dicomSeg = { panel: '@ohif/extension-cornerstone-dicom-seg.panelModule.panelSegmentation', }; -const dicomRt = { +const dicomRT = { viewport: '@ohif/extension-cornerstone-dicom-rt.viewportModule.dicom-rt', sopClassHandler: '@ohif/extension-cornerstone-dicom-rt.sopClassHandlerModule.dicom-rt', }; @@ -218,8 +218,8 @@ function modeFactory({ modeConfiguration }) { displaySetsToDisplay: [dicomSeg.sopClassHandler], }, { - namespace: dicomRt.viewport, - displaySetsToDisplay: [dicomRt.sopClassHandler], + namespace: dicomRT.viewport, + displaySetsToDisplay: [dicomRT.sopClassHandler], }, ], }, @@ -240,7 +240,7 @@ function modeFactory({ modeConfiguration }) { ohif.sopClassHandler, dicompdf.sopClassHandler, dicomsr.sopClassHandler, - dicomRt.sopClassHandler, + dicomRT.sopClassHandler, ], hotkeys: [...hotkeys.defaults.hotkeyBindings], ...modeConfiguration, diff --git a/modes/segmentation/.prettierrc b/modes/segmentation/.prettierrc new file mode 100644 index 00000000000..28448abdf42 --- /dev/null +++ b/modes/segmentation/.prettierrc @@ -0,0 +1,11 @@ +{ + "trailingComma": "es5", + "printWidth": 100, + "proseWrap": "always", + "tabWidth": 2, + "semi": true, + "singleQuote": true, + "arrowParens": "avoid", + "singleAttributePerLine": true, + "endOfLine": "auto" +} diff --git a/package.json b/package.json index dceeec8b347..cb9d4855489 100644 --- a/package.json +++ b/package.json @@ -130,6 +130,8 @@ "source-map-loader": "^4.0.1", "start-server-and-test": "^1.10.0", "style-loader": "^1.0.0", + "stylus": "^0.59.0", + "stylus-loader": "^7.1.3", "terser-webpack-plugin": "^5.1.4", "typescript": "4.6.4", "unused-webpack-plugin": "2.4.0", diff --git a/platform/app/.webpack/rules/extractStyleChunks.js b/platform/app/.webpack/rules/extractStyleChunks.js index 94388a353dd..f7c467fc631 100644 --- a/platform/app/.webpack/rules/extractStyleChunks.js +++ b/platform/app/.webpack/rules/extractStyleChunks.js @@ -2,6 +2,20 @@ const ExtractCssChunksPlugin = require('extract-css-chunks-webpack-plugin'); function extractStyleChunks(isProdBuild) { return [ + // If you are using the old stylus, you should uncomment this + // { + // test: /\.styl$/, + // use: [ + // { + // loader: ExtractCssChunksPlugin.loader, + // options: { + // hot: !isProdBuild, + // }, + // }, + // { loader: 'css-loader' }, + // { loader: 'stylus-loader' }, + // ], + // }, { test: /\.(sa|sc|c)ss$/, use: [ diff --git a/yarn.lock b/yarn.lock index f6cfcd49f53..af72256071b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7,6 +7,11 @@ resolved "https://registry.yarnpkg.com/@aashutoshrathi/word-wrap/-/word-wrap-1.2.6.tgz#bd9154aec9983f77b3a034ecaa015c2e4201f6cf" integrity sha512-1Yjs2SvM8TflER/OD3cOjhWWOZb58A2t7wpE2S9XfBYTiIl+XFhQG2bjy4Pu1I+EAlCNUzRDYDdFwFYUKvXcIA== +"@adobe/css-tools@^4.0.1": + version "4.2.0" + resolved "https://registry.yarnpkg.com/@adobe/css-tools/-/css-tools-4.2.0.tgz#e1a84fca468f4b337816fcb7f0964beb620ba855" + integrity sha512-E09FiIft46CmH5Qnjb0wsW54/YQd69LsxeKUOWawmws1XWvyFGURnAChH0mlr7YPFR1ofwvUQfcL0J3lMxXqPA== + "@algolia/autocomplete-core@1.9.3": version "1.9.3" resolved "https://registry.yarnpkg.com/@algolia/autocomplete-core/-/autocomplete-core-1.9.3.tgz#1d56482a768c33aae0868c8533049e02e8961be7" @@ -8456,7 +8461,7 @@ debug@2.6.9, debug@^2.6.0, debug@^2.6.9: dependencies: ms "2.0.0" -debug@4, debug@4.3.4, debug@^4.0.0, debug@^4.0.1, debug@^4.1.0, debug@^4.1.1, debug@^4.3.3, debug@^4.3.4: +debug@4, debug@4.3.4, debug@^4.0.0, debug@^4.0.1, debug@^4.1.0, debug@^4.1.1, debug@^4.3.2, debug@^4.3.3, debug@^4.3.4: version "4.3.4" resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865" integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ== @@ -19344,6 +19349,25 @@ stylis@4.2.0: resolved "https://registry.yarnpkg.com/stylis/-/stylis-4.2.0.tgz#79daee0208964c8fe695a42fcffcac633a211a51" integrity sha512-Orov6g6BB1sDfYgzWfTHDOxamtX1bE/zo104Dh9e6fqJ3PooipYyfJ0pUmrZO2wAvO8YbEyeFrkV91XTsGMSrw== +stylus-loader@^7.1.3: + version "7.1.3" + resolved "https://registry.yarnpkg.com/stylus-loader/-/stylus-loader-7.1.3.tgz#1fdfa0d34e8c05a569bc0902e1ecdb857d764964" + integrity sha512-TY0SKwiY7D2kMd3UxaWKSf3xHF0FFN/FAfsSqfrhxRT/koXTwffq2cgEWDkLQz7VojMu7qEEHt5TlMjkPx9UDw== + dependencies: + fast-glob "^3.2.12" + normalize-path "^3.0.0" + +stylus@^0.59.0: + version "0.59.0" + resolved "https://registry.yarnpkg.com/stylus/-/stylus-0.59.0.tgz#a344d5932787142a141946536d6e24e6a6be7aa6" + integrity sha512-lQ9w/XIOH5ZHVNuNbWW8D822r+/wBSO/d6XvtyHLF7LW4KaCIDeVbvn5DF8fGCJAUCwVhVi/h6J0NUcnylUEjg== + dependencies: + "@adobe/css-tools" "^4.0.1" + debug "^4.3.2" + glob "^7.1.6" + sax "~1.2.4" + source-map "^0.7.3" + supports-color@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-2.0.0.tgz#535d045ce6b6363fa40117084629995e9df324c7"