-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove node-canvas from @jbrowse/core dependencies #3044
Conversation
of @jbrowse/core dependencies
return new Promise((resolve, reject) => { | ||
img.onload = () => resolve(img) | ||
img.onerror = reject | ||
img.src = dataUri | ||
}) | ||
} | ||
ImageBitmapType = Image |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ImageBitmapType now not available statically (due to trying not to depend on initialization order). There could be alternative ways e.g. we make the ponyfill return a callback that gives us the createCanvas callback perhaps, but this is a bit intrusive.
62a4049
to
70e4d05
Compare
70e4d05
to
ffa1f7b
Compare
Codecov Report
@@ Coverage Diff @@
## main #3044 +/- ##
==========================================
- Coverage 61.71% 61.69% -0.02%
==========================================
Files 591 591
Lines 26919 26922 +3
Branches 6527 6526 -1
==========================================
- Hits 16612 16610 -2
- Misses 10004 10009 +5
Partials 303 303
Continue to review full report at Codecov.
|
I think it should be good to go. The only concern I see is we could more or less use a plain old polyfill for createCanvas instead of this ponyfill but that can probably be changed later if needed |
If we detect
isNode
is true, then we use global variablesnodeCreateCanvas
andnodeImage
to perform canvas operations. These are global variables that apps that know that they run under node can set (namely, @jbrowse/img which runs under node and our integration tests which perform canvas snapshots)We do not try to use the global variables until client code calls
new Image
orcreateCanvas
, which allows us an opportunity to setnodeCreateCanvas
andnodeImage
after initialization e.g. doesn't depend on the order that dependencies are included (if we tried to statically detect whether e.g.nodeCreateCanvas
exists then it would depend on whatever sets global.nodeCreateCanvas to be included first for example, and it is tricky to guarantee order of initialization)Would maybe help with issues such as #1739