# flexview-runtime-extension

> Base FlexView runtime extension utilities

Latest version **0.0.2** (published 2023-08-08) · 0 weekly downloads

## Install

```sh
npm install flexview-runtime-extension
pnpm add flexview-runtime-extension
yarn add flexview-runtime-extension
bun add flexview-runtime-extension
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.2 |
| Published | 2023-08-08 |
| First published | 2023-06-21 |
| Weekly downloads | 0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=14.14.0 <19.0.0 |
| Dependencies | 1 |
| Unpacked size | 51.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Radical Imaging |
| Maintainers | mateusfreira |

## Links

- npm: https://www.npmjs.com/package/flexview-runtime-extension
- Repository: https://github.com/RadicalImaging/FlexViewRuntimeExtension
- Homepage: https://github.com/RadicalImaging/FlexViewRuntimeExtension#readme
- Issues: https://github.com/RadicalImaging/FlexViewRuntimeExtension/issues
- npm.io page: https://npm.io/package/flexview-runtime-extension

## Dependencies (1)

- [typescript](https://npm.io/package/typescript.md) ^4.8.4

## Recent versions

- 0.0.2 (latest) — 2023-08-08
- 0.0.1 — 2023-06-21

## README

# Runtime Extension

This package was created to allow OHIF v3 extensions to be loaded at runtime.
This concept allows the extensions to be built independently from OHIF (even on
separate repositories) and injected during OHIF's initialization via
configuration.

## Using this package

To use this package, you must add it as a dependency of your OHIF v3 extension.
As it is a private repository, you must add path reference to your extension's
`package.json` file or use the `link` feature for both yarn or npm. It is also
possible to configure this repository to
[enable HTTPS+OAuth or SSH authentication](https://stackoverflow.com/questions/28728665/how-to-use-private-github-repo-as-npm-dependency)
and add the repository reference directly in the `package.json` file. Another
alternative would be to pay for npm subscriptions per user and use their private
packages feature. And a last alternative would be to
[host our own npm registry on cloud](https://medium.com/rockedscience/host-private-node-js-packages-on-the-google-cloud-with-artifact-registry-5426538f1afd)
and add this registry to our private repositories.

Whatever is the option you chose to install this package as a dependency of your
extension, you should now be able to import it and use by your extension's code.
Here is an example of how you can create and export your runtime extension:

```javascript
import { RuntimeExtension } from '@radicalimaging/runtime-extension';

const myExtension = {
  id: '@radicalimaging/extension-my',
  preRegistration: (params) => {/* CODE */}
  getHangingProtocolModule: (params) => { /* CODE */ }
  getPanelModule: (params) => {/* CODE */}
  getCommandsModule: (params) => {/* CODE */}
  onModeEnter: () => {/* CODE */}
  onModeExit: () => {/* CODE */}
  /* Other callbacks */
}

const my = {
  hangingProtocol: '@radicalimaging/extension-my.hangingProtocolModule.hp',
  panel1: '@radicalimaging/extension-my.panelModule.panel1',
  panel2: '@radicalimaging/extension-my.panelModule.panel2',
};

const myRuntimeExtension = new RuntimeExtension(myExtension, [{
  modeId: '@ohif/mode-one',
  routePath: 'routeA',
  leftPanels: [my.panel1],
  rightPanels: [my.panel2],
  viewports: [],
  hangingProtocolOverride: my.hangingProtocol,
}]);

export default myRuntimeExtension;
```

After your extension is ready to go, you can export it into a single JavaScript
bundle file. This file you can place directly in your OHIF v3 application root
directory and reference it by the `app-config.js` file under the
`window.config.runtimeExtensions`. Here is an example of the configuration:

```javascript
window.config = {
  ...
  runtimeExtensions: {
    '@radicalimaging/extension-my': './runtime-extensions/my/index.umd.js',
  },
  ...
};
```

For the example above, the JavaScript bundle file was placed on
`./runtime-extensions/my/` directory.

For more instructions on how to enable the runtime extension from the OHIF v3
side, please see this
[README.md](https://github.com/RadicalImaging/FlexViewRuntimeExtensionDemo/blob/runtime-extensions/runtime-extensions/README.md)
file of an actual extension that was ported to runtime extensions to serve as an
example.

---
_Source: https://npm.io/package/flexview-runtime-extension · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
