Skip to content

Commit

Permalink
Embed all jupyterlab-manager plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
trungleduc committed Sep 18, 2023
1 parent f6d7428 commit 9b29dd6
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 30 deletions.
16 changes: 7 additions & 9 deletions packages/voici/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@ import plugins from './voiciplugins';

const serverExtensions = [import('@jupyterlite/server-extension')];

const disabled = [
'@jupyter-widgets/jupyterlab-manager:plugin',
'@jupyter-widgets/jupyterlab-manager:saveWidgetState',
];

/**
* The main function
*/
Expand All @@ -45,6 +40,9 @@ async function main() {
require('@jupyterlab/rendermime-extension'),
require('@jupyterlab/theme-light-extension'),
require('@jupyterlab/theme-dark-extension'),
require('@jupyter-widgets/jupyterlab-manager/lib/plugin').default.filter(
(p: any) => p.id !== '@jupyter-widgets/jupyterlab-manager:plugin'
),
themesManagerPlugin,
plugins,
];
Expand Down Expand Up @@ -110,7 +108,7 @@ async function main() {
);
federatedExtensions.forEach((p) => {
if (p.status === 'fulfilled') {
for (const plugin of activePlugins(p.value, disabled)) {
for (const plugin of activePlugins(p.value, [])) {
mods.push(plugin);
}
} else {
Expand All @@ -124,7 +122,7 @@ async function main() {
);
federatedMimeExtensions.forEach((p) => {
if (p.status === 'fulfilled') {
for (const plugin of activePlugins(p.value, disabled)) {
for (const plugin of activePlugins(p.value, [])) {
mimeExtensions.push(plugin);
}
} else {
Expand All @@ -142,7 +140,7 @@ async function main() {
const litePluginsToRegister: any[] = [];
const baseServerExtensions = await Promise.all(serverExtensions);
baseServerExtensions.forEach((p) => {
for (const plugin of activePlugins(p, disabled)) {
for (const plugin of activePlugins(p, [])) {
litePluginsToRegister.push(plugin);
}
});
Expand All @@ -153,7 +151,7 @@ async function main() {
);
federatedLiteExtensions.forEach((p) => {
if (p.status === 'fulfilled') {
for (const plugin of activePlugins(p.value, disabled)) {
for (const plugin of activePlugins(p.value, [])) {
litePluginsToRegister.push(plugin);
}
} else {
Expand Down
14 changes: 3 additions & 11 deletions packages/voici/src/tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,6 @@ import { treeWidgetPlugin } from './plugins/tree';

const serverExtensions = [import('@jupyterlite/server-extension')];

export const TREE_DISABLED_EXTENSIONS = [
'@jupyter-widgets/jupyterlab-manager:plugin',
'@jupyter-widgets/jupyterlab-manager:saveWidgetState',
'@jupyter-widgets/jupyterlab-manager:base-2.0.0',
'@jupyter-widgets/jupyterlab-manager:controls-2.0.0',
'@jupyter-widgets/jupyterlab-manager:output-1.0.0',
];

/**
* The main function
*/
Expand Down Expand Up @@ -99,7 +91,7 @@ async function main() {
);
federatedExtensions.forEach((p) => {
if (p.status === 'fulfilled') {
for (const plugin of activePlugins(p.value, TREE_DISABLED_EXTENSIONS)) {
for (const plugin of activePlugins(p.value, [])) {
mods.push(plugin);
}
} else {
Expand All @@ -113,7 +105,7 @@ async function main() {
);
federatedMimeExtensions.forEach((p) => {
if (p.status === 'fulfilled') {
for (const plugin of activePlugins(p.value, TREE_DISABLED_EXTENSIONS)) {
for (const plugin of activePlugins(p.value, [])) {
mimeExtensions.push(plugin);
}
} else {
Expand All @@ -131,7 +123,7 @@ async function main() {
const litePluginsToRegister: any[] = [];
const baseServerExtensions = await Promise.all(serverExtensions);
baseServerExtensions.forEach((p) => {
for (const plugin of activePlugins(p, TREE_DISABLED_EXTENSIONS)) {
for (const plugin of activePlugins(p, [])) {
litePluginsToRegister.push(plugin);
}
});
Expand Down
9 changes: 0 additions & 9 deletions voici/addon.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,6 @@

from .tree_exporter import VoiciTreeExporter

# Try to patch xeus-python's jupyter-widgets version st. we pull the right one
try:
from jupyterlite_xeus_python.env_build_addon import XeusPythonEnv

if hasattr(XeusPythonEnv, "pin_packages"):
XeusPythonEnv.pin_packages = ["ipywidgets=8.0.6", "jupyterlab_widgets=3.0.7"]
except ImportError:
pass


class VoiciAddon(BaseAddon):
"""The Voici JupyterLite app"""
Expand Down
13 changes: 12 additions & 1 deletion voici/tree_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from jupyter_server.utils import url_escape, url_path_join
from nbconvert.exporters.html import HTMLExporter
from voila.configuration import VoilaConfiguration
from voila.utils import include_lab_theme
from voila.utils import include_lab_theme, filter_extension

from .exporter import VoiciExporter

Expand Down Expand Up @@ -75,6 +75,17 @@ def patch_page_config(
page_config_copy[
"fullMathjaxUrl"
] = f'{page_config_copy["baseUrl"]}{page_config_copy["fullMathjaxUrl"]}'

federated_extensions = page_config_copy["federated_extensions"]
disabled_extensions = [
"@voila-dashboards/jupyterlab-preview",
"@jupyter/collaboration-extension",
"@jupyter-widgets/jupyterlab-manager",
]
page_config_copy["federated_extensions"] = filter_extension(
federated_extensions=federated_extensions,
disabled_extensions=disabled_extensions,
)
return page_config_copy


Expand Down

0 comments on commit 9b29dd6

Please sign in to comment.