Skip to content

Commit ea5d99c

Browse files
authored
BREAKING CHANGE: Overhaul of top level API and implementation
* Shift some files around * Remove resize detector * Add some basic linting niceties * ci: clean up netlify * refactor: linter fixes * Kill moment and debounce * kill dead config * stylus to css * css imports * setup basic dev * comment these out for now * build examples * Delete dead code * examples index * syntax highlighter for snippets * fix: example component is providing props that are not used * chore: fix eol linting issue * chore: remove vscode eol preferences * docs: newer version of bootstrap * availableTools --> tools * Don't use viewportHeight in state * Chucking in a lot of changes * duplicate vtk viewport's example routing * initCornerstone note * Grid example and todo notes * docs: cleanup * refactor: areStringArraysEqual to own file * fix: better support for custom loadHandlers * enforce component method ordering * fix: loadhandlers should be called with right args; fix: setToolActive warn if bad tool name provided * docs: comprehensive grid example * Ability to set/merge classnames * docs: custom overlay example * docs: escape hatch * Bump cornerstone-tools version (disable resize) * fix null tools error * default windowResize implementation * react-resize-detector support * ci: remove tests for now (we had a single sanity test; not a huge loss) * resize throttle as a prop * Make sure our scrollbar is in an relatively positioned div * Making things a little clearer * fix some resizing issues * clear prefetch on willUnmount * Change ordering of image load * Clear error if we get new imageIds * Default to a single entry, even though this is a required prop. Fail more gracefully without the need to sprinkle in checks * fix stack prefetcher toggling * fix time formatters * fix dot rule issue
1 parent 7a669e7 commit ea5d99c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+10417
-37141
lines changed

.circleci/config.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ jobs:
3535
steps:
3636
- attach_workspace:
3737
at: ~/repo
38-
- run: npm run build && npm run test
38+
- run: npm run build
39+
# No tests yet :(
3940
# https://circleci.com/docs/2.0/collect-test-data/#karma
4041
# - store_test_results:
4142
# path: reports/junit

.editorconfig

Lines changed: 0 additions & 9 deletions
This file was deleted.

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.css

.eslintrc

Lines changed: 0 additions & 16 deletions
This file was deleted.

.eslintrc.json

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"extends": [
3+
"react-app",
4+
"eslint:recommended",
5+
"plugin:react/recommended",
6+
"plugin:prettier/recommended"
7+
],
8+
"parser": "babel-eslint",
9+
"env": {
10+
"jest": true
11+
},
12+
"settings": {
13+
"react": {
14+
"version": "detect"
15+
}
16+
},
17+
"globals": {
18+
"context": true,
19+
"assert": true
20+
},
21+
"rules": {
22+
"no-console": "warn",
23+
"no-undef": "warn",
24+
"no-unused-vars": "warn",
25+
"prettier/prettier": [
26+
"error",
27+
{
28+
"endOfLine": "auto"
29+
}
30+
],
31+
// React
32+
// https://github.com/yannickcr/eslint-plugin-react#recommended
33+
"react/sort-comp": "warn"
34+
}
35+
}

.prettierrc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
{
2+
"trailingComma": "es5",
3+
"printWidth": 80,
4+
"proseWrap": "always",
5+
"tabWidth": 2,
6+
"semi": true,
27
"singleQuote": true
3-
}
8+
}

.vscode/extensions.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"recommendations": ["esbenp.prettier-vscode", "dbaeumer.vscode-eslint"]
3+
}

.vscode/settings.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"editor.rulers": [80, 120],
3+
4+
// ===
5+
// Spacing
6+
// ===
7+
8+
"editor.insertSpaces": true,
9+
"editor.tabSize": 2,
10+
"editor.trimAutoWhitespace": true,
11+
"files.trimTrailingWhitespace": true,
12+
"files.insertFinalNewline": true,
13+
"files.trimFinalNewlines": true,
14+
15+
// ===
16+
// Event Triggers
17+
// ===
18+
19+
"editor.formatOnSave": true,
20+
"eslint.autoFixOnSave": true,
21+
"eslint.run": "onSave",
22+
"eslint.validate": [
23+
{ "language": "javascript", "autoFix": true },
24+
{ "language": "javascriptreact", "autoFix": true }
25+
],
26+
"prettier.disableLanguages": [],
27+
"workbench.colorCustomizations": {}
28+
}

