-
Notifications
You must be signed in to change notification settings - Fork 1
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
Reorganize package #2
base: main
Are you sure you want to change the base?
Conversation
Resolved the |
If I comment out these lines in the generated JS it does work: __esExport("JsonPatchError", helpers_mjs_1.PatchError);
__esExport("deepClone", helpers_mjs_1._deepClone);
__esExport("escapePathComponent", helpers_mjs_1.escapePathComponent);
__esExport("unescapePathComponent", helpers_mjs_1.unescapePathComponent);
And there's probably some way to disable those exports. At that point we can finally render the output but run into serialization issues when we trigger events:
|
Okay, worked around the __esExport issue now, this now renders: import idom
import idom_bokeh
import panel as pn
from idom_bokeh.panel import IDOM
pn.extension()
@idom.component
def ClickCount():
count, set_count = idom.hooks.use_state(0)
return idom.html.button(
{"onClick": lambda event: set_count(count + 1)},
[f"Click count: {count}"],
)
IDOM(ClickCount, width=300) Will tackle the serialization issues tomorrow some time. |
Had to do some patching of the events since the serializer didn't like serializing the |
@rmorshea This is working for me now. |
Will review this tonight. Thanks for looking into it so quickly! |
src/idom_bokeh/src/index.ts
Outdated
if (e.target?.boundingClientRect != null) { | ||
e.target.boundingClientRect = {...e.target.boundingClientRect} | ||
} | ||
if (e.currenttarget?.boundingClientRect != null) { | ||
e.target.boundingClientRect = {...e.currentTarget.boundingClientRect} | ||
} |
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.
Can you explain a bit of the issue here? I haven't encountered this when serializing with JSON.stringify
. Does this need a fix in IDOM core's event-to-object implementation? It should be simple enough to use a spread operator here.
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.
I think Bokeh just doesn't serialize custom objects so the spread operator to turn it into a regular object is indeed all that's needed.
Still haven't gotten this fully working unfortunately but I'm still working on it. Some notes on why this wasn't really working at all before now:
bokeh.ext.json
to be present both for the build step and inside the Python package to detect whether a particular Python package bundles an extension__implementation__
is for packages that are compiled on the fly, for bundled extension we just need to make sure that the Bokeh model references the correct__module__
.register_models
should be given theModel
not theView
So to avoid duplicating the
bokeh.ext.json
and fiddling with paths too much I've moved theidom-bokeh-extension
into the Python package for now. It may be possible to keep them separate but I've never tried and currently I expect this to be somewhat brittle.Unfortunately there are still some issues:
react.js
referencesprocess.env.NODE_ENV
in a bunch of places, I'm guessing the bundler should somehow optimize this away (or something) but bokeh's custom bundler does not appear to do so.process.env.NODE_ENV
I still get the following error:Uncaught TypeError: Cannot redefine property: JsonPatchError
Closes: #1