fix: webpack import bugs showing warnings on import (#4265)

This commit is contained in:
Bill Wallace authored and GitHub committed 2024-07-05 13:19:42 -04:00
1 parent 6d11048ca5
commit 24c511f4bc
23 files changed
+975 -1008

No files matched your search

+3 -3
View File
@@ -46,9 +46,9 @@
},
"dependencies": {
"@babel/runtime": "^7.20.13",
"@cornerstonejs/adapters": "^1.81.6",
"@cornerstonejs/core": "^1.81.6",
"@cornerstonejs/tools": "^1.81.6",
"@cornerstonejs/adapters": "^1.82.0",
"@cornerstonejs/core": "^1.82.0",
"@cornerstonejs/tools": "^1.82.0",
"classnames": "^2.3.2"
}
}
@@ -42,9 +42,9 @@
},
"dependencies": {
"@babel/runtime": "^7.20.13",
"@cornerstonejs/core": "^1.81.6",
"@cornerstonejs/streaming-image-volume-loader": "^1.81.6",
"@cornerstonejs/tools": "^1.81.6",
"@cornerstonejs/core": "^1.82.0",
"@cornerstonejs/streaming-image-volume-loader": "^1.82.0",
"@cornerstonejs/tools": "^1.82.0",
"classnames": "^2.3.2"
}
}
+5 -5
View File
@@ -38,7 +38,7 @@
"@cornerstonejs/codec-libjpeg-turbo-8bit": "^1.2.2",
"@cornerstonejs/codec-openjpeg": "^1.2.2",
"@cornerstonejs/codec-openjph": "^2.4.2",
"@cornerstonejs/dicom-image-loader": "^1.81.6",
"@cornerstonejs/dicom-image-loader": "^1.82.0",
"@icr/polyseg-wasm": "^0.4.0",
"@ohif/core": "3.9.0-beta.58",
"@ohif/ui": "3.9.0-beta.58",
@@ -55,10 +55,10 @@
},
"dependencies": {
"@babel/runtime": "^7.20.13",
"@cornerstonejs/adapters": "^1.81.6",
"@cornerstonejs/core": "^1.81.6",
"@cornerstonejs/streaming-image-volume-loader": "^1.81.6",
"@cornerstonejs/tools": "^1.81.6",
"@cornerstonejs/adapters": "^1.82.0",
"@cornerstonejs/core": "^1.82.0",
"@cornerstonejs/streaming-image-volume-loader": "^1.82.0",
"@cornerstonejs/tools": "^1.82.0",
"@icr/polyseg-wasm": "^0.4.0",
"@kitware/vtk.js": "30.4.1",
"html2canvas": "^1.4.1",
+4 -3
View File
@@ -37,8 +37,8 @@ import { colormaps } from './utils/colormaps';
const { registerColormap } = csUtilities.colormap;
// TODO: Cypress tests are currently grabbing this from the window?
window.cornerstone = cornerstone;
window.cornerstoneTools = cornerstoneTools;
(window as any).cornerstone = cornerstone;
(window as any).cornerstoneTools = cornerstoneTools;
/**
*
*/
@@ -46,7 +46,7 @@ export default async function init({
servicesManager,
commandsManager,
extensionManager,
appConfig,
appConfig
}: Types.Extensions.ExtensionParams): Promise<void> {
// Note: this should run first before initializing the cornerstone
// DO NOT CHANGE THE ORDER
@@ -67,6 +67,7 @@ export default async function init({
preferSizeOverAccuracy: Boolean(appConfig.preferSizeOverAccuracy),
useNorm16Texture: Boolean(appConfig.useNorm16Texture),
},
peerImport: appConfig.peerImport,
});
// For debugging e2e tests that are failing on CI
@@ -49,13 +49,6 @@ class DicomMicroscopyViewport extends Component {
resizeRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({ current: PropTypes.any })]),
};
/**
* Need to return this as a function to prevent webpack from munging it.
*/
public static getImportPath() {
return '/dicom-microscopy-viewer/dicomMicroscopyViewer.min.js';
}
/**
* Get the nearest ROI from the mouse click point
@@ -94,9 +87,8 @@ class DicomMicroscopyViewport extends Component {
// you should only do this once.
async installOpenLayersRenderer(container, displaySet) {
const loadViewer = async metadata => {
await import(
/* webpackIgnore: true */ DicomMicroscopyViewport.getImportPath());
const { viewer: DicomMicroscopyViewer, metadata: metadataUtils } = (window as any).dicomMicroscopyViewer;
const dicomMicroscopyModule = await this.microscopyService.importDicomMicroscopyViewer();
const { viewer: DicomMicroscopyViewer, metadata: metadataUtils } = dicomMicroscopyModule;
const microscopyViewer = DicomMicroscopyViewer.VolumeImageViewer;
@@ -1,5 +1,5 @@
import React from 'react';
import { CommandsManager, ExtensionManager } from '@ohif/core';
import type { Types } from '@ohif/core';
import { useViewportGrid } from '@ohif/ui';
import MicroscopyPanel from './components/MicroscopyPanel/MicroscopyPanel';
@@ -12,11 +12,7 @@ export default function getPanelModule({
commandsManager,
extensionManager,
servicesManager,
}: {
servicesManager: AppTypes.ServicesManager;
commandsManager: CommandsManager;
extensionManager: ExtensionManager;
}) {
}: Types.Extensions.ExtensionParams) {
const wrappedMeasurementPanel = () => {
const [{ activeViewportId, viewports }] = useViewportGrid();
@@ -44,6 +44,7 @@ const extension: Types.Extensions.Extension = {
* that is provided by the Cornerstone extension in OHIF.
*/
getViewportModule({ servicesManager, extensionManager, commandsManager }) {
/**
*
* @param props {*}
@@ -22,8 +22,8 @@ export default class MicroscopyService extends PubSubService {
return {
name: 'microscopyService',
altName: 'MicroscopyService',
create: ({ configuration = {} }) => {
return new MicroscopyService(servicesManager);
create: (props) => {
return new MicroscopyService(props);
},
};
};
@@ -36,9 +36,10 @@ export default class MicroscopyService extends PubSubService {
selectedAnnotation = null;
pendingFocus = false;
constructor(servicesManager) {
constructor({ servicesManager, extensionManager }) {
super(EVENTS);
this.servicesManager = servicesManager;
this.peerImport = extensionManager.appConfig.peerImport;
this._onRoiAdded = this._onRoiAdded.bind(this);
this._onRoiModified = this._onRoiModified.bind(this);
this._onRoiRemoved = this._onRoiRemoved.bind(this);
@@ -69,6 +70,10 @@ export default class MicroscopyService extends PubSubService {
});
}
public importDicomMicroscopyViewer(): Promise<any> {
return this.peerImport("dicom-microscopy-viewer");
}
/**
* Observes when a ROI graphic is added, creating the correspondent annotation
* with the current graphic and view state.
@@ -2,7 +2,6 @@ import dcmjs from 'dcmjs';
import DCM_CODE_VALUES from './dcmCodeValues';
import toArray from './toArray';
import DicomMicroscopyViewport from '../DicomMicroscopyViewport';
const MeasurementReport = dcmjs.adapters.DICOMMicroscopyViewer.MeasurementReport;
@@ -24,7 +23,7 @@ export default async function loadSR(
microscopySRDisplaySet.isLoaded = true;
const { rois, labels } = await _getROIsFromToolState(naturalizedDataset, FrameOfReferenceUID);
const { rois, labels } = await _getROIsFromToolState(microscopyService, naturalizedDataset, FrameOfReferenceUID);
const managedViewer = managedViewers[0];
@@ -45,12 +44,11 @@ export default async function loadSR(
}
}
async function _getROIsFromToolState(naturalizedDataset, FrameOfReferenceUID) {
async function _getROIsFromToolState(microscopyService, naturalizedDataset, FrameOfReferenceUID) {
const toolState = MeasurementReport.generateToolState(naturalizedDataset);
const tools = Object.getOwnPropertyNames(toolState);
// Does a dynamic import to prevent webpack from rebuilding the library
await import(/* webpackIgnore: true */ DicomMicroscopyViewport.getImportPath());
const DICOMMicroscopyViewer = (window as any).dicomMicroscopyViewer;
const DICOMMicroscopyViewer = await microscopyService.importDicomMicroscopyViewer();
const measurementGroupContentItems = _getMeasurementGroups(naturalizedDataset);
+2 -2
View File
@@ -32,8 +32,8 @@
"start": "yarn run dev"
},
"peerDependencies": {
"@cornerstonejs/core": "^1.81.6",
"@cornerstonejs/tools": "^1.81.6",
"@cornerstonejs/core": "^1.82.0",
"@cornerstonejs/tools": "^1.82.0",
"@ohif/core": "3.9.0-beta.58",
"@ohif/extension-cornerstone-dicom-sr": "3.9.0-beta.58",
"@ohif/ui": "3.9.0-beta.58",