@eclipse-lyra/extension-notebook 0.7.56 → 0.7.58

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.
@@ -0,0 +1,11 @@
1
+ //#region src/i18n.de.json
2
+ var EXT_NOTEBOOK_NAME = "Jupyter-ähnlicher Notebook-Editor";
3
+ var EXT_NOTEBOOK_DESC = "Anzeigen und Ausführen von Jupyter-ähnlichen Notebooks (.ipynb) mit Python-Codeausführung und Markdown-Rendering";
4
+ var i18n_de_default = {
5
+ EXT_NOTEBOOK_NAME,
6
+ EXT_NOTEBOOK_DESC
7
+ };
8
+ //#endregion
9
+ export { EXT_NOTEBOOK_DESC, EXT_NOTEBOOK_NAME, i18n_de_default as default };
10
+
11
+ //# sourceMappingURL=i18n.de-D3c6aEZx.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"i18n.de-D3c6aEZx.js","names":[],"sources":["../src/i18n.de.json"],"sourcesContent":["{\n \"EXT_NOTEBOOK_NAME\": \"Jupyter-ähnlicher Notebook-Editor\",\n \"EXT_NOTEBOOK_DESC\": \"Anzeigen und Ausführen von Jupyter-ähnlichen Notebooks (.ipynb) mit Python-Codeausführung und Markdown-Rendering\"\n}\n"],"mappings":""}
@@ -0,0 +1,11 @@
1
+ //#region src/i18n.en.json
2
+ var EXT_NOTEBOOK_NAME = "Jupyter-like Notebook Editor";
3
+ var EXT_NOTEBOOK_DESC = "View and execute Jupyter-like notebooks (.ipynb) with Python code execution and markdown rendering";
4
+ var i18n_en_default = {
5
+ EXT_NOTEBOOK_NAME,
6
+ EXT_NOTEBOOK_DESC
7
+ };
8
+ //#endregion
9
+ export { EXT_NOTEBOOK_DESC, EXT_NOTEBOOK_NAME, i18n_en_default as default };
10
+
11
+ //# sourceMappingURL=i18n.en-8WPN49Yu.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"i18n.en-8WPN49Yu.js","names":[],"sources":["../src/i18n.en.json"],"sourcesContent":["{\n \"EXT_NOTEBOOK_NAME\": \"Jupyter-like Notebook Editor\",\n \"EXT_NOTEBOOK_DESC\": \"View and execute Jupyter-like notebooks (.ipynb) with Python code execution and markdown rendering\"\n}\n"],"mappings":""}
package/dist/index.js CHANGED
@@ -1,17 +1,21 @@
1
- import { T, i } from "./notebook-kernel-api--RBL5TaE.js";
2
- import { i18n, extensionRegistry } from "@eclipse-lyra/core";
1
+ import { t as isNotebookEditorLike } from "./notebook-types-6XV6fOSV.js";
2
+ import { t as TARGET_NOTEBOOK_KERNELS } from "./notebook-kernel-api-c9l3_84P.js";
3
+ import { extensionRegistry, i18n } from "@eclipse-lyra/core";
3
4
  import pkg from "../package.json";
4
- const t = await i18n(/* @__PURE__ */ Object.assign({ "./i18n.de.json": () => import("./i18n.de-a9KEn_KU.js"), "./i18n.en.json": () => import("./i18n.en-Bsu797kK.js") }), true);
5
+ //#region src/index.ts
6
+ var t = await i18n(/* @__PURE__ */ Object.assign({
7
+ "./i18n.de.json": () => import("./i18n.de-D3c6aEZx.js"),
8
+ "./i18n.en.json": () => import("./i18n.en-8WPN49Yu.js")
9
+ }), true);
5
10
  extensionRegistry.registerExtension({
6
- id: pkg.name,
7
- name: t.EXT_NOTEBOOK_NAME,
8
- description: t.EXT_NOTEBOOK_DESC,
9
- loader: () => import("./notebook-extension-SAMx4aPI.js"),
10
- icon: "lyra jupyter",
11
- dependencies: []
11
+ id: pkg.name,
12
+ name: t.EXT_NOTEBOOK_NAME,
13
+ description: t.EXT_NOTEBOOK_DESC,
14
+ loader: () => import("./notebook-extension-BLdbp0aG.js"),
15
+ icon: "lyra jupyter",
16
+ dependencies: []
12
17
  });
