add basic non dicom support
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>DV3D — Non-DICOM Test</title>
|
||||
<style>
|
||||
html,body { height:100%; margin:0; background:#111 }
|
||||
#non-dicom-root { width: 100vw; height: 100vh; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="non-dicom-root" class="dicom-viewer-root"></div>
|
||||
<!-- Provide a small noop React Refresh preamble to avoid plugin-react preamble errors -->
|
||||
<script>
|
||||
// If plugin-react's preamble wasn't injected for some reason, provide no-op
|
||||
// implementations so the runtime does not throw. This disables fast-refresh
|
||||
// semantics for this page but keeps HMR from crashing.
|
||||
window.$RefreshReg$ = window.$RefreshReg$ || function() {};
|
||||
window.$RefreshSig$ = window.$RefreshSig$ || function() { return function(type) { return type; }; };
|
||||
</script>
|
||||
<!-- Vite can load TSX modules directly in dev mode -->
|
||||
<script type="module" src="/src/nonDicomTest.tsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -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