From 8960b89911a9342d93bf1a62bec97a696f101fd4 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 f7dd9a069..fdba3e035 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 f3c38f280..62ff50cf9 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 6ea743999..4c11977cc 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 5dbd96ab1..d421506cd 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 a3522e587..874e7507d 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 bfa51c34a..69752ea3a 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 97316bc8a..801696ccd 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 5e9f7854f..f3b86852c 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 2500760bf..1acdff504 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 90827b906..896b07b4f 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 b380a21a7..e416a9e81 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 0089182ee..5f08c83e5 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 a521bfef0..5148bf4a4 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 9fd18992c..14c4b6d9c 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 7bd03c87e..2e2131c0b 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 57684a9ef..d02715d2e 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 e4907a839..531bb9b3f 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 e8f7fcadf..45f668e02 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 d63c4146b..000000000 --- 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 0354d7afd..f5c914e20 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 15c428e3d..b9e9805fc 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 44e34356d..762d86000 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"] }