.webpack/webpack.config.js

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
const path = require('path');
2+
const webpack = require('webpack');
3+
const autoprefixer = require('autoprefixer');
4+
// Plugins
5+
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer')
6+
.BundleAnalyzerPlugin;
7+
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
8+
const vtkRules = require('vtk.js/Utilities/config/dependency.js').webpack.core
9+
.rules;
10+
11+
const ENTRY_VTK_EXT = path.join(__dirname, './../src/index.js');
12+
const SRC_PATH = path.join(__dirname, './../src');
13+
const OUT_PATH = path.join(__dirname, './../dist');
14+
15+
/**
16+
* `argv` are options from the CLI. They will override our config here if set.
17+
* `-d` - Development shorthand, sets `debug`, `devtool`, and `mode`
18+
* `-p` - Production shorthand, sets `minimize`, `NODE_ENV`, and `mode`
19+
*/
20+
module.exports = (env, argv) => {
21+
const isProdBuild = argv.mode !== 'development';
22+
const outputFilename = isProdBuild ? '[name].umd.min.js' : '[name].umd.js';
23+
24+
return {
25+
entry: {
26+
vtkViewport: ENTRY_VTK_EXT,
27+
},
28+
devtool: 'source-map',
29+
output: {
30+
path: OUT_PATH,
31+
filename: outputFilename,
32+
library: 'VTKViewport',
33+
libraryTarget: 'umd',
34+
globalObject: 'this',
35+
},
36+
module: {
37+
rules: [
38+
{
39+
test: /\.(js|jsx)$/,
40+
exclude: /node_modules/,
41+
use: ['babel-loader'],
42+
},
43+
{
44+
test: /\.css$/,
45+
exclude: /\.module\.css$/,
46+
use: [
47+
'style-loader',
48+
'css-loader',
49+
{
50+
loader: 'postcss-loader',
51+
options: {
52+
plugins: () => [autoprefixer('last 2 version', 'ie >= 10')],
53+
},
54+
},
55+
],
56+
},
57+
].concat(vtkRules),
58+
},
59+
resolve: {
60+
modules: [path.resolve(__dirname, './../node_modules'), SRC_PATH],
61+
},
62+
externals: [
63+
// Used to build/load metadata
64+
{
65+
'cornerstone-core': {
66+
commonjs: 'cornerstone-core',
67+
commonjs2: 'cornerstone-core',
68+
amd: 'cornerstone-core',
69+
root: 'cornerstone',
70+
},
71+
// Vector 3 use
72+
'cornerstone-math': {
73+
commonjs: 'cornerstone-math',
74+
commonjs2: 'cornerstone-math',
75+
amd: 'cornerstone-math',
76+
root: 'cornerstoneMath',
77+
},
78+
//
79+
react: 'react',
80+
// https://webpack.js.org/guides/author-libraries/#external-limitations
81+
'vtk.js/Sources': {
82+
commonjs: 'vtk.js',
83+
commonjs2: 'vtk.js',
84+
amd: 'vtk.js',
85+
root: 'vtk.js',
86+
},
87+
},
88+
],
89+
node: {
90+
// https://github.com/webpack-contrib/style-loader/issues/200
91+
Buffer: false,
92+
},
93+
plugins: [
94+
// Uncomment to generate bundle analyzer
95+
new BundleAnalyzerPlugin(),
96+
// Show build progress
97+
new webpack.ProgressPlugin(),
98+
// Clear dist between builds
99+
// new CleanWebpackPlugin(),
100+
],
101+
};
102+
};

.webpack/webpack.dev.js

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
const path = require('path');
2+
const webpack = require('webpack');
3+
// Plugins
4+
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
5+
const HtmlWebpackPlugin = require('html-webpack-plugin');
6+
7+
const ENTRY_VIEWPORT = path.join(__dirname, './../src/index.js');
8+
const ENTRY_EXAMPLES = path.join(__dirname, './../examples/index.js');
9+
const SRC_PATH = path.join(__dirname, './../src');
10+
const OUT_PATH = path.join(__dirname, './../dist');
11+
12+
module.exports = {
13+
entry: {
14+
examples: ENTRY_EXAMPLES,
15+
},
16+
devtool: 'source-map',
17+
output: {
18+
path: OUT_PATH,
19+
filename: '[name].bundle.[hash].js',
20+
library: 'cornerstoneViewport',
21+
libraryTarget: 'umd',
22+
globalObject: 'this',
23+
},
24+
module: {
25+
rules: [
26+
{
27+
test: /\.(js|jsx)$/,
28+
exclude: /node_modules/,
29+
use: ['babel-loader'],
30+
},
31+
{
32+
test: /\.css$/,
33+
exclude: /\.module\.css$/,
34+
use: ['style-loader', 'css-loader'],
35+
},
36+
],
37+
},
38+
resolve: {
39+
modules: [path.resolve(__dirname, './../node_modules'), SRC_PATH],
40+
alias: {
41+
'@cornerstone-viewport': ENTRY_VIEWPORT,
42+
},
43+
},
44+
plugins: [
45+
// Show build progress
46+
new webpack.ProgressPlugin(),
47+
// Clear dist between builds
48+
new CleanWebpackPlugin(),
49+
// Generate `index.html` with injected build assets
50+
new HtmlWebpackPlugin({
51+
filename: 'index.html',
52+
template: path.resolve(__dirname, '..', 'examples', 'index.html'),
53+
}),
54+
],
55+
// Fix for `cornerstone-wado-image-loader` fs dep
56+
node: { fs: 'empty' },
57+
devServer: {
58+
hot: true,
59+
open: true,
60+
port: 3000,
61+
historyApiFallback: {
62+
disableDotRule: true,
63+
},
64+
},
65+
};

0 commit comments

Comments
 (0)