diff --git a/dicom-viewer/public/non-dicom-test.html b/dicom-viewer/public/non-dicom-test.html new file mode 100644 index 0000000..329e8b5 --- /dev/null +++ b/dicom-viewer/public/non-dicom-test.html @@ -0,0 +1,25 @@ + + + + + + DV3D — Non-DICOM Test + + + +
+ + + + + + diff --git a/dicom-viewer/src/nonDicomTest.tsx b/dicom-viewer/src/nonDicomTest.tsx new file mode 100644 index 0000000..6d4aad5 --- /dev/null +++ b/dicom-viewer/src/nonDicomTest.tsx @@ -0,0 +1,50 @@ +import React from 'react' +import { createRoot } from 'react-dom/client' + +// Sample external images (use CORS-friendly URLs). These are Wikimedia Commons images. +const sampleImages = [ + 'https://upload.wikimedia.org/wikipedia/commons/4/47/PNG_transparency_demonstration_1.png', + 'https://upload.wikimedia.org/wikipedia/commons/6/6a/PNG_Test.png', +] + +// Helper to prefix with `external:` scheme used by the app's loader +const toExternal = (urls: string[]) => urls.map(u => u.startsWith('external:') ? u : `external:${u}`) + +function mount() { + const container = document.getElementById('non-dicom-root') + if (!container) return + + const imageStacks = () => { + // Return a single stack with our sample images + return Promise.resolve([ + { + imageIds: toExternal(sampleImages), + name: 'Non-DICOM Sample Stack', + }, + ]) + } + + // Ensure React Refresh globals exist before loading App so plugin-react + // preamble checks won't fail during HMR. We then dynamically import App. + // This guarantees the globals are set before App is evaluated. + // Provide no-op implementations when not present. + ;(window as any).$RefreshReg$ = (window as any).$RefreshReg$ || function() {} + ;(window as any).$RefreshSig$ = (window as any).$RefreshSig$ || function() { return function(type: any) { return type; }; } + + import('./App').then(({ default: App }) => { + createRoot(container).render( + + + + ) + }).catch(err => { + console.error('Failed to load App for non-dicom test', err) + }) +} + +// Wait for DOM +if (document.readyState === 'loading') { + document.addEventListener('DOMContentLoaded', mount) +} else { + mount() +}