|
22 | 22 |
|
23 | 23 |
|
24 | 24 | # TODO: scripts/static_download.R should produce/update these
|
25 |
| -def libembed_dependency() -> List[HTMLDependency]: |
26 |
| - return [ |
27 |
| - # Jupyter Notebook/Lab both come "preloaded" with several @jupyter-widgets packages |
28 |
| - # (i.e., base, controls, output), all of which are bundled into this extension.js file |
29 |
| - # provided by the widgetsnbextension package, which is a dependency of ipywidgets. |
30 |
| - # https://github.com/nteract/nes/tree/master/portable-widgets |
31 |
| - # https://github.com/jupyter-widgets/ipywidgets/blob/88cec8/packages/html-manager/src/htmlmanager.ts#L115-L120 |
32 |
| - # |
33 |
| - # Unfortunately, I don't think there is a good way for us to "pre-bundle" these dependencies |
34 |
| - # since they could change depending on the version of ipywidgets (and ipywidgets itself |
35 |
| - # doesn't include these dependencies in such a way that require("@jupyter-widget/base") would |
36 |
| - # work robustly when used in other 3rd party widgets). Moreover, I don't think we can simply |
37 |
| - # have @jupyter-widget/base point to https://unpkg.com/@jupyter-widgets/base@__version__/lib/index.js |
38 |
| - # (or a local version of this) since it appears the lib entry points aren't usable in the browser. |
39 |
| - # |
40 |
| - # All this is to say that I think we are stuck with this mega 3.5MB file that contains all of the |
41 |
| - # stuff we need to render widgets outside of the notebook. |
42 |
| - HTMLDependency( |
43 |
| - name="ipywidget-libembed-amd", |
44 |
| - version=parse_version_safely(__html_manager_version__), |
45 |
| - source={"package": "shinywidgets", "subdir": "static"}, |
46 |
| - script={"src": "libembed-amd.js"}, |
47 |
| - ), |
48 |
| - ] |
49 |
| - |
50 |
| - |
51 | 25 | def output_binding_dependency() -> HTMLDependency:
|
| 26 | + # Jupyter Notebook/Lab both come "preloaded" with several @jupyter-widgets packages |
| 27 | + # (i.e., base, controls, output), all of which are bundled into this extension.js file |
| 28 | + # provided by the widgetsnbextension package, which is a dependency of ipywidgets. |
| 29 | + # https://github.com/nteract/nes/tree/master/portable-widgets |
| 30 | + # https://github.com/jupyter-widgets/ipywidgets/blob/88cec8/packages/html-manager/src/htmlmanager.ts#L115-L120 |
| 31 | + # |
| 32 | + # Unfortunately, I don't think there is a good way for us to "pre-bundle" these dependencies |
| 33 | + # since they could change depending on the version of ipywidgets (and ipywidgets itself |
| 34 | + # doesn't include these dependencies in such a way that require("@jupyter-widget/base") would |
| 35 | + # work robustly when used in other 3rd party widgets). Moreover, I don't think we can simply |
| 36 | + # have @jupyter-widget/base point to https://unpkg.com/@jupyter-widgets/base@__version__/lib/index.js |
| 37 | + # (or a local version of this) since it appears the lib entry points aren't usable in the browser. |
| 38 | + # |
| 39 | + # All this is to say that I think we are stuck with this mega 3.5MB file that contains all of the |
| 40 | + # stuff we need to render widgets outside of the notebook. |
52 | 41 | return HTMLDependency(
|
53 | 42 | name="ipywidget-output-binding",
|
54 | 43 | version=__version__,
|
55 | 44 | source={"package": "shinywidgets", "subdir": "static"},
|
56 |
| - script={"src": "output.js"}, |
| 45 | + script=[ |
| 46 | + {"src": "libembed-amd.js"}, |
| 47 | + # Bundle our output.js in the same dependency as libembded since Quarto |
| 48 | + # has a bug where it doesn't renders dependencies in the order they are defined |
| 49 | + # (i.e., this way we can ensure the output.js script always comes after the libembed-amd.js script tag) |
| 50 | + {"src": "output.js"}, |
| 51 | + ], |
57 | 52 | stylesheet={"href": "shinywidgets.css"},
|
58 | 53 | )
|
59 | 54 |
|
|
0 commit comments