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

@@ -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);