Compare commits

..

6 Commits

Author SHA1 Message Date
Ross f323dfd559 imrove multiuser sync support 2026-06-29 09:38:26 +01:00
Ross 0c4da6e022 multiuser sync updates 2026-06-22 09:37:08 +01:00
Ross d0f3431ef4 start ortho automode 2026-06-08 13:50:42 +01:00
Ross b961a806d9 start implmeentting proper crosshairs 2026-06-08 12:51:08 +01:00
Ross 1ddc9a810a update 2026-06-08 09:50:55 +01:00
Ross b2bd2791a5 fix some loading issues and rework cine button 2026-05-28 22:53:52 +01:00
2 changed files with 1383 additions and 166 deletions
+1356 -163
View File
File diff suppressed because it is too large Load Diff
+27 -3
View File
@@ -49,7 +49,7 @@ type RootRecord = {
signature: string;
};
const rootRegistry = new WeakMap<HTMLElement, RootRecord>();
const rootRegistry = new Map<HTMLElement, RootRecord>();
const mainLogger = logger.child("main");
declare global {
@@ -176,13 +176,21 @@ const shouldMountContainer = (container: HTMLElement, options?: MountOptions): b
};
const getContainerLogConfig = (container: HTMLElement, options?: MountOptions) => {
const urlParams = new URLSearchParams(window.location.search);
const urlDebug = urlParams.get("debug");
const localSyncDebug = typeof window !== "undefined" && window.localStorage ? window.localStorage.getItem("multiuser_sync_debug_mode") : null;
const attrLevel = container.getAttribute("data-log-level");
const attrDebug = container.getAttribute("data-log-debug");
const attrFormat = container.getAttribute("data-log-format");
// Resolve minLevel: data-log-level > options.minLevel > data-log-debug (legacy) > options.debug (legacy)
// Resolve minLevel: LocalStorage debug > URL debug parameter > data-log-level > options.minLevel > data-log-debug (legacy)
let minLevel: LogLevel;
if (attrLevel !== null) {
if (localSyncDebug === "true") {
minLevel = "debug";
} else if (urlDebug !== null) {
minLevel = parseDebugFlag(urlDebug);
} else if (attrLevel !== null) {
minLevel = parseLogLevel(attrLevel);
} else if (options?.logging?.minLevel) {
minLevel = options.logging.minLevel;
@@ -223,6 +231,9 @@ const mountContainer = (container: HTMLElement, imageStacks: () => Promise<any[]
annotationJson={container.getAttribute("data-annotationjson") || undefined}
viewerState={container.getAttribute("data-viewerstate") || undefined}
initialLoggerConfig={initialLoggerConfig}
multiuserRoom={container.getAttribute("data-multiuser-room") || undefined}
username={container.getAttribute("data-username") || undefined}
isStaff={container.getAttribute("data-is-staff") === "true"}
/>
);
@@ -230,6 +241,19 @@ const mountContainer = (container: HTMLElement, imageStacks: () => Promise<any[]
};
export function mountDicomViewers(options?: MountOptions) {
// Clean up any stale roots from elements that have been removed from the DOM
for (const [container, entry] of rootRegistry.entries()) {
if (!document.body.contains(container)) {
try {
mainLogger.info("Unmounting stale React root for container that was removed from DOM:", container.id);
entry.root.unmount();
} catch (e) {
mainLogger.warn("Failed to unmount stale React root", e);
}
rootRegistry.delete(container);
}
}
// Test containers
const testContainers = document.querySelectorAll(".dicom-viewer-test-root");
testContainers.forEach((container) => {