Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | // platform/app/src/runtimeShared.ts
// v1 shared-dependency contract for runtime-loaded (UMD) plugins: the host
// assigns its singleton copies to window, keyed by FULL package name. Plugin
// bundles list these as externals (.rspack/pluginExternals.js) and resolve
// them from these globals — e.g. @ohif/ui-next's own UMD build externalizes
// '@ohif/ui-next', which the global assigned here satisfies. MUST stay in
// sync with pluginExternals.hostSharedPackages — enforced by
// runtimeShared.test.js.
//
// Namespace imports are deliberate: consumers get both named exports and the
// bundler's __esModule/default interop, so a plugin's `import React from
// 'react'` resolves window['react'].default and `import { useState }`
// resolves the named export.
//
// Freeze note: every package listed here (and its public API surface) is part
// of the plugin-facing contract from the moment it ships. Runtime plugins
// bind to these globals without being rebuilt against the host, so removing
// an entry, renaming exports, or making breaking API changes in a shared
// package breaks already-published plugins. Treat additions as permanent and
// coordinate any change with a major version of the contract. Moving a
// shared third-party package to a new major version is such a change too:
// runtimeShared.test.js pins those majors, and fails until the migration
// guide and the documented shared versions are updated.
//
// Every extension and mode compiled into the viewer is ALSO put on window, by
// the generated plugin loader once it has loaded (sharePlugin in
// runtimeExtensionLoader.ts; extensions loaded on demand appear only then).
// Those globals are a second tier with no compatibility promise; this list is
// the stable one, assigned before the first runtime plugin is fetched
// (shareHostPackages in runtimeExtensionLoader.ts).
//
// @ohif/i18n is shared because runtime extensions dereference it during
// module evaluation (e.g. dicom-pdf). @ohif/ui is intentionally NOT shared:
// it is legacy and a forbidden import for runtime plugins. React Router and
// i18next are shared so a plugin uses the host's Router and its one i18next
// instance; a plugin's own copy of either sees neither.
import * as react from 'react';
import * as reactDom from 'react-dom';
import * as reactJsxRuntime from 'react/jsx-runtime';
import * as ohifCore from '@ohif/core';
import * as ohifUiNext from '@ohif/ui-next';
import * as ohifI18n from '@ohif/i18n';
import * as ohifExtensionDefault from '@ohif/extension-default';
import * as ohifExtensionCornerstone from '@ohif/extension-cornerstone';
import * as cornerstoneCore from '@cornerstonejs/core';
import * as cornerstoneTools from '@cornerstonejs/tools';
import * as dcmjs from 'dcmjs';
import * as glMatrix from 'gl-matrix';
import * as reactRouter from 'react-router';
import * as reactRouterDom from 'react-router-dom';
import * as i18next from 'i18next';
import * as reactI18next from 'react-i18next';
const shared: Record<string, unknown> = {
react,
'react-dom': reactDom,
'react/jsx-runtime': reactJsxRuntime,
'@ohif/core': ohifCore,
'@ohif/ui-next': ohifUiNext,
'@ohif/i18n': ohifI18n,
'@ohif/extension-default': ohifExtensionDefault,
'@ohif/extension-cornerstone': ohifExtensionCornerstone,
'@cornerstonejs/core': cornerstoneCore,
'@cornerstonejs/tools': cornerstoneTools,
dcmjs,
'gl-matrix': glMatrix,
'react-router': reactRouter,
'react-router-dom': reactRouterDom,
i18next,
'react-i18next': reactI18next,
};
Object.entries(shared).forEach(([name, mod]) => {
(window as unknown as Record<string, unknown>)[name] = mod;
});
|