feat(cli): Ohif cli for modes and extensions modification (#2696)

* feat: Add initial cli tool structure

* feat: add copying template files

* feat: Add mode template and command

* feat: Add readme template generation

* feat: Add documentation to extension template

* feat: Enhance documentation of the template mode

* fix: cli module type

* feat: Add config-based mode and extension registration (#2660)

* feat: Add ohif cli add/remove extension/mode (#2661)

* Basic working CLI for add-extension and remove-extension

* Basic cli for add/remove extension/mode, lots more to do.

* Cleanup and harden]

* feat: Add list of tasks to add-mode

Co-authored-by: Alireza <ar.sedghi@gmail.com>

* feat: Add git initialization for the mode or extension template (#2662)

* fix: package json file to include templates

* feat: Add git initialization for the mode or extension template

* feat: Add more checks of git and target dir

* feat: refactore library utilities

* feat: Add the list command to print extensions and modes (#2664)

* feat: Add the list command to print extensions and modes

* Add todo

* Feat/ohif cli validation + auto install (#2671)

* WIP

* Working mode keyword verification

* Validation

* auto install extensions based on modes

* WIP remove unused extensions on removeMove

* Working add-mode, remove-mode automatic extension management.

* If extension is in used by a mode, don't allow the CLI to uninstall it

* Cleanup addExtension

* cleanup removeExtension and addMode

* Cleanup removeMode

* Update existing extensions with the needed keywords/peer deps

* Fix broken config

* Feat/cli search (#2677)

* feat: refactor pretty print for console

* feat: add search for modes and extensions

* fix: ugly colors

* Feat/ohif cli error handling publishing (#2679)

* WIP

* fix: webpack imports

* wip

* fix: react router dom private routes

* from last commit

* wip

* fix: webpack prod builds

* WIP

* Working regsitration with new IDs

* Stable

Co-authored-by: Alireza <ar.sedghi@gmail.com>

* verify extensions when constructing modes. (#2681)

* verify extensions when constructing modes.

* Add version to unit tests so it conforms to schema

* Update ohif utils exposed via @ohif/core

* Fix import

* fix tests

* feat: ohif-cli link local modes/extensions for development (#2682)

* feat: enable cli to work with project root

* feat: add initial link package

* feat: add link and unlink extension

* feat: add link and unlink mode

* erro handling for link-package

* feat: add comment on ohif-cli linking for development (#2686)

* Docs/ohif cli (#2687)

* feat: Add documentation for templates

* feat: Add more documentation

* Fix/core publish (#2685)

* versions

* wip

* remove webpack clean output

* fix publish

* use next as dist tag for v3 for now

* fix webpack pro recipe for output

* fix: lerna publish next

* fix(cli): fix issues when trying to link an extension or a mode (#2725)

The generated package.json doesn't contain keywords property which is
required by the linkPackage function. The module apth wasn't correclty
handled too, and when there is no pluginOptions, it fails while reading
the file or while generating a default configuration.

* make dicom pdf and video work after cli merge

* add axios dependency

* comment out the chdir for now

* create id and version based on user inputs

* customizable path for extension and modes

* fix template to make the template mode load

* fix the questions to loop if path is not desirable

* fix templates

* correct package json order

* unify the package creation for extension and mode

* bump versions for each package

* bump extension versions to 3.0

* add gitignore to templates

* fix version requirements when ^

* update docs

* update docs and fix tests

* try to fix the tests

* bump node version

* remove the version from extensions

* remove the version from modes

* remove version from extensionManager

* fix eslint

* revert husky version

* fix eslint

* fix node version for new eslint

* fix documentatoin removing version

* fix cicle ci image version

* fix circle ci node image

* fix circle ci node image

* add back the video and pdf

Co-authored-by: Matthis Duclos <matthis.duclos@gmail.com>
Co-authored-by: James A. Petts <jamesapetts@gmail.com>
This commit is contained in:
authored and GitHub committed 2022-04-06 13:28:42 -04:00
1 parent 82df3eac03
commit 7f0ad6f84d
181 files changed
+5985 -3689

No files matched your search

+1 -1
View File
@@ -5,7 +5,7 @@ import { IWebApiDataSource } from '@ohif/core';
*
*/
export default {
id: 'org.ohif.*',
id: '@ohif/extension-*',
/**
* LIFECYCLE HOOKS
@@ -1,5 +1,5 @@
const path = require('path');
const webpackCommon = require('./../../../.webpack/webpack.commonjs.js');
const webpackCommon = require('./../../../.webpack/webpack.base.js');
const SRC_DIR = path.join(__dirname, '../src');
const DIST_DIR = path.join(__dirname, '../dist');
@@ -1,8 +1,9 @@
const webpack = require('webpack');
const merge = require('webpack-merge');
const { merge } = require('webpack-merge');
const path = require('path');
const webpackCommon = require('./../../../.webpack/webpack.commonjs.js');
const webpackCommon = require('./../../../.webpack/webpack.base.js');
const pkg = require('./../package.json');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const ROOT_DIR = path.join(__dirname, './..');
const SRC_DIR = path.join(__dirname, '../src');
@@ -39,6 +40,10 @@ module.exports = (env, argv) => {
new webpack.optimize.LimitChunkCountPlugin({
maxChunks: 1,
}),
new MiniCssExtractPlugin({
filename: './dist/[name].css',
chunkFilename: './dist/[id].css',
}),
],
});
};
+6 -3
View File
@@ -8,7 +8,7 @@
"main": "dist/index.umd.js",
"module": "src/index.js",
"engines": {
"node": ">=10",
"node": ">=14",
"npm": ">=6",
"yarn": ">=1.16.0"
},
@@ -16,6 +16,9 @@
"dist",
"README.md"
],
"keywords": [
"ohif-extension"
],
"publishConfig": {
"access": "public"
},
@@ -29,8 +32,8 @@
"test:unit:ci": "jest --ci --runInBand --collectCoverage"
},
"peerDependencies": {
"@ohif/core": "^0.50.0",
"@ohif/ui": "^0.50.0",
"@ohif/core": "^3.0.0",
"@ohif/ui": "^2.0.0",
"cornerstone-core": "2.6.0",
"cornerstone-math": "0.1.9",
"cornerstone-tools": "6.0.2",
+4 -2
View File
@@ -1,3 +1,5 @@
const id = 'org.ohif.cornerstone';
import packageJson from '../package.json';
export default id;
const id = packageJson.name;
export { id };
+3 -5
View File
@@ -1,7 +1,8 @@
import React from 'react';
import init from './init.js';
import commandsModule from './commandsModule.js';
import CornerstoneViewportDownloadForm from './CornerstoneViewportDownloadForm';
import { id } from './id.js';
// import CornerstoneViewportDownloadForm from './CornerstoneViewportDownloadForm';
const Component = React.lazy(() => {
return import(/* webpackPrefetch: true */ './OHIFCornerstoneViewport');
@@ -22,8 +23,7 @@ export default {
/**
* Only required property. Should be a unique value across all extensions.
*/
id: 'org.ohif.cornerstone',
id,
/**
*
*
@@ -59,5 +59,3 @@ export default {
return commandsModule({ servicesManager, commandsManager });
},
};
export { CornerstoneViewportDownloadForm };
+1 -1
View File
@@ -1,5 +1,5 @@
const path = require('path');
const webpackCommon = require('./../../../.webpack/webpack.commonjs.js');
const webpackCommon = require('./../../../.webpack/webpack.base.js');
const SRC_DIR = path.join(__dirname, '../src');
const DIST_DIR = path.join(__dirname, '../dist');
+10 -5
View File
@@ -1,10 +1,11 @@
const webpack = require('webpack');
const merge = require('webpack-merge');
const { merge } = require('webpack-merge');
const path = require('path');
const webpackCommon = require('./../../../.webpack/webpack.commonjs.js');
const pkg = require('./../package.json');
const webpackCommon = require('./../../../.webpack/webpack.base.js');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const ROOT_DIR = path.join(__dirname, './..');
const pkg = require('./../package.json');
const ROOT_DIR = path.join(__dirname, './../');
const SRC_DIR = path.join(__dirname, '../src');
const DIST_DIR = path.join(__dirname, '../dist');
@@ -30,7 +31,7 @@ module.exports = (env, argv) => {
},
output: {
path: ROOT_DIR,
library: 'OHIFExtDefault',
library: 'OHIFExtCornerstone',
libraryTarget: 'umd',
libraryExport: 'default',
filename: pkg.main,
@@ -39,6 +40,10 @@ module.exports = (env, argv) => {
new webpack.optimize.LimitChunkCountPlugin({
maxChunks: 1,
}),
new MiniCssExtractPlugin({
filename: './dist/[name].css',
chunkFilename: './dist/[id].css',
}),
],
});
};
+9 -8
View File
@@ -1,6 +1,6 @@
{
"name": "@ohif/extension-default",
"version": "1.0.1",
"version": "3.0.0",
"description": "Common/default features and functionality for basic image viewing",
"author": "OHIF Core Team",
"license": "MIT",
@@ -11,7 +11,7 @@
"access": "public"
},
"engines": {
"node": ">=10",
"node": ">=14",
"npm": ">=6",
"yarn": ">=1.18.0"
},
@@ -19,6 +19,9 @@
"dist",
"README.md"
],
"keywords": [
"ohif-extension"
],
"scripts": {
"dev": "cross-env NODE_ENV=development webpack --config .webpack/webpack.dev.js --watch --debug --output-pathinfo",
"dev:dicom-pdf": "yarn run dev",
@@ -27,16 +30,14 @@
"start": "yarn run dev"
},
"peerDependencies": {
"@ohif/core": "^0.50.0",
"@ohif/i18n": "^0.52.8",
"@ohif/core": "^3.0.0",
"@ohif/i18n": "^1.0.0",
"dcmjs": "0.16.1",
"dicomweb-client": "^0.6.0",
"prop-types": "^15.6.2",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-i18next": "^10.11.0",
"react-router": "next",
"react-router-dom": "next",
"webpack": "^5.50.0",
"webpack-merge": "^5.7.3"
},
@@ -165,18 +165,22 @@ function PanelStudyBrowser({
);
const updatedExpandedStudyInstanceUIDs = shouldCollapseStudy
? // eslint-disable-next-line prettier/prettier
[
...expandedStudyInstanceUIDs.filter(
stdyUid => stdyUid !== StudyInstanceUID
),
]
[
...expandedStudyInstanceUIDs.filter(
stdyUid => stdyUid !== StudyInstanceUID
),
]
: [...expandedStudyInstanceUIDs, StudyInstanceUID];
setExpandedStudyInstanceUIDs(updatedExpandedStudyInstanceUIDs);
if (!shouldCollapseStudy) {
const madeInClient = true
requestDisplaySetCreationForStudy(DisplaySetService, StudyInstanceUID, madeInClient);
const madeInClient = true;
requestDisplaySetCreationForStudy(
DisplaySetService,
StudyInstanceUID,
madeInClient
);
}
}
+16 -8
View File
@@ -1,5 +1,6 @@
import React, { useEffect, useState } from 'react';
import PropTypes from 'prop-types';
import { useNavigate } from 'react-router-dom';
import { useTranslation } from 'react-i18next';
import {
SidePanel,
@@ -12,12 +13,10 @@ import {
import i18n from '@ohif/i18n';
import { hotkeys } from '@ohif/core';
import { useNavigate } from 'react-router-dom';
import { useAppConfig } from '@state';
const { availableLanguages, defaultLanguage, currentLanguage } = i18n;
import { useAppConfig } from '@state';
function Toolbar({ servicesManager }) {
const { ToolBarService } = servicesManager.services;
const [toolbarButtons, setToolbarButtons] = useState([]);
@@ -94,7 +93,7 @@ function ViewerLayout({
const navigate = useNavigate();
const onClickReturnButton = () => {
navigate('/')
navigate('/');
};
const { t } = useTranslation();
@@ -108,7 +107,12 @@ function ViewerLayout({
{
title: t('Header:About'),
icon: 'info',
onClick: () => show({ content: AboutModal, title: 'About OHIF Viewer', contentProps: { versionNumber, buildNumber } }),
onClick: () =>
show({
content: AboutModal,
title: 'About OHIF Viewer',
contentProps: { versionNumber, buildNumber },
}),
},
{
title: t('Header:Preferences'),
@@ -136,7 +140,7 @@ function ViewerLayout({
hide();
},
onReset: () => hotkeysManager.restoreDefaultBindings(),
hotkeysModule: hotkeys
hotkeysModule: hotkeys,
},
}),
},
@@ -185,7 +189,11 @@ function ViewerLayout({
return (
<div>
<Header menuOptions={menuOptions} onClickReturnButton={onClickReturnButton} WhiteLabeling={appConfig.whiteLabeling} >
<Header
menuOptions={menuOptions}
onClickReturnButton={onClickReturnButton}
WhiteLabeling={appConfig.whiteLabeling}
>
<ErrorBoundary context="Primary Toolbar">
<div className="relative flex justify-center">
<Toolbar servicesManager={servicesManager} />
@@ -193,7 +201,7 @@ function ViewerLayout({
</ErrorBoundary>
</Header>
<div
className="flex flex-row flex-nowrap items-stretch w-full overflow-hidden"
className="flex flex-row items-stretch w-full overflow-hidden flex-nowrap"
style={{ height: 'calc(100vh - 52px' }}
>
{/* LEFT SIDEPANELS */}
@@ -1,7 +1,7 @@
import { isImage } from '@ohif/core/src/utils/isImage';
import ImageSet from '@ohif/core/src/classes/ImageSet';
import isDisplaySetReconstructable from '@ohif/core/src/utils/isDisplaySetReconstructable';
import id from './id';
import { id } from './id';
const sopClassHandlerName = 'stack';
+4 -2
View File
@@ -1,3 +1,5 @@
const id = 'org.ohif.default';
import packageJson from '../package.json';
export default id;
const id = packageJson.name;
export { id };
+1 -1
View File
@@ -5,7 +5,7 @@ import getSopClassHandlerModule from './getSopClassHandlerModule.js';
import getHangingProtocolModule from './getHangingProtocolModule.js';
import getToolbarModule from './getToolbarModule.js';
import commandsModule from './commandsModule';
import id from './id';
import { id } from './id.js';
export default {
/**
+3 -3
View File
@@ -8,7 +8,7 @@
"main": "dist/index.umd.js",
"module": "src/index.js",
"engines": {
"node": ">=10",
"node": ">=14",
"npm": ">=6",
"yarn": ">=1.16.0"
},
@@ -29,8 +29,8 @@
"test:unit:ci": "jest --ci --runInBand --collectCoverage --passWithNoTests"
},
"peerDependencies": {
"@ohif/core": "^0.50.0",
"@ohif/ui": "^0.50.0",
"@ohif/core": "^3.0.0",
"@ohif/ui": "^2.0.0",
"cornerstone-core": "^2.6.0",
"cornerstone-math": "^0.1.9",
"cornerstone-tools": "6.0.2",
@@ -1,4 +1,4 @@
import { Name, SOPClassHandlerId } from './id';
import { SOPClassHandlerId } from './id';
import { utils, classes } from '@ohif/core';
const { ImageSet } = classes;
@@ -9,49 +9,67 @@ const SOP_CLASS_UIDS = {
const sopClassUids = Object.values(SOP_CLASS_UIDS);
const _getDisplaySetsFromSeries = (instances, servicesManager, extensionManager) => {
const _getDisplaySetsFromSeries = (
instances,
servicesManager,
extensionManager
) => {
const dataSource = extensionManager.getActiveDataSource()[0];
return instances
.map(instance => {
const { Modality, SOPInstanceUID, EncapsulatedDocument } = instance;
const { SeriesDescription = "PDF", MIMETypeOfEncapsulatedDocument, } = instance;
const { SeriesNumber, SeriesDate, SeriesInstanceUID, StudyInstanceUID, } = instance;
const pdfUrl = dataSource.retrieve.directURL({
instance,
tag: 'EncapsulatedDocument',
defaultType: MIMETypeOfEncapsulatedDocument || "application/pdf",
singlepart: "pdf",
});
const displaySet = {
//plugin: id,
Modality,
displaySetInstanceUID: utils.guid(),
SeriesDescription,
SeriesNumber,
SeriesDate,
SOPInstanceUID,
SeriesInstanceUID,
StudyInstanceUID,
SOPClassHandlerId,
referencedImages: null,
measurements: null,
pdfUrl,
others: [instance],
thumbnailSrc: dataSource.retrieve.directURL({ instance, defaultPath: "/thumbnail", defaultType: "image/jpeg", tag: "Absent" }),
isDerivedDisplaySet: true,
isLoaded: false,
sopClassUids,
numImageFrames: 0,
numInstances: 1,
instance,
};
return displaySet;
return instances.map(instance => {
const { Modality, SOPInstanceUID, EncapsulatedDocument } = instance;
const {
SeriesDescription = 'PDF',
MIMETypeOfEncapsulatedDocument,
} = instance;
const {
SeriesNumber,
SeriesDate,
SeriesInstanceUID,
StudyInstanceUID,
} = instance;
const pdfUrl = dataSource.retrieve.directURL({
instance,
tag: 'EncapsulatedDocument',
defaultType: MIMETypeOfEncapsulatedDocument || 'application/pdf',
singlepart: 'pdf',
});
const displaySet = {
//plugin: id,
Modality,
displaySetInstanceUID: utils.guid(),
SeriesDescription,
SeriesNumber,
SeriesDate,
SOPInstanceUID,
SeriesInstanceUID,
StudyInstanceUID,
SOPClassHandlerId,
referencedImages: null,
measurements: null,
pdfUrl,
others: [instance],
thumbnailSrc: dataSource.retrieve.directURL({
instance,
defaultPath: '/thumbnail',
defaultType: 'image/jpeg',
tag: 'Absent',
}),
isDerivedDisplaySet: true,
isLoaded: false,
sopClassUids,
numImageFrames: 0,
numInstances: 1,
instance,
};
return displaySet;
});
};
export default function getSopClassHandlerModule({ servicesManager, extensionManager }) {
export default function getSopClassHandlerModule({
servicesManager,
extensionManager,
}) {
const getDisplaySetsFromSeries = instances => {
return _getDisplaySetsFromSeries(
instances,
@@ -62,7 +80,7 @@ export default function getSopClassHandlerModule({ servicesManager, extensionMan
return [
{
name: Name,
name: 'dicom-pdf',
sopClassUids,
getDisplaySetsFromSeries,
},
+4 -6
View File
@@ -1,8 +1,6 @@
const Name = 'dicom-pdf';
const id = `org.ohif.${Name}`;
import packageJson from '../package.json';
export default id;
const id = packageJson.name;
const SOPClassHandlerId = `${id}.sopClassHandlerModule.dicom-pdf`;
const SOPClassHandlerId = `${id}.sopClassHandlerModule.${Name}`;
export { Name, SOPClassHandlerId, };
export { id, SOPClassHandlerId };
+4 -19
View File
@@ -1,6 +1,6 @@
import React from 'react';
import getSopClassHandlerModule from './getSopClassHandlerModule';
import id from './id.js';
import { id } from './id.js';
const Component = React.lazy(() => {
return import(
@@ -24,23 +24,6 @@ export default {
* Only required property. Should be a unique value across all extensions.
*/
id,
dependencies: [
// TODO -> This isn't used anywhere yet, but we do have a hard dependency, and need to check for these in the future.
// OHIF-229
{
id: 'org.ohif.cornerstone',
version: '3.0.0',
},
{
id: 'org.ohif.measurement-tracking',
version: '^0.0.1',
},
],
preRegistration({ servicesManager, configuration = {} }) {
// No-op for now
},
/**
*
*
@@ -58,7 +41,9 @@ export default {
);
};
return [{ name: 'dicom-pdf', component: ExtendedOHIFCornerstonePdfViewport }];
return [
{ name: 'dicom-pdf', component: ExtendedOHIFCornerstonePdfViewport },
];
},
getCommandsModule({ servicesManager }) {
return {
+1 -1
View File
@@ -1,5 +1,5 @@
const path = require('path');
const webpackCommon = require('./../../../.webpack/webpack.commonjs.js');
const webpackCommon = require('./../../../.webpack/webpack.base.js');
const SRC_DIR = path.join(__dirname, '../src');
const DIST_DIR = path.join(__dirname, '../dist');
+11 -5
View File
@@ -1,10 +1,12 @@
const webpack = require('webpack');
const merge = require('webpack-merge');
const { merge } = require('webpack-merge');
const path = require('path');
const webpackCommon = require('./../../../.webpack/webpack.commonjs.js');
const pkg = require('./../package.json');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const ROOT_DIR = path.join(__dirname, './..');
const pkg = require('./../package.json');
const webpackCommon = require('./../../../.webpack/webpack.base.js');
const ROOT_DIR = path.join(__dirname, './../');
const SRC_DIR = path.join(__dirname, '../src');
const DIST_DIR = path.join(__dirname, '../dist');
@@ -30,7 +32,7 @@ module.exports = (env, argv) => {
},
output: {
path: ROOT_DIR,
library: 'OHIFExtDICOMSR',
library: 'OHIFExtCornerstone',
libraryTarget: 'umd',
libraryExport: 'default',
filename: pkg.main,
@@ -39,6 +41,10 @@ module.exports = (env, argv) => {
new webpack.optimize.LimitChunkCountPlugin({
maxChunks: 1,
}),
new MiniCssExtractPlugin({
filename: './dist/[name].css',
chunkFilename: './dist/[id].css',
}),
],
});
};
+10 -5
View File
@@ -1,6 +1,6 @@
{
"name": "@ohif/extension-dicom-sr",
"version": "0.0.1",
"version": "3.0.0",
"description": "OHIF extension for an SR Cornerstone Viewport",
"author": "OHIF",
"license": "MIT",
@@ -8,7 +8,7 @@
"main": "dist/index.umd.js",
"module": "src/index.js",
"engines": {
"node": ">=10",
"node": ">=14",
"npm": ">=6",
"yarn": ">=1.16.0"
},
@@ -19,6 +19,9 @@
"publishConfig": {
"access": "public"
},
"keywords": [
"ohif-extension"
],
"scripts": {
"dev": "cross-env NODE_ENV=development webpack --config .webpack/webpack.dev.js --watch --debug --output-pathinfo",
"dev:cornerstone": "yarn run dev",
@@ -29,8 +32,8 @@
"test:unit:ci": "jest --ci --runInBand --collectCoverage --passWithNoTests"
},
"peerDependencies": {
"@ohif/core": "^0.50.0",
"@ohif/ui": "^0.50.0",
"@ohif/core": "^3.0.0",
"@ohif/ui": "^2.0.0",
"cornerstone-core": "^2.6.0",
"cornerstone-math": "^0.1.9",
"cornerstone-tools": "6.0.2",
@@ -40,7 +43,9 @@
"hammerjs": "^2.0.8",
"prop-types": "^15.6.2",
"react": "^17.0.2",
"react-cornerstone-viewport": "4.1.2"
"react-cornerstone-viewport": "4.1.2",
"@ohif/extension-cornerstone": "^3.0.0",
"@ohif/extension-measurement-tracking": "^3.0.0"
},
"dependencies": {
"@babel/runtime": "7.16.3",
+4 -3
View File
@@ -1,7 +1,8 @@
const id = 'org.ohif.dicom-sr';
import packageJson from '../package.json';
export default id;
const id = packageJson.name;
const SOPClassHandlerName = 'dicom-sr';
const SOPClassHandlerId = `${id}.sopClassHandlerModule.${SOPClassHandlerName}`;
export { SOPClassHandlerName, SOPClassHandlerId };
export { SOPClassHandlerName, SOPClassHandlerId, id };
+1 -13
View File
@@ -1,8 +1,8 @@
import React from 'react';
import getSopClassHandlerModule from './getSopClassHandlerModule';
import onModeEnter from './onModeEnter';
import id from './id.js';
import init from './init';
import { id } from './id.js';
const Component = React.lazy(() => {
return import(
@@ -26,18 +26,6 @@ export default {
* Only required property. Should be a unique value across all extensions.
*/
id,
dependencies: [
// TODO -> This isn't used anywhere yet, but we do have a hard dependency, and need to check for these in the future.
// OHIF-229
{
id: 'org.ohif.cornerstone',
version: '3.0.0',
},
{
id: 'org.ohif.measurement-tracking',
version: '^0.0.1',
},
],
preRegistration({ servicesManager, configuration = {} }) {
init({ servicesManager, configuration });
+3 -3
View File
@@ -1,6 +1,6 @@
import cornerstoneTools from 'cornerstone-tools';
import dicomSRModule from './tools/modules/dicomSRModule';
import id from './id';
import { id } from './id';
import TOOL_NAMES from './constants/toolNames';
@@ -14,9 +14,9 @@ const defaultConfig = {
* @param {object} configuration
*/
export default function init({ configuration = {} }) {
const conifg = Object.assign({}, defaultConfig, configuration);
const config = Object.assign({}, defaultConfig, configuration);
TOOL_NAMES.DICOM_SR_DISPLAY_TOOL = conifg.TOOL_NAMES.DICOM_SR_DISPLAY_TOOL;
TOOL_NAMES.DICOM_SR_DISPLAY_TOOL = config.TOOL_NAMES.DICOM_SR_DISPLAY_TOOL;
cornerstoneTools.register('module', id, dicomSRModule);
}
@@ -3,7 +3,7 @@ import { pixelToCanvas } from 'cornerstone-core';
import TOOL_NAMES from '../constants/toolNames';
import SCOORD_TYPES from '../constants/scoordTypes';
import id from '../id';
import { id } from '../id';
// Cornerstone 3rd party dev kit imports
const draw = importInternal('drawing/draw');
@@ -14,7 +14,7 @@ import {
} from '@ohif/ui';
import TOOL_NAMES from './../constants/toolNames';
import { adapters } from 'dcmjs';
import id from './../id';
import { id } from './../id';
const { formatDate } = utils;
const scrollToIndex = cornerstoneTools.importInternal('util/scrollToIndex');
@@ -23,7 +23,8 @@ const globalImageIdSpecificToolStateManager =
const { StackManager, guid } = OHIF.utils;
const MEASUREMENT_TRACKING_EXTENSION_ID = 'org.ohif.measurement-tracking';
const MEASUREMENT_TRACKING_EXTENSION_ID =
'@ohif/extension-measurement-tracking';
function OHIFCornerstoneSRViewport({
children,
@@ -81,7 +82,7 @@ function OHIFCornerstoneSRViewport({
)
) {
const contextModule = extensionManager.getModuleEntry(
'org.ohif.measurement-tracking.contextModule.TrackedMeasurementsContext'
'@ohif/extension-measurement-tracking.contextModule.TrackedMeasurementsContext'
);
const useTrackedMeasurements = () => useContext(contextModule.context);
+2 -2
View File
@@ -8,7 +8,7 @@
"main": "dist/index.umd.js",
"module": "src/index.js",
"engines": {
"node": ">=10",
"node": ">=14",
"npm": ">=6",
"yarn": ">=1.16.0"
},
@@ -30,7 +30,7 @@
},
"peerDependencies": {
"@ohif/core": "^0.50.0",
"@ohif/ui": "^0.50.0",
"@ohif/ui": "^2.0.0",
"cornerstone-core": "^2.6.0",
"cornerstone-math": "^0.1.9",
"cornerstone-tools": "6.0.2",
@@ -1,5 +1,5 @@
import { Name, SOPClassHandlerId } from './id';
import { utils, } from '@ohif/core';
import { SOPClassHandlerId } from './id';
import { utils } from '@ohif/core';
const SOP_CLASS_UIDS = {
VIDEO_MICROSCOPIC_IMAGE_STORAGE: '1.2.840.10008.5.1.4.1.1.77.1.2.1',
@@ -25,17 +25,33 @@ const SupportedTransferSyntaxes = {
const supportedTransferSyntaxUIDs = Object.values(SupportedTransferSyntaxes);
const _getDisplaySetsFromSeries = (instances, servicesManager, extensionManager) => {
const _getDisplaySetsFromSeries = (
instances,
servicesManager,
extensionManager
) => {
const dataSource = extensionManager.getActiveDataSource()[0];
return instances
.filter(metadata => {
const tsuid = metadata.AvailableTransferSyntaxUID ||
metadata.TransferSyntaxUID || metadata['00083002'];
const tsuid =
metadata.AvailableTransferSyntaxUID ||
metadata.TransferSyntaxUID ||
metadata['00083002'];
return supportedTransferSyntaxUIDs.includes(tsuid);
})
.map(instance => {
const { Modality, SOPInstanceUID, SeriesDescription = "VIDEO" } = instance;
const { SeriesNumber, SeriesDate, SeriesInstanceUID, StudyInstanceUID, NumberOfFrames } = instance;
const {
Modality,
SOPInstanceUID,
SeriesDescription = 'VIDEO',
} = instance;
const {
SeriesNumber,
SeriesDate,
SeriesInstanceUID,
StudyInstanceUID,
NumberOfFrames,
} = instance;
const displaySet = {
//plugin: id,
Modality,
@@ -49,9 +65,18 @@ const _getDisplaySetsFromSeries = (instances, servicesManager, extensionManager)
SOPClassHandlerId,
referencedImages: null,
measurements: null,
videoUrl: dataSource.retrieve.directURL({ instance, singlepart: "video", tag: "PixelData", }),
videoUrl: dataSource.retrieve.directURL({
instance,
singlepart: 'video',
tag: 'PixelData',
}),
others: [instance],
thumbnailSrc: dataSource.retrieve.directURL({ instance, defaultPath: "/thumbnail", defaultType: "image/jpeg", tag: "Absent" }),
thumbnailSrc: dataSource.retrieve.directURL({
instance,
defaultPath: '/thumbnail',
defaultType: 'image/jpeg',
tag: 'Absent',
}),
isDerivedDisplaySet: true,
isLoaded: false,
sopClassUids,
@@ -62,7 +87,10 @@ const _getDisplaySetsFromSeries = (instances, servicesManager, extensionManager)
});
};
export default function getSopClassHandlerModule({ servicesManager, extensionManager }) {
export default function getSopClassHandlerModule({
servicesManager,
extensionManager,
}) {
const getDisplaySetsFromSeries = instances => {
return _getDisplaySetsFromSeries(
instances,
@@ -73,7 +101,7 @@ export default function getSopClassHandlerModule({ servicesManager, extensionMan
return [
{
name: Name,
name: 'dicom-video',
sopClassUids,
getDisplaySetsFromSeries,
},
+4 -6
View File
@@ -1,8 +1,6 @@
const Name = 'dicom-video';
const id = `org.ohif.${Name}`;
import packageJson from '../package.json';
export default id;
const id = packageJson.name;
const SOPClassHandlerId = `${id}.sopClassHandlerModule.dicom-video`;
const SOPClassHandlerId = `${id}.sopClassHandlerModule.${Name}`;
export { Name, SOPClassHandlerId, };
export { SOPClassHandlerId, id };
+4 -18
View File
@@ -1,6 +1,6 @@
import React from 'react';
import getSopClassHandlerModule from './getSopClassHandlerModule';
import id from './id.js';
import { id } from './id';
const Component = React.lazy(() => {
return import(
@@ -24,22 +24,6 @@ export default {
* Only required property. Should be a unique value across all extensions.
*/
id,
dependencies: [
// TODO -> This isn't used anywhere yet, but we do have a hard dependency, and need to check for these in the future.
// OHIF-229
{
id: 'org.ohif.cornerstone',
version: '3.0.0',
},
{
id: 'org.ohif.measurement-tracking',
version: '^0.0.1',
},
],
preRegistration({ servicesManager, configuration = {} }) {
// No-op for now
},
/**
*
@@ -58,7 +42,9 @@ export default {
);
};
return [{ name: 'dicom-video', component: ExtendedOHIFCornerstoneVideoViewport }];
return [
{ name: 'dicom-video', component: ExtendedOHIFCornerstoneVideoViewport },
];
},
getCommandsModule({ servicesManager }) {
return {
@@ -1,5 +1,5 @@
const path = require('path');
const webpackCommon = require('./../../../.webpack/webpack.commonjs.js');
const webpackCommon = require('./../../../.webpack/webpack.base.js');
const SRC_DIR = path.join(__dirname, '../src');
const DIST_DIR = path.join(__dirname, '../dist');
@@ -1,10 +1,12 @@
const webpack = require('webpack');
const merge = require('webpack-merge');
const { merge } = require('webpack-merge');
const path = require('path');
const webpackCommon = require('./../../../.webpack/webpack.commonjs.js');
const pkg = require('./../package.json');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const ROOT_DIR = path.join(__dirname, './..');
const pkg = require('./../package.json');
const webpackCommon = require('./../../../.webpack/webpack.base.js');
const ROOT_DIR = path.join(__dirname, './../');
const SRC_DIR = path.join(__dirname, '../src');
const DIST_DIR = path.join(__dirname, '../dist');
@@ -30,7 +32,7 @@ module.exports = (env, argv) => {
},
output: {
path: ROOT_DIR,
library: 'OHIFExtDefault',
library: 'OHIFExtCornerstone',
libraryTarget: 'umd',
libraryExport: 'default',
filename: pkg.main,
@@ -39,6 +41,10 @@ module.exports = (env, argv) => {
new webpack.optimize.LimitChunkCountPlugin({
maxChunks: 1,
}),
new MiniCssExtractPlugin({
filename: './dist/[name].css',
chunkFilename: './dist/[id].css',
}),
],
});
};
+11 -7
View File
@@ -1,6 +1,6 @@
{
"name": "@ohif/extension-measurement-tracking",
"version": "0.0.1",
"version": "3.0.0",
"description": "Tracking features and functionality for basic image viewing",
"author": "OHIF Core Team",
"license": "MIT",
@@ -11,7 +11,7 @@
"access": "public"
},
"engines": {
"node": ">=10",
"node": ">=14",
"npm": ">=6",
"yarn": ">=1.18.0"
},
@@ -19,6 +19,9 @@
"dist",
"README.md"
],
"keywords": [
"ohif-extension"
],
"scripts": {
"dev": "cross-env NODE_ENV=development webpack --config .webpack/webpack.dev.js --watch --debug --output-pathinfo",
"dev:dicom-pdf": "yarn run dev",
@@ -27,21 +30,22 @@
"start": "yarn run dev"
},
"peerDependencies": {
"@ohif/core": "^0.50.0",
"@ohif/core": "^3.0.0",
"classnames": "^2.2.6",
"cornerstone-core": "^2.6.0",
"cornerstone-tools": "6.0.2",
"dcmjs": "0.16.1",
"prop-types": "^15.6.2",
"react": "^16.13.1",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-cornerstone-viewport": "^4.1.2",
"react-dom": "^16.13.1",
"webpack": "^5.50.0",
"webpack-merge": "^5.7.3"
"webpack-merge": "^5.7.3",
"@ohif/ui": "^2.0.0"
},
"dependencies": {
"@babel/runtime": "7.16.3",
"@ohif/ui": "^1.8.2",
"@ohif/ui": "^2.0.0",
"@xstate/react": "^0.8.1",
"xstate": "^4.10.0"
}
@@ -17,7 +17,8 @@ const TrackedMeasurementsContext = React.createContext();
TrackedMeasurementsContext.displayName = 'TrackedMeasurementsContext';
const useTrackedMeasurements = () => useContext(TrackedMeasurementsContext);
const SR_SOPCLASSHANDLERID = "org.ohif.dicom-sr.sopClassHandlerModule.dicom-sr";
const SR_SOPCLASSHANDLERID =
'@ohif/extension-dicom-sr.sopClassHandlerModule.dicom-sr';
/**
*
@@ -33,7 +34,10 @@ function TrackedMeasurementsContextProvider(
const machineOptions = Object.assign({}, defaultOptions);
machineOptions.actions = Object.assign({}, machineOptions.actions, {
jumpToFirstMeasurementInActiveViewport: (ctx, evt) => {
const { DisplaySetService, MeasurementService } = servicesManager.services;
const {
DisplaySetService,
MeasurementService,
} = servicesManager.services;
const { trackedStudy, trackedSeries } = ctx;
const measurements = MeasurementService.getMeasurements();
const trackedMeasurements = measurements.filter(
@@ -44,7 +48,10 @@ function TrackedMeasurementsContextProvider(
const id = trackedMeasurements[0].id;
MeasurementService.jumpToMeasurement(viewportGrid.activeViewportIndex, id);
MeasurementService.jumpToMeasurement(
viewportGrid.activeViewportIndex,
id
);
},
showStructuredReportDisplaySetInActiveViewport: (ctx, evt) => {
if (evt.data.createdDisplaySetInstanceUIDs.length > 0) {
@@ -98,7 +105,7 @@ function TrackedMeasurementsContextProvider(
}),
promptHydrateStructuredReport: promptHydrateStructuredReport.bind(null, {
servicesManager,
extensionManager
extensionManager,
}),
});
@@ -149,9 +156,11 @@ function TrackedMeasurementsContextProvider(
// The issue here is that this handler in TrackedMeasurementsContext
// ends up occurring before the Viewport is created, so the displaySet
// is not loaded yet, and isRehydratable is undefined unless we call load().
if (displaySet.SOPClassHandlerId === SR_SOPCLASSHANDLERID &&
!displaySet.isLoaded &&
displaySet.load) {
if (
displaySet.SOPClassHandlerId === SR_SOPCLASSHANDLERID &&
!displaySet.isLoaded &&
displaySet.load
) {
displaySet.load();
}
@@ -0,0 +1,5 @@
import packageJson from '../package.json';
const id = packageJson.name;
export { id };
+3 -1
View File
@@ -1,12 +1,14 @@
import getContextModule from './getContextModule.js';
import getPanelModule from './getPanelModule.js';
import getViewportModule from './getViewportModule.js';
import { id } from './id.js';
export default {
/**
* Only required property. Should be a unique value across all extensions.
*/
id: 'org.ohif.measurement-tracking',
id,
getContextModule,
getPanelModule,
getViewportModule,
@@ -228,7 +228,7 @@ function TrackedCornerstoneViewport(props) {
const renderViewport = () => {
const { component: Component } = extensionManager.getModuleEntry(
'org.ohif.cornerstone.viewportModule.cornerstone'
'@ohif/extension-cornerstone.viewportModule.cornerstone'
);
return (
<Component
@@ -257,7 +257,7 @@ function TrackedCornerstoneViewport(props) {
isLocked: false,
isRehydratable: false,
studyDate: formatDate(SeriesDate), // TODO: This is series date. Is that ok?
currentSeries: SeriesNumber, // TODO - switch entire currentSeries to be UID based or actual position based
currentSeries: SeriesNumber, // TODO - switch entire currentSeries to be UID based or actual position based
seriesDescription: SeriesDescription,
modality: Modality,
patientInformation: {