Skip to content

Commit a5c6e7b

Browse files
committed
🔌 apply default lite plugin settings
1 parent e6be71f commit a5c6e7b

File tree

7 files changed

+34
-50
lines changed

7 files changed

+34
-50
lines changed

.changeset/lovely-roses-dance.md

Lines changed: 7 additions & 0 deletions
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.

apps/simple/static/index.html

Lines changed: 0 additions & 12 deletions
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/[email protected]/pypi/all.json"],
27-
"pipliteWheelUrl": "https://unpkg.com/@jupyterlite/[email protected]/pypi/piplite-0.4.7-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

Lines changed: 0 additions & 12 deletions
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/[email protected]/pypi/all.json"],
19-
"pipliteWheelUrl": "https://unpkg.com/@jupyterlite/[email protected]/pypi/piplite-0.4.7-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

Lines changed: 0 additions & 12 deletions
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/[email protected]/pypi/all.json"],
19-
"pipliteWheelUrl": "https://unpkg.com/@jupyterlite/[email protected]/pypi/piplite-0.4.7-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"

packages/lite/src/jlite.ts

Lines changed: 23 additions & 3 deletions
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/[email protected]/pypi/all.json'],
51+
pipliteWheelUrl:
52+
'https://unpkg.com/@jupyterlite/[email protected]/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

Lines changed: 3 additions & 1 deletion
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

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -89,16 +89,7 @@ export function ThebeServerProvider({
8989
setConnecting(true);
9090
if (customConnectFn) customConnectFn(server);
9191
else if (useBinder) server.connectToServerViaBinder(customRepoProviders);
92-
else if (useJupyterLite)
93-
server.connectToJupyterLiteServer({
94-
litePluginSettings: {
95-
'@jupyterlite/pyodide-kernel-extension:kernel': {
96-
pipliteUrls: ['https://unpkg.com/@jupyterlite/[email protected]/pypi/all.json'],
97-
pipliteWheelUrl:
98-
'https://unpkg.com/@jupyterlite/[email protected]/pypi/piplite-0.4.7-py3-none-any.whl',
99-
},
100-
},
101-
});
92+
else if (useJupyterLite) server.connectToJupyterLiteServer();
10293
else server.connectToJupyterServer();
10394

10495
server.ready.then(

0 commit comments

Comments
 (0)