13
- export {
14
- T as TARGET_NOTEBOOK_KERNELS,
15
- i as isNotebookEditorLike
16
- };
17
- //# sourceMappingURL=index.js.map
18
+ //#endregion
19
+ export { TARGET_NOTEBOOK_KERNELS, isNotebookEditorLike };
20
+
21
+ //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["export * from './notebook-types';\nexport * from './notebook-kernel-api';\nimport { extensionRegistry, i18n } from '@eclipse-lyra/core';\nimport pkg from '../package.json';\n\nconst t = await i18n(import.meta.glob('./i18n*.json'), true);\n\nextensionRegistry.registerExtension({\n id: pkg.name,\n name: t.EXT_NOTEBOOK_NAME,\n description: t.EXT_NOTEBOOK_DESC,\n loader: () => import(\"./notebook-extension\"),\n icon: \"lyra jupyter\",\n dependencies: [],\n});\n"],"names":[],"mappings":";;;AAKA,MAAM,IAAI,MAAM,KAAK,uBAAA,OAAA,EAAA,kBAAA,MAAA,OAAA,uBAAA,GAAA,kBAAA,MAAA,OAAA,uBAAA,EAAA,CAAA,GAAkC,IAAI;AAE3D,kBAAkB,kBAAkB;AAAA,EAClC,IAAI,IAAI;AAAA,EACR,MAAM,EAAE;AAAA,EACR,aAAa,EAAE;AAAA,EACf,QAAQ,MAAM,OAAO,kCAAsB;AAAA,EAC3C,MAAM;AAAA,EACN,cAAc,CAAA;AAChB,CAAC;"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["export * from './notebook-types';\nexport * from './notebook-kernel-api';\nimport { extensionRegistry, i18n } from '@eclipse-lyra/core';\nimport pkg from '../package.json';\n\nconst t = await i18n(import.meta.glob('./i18n*.json'), true);\n\nextensionRegistry.registerExtension({\n id: pkg.name,\n name: t.EXT_NOTEBOOK_NAME,\n description: t.EXT_NOTEBOOK_DESC,\n loader: () => import(\"./notebook-extension\"),\n icon: \"lyra jupyter\",\n dependencies: [],\n});\n"],"mappings":";;;;;AAKA,IAAM,IAAI,MAAM,KAAK,uBAAA,OAAA;CAAA,wBAAA,OAAA;CAAA,wBAAA,OAAA;CAAA,CAAgC,EAAE,KAAK;AAE5D,kBAAkB,kBAAkB;CAClC,IAAI,IAAI;CACR,MAAM,EAAE;CACR,aAAa,EAAE;CACf,cAAc,OAAO;CACrB,MAAM;CACN,cAAc,EAAA;CACf,CAAC"}
@@ -0,0 +1,160 @@
1
+ import { t as isNotebookEditorLike } from "./notebook-types-6XV6fOSV.js";
2
+ import { t as TARGET_NOTEBOOK_KERNELS } from "./notebook-kernel-api-c9l3_84P.js";
3
+ import { File, activeEditorSignal, createJsRuntime } from "@eclipse-lyra/core";
4
+ import { html } from "lit";
5
+ import { registerCatalog } from "@eclipse-lyra/extension-catalog/api";
6
+ //#region src/notebook-catalog.ts
7
+ var NOTEBOOK_CATALOG = {
8
+ label: "Notebooks",
9
+ icon: "lyra jupyter",
10
+ contributionId: "catalog.notebooks",
11
+ items: [
12
+ {
13
+ label: "JavaScript",
14
+ icon: "file-code",
15
+ contributionId: "catalog.notebooks.javascript",
16
+ items: [{
17
+ label: "JavaScript basics",
18
+ icon: "lyra jupyter",
19
+ state: { url: new URL("data:application/octet-stream;base64,ewogICJjZWxscyI6IFsKICAgIHsKICAgICAgImNlbGxfdHlwZSI6ICJtYXJrZG93biIsCiAgICAgICJtZXRhZGF0YSI6IHt9LAogICAgICAic291cmNlIjogWwogICAgICAgICIjIEphdmFTY3JpcHQga2VybmVsXG4iLAogICAgICAgICJcbiIsCiAgICAgICAgIlJ1biBjb2RlIGNlbGxzIHdpdGggdGhlICoqSmF2YVNjcmlwdCoqIGtlcm5lbC4gRWFjaCBjZWxsIHJ1bnMgaW4gYSBzaGFyZWQgcnVudGltZS4iCiAgICAgIF0KICAgIH0sCiAgICB7CiAgICAgICJjZWxsX3R5cGUiOiAiY29kZSIsCiAgICAgICJleGVjdXRpb25fY291bnQiOiBudWxsLAogICAgICAibWV0YWRhdGEiOiB7fSwKICAgICAgIm91dHB1dHMiOiBbXSwKICAgICAgInNvdXJjZSI6IFsKICAgICAgICAiY29uc3QgeCA9IDEgKyAyO1xuIiwKICAgICAgICAicmV0dXJuIHg7IgogICAgICBdCiAgICB9LAogICAgewogICAgICAiY2VsbF90eXBlIjogImNvZGUiLAogICAgICAiZXhlY3V0aW9uX2NvdW50IjogbnVsbCwKICAgICAgIm1ldGFkYXRhIjoge30sCiAgICAgICJvdXRwdXRzIjogW10sCiAgICAgICJzb3VyY2UiOiBbCiAgICAgICAgImNvbnN0IGl0ZW1zID0gWydEdWNrREInLCAnUEdsaXRlJywgJ05vdGVib29rcyddO1xuIiwKICAgICAgICAicmV0dXJuIGl0ZW1zLmpvaW4oJywgJyk7IgogICAgICBdCiAgICB9LAogICAgewogICAgICAiY2VsbF90eXBlIjogImNvZGUiLAogICAgICAiZXhlY3V0aW9uX2NvdW50IjogbnVsbCwKICAgICAgIm1ldGFkYXRhIjoge30sCiAgICAgICJvdXRwdXRzIjogW10sCiAgICAgICJzb3VyY2UiOiBbCiAgICAgICAgImNvbnN0IGZpYiA9IChuKSA9PiBuIDw9IDEgPyBuIDogZmliKG4gLSAxKSArIGZpYihuIC0gMik7XG4iLAogICAgICAgICJyZXR1cm4gZmliKDEwKTsiCiAgICAgIF0KICAgIH0KICBdLAogICJtZXRhZGF0YSI6IHsKICAgICJrZXJuZWwiOiAiamF2YXNjcmlwdCIsCiAgICAibGFuZ3VhZ2VfaW5mbyI6IHsKICAgICAgIm5hbWUiOiAicHl0aG9uIgogICAgfQogIH0sCiAgIm5iZm9ybWF0IjogNCwKICAibmJmb3JtYXRfbWlub3IiOiA0Cn0K", "" + import.meta.url).href }
20
+ }]
21
+ },
22
+ {
23
+ label: "DuckDB",
24
+ icon: "file-code",
25
+ contributionId: "catalog.notebooks.duckdb",
26
+ items: [{
27
+ label: "DuckDB in notebooks",
28
+ icon: "lyra jupyter",
29
+ state: { url: new URL("data:application/octet-stream;base64,ewogICJjZWxscyI6IFsKICAgIHsKICAgICAgImNlbGxfdHlwZSI6ICJtYXJrZG93biIsCiAgICAgICJzb3VyY2UiOiBbIiMgRHVja0RCIGluIG5vdGVib29rc1xuXG5Vc2UgdGhlICoqRHVja0RCKioga2VybmVsIHRvIHJ1biBTUUwgaW4gY2VsbHMuIFJlc3VsdHMgYXJlIHNob3duIGFzIHRleHQuIl0sCiAgICAgICJtZXRhZGF0YSI6IHt9CiAgICB9LAogICAgewogICAgICAiY2VsbF90eXBlIjogImNvZGUiLAogICAgICAic291cmNlIjogWyJTRUxFQ1QgJ0R1Y2tEQicgQVMgZW5naW5lLCB2ZXJzaW9uKCkgQVMgdjsiXSwKICAgICAgImV4ZWN1dGlvbl9jb3VudCI6IG51bGwsCiAgICAgICJvdXRwdXRzIjogW10sCiAgICAgICJtZXRhZGF0YSI6IHt9CiAgICB9LAogICAgewogICAgICAiY2VsbF90eXBlIjogImNvZGUiLAogICAgICAic291cmNlIjogWyJDUkVBVEUgT1IgUkVQTEFDRSBURU1QIFRBQkxFIHQgKGlkIElOVCwgbmFtZSBWQVJDSEFSKTtcbklOU0VSVCBJTlRPIHQgVkFMVUVTICgxLCAnYScpLCAoMiwgJ2InKSwgKDMsICdjJyk7XG5TRUxFQ1QgKiBGUk9NIHQ7Il0sCiAgICAgICJleGVjdXRpb25fY291bnQiOiBudWxsLAogICAgICAib3V0cHV0cyI6IFtdLAogICAgICAibWV0YWRhdGEiOiB7fQogICAgfSwKICAgIHsKICAgICAgImNlbGxfdHlwZSI6ICJjb2RlIiwKICAgICAgInNvdXJjZSI6IFsiU0VMRUNUIG5hbWUsIGlkICogMTAgQVMgc2NhbGVkIEZST00gdCBPUkRFUiBCWSBpZCBERVNDOyJdLAogICAgICAiZXhlY3V0aW9uX2NvdW50IjogbnVsbCwKICAgICAgIm91dHB1dHMiOiBbXSwKICAgICAgIm1ldGFkYXRhIjoge30KICAgIH0KICBdLAogICJtZXRhZGF0YSI6IHsgImtlcm5lbCI6ICJkdWNrZGIiIH0sCiAgIm5iZm9ybWF0IjogNCwKICAibmJmb3JtYXRfbWlub3IiOiA0Cn0K", "" + import.meta.url).href }
30
+ }]
31
+ },
32
+ {
33
+ label: "PGlite",
34
+ icon: "file-code",
35
+ contributionId: "catalog.notebooks.pglite",
36
+ items: [{
37
+ label: "PostgreSQL in notebooks",
38
+ icon: "lyra jupyter",
39
+ state: { url: new URL("data:application/octet-stream;base64,ewogICJjZWxscyI6IFsKICAgIHsKICAgICAgImNlbGxfdHlwZSI6ICJtYXJrZG93biIsCiAgICAgICJzb3VyY2UiOiBbIiMgUG9zdGdyZVNRTCAoUEdsaXRlKSBpbiBub3RlYm9va3NcblxuVXNlIHRoZSAqKlBHbGl0ZSoqIGtlcm5lbCB0byBydW4gUG9zdGdyZVNRTCBTUUwgaW4gdGhlIGJyb3dzZXIuIl0sCiAgICAgICJtZXRhZGF0YSI6IHt9CiAgICB9LAogICAgewogICAgICAiY2VsbF90eXBlIjogImNvZGUiLAogICAgICAic291cmNlIjogWyJTRUxFQ1QgJ1BHbGl0ZScgQVMgZW5naW5lLCB2ZXJzaW9uKCkgQVMgdjsiXSwKICAgICAgImV4ZWN1dGlvbl9jb3VudCI6IG51bGwsCiAgICAgICJvdXRwdXRzIjogW10sCiAgICAgICJtZXRhZGF0YSI6IHt9CiAgICB9LAogICAgewogICAgICAiY2VsbF90eXBlIjogImNvZGUiLAogICAgICAic291cmNlIjogWyJDUkVBVEUgVEFCTEUgSUYgTk9UIEVYSVNUUyBkZW1vIChpZCBTRVJJQUwgUFJJTUFSWSBLRVksIGxhYmVsIFRFWFQpO1xuSU5TRVJUIElOVE8gZGVtbyAobGFiZWwpIFZBTFVFUyAoJ2ZpcnN0JyksICgnc2Vjb25kJyksICgndGhpcmQnKTtcblNFTEVDVCAqIEZST00gZGVtbzsiXSwKICAgICAgImV4ZWN1dGlvbl9jb3VudCI6IG51bGwsCiAgICAgICJvdXRwdXRzIjogW10sCiAgICAgICJtZXRhZGF0YSI6IHt9CiAgICB9LAogICAgewogICAgICAiY2VsbF90eXBlIjogImNvZGUiLAogICAgICAic291cmNlIjogWyJTRUxFQ1QgbGFiZWwsIGlkICogMiBBUyBkb3VibGVfaWQgRlJPTSBkZW1vIE9SREVSIEJZIGlkOyJdLAogICAgICAiZXhlY3V0aW9uX2NvdW50IjogbnVsbCwKICAgICAgIm91dHB1dHMiOiBbXSwKICAgICAgIm1ldGFkYXRhIjoge30KICAgIH0KICBdLAogICJtZXRhZGF0YSI6IHsgImtlcm5lbCI6ICJwZ2xpdGUiIH0sCiAgIm5iZm9ybWF0IjogNCwKICAibmJmb3JtYXRfbWlub3IiOiA0Cn0K", "" + import.meta.url).href }
40
+ }]
41
+ }
42
+ ]
43
+ };
44
+ function registerNotebookCatalog() {
45
+ registerCatalog(NOTEBOOK_CATALOG);
46
+ }
47
+ //#endregion
48
+ //#region src/javascript-kernel.ts
49
+ var JavaScriptNotebookKernel = class {
50
+ constructor() {
51
+ this.id = "javascript";
52
+ this.label = "JavaScript";
53
+ this.language = "javascript";
54
+ this.runtime = null;
55
+ }
56
+ getRuntime() {
57
+ if (!this.runtime) this.runtime = createJsRuntime();
58
+ return this.runtime;
59
+ }
60
+ async getVersion() {
61
+ return "JavaScript";
62
+ }
63
+ async execute(code) {
64
+ try {
65
+ const result = await this.getRuntime().execute(code);
66
+ if (result === void 0 || result === null) return {};
67
+ return { data: String(result) };
68
+ } catch (err) {
69
+ return { error: err instanceof Error ? err.message : String(err) };
70
+ }
71
+ }
72
+ close() {
73
+ if (this.runtime) {
74
+ this.runtime.close();
75
+ this.runtime = null;
76
+ }
77
+ }
78
+ };
79
+ var javascriptKernelContribution = {
80
+ id: "javascript",
81
+ label: "JavaScript",
82
+ language: "javascript",
83
+ loadKernel: async () => new JavaScriptNotebookKernel()
84
+ };
85
+ //#endregion
86
+ //#region src/notebook-extension.ts
87
+ var notebook_extension_default = ({ editorRegistry, commandRegistry, contributionRegistry }) => {
88
+ registerNotebookCatalog();
89
+ contributionRegistry.registerContribution(TARGET_NOTEBOOK_KERNELS, javascriptKernelContribution);
90
+ const INITIAL_NOTEBOOK_CONTENT = {
91
+ cells: [{
92
+ cell_type: "markdown",
93
+ source: ["Press the **Run** button in the code cell below to execute it."],
94
+ metadata: {}
95
+ }, {
96
+ cell_type: "code",
97
+ source: ["return \"Hello, World!\""],
98
+ execution_count: null,
99
+ outputs: [],
100
+ metadata: {}
101
+ }],
102
+ metadata: { kernel: "javascript" },
103
+ nbformat: 4,
104
+ nbformat_minor: 4
105
+ };
106
+ commandRegistry.registerHandler("notebook.runCell", {
107
+ ranking: 10,
108
+ canExecute: (context) => {
109
+ const activeEditor = activeEditorSignal.get();
110
+ if (isNotebookEditorLike(activeEditor)) {
111
+ const cellIndex = context.params?.cellIndex;
112
+ if (cellIndex !== void 0) return cellIndex >= 0 && cellIndex < (activeEditor.notebook?.cells.length ?? 0);
113
+ return activeEditor.focusedCellIndex >= 0;
114
+ }
115
+ return false;
116
+ },
117
+ execute: async (context) => {
118
+ const activeEditor = activeEditorSignal.get();
119
+ if (isNotebookEditorLike(activeEditor)) {
120
+ const cellIndex = context.params?.cellIndex ?? activeEditor.focusedCellIndex;
121
+ if (cellIndex >= 0) await activeEditor.executeCell(cellIndex);
122
+ }
123
+ }
124
+ });
125
+ editorRegistry.registerEditorInputHandler({
126
+ editorId: "system.notebooeditor",
127
+ label: "Jupyter Notebook",
128
+ icon: "lyra jupyter",
129
+ lazyInit: () => import("./notebook-runtime-CWTQxD9j.js"),
130
+ canHandle: (input) => input instanceof File && input.getName().toLowerCase().endsWith(".ipynb"),
131
+ handle: async (input) => {
132
+ const editorInput = {
133
+ title: input.getWorkspacePath(),
134
+ data: input,
135
+ key: input.getWorkspacePath(),
136
+ icon: "lyra jupyter",
137
+ state: {}
138
+ };
139
+ editorInput.component = (id) => html`
140
+ <lyra-notebook-editor id="${id}" .input=${editorInput}></lyra-notebook-editor>`;
141
+ return editorInput;
142
+ },
143
+ ranking: 100
144
+ });
145
+ contributionRegistry.registerContribution("filebrowser.create", {
146
+ label: "Jupyter Notebook",
147
+ icon: "lyra jupyter",
148
+ command: "touch",
149
+ params: {
150
+ path: "notebook.ipynb",
151
+ extension: ".ipynb",
152
+ ask: true,
153
+ contents: JSON.stringify(INITIAL_NOTEBOOK_CONTENT, null, 2)
154
+ }
155
+ });
156
+ };
157
+ //#endregion
158
+ export { notebook_extension_default as default };
159
+
160
+ //# sourceMappingURL=notebook-extension-BLdbp0aG.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notebook-extension-BLdbp0aG.js","names":[],"sources":["../src/notebook-catalog.ts","../src/javascript-kernel.ts","../src/notebook-extension.ts"],"sourcesContent":["import type { CatalogContribution } from \"@eclipse-lyra/extension-catalog/api\";\nimport { registerCatalog } from \"@eclipse-lyra/extension-catalog/api\";\n\nconst NOTEBOOK_CATALOG: CatalogContribution = {\n label: \"Notebooks\",\n icon: \"lyra 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: \"lyra jupyter\", state: { url: new URL(\"./catalog/javascript-basics.ipynb\", import.meta.url).href } },\n ],\n },\n {\n label: \"DuckDB\",\n icon: \"file-code\",\n contributionId: \"catalog.notebooks.duckdb\",\n items: [\n { label: \"DuckDB in notebooks\", icon: \"lyra jupyter\", state: { url: new URL(\"./catalog/duckdb-sample.ipynb\", import.meta.url).href } },\n ],\n },\n {\n label: \"PGlite\",\n icon: \"file-code\",\n contributionId: \"catalog.notebooks.pglite\",\n items: [\n { label: \"PostgreSQL in notebooks\", icon: \"lyra jupyter\", state: { url: new URL(\"./catalog/pglite-sample.ipynb\", import.meta.url).href } },\n ],\n },\n ],\n};\n\nexport function registerNotebookCatalog(): void {\n registerCatalog(NOTEBOOK_CATALOG);\n}\n","import { createJsRuntime, type JsRuntime } from '@eclipse-lyra/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-lyra/core\";\nimport { File } from \"@eclipse-lyra/core\";\nimport { activeEditorSignal } from \"@eclipse-lyra/core\";\nimport type { ExecutionContext } from \"@eclipse-lyra/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: \"lyra 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: \"lyra jupyter\",\n state: {},\n } as EditorInput;\n editorInput.component = (id: string) => html`\n <lyra-notebook-editor id=\"${id}\" .input=${editorInput}></lyra-notebook-editor>`;\n return editorInput;\n },\n ranking: 100,\n });\n\n contributionRegistry.registerContribution('filebrowser.create', {\n label: 'Jupyter Notebook',\n icon: 'lyra 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":"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"}
@@ -0,0 +1,6 @@
1
+ //#region src/notebook-kernel-api.ts
2
+ var TARGET_NOTEBOOK_KERNELS = "system.notebookkernels";
3
+ //#endregion
4
+ export { TARGET_NOTEBOOK_KERNELS as t };
5
+
6
+ //# sourceMappingURL=notebook-kernel-api-c9l3_84P.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notebook-kernel-api-c9l3_84P.js","names":[],"sources":["../src/notebook-kernel-api.ts"],"sourcesContent":["export const TARGET_NOTEBOOK_KERNELS = 'system.notebookkernels';\n\nexport interface NotebookExecutionResult {\n data?: string;\n imageData?: string;\n error?: string;\n}\n\nexport interface NotebookKernel {\n readonly id: string;\n readonly label: string;\n readonly icon?: string;\n readonly language: string;\n execute(code: string): Promise<NotebookExecutionResult>;\n connect?(options?: { requiredPackages?: string[] }): Promise<void>;\n disconnect?(): Promise<void>;\n restart?(): Promise<void>;\n interrupt?(): void;\n getVersion?(): Promise<string | undefined>;\n openPackageManager?(\n context?: {\n requiredPackages: string[];\n onPackageAdded: (name: string) => void;\n onPackageRemoved: (name: string) => void;\n }\n ): void;\n close?(): void | Promise<void>;\n}\n\nexport interface NotebookKernelContribution {\n id: string;\n label: string;\n icon?: string;\n language: string;\n loadKernel(): Promise<NotebookKernel>;\n}\n"],"mappings":";AAAA,IAAa,0BAA0B"}