-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ability to add plugins to JBrowseR, convert code to typescript (#27)
- Loading branch information
Showing
14 changed files
with
2,156 additions
and
553 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
module.exports = { | ||
env: { | ||
browser: true, | ||
es2021: true, | ||
}, | ||
extends: [ | ||
'eslint:recommended', | ||
'plugin:@typescript-eslint/recommended', | ||
'plugin:@typescript-eslint/recommended-type-checked', | ||
'plugin:@typescript-eslint/stylistic-type-checked', | ||
'plugin:react/recommended', | ||
'plugin:react-hooks/recommended', | ||
'plugin:unicorn/recommended', | ||
], | ||
settings: { | ||
react: { | ||
version: 'detect', | ||
}, | ||
}, | ||
parser: '@typescript-eslint/parser', | ||
parserOptions: { | ||
ecmaVersion: 'latest', | ||
sourceType: 'module', | ||
project: './tsconfig.json', | ||
}, | ||
globals: { | ||
Shiny: true, | ||
}, | ||
plugins: ['@typescript-eslint', 'react', 'react-refresh'], | ||
rules: { | ||
'unicorn/prevent-abbreviations': 'off', | ||
'unicorn/no-null': 'off', | ||
'unicorn/filename-case': 'off', | ||
'unicorn/no-useless-undefined': 'off', | ||
'unicorn/no-nested-ternary': 'off', | ||
|
||
'react/prop-types': 'off', | ||
'react-refresh/only-export-components': 'warn', | ||
|
||
'@typescript-eslint/no-base-to-string': 'off', | ||
'@typescript-eslint/no-unsafe-member-access': 'off', | ||
'@typescript-eslint/no-unsafe-argument': 'off', | ||
'@typescript-eslint/no-unsafe-assignment': 'off', | ||
'@typescript-eslint/no-unsafe-call': 'off', | ||
'@typescript-eslint/no-unsafe-return': 'off', | ||
'@typescript-eslint/restrict-template-expressions': 'off', | ||
'@typescript-eslint/ban-ts-comment': 'off', | ||
'@typescript-eslint/no-unused-vars': [ | ||
'warn', | ||
{ argsIgnorePattern: '^_', ignoreRestSiblings: true }, | ||
], | ||
curly: 'error', | ||
'no-extra-semi': 'off', | ||
}, | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import React from 'react' | ||
import { | ||
createViewState, | ||
JBrowseLinearGenomeView, | ||
loadPlugins, | ||
} from '@jbrowse/react-linear-genome-view' | ||
import { ErrorMessage } from '@jbrowse/core/ui' | ||
|
||
import { messageShiny } from '../utils' | ||
|
||
type ViewState = ReturnType<typeof createViewState> | ||
export default function View({ | ||
config, | ||
location, | ||
}: { | ||
location: string | ||
config: string | ||
}) { | ||
const [viewState, setViewState] = React.useState<ViewState>() | ||
const [error, setError] = React.useState<unknown>() | ||
React.useEffect(() => { | ||
// eslint-disable-next-line @typescript-eslint/no-floating-promises | ||
;(async () => { | ||
try { | ||
const { | ||
assembly, | ||
tracks, | ||
defaultSession, | ||
theme, | ||
text_index, | ||
plugins: pluginInput = [], | ||
} = JSON.parse(config) | ||
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), | ||
}) | ||
setViewState(state) | ||
} catch (error) { | ||
console.error(error) | ||
setError(error) | ||
} | ||
})() | ||
}, [config, location]) | ||
|
||
return error ? ( | ||
<ErrorMessage error={error} /> | ||
) : viewState ? ( | ||
<JBrowseLinearGenomeView viewState={viewState} /> | ||
) : ( | ||
<h3>Loading...</h3> | ||
) | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import React from 'react' | ||
import { | ||
createViewState, | ||
JBrowseLinearGenomeView, | ||
} from '@jbrowse/react-linear-genome-view' | ||
|
||
import { messageShiny } from '../utils' | ||
|
||
export default function View(props: { | ||
tracks: string | ||
assembly: string | ||
location: string | ||
theme: string | ||
text_index: string | ||
}) { | ||
const { theme, text_index, assembly, tracks, location, ...rest } = | ||
Object.fromEntries( | ||
Object.entries(props).map(([key, value]) => [ | ||
key, | ||
key === 'location' ? value : JSON.parse(value), | ||
]), | ||
) | ||
const state = createViewState({ | ||
...rest, | ||
onChange: messageShiny, | ||
configuration: { theme }, | ||
aggregateTextSearchAdapters: text_index, | ||
location, | ||
assembly, | ||
tracks, | ||
}) | ||
|
||
return <JBrowseLinearGenomeView viewState={state} /> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.