From 03ab30ef729d9acfccaf3c356bb8a3312810a58c Mon Sep 17 00:00:00 2001 From: Colin Date: Wed, 30 Aug 2023 10:58:27 -0400 Subject: [PATCH] Plugins param --- package.json | 1 + srcjs/components/JsonView.jsx | 40 +++++++++++++++++++++++++++-------- yarn.lock | 5 +++++ 3 files changed, 37 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index 4145c6f..c3cd5ad 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ "@babel/preset-env": "^7.22.4", "@babel/preset-react": "^7.22.3", "babel-loader": "^9.1.2", + "prettier": "^3.0.3", "webpack": "^5.85.0", "webpack-cli": "^5.1.1" } diff --git a/srcjs/components/JsonView.jsx b/srcjs/components/JsonView.jsx index 51b7381..7bcde2c 100644 --- a/srcjs/components/JsonView.jsx +++ b/srcjs/components/JsonView.jsx @@ -7,17 +7,39 @@ import { messageShiny } from '../utils' export default function View(props) { const configObject = JSON.parse(props.config) - const { assembly, tracks, defaultSession, theme, text_index } = configObject - const location = props.location - const state = createViewState({ + const { assembly, tracks, defaultSession, - location, - onChange: messageShiny, - configuration: { theme }, - aggregateTextSearchAdapters: [text_index], - }) + theme, + text_index, + plugins: pluginInput = [], + } = configObject + const location = props.location + + const [viewState, setViewState] = useState() + useEffect(() => { + // eslint-disable-next-line @typescript-eslint/no-floating-promises + ;(async () => { + try { + const plugins = await loadPlugins(pluginInput) + const state = createViewState({ + assembly, + tracks, + defaultSession, + location, + onChange: messageShiny, + configuration: { theme }, + aggregateTextSearchAdapters: [text_index], + plugins: plugins.map(p => p.plugin), + }) + state.session.view.showTrack('segdups_ucsc_hg19') + setViewState(state) + } catch (e) { + setError(e) + } + })() + }, []) - return + return } diff --git a/yarn.lock b/yarn.lock index cc38b12..b4f1686 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3442,6 +3442,11 @@ pluralize@^8.0.0: resolved "https://registry.yarnpkg.com/pluralize/-/pluralize-8.0.0.tgz#1a6fa16a38d12a1901e0320fa017051c539ce3b1" integrity sha512-Nc3IT5yHzflTfbjgqWcCPpo7DaKy4FnpB0l/zCAW0Tc7jxAiuqSxHasntB3D7887LSrA93kDJ9IXovxJYxyLCA== +prettier@^3.0.3: + version "3.0.3" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.0.3.tgz#432a51f7ba422d1469096c0fdc28e235db8f9643" + integrity sha512-L/4pUDMxcNa8R/EthV08Zt42WBO4h1rarVtK0K+QJG0X187OLo7l699jWw0GKuwzkPQ//jMFA/8Xm6Fh3J/DAg== + process@^0.11.10: version "0.11.10" resolved "https://registry.yarnpkg.com/process/-/process-0.11.10.tgz#7332300e840161bda3e69a1d1d91a7d4bc16f182"