Skip to content

Commit

Permalink
Wire up
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdcolin committed Oct 17, 2022
1 parent e7288d3 commit 85801b1
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 8 deletions.
2 changes: 2 additions & 0 deletions products/jbrowse-react-linear-genome-view/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,14 @@
"@jbrowse/plugin-wiggle": "^2.1.5",
"@mui/icons-material": "^5.0.0",
"@mui/material": "^5.0.0",
"librpc-web-mod": "^1.1.5",
"mobx": "^6.6.0",
"mobx-react": "^7.5.0",
"mobx-state-tree": "^5.0.0",
"prop-types": "^15.0.0",
"react-use-measure": "^2.1.1",
"rxjs": "^6.0.0",
"serialize-error": "^8.0.0",
"tss-react": "^3.7.0"
},
"peerDependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ import createSessionModel from './createSessionModel'

export default function createModel(
runtimePlugins: PluginConstructor[],
makeWorkerInstance: () => any,
makeWorkerInstance: () => any = () => {
throw new Error('no makeWorkerInstance supplied')
},
) {
console.log({ makeWorkerInstance })
const pluginManager = new PluginManager(
[...corePlugins, ...runtimePlugins].map(P => new P()),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ interface ViewStateOptions {
defaultSession?: SessionSnapshot
disableAddTracks?: boolean
onChange?: (patch: IJsonPatch, reversePatch: IJsonPatch) => void
makeWorkerInstance?: () => any
}

export default function createViewState(opts: ViewStateOptions) {
Expand All @@ -41,8 +42,12 @@ export default function createViewState(opts: ViewStateOptions) {
location,
onChange,
disableAddTracks = false,
makeWorkerInstance,
} = opts
const { model, pluginManager } = createModel(plugins || [])
const { model, pluginManager } = createModel(
plugins || [],
makeWorkerInstance,
)
let { defaultSession } = opts
if (!defaultSession) {
defaultSession = {
Expand Down
2 changes: 1 addition & 1 deletion products/jbrowse-react-linear-genome-view/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ export { createJBrowseTheme, ThemeProvider } from './deprecations'
export { default as JBrowseLinearGenomeView } from './JBrowseLinearGenomeView'
export { default as createModel } from './createModel'
export { default as createViewState } from './createViewState'
export { default as makeWorkerInstance } from './makeWorkerInstance'
export { default as loadPlugins } from './loadPlugins'
export type { ViewModel } from './createModel/createModel'
export { makeWorkerInstance } from './makeWorkerInstance'
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,5 @@
// also note: the craco config for webpack publicPath: 'auto' is needed for
// these workers
export default function makeWorkerInstance() {
console.log('t2')
return new Worker(new URL('./rpc.worker.ts', import.meta.url))
}
2 changes: 0 additions & 2 deletions products/jbrowse-react-linear-genome-view/src/rpc.worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import { remoteAbortRpcHandler } from '@jbrowse/core/rpc/remoteAbortSignals'
import PluginLoader, { PluginDefinition } from '@jbrowse/core/PluginLoader'
import { serializeError } from 'serialize-error'

console.log('t1')

// locals
import corePlugins from './corePlugins'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ import PluginManager from '@jbrowse/core/PluginManager'
import Plugin from '@jbrowse/core/Plugin'

// locals
import { createViewState, loadPlugins, JBrowseLinearGenomeView } from '../src'
import {
createViewState,
loadPlugins,
makeWorkerInstance,
JBrowseLinearGenomeView,
} from '../src'

// configs
import volvoxConfig from '../public/test_data/volvox/config.json'
Expand Down Expand Up @@ -67,6 +72,7 @@ export const WithWebWorker = () => {
defaultDriver: 'WebWorkerRpcDriver',
},
},
makeWorkerInstance,
})
return <JBrowseLinearGenomeView viewState={state} />
}
Expand Down
1 change: 1 addition & 0 deletions products/jbrowse-web/src/Loader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ const Renderer = observer(
try {
if (sessionError) {
rootModel.setDefaultSession()
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
rootModel.session!.notify(
`Error loading session: ${sessionError}. If you
received this URL from another user, request that they send you
Expand Down

0 comments on commit 85801b1

Please sign in to comment.