From 4c8a808a12718865501e362ce37c2d2f75a1a687 Mon Sep 17 00:00:00 2001 From: Ibrahim <93064150+IbrahimCSAE@users.noreply.github.com> Date: Fri, 24 May 2024 12:21:09 -0400 Subject: [PATCH] feat(types): typed app config (#4171) --- platform/app/public/config/aws.js | 2 + platform/app/public/config/default.js | 3 +- platform/app/public/config/default_16bit.js | 1 + platform/app/public/config/demo.js | 1 + platform/app/public/config/dicomweb-server.js | 1 + .../app/public/config/dicomweb_relative.js | 1 + .../app/public/config/docker_nginx-orthanc.js | 1 + .../docker_openresty-orthanc-keycloak.js | 1 + .../public/config/docker_openresty-orthanc.js | 1 + platform/app/public/config/e2e.js | 1 + platform/app/public/config/google.js | 1 + platform/app/public/config/idc.js | 1 + platform/app/public/config/local_dcm4chee.js | 1 + platform/app/public/config/local_orthanc.js | 1 + platform/app/public/config/local_static.js | 1 + platform/app/public/config/multiple.js | 1 + platform/app/public/config/netlify.js | 2 + .../core/src/extensions/ExtensionManager.ts | 3 +- platform/core/src/types/AppConfig.ts | 21 ------- platform/core/src/types/AppTypes.ts | 56 +++++++++++++++++++ platform/core/src/types/index.ts | 1 - tsconfig.json | 2 +- 22 files changed, 78 insertions(+), 26 deletions(-) delete mode 100644 platform/core/src/types/AppConfig.ts diff --git a/platform/app/public/config/aws.js b/platform/app/public/config/aws.js index f7dd9a0698..fdba3e035c 100644 --- a/platform/app/public/config/aws.js +++ b/platform/app/public/config/aws.js @@ -1,3 +1,5 @@ +/** @type {AppTypes.Config} */ + window.config = { routerBasename: '/', extensions: [], diff --git a/platform/app/public/config/default.js b/platform/app/public/config/default.js index f3c38f2806..62ff50cf9b 100644 --- a/platform/app/public/config/default.js +++ b/platform/app/public/config/default.js @@ -1,4 +1,5 @@ -/** @type {import('@ohif/core').OHIFConfig} */ +/** @type {AppTypes.Config} */ + const config = { routerBasename: '/', // whiteLabeling: {}, diff --git a/platform/app/public/config/default_16bit.js b/platform/app/public/config/default_16bit.js index 6ea7439990..4c11977ccc 100644 --- a/platform/app/public/config/default_16bit.js +++ b/platform/app/public/config/default_16bit.js @@ -1,3 +1,4 @@ +/** @type {AppTypes.Config} */ window.config = { routerBasename: '/', // whiteLabeling: {}, diff --git a/platform/app/public/config/demo.js b/platform/app/public/config/demo.js index 5dbd96ab15..d421506cd2 100644 --- a/platform/app/public/config/demo.js +++ b/platform/app/public/config/demo.js @@ -1,3 +1,4 @@ +/** @type {AppTypes.Config} */ window.config = { routerBasename: '/', modes: [], diff --git a/platform/app/public/config/dicomweb-server.js b/platform/app/public/config/dicomweb-server.js index a3522e587c..874e7507d4 100644 --- a/platform/app/public/config/dicomweb-server.js +++ b/platform/app/public/config/dicomweb-server.js @@ -1,3 +1,4 @@ +/** @type {AppTypes.Config} */ window.config = { routerBasename: '/', extensions: [], diff --git a/platform/app/public/config/dicomweb_relative.js b/platform/app/public/config/dicomweb_relative.js index bfa51c34ae..69752ea3a7 100644 --- a/platform/app/public/config/dicomweb_relative.js +++ b/platform/app/public/config/dicomweb_relative.js @@ -1,3 +1,4 @@ +/** @type {AppTypes.Config} */ window.config = { routerBasename: '/', extensions: [], diff --git a/platform/app/public/config/docker_nginx-orthanc.js b/platform/app/public/config/docker_nginx-orthanc.js index 97316bc8ad..801696ccdf 100644 --- a/platform/app/public/config/docker_nginx-orthanc.js +++ b/platform/app/public/config/docker_nginx-orthanc.js @@ -1,3 +1,4 @@ +/** @type {AppTypes.Config} */ window.config = { routerBasename: '/', showStudyList: true, diff --git a/platform/app/public/config/docker_openresty-orthanc-keycloak.js b/platform/app/public/config/docker_openresty-orthanc-keycloak.js index 5e9f7854f3..f3b86852c6 100644 --- a/platform/app/public/config/docker_openresty-orthanc-keycloak.js +++ b/platform/app/public/config/docker_openresty-orthanc-keycloak.js @@ -1,3 +1,4 @@ +/** @type {AppTypes.Config} */ window.config = { routerBasename: '/', showStudyList: true, diff --git a/platform/app/public/config/docker_openresty-orthanc.js b/platform/app/public/config/docker_openresty-orthanc.js index 2500760bf2..1acdff5044 100644 --- a/platform/app/public/config/docker_openresty-orthanc.js +++ b/platform/app/public/config/docker_openresty-orthanc.js @@ -1,3 +1,4 @@ +/** @type {AppTypes.Config} */ window.config = { routerBasename: '/', showStudyList: true, diff --git a/platform/app/public/config/e2e.js b/platform/app/public/config/e2e.js index 90827b906c..896b07b4f0 100644 --- a/platform/app/public/config/e2e.js +++ b/platform/app/public/config/e2e.js @@ -1,3 +1,4 @@ +/** @type {AppTypes.Config} */ window.config = { routerBasename: '/', extensions: [], diff --git a/platform/app/public/config/google.js b/platform/app/public/config/google.js index b380a21a72..e416a9e811 100644 --- a/platform/app/public/config/google.js +++ b/platform/app/public/config/google.js @@ -1,3 +1,4 @@ +/** @type {AppTypes.Config} */ window.config = { routerBasename: '/', customizationService: { diff --git a/platform/app/public/config/idc.js b/platform/app/public/config/idc.js index 0089182ee9..5f08c83e5b 100644 --- a/platform/app/public/config/idc.js +++ b/platform/app/public/config/idc.js @@ -1,3 +1,4 @@ +/** @type {AppTypes.Config} */ window.config = { routerBasename: '/', enableGoogleCloudAdapter: true, diff --git a/platform/app/public/config/local_dcm4chee.js b/platform/app/public/config/local_dcm4chee.js index a521bfef06..5148bf4a4a 100644 --- a/platform/app/public/config/local_dcm4chee.js +++ b/platform/app/public/config/local_dcm4chee.js @@ -1,3 +1,4 @@ +/** @type {AppTypes.Config} */ window.config = { routerBasename: '/', customizationService: { diff --git a/platform/app/public/config/local_orthanc.js b/platform/app/public/config/local_orthanc.js index 9fd18992cd..14c4b6d9c6 100644 --- a/platform/app/public/config/local_orthanc.js +++ b/platform/app/public/config/local_orthanc.js @@ -1,3 +1,4 @@ +/** @type {AppTypes.Config} */ window.config = { routerBasename: '/', extensions: [], diff --git a/platform/app/public/config/local_static.js b/platform/app/public/config/local_static.js index 7bd03c87eb..2e2131c0b0 100644 --- a/platform/app/public/config/local_static.js +++ b/platform/app/public/config/local_static.js @@ -1,3 +1,4 @@ +/** @type {AppTypes.Config} */ window.config = { routerBasename: '/', customizationService: ['@ohif/extension-default.customizationModule.helloPage'], diff --git a/platform/app/public/config/multiple.js b/platform/app/public/config/multiple.js index 57684a9ef5..d02715d2e7 100644 --- a/platform/app/public/config/multiple.js +++ b/platform/app/public/config/multiple.js @@ -1,3 +1,4 @@ +/** @type {AppTypes.Config} */ window.config = { // Activate the new HP mode.... isNewHP: true, diff --git a/platform/app/public/config/netlify.js b/platform/app/public/config/netlify.js index e4907a839f..531bb9b3f0 100644 --- a/platform/app/public/config/netlify.js +++ b/platform/app/public/config/netlify.js @@ -1,3 +1,5 @@ +/** @type {AppTypes.Config} */ + window.config = { routerBasename: '/', extensions: [], diff --git a/platform/core/src/extensions/ExtensionManager.ts b/platform/core/src/extensions/ExtensionManager.ts index e8f7fcadf2..45f668e02a 100644 --- a/platform/core/src/extensions/ExtensionManager.ts +++ b/platform/core/src/extensions/ExtensionManager.ts @@ -1,6 +1,5 @@ import MODULE_TYPES from './MODULE_TYPES'; import log from '../log'; -import { AppConfig } from '../types/AppConfig'; import { PubSubService, ServiceProvidersManager } from '../services'; import { HotkeysManager, CommandsManager } from '../classes'; import { DataSourceDefinition } from '../types'; @@ -13,7 +12,7 @@ export interface ExtensionConstructor { serviceProvidersManager: ServiceProvidersManager; commandsManager: CommandsManager; hotkeysManager: HotkeysManager; - appConfig: AppConfig; + appConfig: AppTypes.Config; } /** diff --git a/platform/core/src/types/AppConfig.ts b/platform/core/src/types/AppConfig.ts deleted file mode 100644 index d63c4146b3..0000000000 --- a/platform/core/src/types/AppConfig.ts +++ /dev/null @@ -1,21 +0,0 @@ -import Hotkey from '../classes/Hotkey'; - -export interface AppConfig { - extensions?: string[]; - defaultDataSourceName?: string; - hotkeys?: Record | Hotkey[]; - useSharedArrayBuffer?: string; - preferSizeOverAccuracy?: boolean; - useNorm16Texture?: boolean; - useCPURendering?: boolean; - strictZSpacingForVolumeViewport?: boolean; - useCursors?: boolean; - maxCacheSize?: number; - showWarningMessageForCrossOrigin?: boolean; - showCPUFallbackMessage?: boolean; - maxNumRequests?: { - interaction?: number; - prefetch?: number; - thumbnail?: number; - }; -} diff --git a/platform/core/src/types/AppTypes.ts b/platform/core/src/types/AppTypes.ts index 0354d7afd4..f5c914e202 100644 --- a/platform/core/src/types/AppTypes.ts +++ b/platform/core/src/types/AppTypes.ts @@ -19,6 +19,8 @@ import ServicesManagerType from '../services/ServicesManager'; import CommandsManagerType from '../classes/CommandsManager'; import ExtensionManagerType from '../extensions/ExtensionManager'; +import Hotkey from '../classes/Hotkey'; + declare global { namespace AppTypes { export type ServicesManager = ServicesManagerType; @@ -63,6 +65,60 @@ declare global { uiViewportDialogService?: UIViewportDialogServiceType; panelService?: PanelServiceType; } + export interface Config { + routerBasename?: string; + customizationService?: any; + extensions?: string[]; + modes?: string[]; + defaultDataSourceName?: string; + hotkeys?: Record | Hotkey[]; + useSharedArrayBuffer?: 'AUTO' | 'FALSE' | 'TRUE'; + preferSizeOverAccuracy?: boolean; + useNorm16Texture?: boolean; + useCPURendering?: boolean; + strictZSpacingForVolumeViewport?: boolean; + useCursors?: boolean; + maxCacheSize?: number; + max3DTextureSize?: number; + showWarningMessageForCrossOrigin?: boolean; + showCPUFallbackMessage?: boolean; + maxNumRequests?: { + interaction?: number; + prefetch?: number; + thumbnail?: number; + }; + disableEditing?: boolean; + maxNumberOfWebWorkers?: number; + acceptHeader?: string[]; + investigationalUseDialog?: { + option: 'always' | 'never' | 'configure'; + days?: number; + }; + groupEnabledModesFirst?: boolean; + disableConfirmationPrompts?: boolean; + showPatientInfo?: 'visible' | 'visibleCollapsed' | 'disabled' | 'visibleReadOnly'; + requestTransferSyntaxUID?: string; + omitQuotationForMultipartRequest?: boolean; + modesConfiguration?: { + [key: string]: object; + }; + showLoadingIndicator?: boolean; + supportsWildcard?: boolean; + allowMultiSelectExport?: boolean; + activateViewportBeforeInteraction?: boolean; + autoPlayCine?: boolean; + showStudyList?: boolean; + whiteLabeling?: any; + httpErrorHandler?: any; + addWindowLevelActionMenu?: boolean; + dangerouslyUseDynamicConfig?: { + enabled: boolean; + regex: RegExp; + }; + onConfiguration?: (dicomWebConfig: any, options: any) => any; + dataSources?: any; + oidc?: any; + } } export type withAppTypes = T & diff --git a/platform/core/src/types/index.ts b/platform/core/src/types/index.ts index 15c428e3db..b9e9805fc3 100644 --- a/platform/core/src/types/index.ts +++ b/platform/core/src/types/index.ts @@ -11,7 +11,6 @@ import type { PresentationIds } from '../services/ViewportGridService'; export type * from '../services/CustomizationService/types'; // Separate out some generic types -export type * from './AppConfig'; export type * from './Consumer'; export type * from './Command'; export type * from './DisplaySet'; diff --git a/tsconfig.json b/tsconfig.json index 44e34356da..762d860007 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -19,6 +19,6 @@ "@ohif/app": ["platform/app/src"] } }, - "include": ["platform/**/src/**/*", "extensions/**/src/**/*", "modes/**/src/**/*"], + "include": ["platform/**/src/**/*", "platform/**/public/**/*", "extensions/**/src/**/*", "modes/**/src/**/*"], "exclude": ["node_modules", "dist"] }