-
Notifications
You must be signed in to change notification settings - Fork 945
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
[WIP] Split out embed manager #1394
[WIP] Split out embed manager #1394
Conversation
It's now the main purpose of that module
This removes the 'privileged' position of the widgets defined in 'jupyter-js-widgets'.
This is useful until the release of jupyter-js-widgets stabilises
It would be really helpful to have a say |
@maartenbreddels That makes sense. Do you see this just returning a hard-coded URL (maybe with the version dynamically included)? |
To test this PR:
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="./embed-jupyter-widgets.js"></script>
<script type="application/vnd.jupyter.widget-state+json">
{
"version_major": 2,
"version_minor": 0,
"state": {
"1ba8af4bbc874fe581360d8f6734079d": {
"model_name": "SliderStyleModel",
"model_module": "jupyter-js-widgets",
"model_module_version": "3.0.0",
"state": {
"description_width": ""
}
},
"635ea1d3185746ef88b2a9453cdbf7ad": {
"model_name": "LayoutModel",
"model_module": "jupyter-js-widgets",
"model_module_version": "3.0.0",
"state": {}
},
"7c1d41e9e96b4f94ae9219b31257cd2e": {
"model_name": "IntSliderModel",
"model_module": "jupyter-js-widgets",
"model_module_version": "3.0.0",
"state": {
"style": "IPY_MODEL_1ba8af4bbc874fe581360d8f6734079d",
"layout": "IPY_MODEL_635ea1d3185746ef88b2a9453cdbf7ad"
}
}
}
}
</script>
<!-- <style> -->
<!-- .jupyter-widgets-disconnected::before { -->
<!-- content: "" ; -->
<!-- } -->
<!-- </style> -->
</head>
<body>
<h1>Output embedding example</h1>
<div id="widget-embedded-here">
<script type="application/vnd.jupyter.widget-view+json">
{
"model_id": "7c1d41e9e96b4f94ae9219b31257cd2e",
"version_minor": "0",
"version_major": "2"
}
</script>
</div>
</body>
</html>
|
@pbugnion - are you saying this PR is ready to review (i.e., remove the WIP in the title)? |
Thanks! It's ready for review, but there's definitely still some work that needs doing (I've highlighted what's left to do in checkboxes in the PR description). I just don't feel confident addressing what's left to do without you (or someone else) validating the approach so far. |
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 this general approach looks good. Since you have to import jupyter-js-widgets anyway for the manager base class, you might just include jupyter-js-widgets by default at this point.
embed-jupyter-widgets/package.json
Outdated
"dependencies": { | ||
"@phosphor/widgets": "^1.2.0", | ||
"font-awesome": "^4.7.0", | ||
"jupyter-js-widgets": "file:../jupyter-js-widgets" |
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.
Just like the other managers (widgetsnbextension, jupyterlab_widgets) rely on a published version of jupyter-js-widgets, we'll probably update this when we release to point to a release instead of a file path.
@pbugnion - are you around sometime today to have a video chat, or maybe in-person chat? |
A video chat sounds good, time zone issues notwithstanding (I live in London). I suppose mornings or early afternoons in EST would work best. |
Those changes look great, thanks! |
How were you thinking of loading the |
If you're talking about what version to specify in widgetsnbextension, yes, for now hardcoding the embed-jupyter-widgets version there. |
What do you think about calling it |
|
To avoid merge conflicts or duplicating work you might be doing, I might try and tackle the documentation for this, unless you think there's something more pressing? |
I'm about ready to merge this. Just contemplating the name of the package... |
Thanks again @pbugnion for taking this on! |
This is a very tentative PR to split out the embed manager from the jupyter-js-widgets package into its own embed-jupyter-widgets package. This PR arose from both comments in the code and a discussion around PR #1380.
Prior to this PR, to embed the widgets you had to include
https://unpkg.com/jupyter-js-widgets@~3.0.0-alpha.6/dist/embed.js
in the HTML. This distributed both the embed widget manager and the JS for the default widgets present in Jupyter. After this PR, you will have to includehttps://unpkg.com/embed-js-widgets@*/dist/index.js
. The default jupyter widgets lose their special status: they are now bundled as an AMD library like any other set of custom widgets. They are then fetched from unpkg (or locally) dynamically when they are requested in the embed state.This changes several things, some of which I was very unsure of, so it would be good to get some feedback:
https://unpkg.com/jupyter-js-widgets@~3.0.0-alpha.6/dist/embed.js
still works: it just now releases an AMD packaged library which cannot be used by itself.embed-jupyter-widgets
as a local dependency, but I think it makes sense to load the core widgets fromunpkg
-- since this is what users will do most of the time. This won't work until there is a new version of the library on unpkg though.generateEmbedScript
inembed-helper
seems to be unused. Should it be removed?AFAICT, this is what's left to do:
jupyter-js-widgets
on unpkg and check that embedding still works.disconnected
symbol go away.