add basic non dicom support

This commit is contained in:
Ross
2025-12-15 11:39:44 +00:00
parent 72462b49ef
commit ef62ffac9f
2 changed files with 75 additions and 0 deletions
+50
View File
@@ -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(
<React.StrictMode>
<App container_id={'nondicom'} imageStacks={imageStacks} />
</React.StrictMode>
)
}).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()
}