add basic non dicom support
This commit is contained in:
@@ -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()
|
||||
}
|
||||
Reference in New Issue
Block a user