diff --git a/modes/example/.webpack/webpack.dev.js b/modes/example/.webpack/webpack.dev.js new file mode 100644 index 000000000..1ae308448 --- /dev/null +++ b/modes/example/.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/modes/example/.webpack/webpack.prod.js b/modes/example/.webpack/webpack.prod.js new file mode 100644 index 000000000..ca612cd37 --- /dev/null +++ b/modes/example/.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: 'OHIFExtCornerstone', + libraryTarget: 'umd', + libraryExport: 'default', + filename: pkg.main, + }, + plugins: [ + new webpack.optimize.LimitChunkCountPlugin({ + maxChunks: 1, + }), + ], + }); +}; diff --git a/modes/example/LICENSE b/modes/example/LICENSE new file mode 100644 index 000000000..19e20dd35 --- /dev/null +++ b/modes/example/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2018 Open Health Imaging Foundation + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/modes/example/babel.config.js b/modes/example/babel.config.js new file mode 100644 index 000000000..fed6f05fe --- /dev/null +++ b/modes/example/babel.config.js @@ -0,0 +1 @@ +module.exports = require("../../babel.config.js"); diff --git a/modes/example/package.json b/modes/example/package.json new file mode 100644 index 000000000..e98a3601e --- /dev/null +++ b/modes/example/package.json @@ -0,0 +1,35 @@ +{ + "name": "@ohif/mode-example", + "version": "0.0.1", + "description": "Example mode for OHIF", + "author": "OHIF", + "license": "MIT", + "repository": "OHIF/Viewers", + "main": "dist/index.umd.js", + "module": "src/index.js", + "engines": { + "node": ">=10", + "npm": ">=6", + "yarn": ">=1.16.0" + }, + "files": [ + "dist", + "README.md" + ], + "publishConfig": { + "access": "public" + }, + "scripts": { + "dev": "cross-env NODE_ENV=development webpack --config .webpack/webpack.dev.js --watch --debug --output-pathinfo", + "dev:cornerstone": "yarn run dev", + "build": "cross-env NODE_ENV=production webpack --config .webpack/webpack.prod.js", + "build:package": "yarn run build", + "start": "yarn run dev", + "test:unit": "jest --watchAll", + "test:unit:ci": "jest --ci --runInBand --collectCoverage" + }, + "peerDependencies": {}, + "dependencies": { + "@babel/runtime": "7.7.6" + } +} diff --git a/modes/example/src/index.js b/modes/example/src/index.js new file mode 100644 index 000000000..3f2243bd5 --- /dev/null +++ b/modes/example/src/index.js @@ -0,0 +1,38 @@ +export default function mode({ modeConfiguration }) { + return { + id: 'example-mode', + validationTags: { + study: [], + series: [], + }, + isValidMode: (studyTags, seriesTags) => { + // All series are welcome in this mode! + return true; + }, + routes: [ + { + path: 'viewer', + preInit: ({ toolbarManager }) => { + toolbarManager && + toolbarManager.setDefaultLoadOut([ + [], // Primary + [], // Secondary + ]); + }, + layoutTemplate: ({ routeProps }) => { + return { + id: 'org.ohif.defaults.viewerlayout', + props: { + // named slots + leftPanels: ['org.ohif.defaults.seriesList'], + rightPanels: ['org.ohif.defaults.measure'], + viewports: ['org.ohif.defaults.cornerstoneViewport'], + }, + }; + }, + }, + ], + extensions: ['org.ohif.defaults', 'org.ohif.cornerstone'], + sopClassHandlers: ['org.ohif.defaults.stack'], + }; +}