Skip to content

Commit ada3353

Browse files
authored
Fix widgets disconnect (#786)
* 🔝 bump `@jupyterlite/pyodide-` deps * 🔌 apply default lite plugin settings
1 parent 6c86dfc commit ada3353

10 files changed

+108
-119
lines changed

.changeset/lovely-roses-dance.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'thebe-react': minor
3+
'thebe-lite': minor
4+
'demo-simple': minor
5+
---
6+
7+
Clients no longer have to explicitly supply `litePluginSettings` unless they explicitly want to override them. This simplifies upgrades as clients should just bump packages, and the correct plugin settings for the bundled pyodide kernel will be applied by default.

.changeset/selfish-feet-travel.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'thebe-lite': minor
3+
---
4+
5+
Upgrading `@jupyterlite/pyodide-kernel-extension` to fix ipywidget disconnect issues.

apps/simple/static/index.html

-12
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,6 @@
1919
}
2020
}
2121
</script>
22-
<script id="jupyter-config-data" type="application/json">
23-
{
24-
"litePluginSettings": {
25-
"@jupyterlite/pyodide-kernel-extension:kernel": {
26-
"pipliteUrls": ["https://unpkg.com/@jupyterlite/pyodide-kernel@0.4.2/pypi/all.json"],
27-
"pipliteWheelUrl": "https://unpkg.com/@jupyterlite/pyodide-kernel@0.4.2/pypi/piplite-0.4.2-py3-none-any.whl"
28-
}
29-
},
30-
"enableMemoryStorage": true,
31-
"settingsStorageDrivers": ["memoryStorageDriver"]
32-
}
33-
</script>
3422
<!-- this following is the thebe entrypoint script -->
3523
<script src="thebe-lite.min.js"></script>
3624
<script src="index.js"></script>

apps/simple/static/ipywidgets-lite.html

-12
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,6 @@
1111
useBinder: false
1212
}
1313
</script>
14-
<script id="jupyter-config-data" type="application/json">
15-
{
16-
"litePluginSettings": {
17-
"@jupyterlite/pyodide-kernel-extension:kernel": {
18-
"pipliteUrls": ["https://unpkg.com/@jupyterlite/pyodide-kernel@0.4.2/pypi/all.json"],
19-
"pipliteWheelUrl": "https://unpkg.com/@jupyterlite/pyodide-kernel@0.4.2/pypi/piplite-0.4.2-py3-none-any.whl"
20-
}
21-
},
22-
"enableMemoryStorage": true,
23-
"settingsStorageDrivers": ["memoryStorageDriver"]
24-
}
25-
</script>
2614
<link
2715
rel="stylesheet"
2816
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"

apps/simple/static/lite.html

-12
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,6 @@
1111
useBinder: false
1212
}
1313
</script>
14-
<script id="jupyter-config-data" type="application/json">
15-
{
16-
"litePluginSettings": {
17-
"@jupyterlite/pyodide-kernel-extension:kernel": {
18-
"pipliteUrls": ["https://unpkg.com/@jupyterlite/pyodide-kernel@0.4.2/pypi/all.json"],
19-
"pipliteWheelUrl": "https://unpkg.com/@jupyterlite/pyodide-kernel@0.4.2/pypi/piplite-0.4.2-py3-none-any.whl"
20-
}
21-
},
22-
"enableMemoryStorage": true,
23-
"settingsStorageDrivers": ["memoryStorageDriver"]
24-
}
25-
</script>
2614
<link
2715
rel="stylesheet"
2816
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"

package-lock.json

+65-65
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/lite/package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@
4646
"homepage": "https://github.com/executablebooks/thebe#readme",
4747
"dependencies": {
4848
"@jupyterlab/coreutils": "^6.2.5",
49-
"@jupyterlite/pyodide-kernel": "0.4.2",
50-
"@jupyterlite/pyodide-kernel-extension": "0.4.2",
51-
"@jupyterlite/server": "0.4.1",
52-
"@jupyterlite/server-extension": "0.4.1",
49+
"@jupyterlite/pyodide-kernel": "0.4.7",
50+
"@jupyterlite/pyodide-kernel-extension": "0.4.7",
51+
"@jupyterlite/server": "0.4.5",
52+
"@jupyterlite/server-extension": "0.4.5",
5353
"hook-shell-script-webpack-plugin": "^0.1.4"
5454
},
5555
"devDependencies": {

packages/lite/src/jlite.ts

+23-3
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,29 @@ export async function startJupyterLiteServer(config?: LiteServerConfig): Promise
4444
* Do not rely on a configuration being on the document body, accept configuration via arguments
4545
* and set options on the page config directly
4646
*/
47-
if (config?.litePluginSettings) {
48-
PageConfig.setOption('litePluginSettings', JSON.stringify(config.litePluginSettings));
49-
}
47+
const defaultLiteConfig = {
48+
litePluginSettings: {
49+
'@jupyterlite/pyodide-kernel-extension:kernel': {
50+
pipliteUrls: ['https://unpkg.com/@jupyterlite/pyodide-kernel@0.4.7/pypi/all.json'],
51+
pipliteWheelUrl:
52+
'https://unpkg.com/@jupyterlite/pyodide-kernel@0.4.7/pypi/piplite-0.4.7-py3-none-any.whl',
53+
},
54+
},
55+
enableMemoryStorage: true,
56+
settingsStorageDrivers: ['memoryStorageDriver'],
57+
};
58+
PageConfig.setOption(
59+
'litePluginSettings',
60+
JSON.stringify({ ...defaultLiteConfig.litePluginSettings, ...config?.litePluginSettings }),
61+
);
62+
PageConfig.setOption(
63+
'enableMemoryStorage',
64+
JSON.stringify(config?.enableMemoryStorage ?? defaultLiteConfig.enableMemoryStorage),
65+
);
66+
PageConfig.setOption(
67+
'settingsStorageDrivers',
68+
JSON.stringify(config?.settingsStorageDrivers ?? defaultLiteConfig.settingsStorageDrivers),
69+
);
5070

5171
/**
5272
* Seems like there are 4 different extensions we may want to handle

packages/lite/src/types.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ import type { ServiceManager } from '@jupyterlab/services';
1515
*/
1616

1717
export type LiteServerConfig = {
18-
litePluginSettings: Record<string, any>;
18+
litePluginSettings?: Record<string, any>;
19+
enableMemoryStorage?: boolean;
20+
settingsStorageDrivers?: string[];
1921
};
2022

2123
export interface ThebeLiteGlobal {

packages/react/src/ThebeServerProvider.tsx

+1-10
Original file line numberDiff line numberDiff line change
@@ -92,16 +92,7 @@ export function ThebeServerProvider({
9292
setConnecting(true);
9393
if (customConnectFn) customConnectFn(server);
9494
else if (useBinder) server.connectToServerViaBinder(customRepoProviders);
95-
else if (useJupyterLite)
96-
server.connectToJupyterLiteServer({
97-
litePluginSettings: {
98-
'@jupyterlite/pyodide-kernel-extension:kernel': {
99-
pipliteUrls: ['https://unpkg.com/@jupyterlite/pyodide-kernel@0.4.2/pypi/all.json'],
100-
pipliteWheelUrl:
101-
'https://unpkg.com/@jupyterlite/pyodide-kernel@0.4.2/pypi/piplite-0.4.2-py3-none-any.whl',
102-
},
103-
},
104-
});
95+
else if (useJupyterLite) server.connectToJupyterLiteServer();
10596
else server.connectToJupyterServer();
10697

10798
server.ready.then(

0 commit comments

Comments
 (0)