Skip to content

Commit

Permalink
fix(modules): add stylus loader as an option to be uncommented (#3710)
Browse files Browse the repository at this point in the history
  • Loading branch information
sedghi authored Oct 10, 2023
1 parent dc929d3 commit 7c57f67
Show file tree
Hide file tree
Showing 9 changed files with 92 additions and 9 deletions.
10 changes: 10 additions & 0 deletions .webpack/rules/stylusToJavaScript.js
Original file line number Diff line number Diff line change
@@ -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;
4 changes: 4 additions & 0 deletions .webpack/webpack.base.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ class SegmentationService extends PubSubService {
);
}

if (active !== undefined) {
if (active === true) {
this._setActiveSegment(segmentationId, segmentIndex, suppressEvents);
}

Expand Down Expand Up @@ -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.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down Expand Up @@ -46,7 +47,7 @@ function disableSync(syncName, servicesManager) {
syncName
);
});
};
}

/**
* Gets the consistent spacing stack viewport types, which are the ones which
Expand Down Expand Up @@ -77,4 +78,4 @@ function getReconstructableStackViewports(viewportGridService, displaySetService
}
});
return viewports;
};
}
8 changes: 4 additions & 4 deletions modes/longitudinal/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
};
Expand Down Expand Up @@ -218,8 +218,8 @@ function modeFactory({ modeConfiguration }) {
displaySetsToDisplay: [dicomSeg.sopClassHandler],
},
{
namespace: dicomRt.viewport,
displaySetsToDisplay: [dicomRt.sopClassHandler],
namespace: dicomRT.viewport,
displaySetsToDisplay: [dicomRT.sopClassHandler],
},
],
},
Expand All @@ -240,7 +240,7 @@ function modeFactory({ modeConfiguration }) {
ohif.sopClassHandler,
dicompdf.sopClassHandler,
dicomsr.sopClassHandler,
dicomRt.sopClassHandler,
dicomRT.sopClassHandler,
],
hotkeys: [...hotkeys.defaults.hotkeyBindings],
...modeConfiguration,
Expand Down
11 changes: 11 additions & 0 deletions modes/segmentation/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"trailingComma": "es5",
"printWidth": 100,
"proseWrap": "always",
"tabWidth": 2,
"semi": true,
"singleQuote": true,
"arrowParens": "avoid",
"singleAttributePerLine": true,
"endOfLine": "auto"
}
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
14 changes: 14 additions & 0 deletions platform/app/.webpack/rules/extractStyleChunks.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand Down
26 changes: 25 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]":
version "1.9.3"
resolved "https://registry.yarnpkg.com/@algolia/autocomplete-core/-/autocomplete-core-1.9.3.tgz#1d56482a768c33aae0868c8533049e02e8961be7"
Expand Down Expand Up @@ -8456,7 +8461,7 @@ [email protected], debug@^2.6.0, debug@^2.6.9:
dependencies:
ms "2.0.0"

debug@4, [email protected], 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, [email protected], 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==
Expand Down Expand Up @@ -19344,6 +19349,25 @@ [email protected]:
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"
Expand Down

0 comments on commit 7c57f67

Please sign in to comment.