Skip to content

Commit

Permalink
Avoid circular reference
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdcolin committed Oct 15, 2023
1 parent 51ddb25 commit b37db97
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 19 deletions.
13 changes: 13 additions & 0 deletions packages/core/util/blobToDataURL.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export function blobToDataURL(blob: Blob): Promise<string> {
const a = new FileReader()
return new Promise((resolve, reject) => {
a.onload = e => {
if (e.target) {
resolve(e.target.result as string)
} else {
reject(new Error('unknown result reading blob from canvas'))
}
}
a.readAsDataURL(blob)
})
}
16 changes: 2 additions & 14 deletions packages/core/util/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -892,20 +892,6 @@ export const complement = (() => {
}
})()

export function blobToDataURL(blob: Blob): Promise<string> {
const a = new FileReader()
return new Promise((resolve, reject) => {
a.onload = e => {
if (e.target) {
resolve(e.target.result as string)
} else {
reject(new Error('unknown result reading blob from canvas'))
}
}
a.readAsDataURL(blob)
})
}

// requires immediate execution in jest environment, because (hypothesis) it
// otherwise listens for prerendered_canvas but reads empty pixels, and doesn't
// get the contents of the canvas
Expand Down Expand Up @@ -1382,3 +1368,5 @@ export function stripAlpha(str: string) {
const c = colord(str)
return c.alpha(1).toHex()
}

export { blobToDataURL } from './blobToDataURL'
2 changes: 1 addition & 1 deletion packages/core/util/offscreenCanvasUtils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { CanvasSequence } from 'canvas-sequencer'

// locals
import { createCanvas, createImageBitmap } from './offscreenCanvasPonyfill'
import { blobToDataURL } from './index'
import { blobToDataURL } from './blobToDataURL'

export type RenderReturn = Record<string, unknown> | void

Expand Down
2 changes: 1 addition & 1 deletion plugins/linear-genome-view/src/LinearGenomeView/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import PluginManager from '@jbrowse/core/PluginManager'
import { ViewType } from '@jbrowse/core/pluggableElementTypes'
import { stateModelFactory } from './model'

export default (pluginManager: PluginManager) => {
export default function LinearGenomeViewF(pluginManager: PluginManager) {
pluginManager.addViewType(() => {
return new ViewType({
name: 'LinearGenomeView',
Expand Down
6 changes: 3 additions & 3 deletions products/jbrowse-web/src/tests/ErrorConditions.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { createViewNoWait, doBeforeEach, mockConsole } from './util'
import chromeSizesConfig from '../../test_data/config_chrom_sizes_test.json'
import wrongAssemblyTest from '../../test_data/wrong_assembly.json'

const delay = { timeout: 15000 }
const delay = { timeout: 30000 }

beforeEach(() => {
doBeforeEach()
Expand All @@ -17,12 +17,12 @@ test('404 sequence file', async () => {
delay,
)
})
}, 15000)
}, 30000)

test('wrong assembly', async () => {
await mockConsole(async () => {
const { view, findAllByText } = createViewNoWait(wrongAssemblyTest)
view.showTrack('volvox_wrong_assembly')
await findAllByText(/does not match/, {}, delay)
})
}, 15000)
}, 30000)

0 comments on commit b37db97

Please sign in to comment.