From 97004de4465b75582bafeedefa8bd1764d7cc71d Mon Sep 17 00:00:00 2001 From: Rodrigo Antinarelli Date: Thu, 7 May 2020 10:34:17 -0300 Subject: [PATCH] feat: OHIF-117 ohif extension default (#1712) * initial structure for extension default * webpack config * split default modules into separated files * bump versions * update index * update index * fix * Co-authored-by: Danny Brown --- extensions/default/.webpack/webpack.dev.js | 8 ++++ extensions/default/.webpack/webpack.prod.js | 44 +++++++++++++++++++ extensions/default/package.json | 39 ++++++++++++++++ .../default/src/getDataSourcesModule.js | 39 ++++++++++++++++ extensions/default/src/index.js | 9 ++++ 5 files changed, 139 insertions(+) create mode 100644 extensions/default/.webpack/webpack.dev.js create mode 100644 extensions/default/.webpack/webpack.prod.js create mode 100644 extensions/default/package.json create mode 100644 extensions/default/src/getDataSourcesModule.js create mode 100644 extensions/default/src/index.js diff --git a/extensions/default/.webpack/webpack.dev.js b/extensions/default/.webpack/webpack.dev.js new file mode 100644 index 000000000..1ae308448 --- /dev/null +++ b/extensions/default/.webpack/webpack.dev.js @@ -0,0 +1,8 @@ +const path = require('path'); +const webpackCommon = require('./../../../.webpack/webpack.commonjs.js'); +const SRC_DIR = path.join(__dirname, '../src'); +const DIST_DIR = path.join(__dirname, '../dist'); + +module.exports = (env, argv) => { + return webpackCommon(env, argv, { SRC_DIR, DIST_DIR }); +}; diff --git a/extensions/default/.webpack/webpack.prod.js b/extensions/default/.webpack/webpack.prod.js new file mode 100644 index 000000000..f51038902 --- /dev/null +++ b/extensions/default/.webpack/webpack.prod.js @@ -0,0 +1,44 @@ +const webpack = require('webpack'); +const merge = require('webpack-merge'); +const path = require('path'); +const webpackCommon = require('./../../../.webpack/webpack.commonjs.js'); +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'); + +module.exports = (env, argv) => { + const commonConfig = webpackCommon(env, argv, { SRC_DIR, DIST_DIR }); + + return merge(commonConfig, { + devtool: 'source-map', + stats: { + colors: true, + hash: true, + timings: true, + assets: true, + chunks: false, + chunkModules: false, + modules: false, + children: false, + warnings: true, + }, + optimization: { + minimize: true, + sideEffects: true, + }, + output: { + path: ROOT_DIR, + library: 'OHIFExtDefault', + libraryTarget: 'umd', + libraryExport: 'default', + filename: pkg.main, + }, + plugins: [ + new webpack.optimize.LimitChunkCountPlugin({ + maxChunks: 1, + }), + ], + }); +}; diff --git a/extensions/default/package.json b/extensions/default/package.json new file mode 100644 index 000000000..6071aea84 --- /dev/null +++ b/extensions/default/package.json @@ -0,0 +1,39 @@ +{ + "name": "@ohif/extension-default", + "version": "1.0.1", + "description": "Common/default features and functionality for basic image viewing", + "author": "OHIF Core Team", + "license": "MIT", + "repository": "OHIF/Viewers", + "main": "dist/index.umd.js", + "module": "src/index.js", + "publishConfig": { + "access": "public" + }, + "engines": { + "node": ">=10", + "npm": ">=6", + "yarn": ">=1.19.1" + }, + "files": [ + "dist", + "README.md" + ], + "scripts": { + "dev": "cross-env NODE_ENV=development webpack --config .webpack/webpack.dev.js --watch --debug --output-pathinfo", + "dev:dicom-pdf": "yarn run dev", + "build": "cross-env NODE_ENV=production webpack --config .webpack/webpack.prod.js", + "build:package": "yarn run build", + "start": "yarn run dev" + }, + "peerDependencies": { + "@ohif/core": "^0.50.0", + "prop-types": "^15.6.2", + "react": "^16.13.1", + "react-dom": "^16.13.1", + "webpack": "^4.0.0" + }, + "dependencies": { + "@babel/runtime": "7.7.6" + } +} diff --git a/extensions/default/src/getDataSourcesModule.js b/extensions/default/src/getDataSourcesModule.js new file mode 100644 index 000000000..84e7c9f81 --- /dev/null +++ b/extensions/default/src/getDataSourcesModule.js @@ -0,0 +1,39 @@ +// TODO: Pull in IWebClientApi from @ohif/core +// TODO: Use constructor to create an instance of IWebClientApi +// TODO: Use existing DICOMWeb configuration (previously, appConfig, to configure instance) + +/** + * + */ +function getDataSourcesModule() { + return [ + { + name: 'dicomweb-client', + type: 'webApi', + /** + * TODO: Create JSDoc for this Data Source implementation. + */ + createDataSource: dataSourceConfiguration => { + // instantiate DicomWebClient + // const dicomWebClient = new DicomWebClient(dataSourceConfiguration); + + return { + query: { + studies: { + mapParams: params => params, + searchStudies: params => { + /** dicomWebClient.searchStudies(params) **/ + }, + searchSeries: params => { + /** dicomWebClient.searchSeries(params) **/ + }, + processResults: results => results, + }, + }, + }; + }, + }, + ]; +} + +export default getDataSourcesModule; diff --git a/extensions/default/src/index.js b/extensions/default/src/index.js new file mode 100644 index 000000000..13e977231 --- /dev/null +++ b/extensions/default/src/index.js @@ -0,0 +1,9 @@ +import getDataSourcesModule from './getDataSourcesModule.js'; + +export default { + /** + * Only required property. Should be a unique value across all extensions. + */ + id: 'org.ohif.default', + getDataSourcesModule, +};