@eclipse-docks/extension-notebook 0.7.71 → 0.7.72
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/dist/index.js
CHANGED
|
@@ -11,7 +11,7 @@ extensionRegistry.registerExtension({
|
|
|
11
11
|
id: pkg.name,
|
|
12
12
|
name: t.EXT_NOTEBOOK_NAME,
|
|
13
13
|
description: t.EXT_NOTEBOOK_DESC,
|
|
14
|
-
loader: () => import("./notebook-extension-
|
|
14
|
+
loader: () => import("./notebook-extension-5RGkFBo2.js"),
|
|
15
15
|
icon: "docks jupyter",
|
|
16
16
|
dependencies: []
|
|
17
17
|
});
|
|
@@ -142,7 +142,7 @@ var notebook_extension_default = ({ editorRegistry, commandRegistry, contributio
|
|
|
142
142
|
title: input.getWorkspacePath(),
|
|
143
143
|
data: input,
|
|
144
144
|
key: input.getWorkspacePath(),
|
|
145
|
-
icon:
|
|
145
|
+
icon: editorRegistry.getFileIcon(input.getName()),
|
|
146
146
|
state: {}
|
|
147
147
|
};
|
|
148
148
|
editorInput.component = (id) => html`
|
|
@@ -166,4 +166,4 @@ var notebook_extension_default = ({ editorRegistry, commandRegistry, contributio
|
|
|
166
166
|
//#endregion
|
|
167
167
|
export { notebook_extension_default as default };
|
|
168
168
|
|
|
169
|
-
//# sourceMappingURL=notebook-extension-
|
|
169
|
+
//# sourceMappingURL=notebook-extension-5RGkFBo2.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notebook-extension-
|
|
1
|
+
{"version":3,"file":"notebook-extension-5RGkFBo2.js","names":[],"sources":["../src/notebook-catalog.ts","../src/javascript-kernel.ts","../src/notebook-extension.ts"],"sourcesContent":["import type { CatalogContribution } from \"@eclipse-docks/extension-catalog/api\";\nimport { registerCatalog } from \"@eclipse-docks/extension-catalog/api\";\n\nconst NOTEBOOK_CATALOG: CatalogContribution = {\n label: \"Notebooks\",\n icon: \"docks jupyter\",\n contributionId: \"catalog.notebooks\",\n items: [\n {\n label: \"JavaScript\",\n icon: \"file-code\",\n contributionId: \"catalog.notebooks.javascript\",\n items: [\n { label: \"JavaScript basics\", icon: \"docks jupyter\", state: { url: new URL(\"./catalog/javascript-basics.ipynb\", import.meta.url).href, filename: \"javascript-basics.ipynb\" } },\n ],\n },\n {\n label: \"DuckDB\",\n icon: \"file-code\",\n contributionId: \"catalog.notebooks.duckdb\",\n items: [\n { label: \"DuckDB in notebooks\", icon: \"docks jupyter\", state: { url: new URL(\"./catalog/duckdb-sample.ipynb\", import.meta.url).href, filename: \"duckdb-sample.ipynb\" } },\n ],\n },\n {\n label: \"PGlite\",\n icon: \"file-code\",\n contributionId: \"catalog.notebooks.pglite\",\n items: [\n { label: \"PostgreSQL in notebooks\", icon: \"docks jupyter\", state: { url: new URL(\"./catalog/pglite-sample.ipynb\", import.meta.url).href, filename: \"pglite-sample.ipynb\" } },\n ],\n },\n ],\n};\n\nexport function registerNotebookCatalog(): void {\n registerCatalog(NOTEBOOK_CATALOG);\n}\n","import { createJsRuntime, type JsRuntime } from '@eclipse-docks/core';\nimport type { NotebookExecutionResult, NotebookKernel, NotebookKernelContribution } from './notebook-kernel-api';\n\nclass JavaScriptNotebookKernel implements NotebookKernel {\n readonly id = 'javascript';\n readonly label = 'JavaScript';\n readonly language = 'javascript';\n\n private runtime: JsRuntime | null = null;\n\n private getRuntime(): JsRuntime {\n if (!this.runtime) {\n this.runtime = createJsRuntime();\n }\n return this.runtime;\n }\n\n async getVersion(): Promise<string> {\n return 'JavaScript';\n }\n\n async execute(code: string): Promise<NotebookExecutionResult> {\n try {\n const result = await this.getRuntime().execute(code);\n if (result === undefined || result === null) {\n return {};\n }\n return { data: String(result) };\n } catch (err) {\n return { error: err instanceof Error ? err.message : String(err) };\n }\n }\n\n close(): void {\n if (this.runtime) {\n this.runtime.close();\n this.runtime = null;\n }\n }\n}\n\nexport const javascriptKernelContribution: NotebookKernelContribution = {\n id: 'javascript',\n label: 'JavaScript',\n language: 'javascript',\n loadKernel: async (): Promise<NotebookKernel> => new JavaScriptNotebookKernel(),\n};\n","import { html } from \"lit\";\nimport type { EditorInput } from \"@eclipse-docks/core\";\nimport { File } from \"@eclipse-docks/core\";\nimport { activeEditorSignal } from \"@eclipse-docks/core\";\nimport type { ExecutionContext } from \"@eclipse-docks/core\";\nimport { registerNotebookCatalog } from \"./notebook-catalog\";\nimport { NotebookData, isNotebookEditorLike } from \"./notebook-types\";\nimport { TARGET_NOTEBOOK_KERNELS } from \"./notebook-kernel-api\";\nimport { javascriptKernelContribution } from \"./javascript-kernel\";\n\nexport default ({ editorRegistry, commandRegistry, contributionRegistry }: any) => {\n registerNotebookCatalog();\n contributionRegistry.registerContribution(TARGET_NOTEBOOK_KERNELS, javascriptKernelContribution);\n\n const INITIAL_NOTEBOOK_CONTENT: NotebookData = {\n cells: [\n {\n cell_type: 'markdown',\n source: ['Press the **Run** button in the code cell below to execute it.'],\n metadata: {}\n },\n {\n cell_type: 'code',\n source: ['return \"Hello, World!\"'],\n execution_count: null,\n outputs: [],\n metadata: {}\n }\n ],\n metadata: { kernel: 'javascript' },\n nbformat: 4,\n nbformat_minor: 4\n };\n commandRegistry.registerHandler('notebook.runCell', {\n ranking: 10,\n canExecute: (context: ExecutionContext) => {\n const activeEditor = activeEditorSignal.get();\n if (isNotebookEditorLike(activeEditor)) {\n const cellIndex = context.params?.cellIndex;\n if (cellIndex !== undefined) {\n return cellIndex >= 0 && cellIndex < (activeEditor.notebook?.cells.length ?? 0);\n }\n return activeEditor.focusedCellIndex >= 0;\n }\n return false;\n },\n execute: async (context: ExecutionContext) => {\n const activeEditor = activeEditorSignal.get();\n if (isNotebookEditorLike(activeEditor)) {\n const cellIndex = context.params?.cellIndex ?? activeEditor.focusedCellIndex;\n if (cellIndex >= 0) {\n await activeEditor.executeCell(cellIndex);\n }\n }\n }\n });\n\n editorRegistry.registerEditorInputHandler({\n editorId: \"system.notebooeditor\",\n label: \"Jupyter Notebook\",\n icon: \"docks jupyter\",\n lazyInit: () => import('./notebook-runtime'),\n canHandle: (input: any) => input instanceof File && input.getName().toLowerCase().endsWith(\".ipynb\"),\n handle: async (input: File) => {\n const editorInput = {\n title: input.getWorkspacePath(),\n data: input,\n key: input.getWorkspacePath(),\n icon: editorRegistry.getFileIcon(input.getName()),\n state: {},\n } as EditorInput;\n editorInput.component = (id: string) => html`\n <docks-notebook-editor id=\"${id}\" .input=${editorInput}></docks-notebook-editor>`;\n return editorInput;\n },\n ranking: 100,\n });\n\n contributionRegistry.registerContribution('filebrowser.create', {\n label: 'Jupyter Notebook',\n icon: 'docks jupyter',\n command: 'touch',\n params: {\n path: \"notebook.ipynb\",\n extension: '.ipynb',\n ask: true,\n contents: JSON.stringify(INITIAL_NOTEBOOK_CONTENT, null, 2)\n }\n });\n};\n\n\n"],"mappings":";;;;;;AAGA,IAAM,mBAAwC;CAC1C,OAAO;CACP,MAAM;CACN,gBAAgB;CAChB,OAAO;EACH;GACI,OAAO;GACP,MAAM;GACN,gBAAgB;GAChB,OAAO,CACH;IAAE,OAAO;IAAqB,MAAM;IAAiB,OAAO;KAAE,KAAK,IAAA,IAAA,y6CAAA,KAAA,OAAA,KAAA,IAA6D,CAAC;KAAM,UAAU;;IAA6B,CAAA;GAErL;EACD;GACI,OAAO;GACP,MAAM;GACN,gBAAgB;GAChB,OAAO,CACH;IAAE,OAAO;IAAuB,MAAM;IAAiB,OAAO;KAAE,KAAK,IAAA,IAAA,quCAAA,KAAA,OAAA,KAAA,IAAyD,CAAC;KAAM,UAAU;;IAAyB,CAAA;GAE/K;EACD;GACI,OAAO;GACP,MAAM;GACN,gBAAgB;GAChB,OAAO,CACH;IAAE,OAAO;IAA2B,MAAM;IAAiB,OAAO;KAAE,KAAK,IAAA,IAAA,qxCAAA,KAAA,OAAA,KAAA,IAAyD,CAAC;KAAM,UAAU;;IAAyB,CAAA;;;CAI3L;AAED,SAAgB,0BAAgC;AAC5C,iBAAgB,iBAAiB;;;;ACjCrC,IAAM,2BAAN,MAAyD;;Y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