@datalayer/jupyter-react 1.2.3 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -0
- package/lib/app/tabs/components/FileBrowserComponent.js +1 -1
- package/lib/app/tabs/components/FileBrowserComponent.js.map +1 -1
- package/lib/app/tabs/components/NotebookComponent.js +10 -4
- package/lib/app/tabs/components/NotebookComponent.js.map +1 -1
- package/lib/components/console/Console.js +1 -1
- package/lib/components/console/Console.js.map +1 -1
- package/lib/components/filemanager/FileManagerJupyterLab.js +1 -1
- package/lib/components/filemanager/FileManagerJupyterLab.js.map +1 -1
- package/lib/components/jupyterlab/JupyterLabApp.js +1 -1
- package/lib/components/jupyterlab/JupyterLabApp.js.map +1 -1
- package/lib/components/kernel/KernelSelector.js +1 -1
- package/lib/components/kernel/KernelSelector.js.map +1 -1
- package/lib/components/kernel/Kernels.js +1 -1
- package/lib/components/kernel/Kernels.js.map +1 -1
- package/lib/components/notebook/Notebook.d.ts +95 -41
- package/lib/components/notebook/Notebook.js +57 -276
- package/lib/components/notebook/Notebook.js.map +1 -1
- package/lib/components/notebook/NotebookAdapter.d.ts +263 -66
- package/lib/components/notebook/NotebookAdapter.js +639 -583
- package/lib/components/notebook/NotebookAdapter.js.map +1 -1
- package/lib/components/notebook/{Notebook2Base.d.ts → NotebookBase.d.ts} +2 -2
- package/lib/components/notebook/{Notebook2Base.js → NotebookBase.js} +29 -29
- package/lib/components/notebook/NotebookBase.js.map +1 -0
- package/lib/components/notebook/NotebookState.d.ts +37 -89
- package/lib/components/notebook/NotebookState.js +72 -155
- package/lib/components/notebook/NotebookState.js.map +1 -1
- package/lib/components/notebook/index.d.ts +2 -6
- package/lib/components/notebook/index.js +2 -6
- package/lib/components/notebook/index.js.map +1 -1
- package/lib/components/notebook/toolbar/NotebookToolbar.js +11 -16
- package/lib/components/notebook/toolbar/NotebookToolbar.js.map +1 -1
- package/lib/components/output/Output.js +1 -1
- package/lib/components/output/Output.js.map +1 -1
- package/lib/components/terminal/Terminal.js +1 -1
- package/lib/components/terminal/Terminal.js.map +1 -1
- package/lib/examples/Bokeh.js +6 -2
- package/lib/examples/Bokeh.js.map +1 -1
- package/lib/examples/Bqplot.js +7 -3
- package/lib/examples/Bqplot.js.map +1 -1
- package/lib/examples/Cell.js +1 -1
- package/lib/examples/Cell.js.map +1 -1
- package/lib/examples/CellLite.js +1 -1
- package/lib/examples/CellLite.js.map +1 -1
- package/lib/examples/Cells.js +1 -1
- package/lib/examples/Cells.js.map +1 -1
- package/lib/examples/CellsExecute.js +1 -1
- package/lib/examples/CellsExecute.js.map +1 -1
- package/lib/examples/ConsoleLite.js +2 -2
- package/lib/examples/ConsoleLite.js.map +1 -1
- package/lib/examples/Dashboard.js +7 -3
- package/lib/examples/Dashboard.js.map +1 -1
- package/lib/examples/Deno.js +8 -3
- package/lib/examples/Deno.js.map +1 -1
- package/lib/examples/Examples.js +6 -14
- package/lib/examples/Examples.js.map +1 -1
- package/lib/examples/FileBrowser.js +1 -1
- package/lib/examples/FileBrowser.js.map +1 -1
- package/lib/examples/GeoJson.js +9 -5
- package/lib/examples/GeoJson.js.map +1 -1
- package/lib/examples/IPyLeaflet.js +7 -3
- package/lib/examples/IPyLeaflet.js.map +1 -1
- package/lib/examples/IPyReact.js +6 -2
- package/lib/examples/IPyReact.js.map +1 -1
- package/lib/examples/IPyWidgets.js +7 -3
- package/lib/examples/IPyWidgets.js.map +1 -1
- package/lib/examples/IPyWidgetsState.js +13 -4
- package/lib/examples/IPyWidgetsState.js.map +1 -1
- package/lib/examples/JupyterContext.js +47 -24
- package/lib/examples/JupyterContext.js.map +1 -1
- package/lib/examples/JupyterLabTheme.js +4 -3
- package/lib/examples/JupyterLabTheme.js.map +1 -1
- package/lib/examples/KernelExecute.js +1 -1
- package/lib/examples/KernelExecute.js.map +1 -1
- package/lib/examples/KernelExecuteLite.js +1 -1
- package/lib/examples/KernelExecuteLite.js.map +1 -1
- package/lib/examples/KernelExecutor.js +1 -1
- package/lib/examples/KernelExecutor.js.map +1 -1
- package/lib/examples/KernelExecutorLite.js +1 -1
- package/lib/examples/KernelExecutorLite.js.map +1 -1
- package/lib/examples/Kernels.js +1 -1
- package/lib/examples/Kernels.js.map +1 -1
- package/lib/examples/Matplotlib.js +6 -2
- package/lib/examples/Matplotlib.js.map +1 -1
- package/lib/examples/Notebook.js +19 -8
- package/lib/examples/Notebook.js.map +1 -1
- package/lib/examples/{Notebook2Actions.js → NotebookActions.js} +6 -6
- package/lib/examples/NotebookActions.js.map +1 -0
- package/lib/examples/NotebookCellSidebar.js +17 -4
- package/lib/examples/NotebookCellSidebar.js.map +1 -1
- package/lib/examples/NotebookCellToolbar.js +7 -3
- package/lib/examples/NotebookCellToolbar.js.map +1 -1
- package/lib/examples/NotebookCollaborative.js +6 -9
- package/lib/examples/NotebookCollaborative.js.map +1 -1
- package/lib/examples/NotebookColormode.js +2 -2
- package/lib/examples/NotebookColormode.js.map +1 -1
- package/lib/examples/NotebookExtension.js +6 -2
- package/lib/examples/NotebookExtension.js.map +1 -1
- package/lib/examples/NotebookExternalContent.js +22 -14
- package/lib/examples/NotebookExternalContent.js.map +1 -1
- package/lib/examples/NotebookInit.js +23 -48
- package/lib/examples/NotebookInit.js.map +1 -1
- package/lib/examples/NotebookKernel.js +7 -16
- package/lib/examples/NotebookKernel.js.map +1 -1
- package/lib/examples/NotebookKernelChange.js +19 -12
- package/lib/examples/NotebookKernelChange.js.map +1 -1
- package/lib/examples/NotebookLess.js +13 -4
- package/lib/examples/NotebookLess.js.map +1 -1
- package/lib/examples/NotebookLite.js +21 -10
- package/lib/examples/NotebookLite.js.map +1 -1
- package/lib/examples/NotebookLocalServer.js +15 -6
- package/lib/examples/NotebookLocalServer.js.map +1 -1
- package/lib/examples/NotebookNbformat.js +2 -2
- package/lib/examples/NotebookNbformat.js.map +1 -1
- package/lib/examples/NotebookNbformatChange.js +16 -6
- package/lib/examples/NotebookNbformatChange.js.map +1 -1
- package/lib/examples/NotebookNoContext.js +10 -2
- package/lib/examples/NotebookNoContext.js.map +1 -1
- package/lib/examples/NotebookNoPrimer.js +11 -3
- package/lib/examples/NotebookNoPrimer.js.map +1 -1
- package/lib/examples/NotebookOnSessionConnection.js +13 -5
- package/lib/examples/NotebookOnSessionConnection.js.map +1 -1
- package/lib/examples/NotebookPath.js +13 -5
- package/lib/examples/NotebookPath.js.map +1 -1
- package/lib/examples/NotebookPathChange.js +7 -3
- package/lib/examples/NotebookPathChange.js.map +1 -1
- package/lib/examples/NotebookReadonly.js +6 -2
- package/lib/examples/NotebookReadonly.js.map +1 -1
- package/lib/examples/NotebookServiceManager.js +12 -6
- package/lib/examples/NotebookServiceManager.js.map +1 -1
- package/lib/examples/NotebookSkeleton.js +14 -4
- package/lib/examples/NotebookSkeleton.js.map +1 -1
- package/lib/examples/NotebookTOC.js +7 -3
- package/lib/examples/NotebookTOC.js.map +1 -1
- package/lib/examples/NotebookTheme.js +7 -3
- package/lib/examples/NotebookTheme.js.map +1 -1
- package/lib/examples/NotebookThemeColormode.js +2 -2
- package/lib/examples/NotebookThemeColormode.js.map +1 -1
- package/lib/examples/NotebookURL.js +11 -3
- package/lib/examples/NotebookURL.js.map +1 -1
- package/lib/examples/NotebookUnmount.js +8 -6
- package/lib/examples/NotebookUnmount.js.map +1 -1
- package/lib/examples/ObservableHQ.js +8 -3
- package/lib/examples/ObservableHQ.js.map +1 -1
- package/lib/examples/OutputWithMonitoring.js +11 -5
- package/lib/examples/OutputWithMonitoring.js.map +1 -1
- package/lib/examples/Outputs.js +13 -8
- package/lib/examples/Outputs.js.map +1 -1
- package/lib/examples/OutputsIpynb.js +3 -3
- package/lib/examples/OutputsIpynb.js.map +1 -1
- package/lib/examples/Panel.js +8 -4
- package/lib/examples/Panel.js.map +1 -1
- package/lib/examples/Plotly.js +7 -3
- package/lib/examples/Plotly.js.map +1 -1
- package/lib/examples/PyGWalker.js +13 -4
- package/lib/examples/PyGWalker.js.map +1 -1
- package/lib/examples/RunningSessions.js +5 -5
- package/lib/examples/RunningSessions.js.map +1 -1
- package/lib/examples/Vega.js +11 -3
- package/lib/examples/Vega.js.map +1 -1
- package/lib/examples/Viewer.js +2 -2
- package/lib/examples/Viewer.js.map +1 -1
- package/lib/examples/extensions/celltoolbar/CellToolbarComponent.js +8 -25
- package/lib/examples/extensions/celltoolbar/CellToolbarComponent.js.map +1 -1
- package/lib/examples/extensions/toc/TocComponent.d.ts +1 -0
- package/lib/examples/extensions/toc/TocComponent.js +39 -28
- package/lib/examples/extensions/toc/TocComponent.js.map +1 -1
- package/lib/examples/extensions/toc/TocExtension.d.ts +1 -3
- package/lib/examples/extensions/toc/TocExtension.js +28 -11
- package/lib/examples/extensions/toc/TocExtension.js.map +1 -1
- package/lib/jupyter/JupyterConfig.d.ts +9 -2
- package/lib/jupyter/JupyterConfig.js.map +1 -1
- package/lib/jupyter/{JupyterContext.d.ts → JupyterUse.d.ts} +3 -26
- package/lib/jupyter/JupyterUse.js +26 -0
- package/lib/jupyter/JupyterUse.js.map +1 -0
- package/lib/jupyter/index.d.ts +1 -3
- package/lib/jupyter/index.js +1 -3
- package/lib/jupyter/index.js.map +1 -1
- package/lib/jupyter/lite/contents/broadcast.js +5 -2
- package/lib/jupyter/lite/contents/broadcast.js.map +1 -1
- package/lib/jupyter/lite/contents/contents.js +5 -0
- package/lib/jupyter/lite/contents/contents.js.map +1 -1
- package/lib/jupyter/lite/contents/drivecontents.js +5 -0
- package/lib/jupyter/lite/contents/drivecontents.js.map +1 -1
- package/lib/jupyter/lite/contents/drivefs.js +5 -2
- package/lib/jupyter/lite/contents/drivefs.js.map +1 -1
- package/lib/jupyter/lite/contents/emscripten.js +5 -2
- package/lib/jupyter/lite/contents/emscripten.js.map +1 -1
- package/lib/jupyter/lite/contents/index.js +5 -0
- package/lib/jupyter/lite/contents/index.js.map +1 -1
- package/lib/jupyter/lite/contents/tokens.js +5 -0
- package/lib/jupyter/lite/contents/tokens.js.map +1 -1
- package/lib/jupyter/lite/javascript-kernel/comlink.worker.js +15 -0
- package/lib/jupyter/lite/javascript-kernel/comlink.worker.js.map +1 -0
- package/lib/jupyter/lite/javascript-kernel/index.d.ts +2 -0
- package/lib/jupyter/lite/javascript-kernel/index.js +10 -0
- package/lib/jupyter/lite/javascript-kernel/index.js.map +1 -0
- package/lib/jupyter/lite/javascript-kernel/kernel.d.ts +121 -0
- package/lib/jupyter/lite/javascript-kernel/kernel.js +239 -0
- package/lib/jupyter/lite/javascript-kernel/kernel.js.map +1 -0
- package/lib/jupyter/lite/javascript-kernel/tokens.d.ts +27 -0
- package/lib/jupyter/lite/javascript-kernel/tokens.js +7 -0
- package/lib/jupyter/lite/javascript-kernel/tokens.js.map +1 -0
- package/lib/jupyter/lite/javascript-kernel/worker.d.ts +37 -0
- package/lib/jupyter/lite/javascript-kernel/worker.js +117 -0
- package/lib/jupyter/lite/javascript-kernel/worker.js.map +1 -0
- package/lib/jupyter/lite/javascript-kernel-extension/index.d.ts +3 -0
- package/lib/jupyter/lite/javascript-kernel-extension/index.js +37 -0
- package/lib/jupyter/lite/javascript-kernel-extension/index.js.map +1 -0
- package/lib/jupyter/lite/kernel/index.js +5 -0
- package/lib/jupyter/lite/kernel/index.js.map +1 -1
- package/lib/jupyter/lite/kernel/kernel.js +5 -0
- package/lib/jupyter/lite/kernel/kernel.js.map +1 -1
- package/lib/jupyter/lite/kernel/kernels.js +5 -0
- package/lib/jupyter/lite/kernel/kernels.js.map +1 -1
- package/lib/jupyter/lite/kernel/kernelspecs.js +5 -0
- package/lib/jupyter/lite/kernel/kernelspecs.js.map +1 -1
- package/lib/jupyter/lite/kernel/tokens.js +5 -2
- package/lib/jupyter/lite/kernel/tokens.js.map +1 -1
- package/lib/jupyter/lite/licenses/index.js +5 -0
- package/lib/jupyter/lite/licenses/index.js.map +1 -1
- package/lib/jupyter/lite/licenses/licenses.js +5 -0
- package/lib/jupyter/lite/licenses/licenses.js.map +1 -1
- package/lib/jupyter/lite/licenses/tokens.js +5 -0
- package/lib/jupyter/lite/licenses/tokens.js.map +1 -1
- package/lib/jupyter/lite/localforage/index.js +5 -0
- package/lib/jupyter/lite/localforage/index.js.map +1 -1
- package/lib/jupyter/lite/localforage/memory.js +5 -2
- package/lib/jupyter/lite/localforage/memory.js.map +1 -1
- package/lib/jupyter/lite/localforage/tokens.js +5 -2
- package/lib/jupyter/lite/localforage/tokens.js.map +1 -1
- package/lib/jupyter/lite/pyodide-kernel/_pypi.js +5 -0
- package/lib/jupyter/lite/pyodide-kernel/_pypi.js.map +1 -1
- package/lib/jupyter/lite/pyodide-kernel/coincident.worker.js +5 -0
- package/lib/jupyter/lite/pyodide-kernel/coincident.worker.js.map +1 -1
- package/lib/jupyter/lite/pyodide-kernel/comlink.worker.js +5 -0
- package/lib/jupyter/lite/pyodide-kernel/comlink.worker.js.map +1 -1
- package/lib/jupyter/lite/pyodide-kernel/index.js +5 -0
- package/lib/jupyter/lite/pyodide-kernel/index.js.map +1 -1
- package/lib/jupyter/lite/pyodide-kernel/kernel.js +5 -0
- package/lib/jupyter/lite/pyodide-kernel/kernel.js.map +1 -1
- package/lib/jupyter/lite/pyodide-kernel/tokens.js +5 -2
- package/lib/jupyter/lite/pyodide-kernel/tokens.js.map +1 -1
- package/lib/jupyter/lite/pyodide-kernel/worker.js +5 -2
- package/lib/jupyter/lite/pyodide-kernel/worker.js.map +1 -1
- package/lib/jupyter/lite/pyodide-kernel-extension/index.js +6 -1
- package/lib/jupyter/lite/pyodide-kernel-extension/index.js.map +1 -1
- package/lib/jupyter/lite/server/app.js +5 -0
- package/lib/jupyter/lite/server/app.js.map +1 -1
- package/lib/jupyter/lite/server/index.js +5 -0
- package/lib/jupyter/lite/server/index.js.map +1 -1
- package/lib/jupyter/lite/server/router.js +5 -0
- package/lib/jupyter/lite/server/router.js.map +1 -1
- package/lib/jupyter/lite/server/service-manager.js +5 -0
- package/lib/jupyter/lite/server/service-manager.js.map +1 -1
- package/lib/jupyter/lite/server/service-worker.js +5 -0
- package/lib/jupyter/lite/server/service-worker.js.map +1 -1
- package/lib/jupyter/lite/server/status.js +5 -0
- package/lib/jupyter/lite/server/status.js.map +1 -1
- package/lib/jupyter/lite/server/tokens.js +5 -0
- package/lib/jupyter/lite/server/tokens.js.map +1 -1
- package/lib/jupyter/lite/server-extension/index.js +5 -0
- package/lib/jupyter/lite/server-extension/index.js.map +1 -1
- package/lib/jupyter/lite/session/index.js +5 -0
- package/lib/jupyter/lite/session/index.js.map +1 -1
- package/lib/jupyter/lite/session/sessions.js +5 -0
- package/lib/jupyter/lite/session/sessions.js.map +1 -1
- package/lib/jupyter/lite/session/tokens.js +5 -0
- package/lib/jupyter/lite/session/tokens.js.map +1 -1
- package/lib/jupyter/lite/settings/index.js +5 -0
- package/lib/jupyter/lite/settings/index.js.map +1 -1
- package/lib/jupyter/lite/settings/settings.js +5 -0
- package/lib/jupyter/lite/settings/settings.js.map +1 -1
- package/lib/jupyter/lite/settings/tokens.js +5 -0
- package/lib/jupyter/lite/settings/tokens.js.map +1 -1
- package/lib/jupyter/lite/translation/index.js +5 -0
- package/lib/jupyter/lite/translation/index.js.map +1 -1
- package/lib/jupyter/lite/translation/tokens.js +5 -0
- package/lib/jupyter/lite/translation/tokens.js.map +1 -1
- package/lib/jupyter/lite/translation/translation.js +5 -0
- package/lib/jupyter/lite/translation/translation.js.map +1 -1
- package/lib/jupyter/lite/types/index.js +5 -0
- package/lib/jupyter/lite/types/index.js.map +1 -1
- package/lib/jupyter/lite/types/tokens.js +5 -2
- package/lib/jupyter/lite/types/tokens.js.map +1 -1
- package/lib/state/JupyterReactState.d.ts +2 -2
- package/lib/state/JupyterReactState.js +3 -1
- package/lib/state/JupyterReactState.js.map +1 -1
- package/lib/tools/core/executor.d.ts +4 -4
- package/lib/tools/core/executor.js +2 -2
- package/lib/tools/core/executor.js.map +1 -1
- package/lib/utils/Utils.d.ts +7 -0
- package/lib/utils/Utils.js +32 -0
- package/lib/utils/Utils.js.map +1 -1
- package/package.json +4 -1
- package/style/icons/javascript/logo-32x32.png +0 -0
- package/style/icons/javascript/logo-64x64.png +0 -0
- package/lib/components/notebook/Notebook2.d.ts +0 -112
- package/lib/components/notebook/Notebook2.js +0 -121
- package/lib/components/notebook/Notebook2.js.map +0 -1
- package/lib/components/notebook/Notebook2Adapter.d.ts +0 -269
- package/lib/components/notebook/Notebook2Adapter.js +0 -688
- package/lib/components/notebook/Notebook2Adapter.js.map +0 -1
- package/lib/components/notebook/Notebook2Base.js.map +0 -1
- package/lib/components/notebook/Notebook2State.d.ts +0 -59
- package/lib/components/notebook/Notebook2State.js +0 -122
- package/lib/components/notebook/Notebook2State.js.map +0 -1
- package/lib/examples/Notebook2.js +0 -30
- package/lib/examples/Notebook2.js.map +0 -1
- package/lib/examples/Notebook2Actions.js.map +0 -1
- package/lib/examples/Notebook2Collaborative.d.ts +0 -1
- package/lib/examples/Notebook2Collaborative.js +0 -23
- package/lib/examples/Notebook2Collaborative.js.map +0 -1
- package/lib/examples/Notebook2Lite.d.ts +0 -1
- package/lib/examples/Notebook2Lite.js +0 -39
- package/lib/examples/Notebook2Lite.js.map +0 -1
- package/lib/examples/NotebookLiteContext.d.ts +0 -1
- package/lib/examples/NotebookLiteContext.js +0 -24
- package/lib/examples/NotebookLiteContext.js.map +0 -1
- package/lib/examples/toolbars/NotebookToolbarAutoSave.d.ts +0 -4
- package/lib/examples/toolbars/NotebookToolbarAutoSave.js +0 -70
- package/lib/examples/toolbars/NotebookToolbarAutoSave.js.map +0 -1
- package/lib/examples/toolbars/NotebookToolbarStatus.d.ts +0 -4
- package/lib/examples/toolbars/NotebookToolbarStatus.js +0 -15
- package/lib/examples/toolbars/NotebookToolbarStatus.js.map +0 -1
- package/lib/jupyter/Jupyter.d.ts +0 -18
- package/lib/jupyter/Jupyter.js +0 -38
- package/lib/jupyter/Jupyter.js.map +0 -1
- package/lib/jupyter/JupyterContext.js +0 -99
- package/lib/jupyter/JupyterContext.js.map +0 -1
- /package/lib/examples/{Notebook2.d.ts → NotebookActions.d.ts} +0 -0
- /package/lib/{examples/Notebook2Actions.d.ts → jupyter/lite/javascript-kernel/comlink.worker.d.ts} +0 -0
- /package/style/icons/{pyodide.svg → pyodide/pyodide.svg} +0 -0
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { KernelMessage } from '@jupyterlab/services';
|
|
2
|
+
import { IRemoteJavaScriptWorkerKernel } from './tokens';
|
|
3
|
+
import { BaseKernel, IKernel } from '../kernel';
|
|
4
|
+
/**
|
|
5
|
+
* A kernel that executes code in an IFrame.
|
|
6
|
+
*/
|
|
7
|
+
export declare class JavaScriptKernel extends BaseKernel implements IKernel {
|
|
8
|
+
/**
|
|
9
|
+
* Instantiate a new JavaScriptKernel
|
|
10
|
+
*
|
|
11
|
+
* @param options The instantiation options for a new JavaScriptKernel
|
|
12
|
+
*/
|
|
13
|
+
constructor(options: JavaScriptKernel.IOptions);
|
|
14
|
+
/**
|
|
15
|
+
* Dispose the kernel.
|
|
16
|
+
*/
|
|
17
|
+
dispose(): void;
|
|
18
|
+
/**
|
|
19
|
+
* A promise that is fulfilled when the kernel is ready.
|
|
20
|
+
*/
|
|
21
|
+
get ready(): Promise<void>;
|
|
22
|
+
/**
|
|
23
|
+
* Handle a kernel_info_request message
|
|
24
|
+
*/
|
|
25
|
+
kernelInfoRequest(): Promise<KernelMessage.IInfoReplyMsg['content']>;
|
|
26
|
+
/**
|
|
27
|
+
* Handle an `execute_request` message
|
|
28
|
+
*
|
|
29
|
+
* @param msg The parent message.
|
|
30
|
+
*/
|
|
31
|
+
executeRequest(content: KernelMessage.IExecuteRequestMsg['content']): Promise<KernelMessage.IExecuteReplyMsg['content']>;
|
|
32
|
+
/**
|
|
33
|
+
* Handle an complete_request message
|
|
34
|
+
*
|
|
35
|
+
* @param msg The parent message.
|
|
36
|
+
*/
|
|
37
|
+
completeRequest(content: KernelMessage.ICompleteRequestMsg['content']): Promise<KernelMessage.ICompleteReplyMsg['content']>;
|
|
38
|
+
/**
|
|
39
|
+
* Handle an `inspect_request` message.
|
|
40
|
+
*
|
|
41
|
+
* @param content - The content of the request.
|
|
42
|
+
*
|
|
43
|
+
* @returns A promise that resolves with the response message.
|
|
44
|
+
*/
|
|
45
|
+
inspectRequest(content: KernelMessage.IInspectRequestMsg['content']): Promise<KernelMessage.IInspectReplyMsg['content']>;
|
|
46
|
+
/**
|
|
47
|
+
* Handle an `is_complete_request` message.
|
|
48
|
+
*
|
|
49
|
+
* @param content - The content of the request.
|
|
50
|
+
*
|
|
51
|
+
* @returns A promise that resolves with the response message.
|
|
52
|
+
*/
|
|
53
|
+
isCompleteRequest(content: KernelMessage.IIsCompleteRequestMsg['content']): Promise<KernelMessage.IIsCompleteReplyMsg['content']>;
|
|
54
|
+
/**
|
|
55
|
+
* Handle a `comm_info_request` message.
|
|
56
|
+
*
|
|
57
|
+
* @param content - The content of the request.
|
|
58
|
+
*
|
|
59
|
+
* @returns A promise that resolves with the response message.
|
|
60
|
+
*/
|
|
61
|
+
commInfoRequest(content: KernelMessage.ICommInfoRequestMsg['content']): Promise<KernelMessage.ICommInfoReplyMsg['content']>;
|
|
62
|
+
/**
|
|
63
|
+
* Send an `input_reply` message.
|
|
64
|
+
*
|
|
65
|
+
* @param content - The content of the reply.
|
|
66
|
+
*/
|
|
67
|
+
inputReply(content: KernelMessage.IInputReplyMsg['content']): void;
|
|
68
|
+
/**
|
|
69
|
+
* Send an `comm_open` message.
|
|
70
|
+
*
|
|
71
|
+
* @param msg - The comm_open message.
|
|
72
|
+
*/
|
|
73
|
+
commOpen(msg: KernelMessage.ICommOpenMsg): Promise<void>;
|
|
74
|
+
/**
|
|
75
|
+
* Send an `comm_msg` message.
|
|
76
|
+
*
|
|
77
|
+
* @param msg - The comm_msg message.
|
|
78
|
+
*/
|
|
79
|
+
commMsg(msg: KernelMessage.ICommMsgMsg): Promise<void>;
|
|
80
|
+
/**
|
|
81
|
+
* Send an `comm_close` message.
|
|
82
|
+
*
|
|
83
|
+
* @param close - The comm_close message.
|
|
84
|
+
*/
|
|
85
|
+
commClose(msg: KernelMessage.ICommCloseMsg): Promise<void>;
|
|
86
|
+
/**
|
|
87
|
+
* Load the worker.
|
|
88
|
+
*
|
|
89
|
+
* ### Note
|
|
90
|
+
*
|
|
91
|
+
* Subclasses must implement this typographically almost _exactly_ for
|
|
92
|
+
* webpack to find it.
|
|
93
|
+
*/
|
|
94
|
+
protected initWorker(options: JavaScriptKernel.IOptions): Worker;
|
|
95
|
+
/**
|
|
96
|
+
* Initialize the remote kernel.
|
|
97
|
+
*
|
|
98
|
+
* @param options The options for the remote kernel.
|
|
99
|
+
* @returns The initialized remote kernel.
|
|
100
|
+
*/
|
|
101
|
+
protected initRemote(options: JavaScriptKernel.IOptions): IRemoteJavaScriptWorkerKernel;
|
|
102
|
+
/**
|
|
103
|
+
* Process a message coming from the JavaScript web worker.
|
|
104
|
+
*
|
|
105
|
+
* @param msg The worker message to process.
|
|
106
|
+
*/
|
|
107
|
+
private _processWorkerMessage;
|
|
108
|
+
protected remoteKernel: IRemoteJavaScriptWorkerKernel;
|
|
109
|
+
private _worker;
|
|
110
|
+
private _ready;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* A namespace for JavaScriptKernel statics
|
|
114
|
+
*/
|
|
115
|
+
declare namespace JavaScriptKernel {
|
|
116
|
+
/**
|
|
117
|
+
* The instantiation options for a JavaScript kernel.
|
|
118
|
+
*/
|
|
119
|
+
type IOptions = IKernel.IOptions;
|
|
120
|
+
}
|
|
121
|
+
export {};
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2021-2023 Datalayer, Inc.
|
|
3
|
+
*
|
|
4
|
+
* MIT License
|
|
5
|
+
*/
|
|
6
|
+
import { PageConfig } from '@jupyterlab/coreutils';
|
|
7
|
+
import { PromiseDelegate } from '@lumino/coreutils';
|
|
8
|
+
import { wrap } from 'comlink';
|
|
9
|
+
import { BaseKernel } from '../kernel';
|
|
10
|
+
/**
|
|
11
|
+
* A kernel that executes code in an IFrame.
|
|
12
|
+
*/
|
|
13
|
+
export class JavaScriptKernel extends BaseKernel {
|
|
14
|
+
/**
|
|
15
|
+
* Instantiate a new JavaScriptKernel
|
|
16
|
+
*
|
|
17
|
+
* @param options The instantiation options for a new JavaScriptKernel
|
|
18
|
+
*/
|
|
19
|
+
constructor(options) {
|
|
20
|
+
super(options);
|
|
21
|
+
this._worker = this.initWorker(options);
|
|
22
|
+
this._worker.onmessage = e => this._processWorkerMessage(e.data);
|
|
23
|
+
this.remoteKernel = this.initRemote(options);
|
|
24
|
+
this._ready.resolve();
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Dispose the kernel.
|
|
28
|
+
*/
|
|
29
|
+
dispose() {
|
|
30
|
+
if (this.isDisposed) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
this._worker.terminate();
|
|
34
|
+
this._worker = null;
|
|
35
|
+
super.dispose();
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* A promise that is fulfilled when the kernel is ready.
|
|
39
|
+
*/
|
|
40
|
+
get ready() {
|
|
41
|
+
return this._ready.promise;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Handle a kernel_info_request message
|
|
45
|
+
*/
|
|
46
|
+
async kernelInfoRequest() {
|
|
47
|
+
const content = {
|
|
48
|
+
implementation: 'JavaScript',
|
|
49
|
+
implementation_version: '0.1.0',
|
|
50
|
+
language_info: {
|
|
51
|
+
codemirror_mode: {
|
|
52
|
+
name: 'javascript',
|
|
53
|
+
},
|
|
54
|
+
file_extension: '.js',
|
|
55
|
+
mimetype: 'text/javascript',
|
|
56
|
+
name: 'javascript',
|
|
57
|
+
nbconvert_exporter: 'javascript',
|
|
58
|
+
pygments_lexer: 'javascript',
|
|
59
|
+
version: 'es2017',
|
|
60
|
+
},
|
|
61
|
+
protocol_version: '5.3',
|
|
62
|
+
status: 'ok',
|
|
63
|
+
banner: 'A JavaScript kernel running in the browser',
|
|
64
|
+
help_links: [
|
|
65
|
+
{
|
|
66
|
+
text: 'JavaScript Kernel',
|
|
67
|
+
url: 'https://github.com/jupyterlite/javascript-kernel',
|
|
68
|
+
},
|
|
69
|
+
],
|
|
70
|
+
};
|
|
71
|
+
return content;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Handle an `execute_request` message
|
|
75
|
+
*
|
|
76
|
+
* @param msg The parent message.
|
|
77
|
+
*/
|
|
78
|
+
async executeRequest(content) {
|
|
79
|
+
const result = await this.remoteKernel.execute(content, this.parent);
|
|
80
|
+
result.execution_count = this.executionCount;
|
|
81
|
+
return result;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Handle an complete_request message
|
|
85
|
+
*
|
|
86
|
+
* @param msg The parent message.
|
|
87
|
+
*/
|
|
88
|
+
async completeRequest(content) {
|
|
89
|
+
return await this.remoteKernel.complete(content, this.parent);
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Handle an `inspect_request` message.
|
|
93
|
+
*
|
|
94
|
+
* @param content - The content of the request.
|
|
95
|
+
*
|
|
96
|
+
* @returns A promise that resolves with the response message.
|
|
97
|
+
*/
|
|
98
|
+
async inspectRequest(content) {
|
|
99
|
+
throw new Error('Not implemented');
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Handle an `is_complete_request` message.
|
|
103
|
+
*
|
|
104
|
+
* @param content - The content of the request.
|
|
105
|
+
*
|
|
106
|
+
* @returns A promise that resolves with the response message.
|
|
107
|
+
*/
|
|
108
|
+
async isCompleteRequest(content) {
|
|
109
|
+
throw new Error('Not implemented');
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Handle a `comm_info_request` message.
|
|
113
|
+
*
|
|
114
|
+
* @param content - The content of the request.
|
|
115
|
+
*
|
|
116
|
+
* @returns A promise that resolves with the response message.
|
|
117
|
+
*/
|
|
118
|
+
async commInfoRequest(content) {
|
|
119
|
+
throw new Error('Not implemented');
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Send an `input_reply` message.
|
|
123
|
+
*
|
|
124
|
+
* @param content - The content of the reply.
|
|
125
|
+
*/
|
|
126
|
+
inputReply(content) {
|
|
127
|
+
throw new Error('Not implemented');
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Send an `comm_open` message.
|
|
131
|
+
*
|
|
132
|
+
* @param msg - The comm_open message.
|
|
133
|
+
*/
|
|
134
|
+
async commOpen(msg) {
|
|
135
|
+
throw new Error('Not implemented');
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Send an `comm_msg` message.
|
|
139
|
+
*
|
|
140
|
+
* @param msg - The comm_msg message.
|
|
141
|
+
*/
|
|
142
|
+
async commMsg(msg) {
|
|
143
|
+
throw new Error('Not implemented');
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Send an `comm_close` message.
|
|
147
|
+
*
|
|
148
|
+
* @param close - The comm_close message.
|
|
149
|
+
*/
|
|
150
|
+
async commClose(msg) {
|
|
151
|
+
throw new Error('Not implemented');
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Load the worker.
|
|
155
|
+
*
|
|
156
|
+
* ### Note
|
|
157
|
+
*
|
|
158
|
+
* Subclasses must implement this typographically almost _exactly_ for
|
|
159
|
+
* webpack to find it.
|
|
160
|
+
*/
|
|
161
|
+
initWorker(options) {
|
|
162
|
+
return new Worker(new URL('./comlink.worker.js', import.meta.url), {
|
|
163
|
+
type: 'module',
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Initialize the remote kernel.
|
|
168
|
+
*
|
|
169
|
+
* @param options The options for the remote kernel.
|
|
170
|
+
* @returns The initialized remote kernel.
|
|
171
|
+
*/
|
|
172
|
+
initRemote(options) {
|
|
173
|
+
const remote = wrap(this._worker);
|
|
174
|
+
remote.initialize({ baseUrl: PageConfig.getBaseUrl() });
|
|
175
|
+
return remote;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Process a message coming from the JavaScript web worker.
|
|
179
|
+
*
|
|
180
|
+
* @param msg The worker message to process.
|
|
181
|
+
*/
|
|
182
|
+
_processWorkerMessage(msg) {
|
|
183
|
+
if (!msg.type) {
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
const parentHeader = msg.parentHeader || this.parentHeader;
|
|
187
|
+
switch (msg.type) {
|
|
188
|
+
case 'stream': {
|
|
189
|
+
const bundle = msg.bundle ?? { name: 'stdout', text: '' };
|
|
190
|
+
this.stream(bundle, parentHeader);
|
|
191
|
+
break;
|
|
192
|
+
}
|
|
193
|
+
case 'input_request': {
|
|
194
|
+
const bundle = msg.content ?? { prompt: '', password: false };
|
|
195
|
+
this.inputRequest(bundle, parentHeader);
|
|
196
|
+
break;
|
|
197
|
+
}
|
|
198
|
+
case 'display_data': {
|
|
199
|
+
const bundle = msg.bundle ?? { data: {}, metadata: {}, transient: {} };
|
|
200
|
+
this.displayData(bundle, parentHeader);
|
|
201
|
+
break;
|
|
202
|
+
}
|
|
203
|
+
case 'update_display_data': {
|
|
204
|
+
const bundle = msg.bundle ?? { data: {}, metadata: {}, transient: {} };
|
|
205
|
+
this.updateDisplayData(bundle, parentHeader);
|
|
206
|
+
break;
|
|
207
|
+
}
|
|
208
|
+
case 'clear_output': {
|
|
209
|
+
const bundle = msg.bundle ?? { wait: false };
|
|
210
|
+
this.clearOutput(bundle, parentHeader);
|
|
211
|
+
break;
|
|
212
|
+
}
|
|
213
|
+
case 'execute_result': {
|
|
214
|
+
const bundle = msg.bundle ?? {
|
|
215
|
+
execution_count: 0,
|
|
216
|
+
data: {},
|
|
217
|
+
metadata: {},
|
|
218
|
+
};
|
|
219
|
+
this.publishExecuteResult(bundle, parentHeader);
|
|
220
|
+
break;
|
|
221
|
+
}
|
|
222
|
+
case 'execute_error': {
|
|
223
|
+
const bundle = msg.bundle ?? { ename: '', evalue: '', traceback: [] };
|
|
224
|
+
this.publishExecuteError(bundle, parentHeader);
|
|
225
|
+
break;
|
|
226
|
+
}
|
|
227
|
+
case 'comm_msg':
|
|
228
|
+
case 'comm_open':
|
|
229
|
+
case 'comm_close': {
|
|
230
|
+
this.handleComm(msg.type, msg.content, msg.metadata, msg.buffers, msg.parentHeader);
|
|
231
|
+
break;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
remoteKernel;
|
|
236
|
+
_worker;
|
|
237
|
+
_ready = new PromiseDelegate();
|
|
238
|
+
}
|
|
239
|
+
//# sourceMappingURL=kernel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kernel.js","sourceRoot":"","sources":["../../../../src/jupyter/lite/javascript-kernel/kernel.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEnD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAE/B,OAAO,EAAE,UAAU,EAAW,MAAM,WAAW,CAAC;AAEhD;;GAEG;AACH,MAAM,OAAO,gBAAiB,SAAQ,UAAU;IAC9C;;;;OAIG;IACH,YAAY,OAAkC;QAC5C,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QACxC,IAAI,CAAC,OAAO,CAAC,SAAS,GAAG,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QACjE,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QAC7C,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;IACxB,CAAC;IAED;;OAEG;IACH,OAAO;QACL,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YACpB,OAAO;QACT,CAAC;QACD,IAAI,CAAC,OAA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IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;gBAC7C,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;gBACvC,MAAM;YACR,CAAC;YACD,KAAK,gBAAgB,CAAC,CAAC,CAAC;gBACtB,MAAM,MAAM,GAAG,GAAG,CAAC,MAAM,IAAI;oBAC3B,eAAe,EAAE,CAAC;oBAClB,IAAI,EAAE,EAAE;oBACR,QAAQ,EAAE,EAAE;iBACb,CAAC;gBACF,IAAI,CAAC,oBAAoB,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;gBAChD,MAAM;YACR,CAAC;YACD,KAAK,eAAe,CAAC,CAAC,CAAC;gBACrB,MAAM,MAAM,GAAG,GAAG,CAAC,MAAM,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC;gBACtE,IAAI,CAAC,mBAAmB,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;gBAC/C,MAAM;YACR,CAAC;YACD,KAAK,UAAU,CAAC;YAChB,KAAK,WAAW,CAAC;YACjB,KAAK,YAAY,CAAC,CAAC,CAAC;gBAClB,IAAI,CAAC,UAAU,CACb,GAAG,CAAC,IAAI,EACR,GAAG,CAAC,OAAO,EACX,GAAG,CAAC,QAAQ,EACZ,GAAG,CAAC,OAAO,EACX,GAAG,CAAC,YAAY,CACjB,CAAC;gBACF,MAAM;YACR,CAAC;QACH,CAAC;IACH,CAAC;IAES,YAAY,CAAgC;IAE9C,OAAO,CAAS;IAChB,MAAM,GAAG,IAAI,eAAe,EAAQ,CAAC;CAC9C"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Definitions for the JavaScript kernel.
|
|
3
|
+
*/
|
|
4
|
+
import type { Remote } from 'comlink';
|
|
5
|
+
import { IWorkerKernel } from '../kernel';
|
|
6
|
+
/**
|
|
7
|
+
* An interface for JavaScript workers.
|
|
8
|
+
*/
|
|
9
|
+
export interface IJavaScriptWorkerKernel extends IWorkerKernel {
|
|
10
|
+
/**
|
|
11
|
+
* Handle any lazy initialization activities.
|
|
12
|
+
*/
|
|
13
|
+
initialize(options: IJavaScriptWorkerKernel.IOptions): Promise<void>;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* An convenience interface for JavaScript workers wrapped by a comlink Remote.
|
|
17
|
+
*/
|
|
18
|
+
export type IRemoteJavaScriptWorkerKernel = Remote<IJavaScriptWorkerKernel>;
|
|
19
|
+
/**
|
|
20
|
+
* An namespace for JavaScript workers.
|
|
21
|
+
*/
|
|
22
|
+
export declare namespace IJavaScriptWorkerKernel {
|
|
23
|
+
/**
|
|
24
|
+
* Initialization options for a worker.
|
|
25
|
+
*/
|
|
26
|
+
type IOptions = IWorkerKernel.IOptions;
|
|
27
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tokens.js","sourceRoot":"","sources":["../../../../src/jupyter/lite/javascript-kernel/tokens.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { IJavaScriptWorkerKernel } from './tokens';
|
|
2
|
+
export declare class JavaScriptRemoteKernel {
|
|
3
|
+
/**
|
|
4
|
+
* Initialize the remote kernel.
|
|
5
|
+
*
|
|
6
|
+
* @param options The options for the kernel.
|
|
7
|
+
*/
|
|
8
|
+
initialize(options: IJavaScriptWorkerKernel.IOptions): Promise<void>;
|
|
9
|
+
/**
|
|
10
|
+
* Execute code in the worker kernel.
|
|
11
|
+
*/
|
|
12
|
+
execute(content: any, parent: any): Promise<{
|
|
13
|
+
status: string;
|
|
14
|
+
user_expressions: {};
|
|
15
|
+
ename?: undefined;
|
|
16
|
+
evalue?: undefined;
|
|
17
|
+
traceback?: undefined;
|
|
18
|
+
} | {
|
|
19
|
+
status: string;
|
|
20
|
+
ename: string;
|
|
21
|
+
evalue: string;
|
|
22
|
+
traceback: string[];
|
|
23
|
+
user_expressions?: undefined;
|
|
24
|
+
}>;
|
|
25
|
+
/**
|
|
26
|
+
* Handle the complete message
|
|
27
|
+
*/
|
|
28
|
+
complete(content: any, parent: any): Promise<{
|
|
29
|
+
matches: string[];
|
|
30
|
+
cursor_start: number;
|
|
31
|
+
cursor_end: any;
|
|
32
|
+
metadata: {};
|
|
33
|
+
status: string;
|
|
34
|
+
}>;
|
|
35
|
+
private _inspect;
|
|
36
|
+
private _executionCount;
|
|
37
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2021-2023 Datalayer, Inc.
|
|
3
|
+
*
|
|
4
|
+
* MIT License
|
|
5
|
+
*/
|
|
6
|
+
import objectInspect from 'object-inspect';
|
|
7
|
+
export class JavaScriptRemoteKernel {
|
|
8
|
+
/**
|
|
9
|
+
* Initialize the remote kernel.
|
|
10
|
+
*
|
|
11
|
+
* @param options The options for the kernel.
|
|
12
|
+
*/
|
|
13
|
+
async initialize(options) {
|
|
14
|
+
// eslint-disable-next-line no-console
|
|
15
|
+
console.log = function (...args) {
|
|
16
|
+
const bundle = {
|
|
17
|
+
name: 'stdout',
|
|
18
|
+
text: args.join(' ') + '\n',
|
|
19
|
+
};
|
|
20
|
+
postMessage({
|
|
21
|
+
type: 'stream',
|
|
22
|
+
bundle,
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
// eslint-disable-next-line no-console
|
|
26
|
+
console.info = console.log;
|
|
27
|
+
console.error = function (...args) {
|
|
28
|
+
const bundle = {
|
|
29
|
+
name: 'stderr',
|
|
30
|
+
text: args.join(' ') + '\n',
|
|
31
|
+
};
|
|
32
|
+
postMessage({
|
|
33
|
+
type: 'stream',
|
|
34
|
+
bundle,
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
console.warn = console.error;
|
|
38
|
+
self.onerror = function (message, source, lineno, colno, error) {
|
|
39
|
+
console.error(message);
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Execute code in the worker kernel.
|
|
44
|
+
*/
|
|
45
|
+
async execute(content, parent) {
|
|
46
|
+
const { code } = content;
|
|
47
|
+
try {
|
|
48
|
+
const result = self.eval(code);
|
|
49
|
+
this._executionCount++;
|
|
50
|
+
const textPlain = this._inspect(result);
|
|
51
|
+
const data = {};
|
|
52
|
+
if (typeof textPlain === 'string') {
|
|
53
|
+
data['text/plain'] = textPlain;
|
|
54
|
+
}
|
|
55
|
+
const bundle = {
|
|
56
|
+
data,
|
|
57
|
+
metadata: {},
|
|
58
|
+
execution_count: this._executionCount,
|
|
59
|
+
};
|
|
60
|
+
postMessage({
|
|
61
|
+
bundle,
|
|
62
|
+
type: 'execute_result',
|
|
63
|
+
});
|
|
64
|
+
return {
|
|
65
|
+
status: 'ok',
|
|
66
|
+
user_expressions: {},
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
catch (e) {
|
|
70
|
+
const { name, stack, message } = e;
|
|
71
|
+
const bundle = {
|
|
72
|
+
ename: name,
|
|
73
|
+
evalue: message,
|
|
74
|
+
traceback: [`${stack}`],
|
|
75
|
+
};
|
|
76
|
+
postMessage({
|
|
77
|
+
bundle,
|
|
78
|
+
type: 'execute_error',
|
|
79
|
+
});
|
|
80
|
+
return {
|
|
81
|
+
status: 'error',
|
|
82
|
+
ename: name,
|
|
83
|
+
evalue: message,
|
|
84
|
+
traceback: [`${stack}`],
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Handle the complete message
|
|
90
|
+
*/
|
|
91
|
+
async complete(content, parent) {
|
|
92
|
+
// naive completion on window names only
|
|
93
|
+
// TODO: improve and move logic to the iframe
|
|
94
|
+
const vars = Object.getOwnPropertyNames(self);
|
|
95
|
+
const { code, cursor_pos } = content;
|
|
96
|
+
const words = code.slice(0, cursor_pos).match(/(\w+)$/) ?? [];
|
|
97
|
+
const word = words[0] ?? '';
|
|
98
|
+
const matches = vars.filter(v => v.startsWith(word));
|
|
99
|
+
return {
|
|
100
|
+
matches,
|
|
101
|
+
cursor_start: cursor_pos - word.length,
|
|
102
|
+
cursor_end: cursor_pos,
|
|
103
|
+
metadata: {},
|
|
104
|
+
status: 'ok',
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
_inspect(val) {
|
|
108
|
+
if (typeof val === 'undefined') {
|
|
109
|
+
return undefined;
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
return objectInspect(val);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
_executionCount = 0;
|
|
116
|
+
}
|
|
117
|
+
//# sourceMappingURL=worker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worker.js","sourceRoot":"","sources":["../../../../src/jupyter/lite/javascript-kernel/worker.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,aAAa,MAAM,gBAAgB,CAAC;AAE3C,MAAM,OAAO,sBAAsB;IACjC;;;;OAIG;IACH,KAAK,CAAC,UAAU,CAAC,OAAyC;QACxD,sCAAsC;QACtC,OAAO,CAAC,GAAG,GAAG,UAAU,GAAG,IAAI;YAC7B,MAAM,MAAM,GAAG;gBACb,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI;aAC5B,CAAC;YACF,WAAW,CAAC;gBACV,IAAI,EAAE,QAAQ;gBACd,MAAM;aACP,CAAC,CAAC;QACL,CAAC,CAAC;QACF,sCAAsC;QACtC,OAAO,CAAC,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC;QAE3B,OAAO,CAAC,KAAK,GAAG,UAAU,GAAG,IAAI;YAC/B,MAAM,MAAM,GAAG;gBACb,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI;aAC5B,CAAC;YACF,WAAW,CAAC;gBACV,IAAI,EAAE,QAAQ;gBAC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Inc.
|
|
3
|
+
*
|
|
4
|
+
* MIT License
|
|
5
|
+
*/
|
|
6
|
+
import { IKernelSpecs } from '../kernel';
|
|
7
|
+
import { JavaScriptKernel } from '../javascript-kernel';
|
|
8
|
+
import jsLogo32 from '../../../../style/icons/javascript/logo-32x32.png';
|
|
9
|
+
import jsLogo64 from '../../../../style/icons/javascript/logo-64x64.png';
|
|
10
|
+
/**
|
|
11
|
+
* A plugin to register the JavaScript kernel.
|
|
12
|
+
*/
|
|
13
|
+
const kernel = {
|
|
14
|
+
id: '@jupyterlite/javascript-kernel-extension:kernel',
|
|
15
|
+
autoStart: true,
|
|
16
|
+
requires: [IKernelSpecs],
|
|
17
|
+
activate: (app, kernelspecs) => {
|
|
18
|
+
kernelspecs.register({
|
|
19
|
+
spec: {
|
|
20
|
+
name: 'javascript',
|
|
21
|
+
display_name: 'JavaScript (Web Worker)',
|
|
22
|
+
language: 'javascript',
|
|
23
|
+
argv: [],
|
|
24
|
+
resources: {
|
|
25
|
+
'logo-32x32': jsLogo32,
|
|
26
|
+
'logo-64x64': jsLogo64,
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
create: async (options) => {
|
|
30
|
+
return new JavaScriptKernel(options);
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
const plugins = [kernel];
|
|
36
|
+
export default plugins;
|
|
37
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/jupyter/lite/javascript-kernel-extension/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,OAAO,EAAW,YAAY,EAAE,MAAM,WAAW,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAExD,OAAO,QAAQ,MAAM,mDAAmD,CAAC;AACzE,OAAO,QAAQ,MAAM,mDAAmD,CAAC;AAEzE;;GAEG;AACH,MAAM,MAAM,GAAkC;IAC5C,EAAE,EAAE,iDAAiD;IACrD,SAAS,EAAE,IAAI;IACf,QAAQ,EAAE,CAAC,YAAY,CAAC;IACxB,QAAQ,EAAE,CAAC,GAAsB,EAAE,WAAyB,EAAE,EAAE;QAC9D,WAAW,CAAC,QAAQ,CAAC;YACnB,IAAI,EAAE;gBACJ,IAAI,EAAE,YAAY;gBAClB,YAAY,EAAE,yBAAyB;gBACvC,QAAQ,EAAE,YAAY;gBACtB,IAAI,EAAE,EAAE;gBACR,SAAS,EAAE;oBACT,YAAY,EAAE,QAAQ;oBACtB,YAAY,EAAE,QAAQ;iBACvB;aACF;YACD,MAAM,EAAE,KAAK,EAAE,OAAyB,EAAoB,EAAE;gBAC5D,OAAO,IAAI,gBAAgB,CAAC,OAAO,CAAC,CAAC;YACvC,CAAC;SACF,CAAC,CAAC;IACL,CAAC;CACF,CAAC;AAEF,MAAM,OAAO,GAAmC,CAAC,MAAM,CAAC,CAAC;AAEzD,eAAe,OAAO,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/jupyter/lite/kernel/index.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,2DAA2D;AAE3D,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/jupyter/lite/kernel/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,0CAA0C;AAC1C,2DAA2D;AAE3D,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC"}
|