Better entrypoint for extensions
This commit is contained in:
parent
2429294dda
commit
c05058a0f5
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"packages": ["packages/*"],
|
"packages": ["extensions/*", "platform/*"],
|
||||||
"npmClient": "yarn",
|
"npmClient": "yarn",
|
||||||
"useWorkspaces": true,
|
"useWorkspaces": true,
|
||||||
"version": "independent"
|
"version": "independent"
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import './config';
|
import './config';
|
||||||
// Imported flat feature since is not transpiled for old browser versions
|
// Polyfills
|
||||||
import 'core-js/features/array/flat';
|
import 'core-js/features/array/flat';
|
||||||
import 'core-js/stable';
|
import 'core-js/stable';
|
||||||
import 'regenerator-runtime/runtime';
|
import 'regenerator-runtime/runtime';
|
||||||
@ -23,7 +23,6 @@ import initCornerstoneTools from './initCornerstoneTools.js';
|
|||||||
import { GenericViewerCommands, MeasurementsPanel } from './appExtensions';
|
import { GenericViewerCommands, MeasurementsPanel } from './appExtensions';
|
||||||
import OHIFCornerstoneExtension from '@ohif/extension-cornerstone';
|
import OHIFCornerstoneExtension from '@ohif/extension-cornerstone';
|
||||||
import OHIFStandaloneViewer from './OHIFStandaloneViewer';
|
import OHIFStandaloneViewer from './OHIFStandaloneViewer';
|
||||||
// ~~ EXTENSIONS
|
|
||||||
import { OidcProvider } from 'redux-oidc';
|
import { OidcProvider } from 'redux-oidc';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import { Provider } from 'react-redux';
|
import { Provider } from 'react-redux';
|
||||||
@ -131,6 +130,9 @@ class App extends Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param
|
||||||
|
*/
|
||||||
function _initExtensions(extensions) {
|
function _initExtensions(extensions) {
|
||||||
const defaultExtensions = [
|
const defaultExtensions = [
|
||||||
GenericViewerCommands,
|
GenericViewerCommands,
|
||||||
@ -140,13 +142,6 @@ function _initExtensions(extensions) {
|
|||||||
const mergedExtensions = defaultExtensions.concat(extensions);
|
const mergedExtensions = defaultExtensions.concat(extensions);
|
||||||
extensionManager.registerExtensions(mergedExtensions);
|
extensionManager.registerExtensions(mergedExtensions);
|
||||||
|
|
||||||
// [
|
|
||||||
// OHIFVTKExtension,
|
|
||||||
// OHIFDicomPDFExtension,
|
|
||||||
// OHIFDicomHtmlExtension,
|
|
||||||
// OHIFDicomMicroscopyExtension,
|
|
||||||
// ]
|
|
||||||
|
|
||||||
// Must run after extension commands are registered
|
// Must run after extension commands are registered
|
||||||
if (window.config.hotkeys) {
|
if (window.config.hotkeys) {
|
||||||
hotkeysManager.setHotkeys(window.config.hotkeys, true);
|
hotkeysManager.setHotkeys(window.config.hotkeys, true);
|
||||||
@ -160,6 +155,4 @@ function _initServers(servers) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default App;
|
export default App;
|
||||||
|
|
||||||
// Make our managers accessible
|
|
||||||
export { commandsManager, extensionManager, hotkeysManager };
|
export { commandsManager, extensionManager, hotkeysManager };
|
||||||
|
|||||||
@ -1,26 +1,47 @@
|
|||||||
/**
|
/**
|
||||||
* Entry point for development and production PWA builds.
|
* Entry point for development and production PWA builds.
|
||||||
* Packaged (NPM) builds go through `index_publish.js`
|
* Packaged (NPM) builds go through `index-umd.js`
|
||||||
*/
|
*/
|
||||||
import App from './App.js';
|
import App from './App.js';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import ReactDOM from 'react-dom';
|
import ReactDOM from 'react-dom';
|
||||||
|
|
||||||
// EXTENSIONS
|
/**
|
||||||
|
* EXTENSIONS
|
||||||
|
* =================
|
||||||
|
*
|
||||||
|
* Importing and modifying the extensions our app uses HERE allows us to leverage
|
||||||
|
* tree shaking and a few other niceties. However, by including them here they become
|
||||||
|
* "baked in" to the published application.
|
||||||
|
*
|
||||||
|
* Depending on your use case/needs, you may want to consider not adding any extensions
|
||||||
|
* by default HERE, and instead provide them via the configuration specified at
|
||||||
|
* `window.config.extensions`, or by using the exported `App` component, and passing
|
||||||
|
* in your extensions as props.
|
||||||
|
*/
|
||||||
import OHIFVTKExtension from '@ohif/extension-vtk';
|
import OHIFVTKExtension from '@ohif/extension-vtk';
|
||||||
import OHIFDicomHtmlExtension from '@ohif/extension-dicom-html';
|
import OHIFDicomHtmlExtension from '@ohif/extension-dicom-html';
|
||||||
import OHIFDicomMicroscopyExtension from '@ohif/extension-dicom-microscopy';
|
import OHIFDicomMicroscopyExtension from '@ohif/extension-dicom-microscopy';
|
||||||
import OHIFDicomPDFExtension from '@ohif/extension-dicom-pdf';
|
import OHIFDicomPDFExtension from '@ohif/extension-dicom-pdf';
|
||||||
|
|
||||||
// Default Settings
|
// Default Settings
|
||||||
window.config = window.config || {};
|
let config = {};
|
||||||
window.config.extensions = [OHIFVTKExtension];
|
|
||||||
|
|
||||||
const appDefaults = {
|
const appDefaults = {
|
||||||
routerBasename: '/',
|
routerBasename: '/',
|
||||||
relativeWebWorkerScriptsPath: '',
|
relativeWebWorkerScriptsPath: '',
|
||||||
};
|
};
|
||||||
const appProps = Object.assign({}, appDefaults, window.config);
|
|
||||||
|
if (window) {
|
||||||
|
config = window.config || {};
|
||||||
|
config.extensions = [
|
||||||
|
OHIFVTKExtension,
|
||||||
|
OHIFDicomHtmlExtension,
|
||||||
|
OHIFDicomMicroscopyExtension,
|
||||||
|
OHIFDicomPDFExtension,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
const appProps = Object.assign({}, appDefaults, config);
|
||||||
|
|
||||||
// Create App
|
// Create App
|
||||||
const app = React.createElement(App, appProps, null);
|
const app = React.createElement(App, appProps, null);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user