@eclipse-lyra/extension-notebook 0.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.
@@ -0,0 +1,13 @@
1
+ declare const _default: {
2
+ "namespace": "extensions",
3
+ "en": {
4
+ "EXT_NOTEBOOK_NAME": "Jupyter-like Notebook Editor",
5
+ "EXT_NOTEBOOK_DESC": "View and execute Jupyter-like notebooks (.ipynb) with Python code execution and markdown rendering"
6
+ },
7
+ "de": {
8
+ "EXT_NOTEBOOK_NAME": "Jupyter-ähnlicher Notebook-Editor",
9
+ "EXT_NOTEBOOK_DESC": "Anzeigen und Ausführen von Jupyter-ähnlichen Notebooks (.ipynb) mit Python-Codeausführung und Markdown-Rendering"
10
+ }
11
+ };
12
+
13
+ export default _default;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
package/dist/index.js ADDED
@@ -0,0 +1,21 @@
1
+ import { contributionRegistry, SYSTEM_LANGUAGE_BUNDLES, i18nLazy, extensionRegistry } from "@eclipse-lyra/core";
2
+ import pkg from "../package.json";
3
+ const namespace = "extensions";
4
+ const en = { "EXT_NOTEBOOK_NAME": "Jupyter-like Notebook Editor", "EXT_NOTEBOOK_DESC": "View and execute Jupyter-like notebooks (.ipynb) with Python code execution and markdown rendering" };
5
+ const de = { "EXT_NOTEBOOK_NAME": "Jupyter-ähnlicher Notebook-Editor", "EXT_NOTEBOOK_DESC": "Anzeigen und Ausführen von Jupyter-ähnlichen Notebooks (.ipynb) mit Python-Codeausführung und Markdown-Rendering" };
6
+ const bundle = {
7
+ namespace,
8
+ en,
9
+ de
10
+ };
11
+ contributionRegistry.registerContribution(SYSTEM_LANGUAGE_BUNDLES, bundle);
12
+ const t = i18nLazy("extensions");
13
+ extensionRegistry.registerExtension({
14
+ id: pkg.name,
15
+ name: t("EXT_NOTEBOOK_NAME"),
16
+ description: t("EXT_NOTEBOOK_DESC"),
17
+ loader: () => import("./notebook-extension-CIJUGgLe.js"),
18
+ icon: "lyra jupyter",
19
+ dependencies: ["@eclipse-lyra/extension-python-runtime"]
20
+ });
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import { extensionRegistry, i18nLazy, contributionRegistry, SYSTEM_LANGUAGE_BUNDLES } from '@eclipse-lyra/core';\nimport bundle from './i18n.json';\nimport pkg from '../package.json';\n\ncontributionRegistry.registerContribution(SYSTEM_LANGUAGE_BUNDLES, bundle as any);\n\nconst t = i18nLazy('extensions');\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: [\"@eclipse-lyra/extension-python-runtime\"],\n});\n"],"names":[],"mappings":";;;;;;;;;;AAIA,qBAAqB,qBAAqB,yBAAyB,MAAa;AAEhF,MAAM,IAAI,SAAS,YAAY;AAE/B,kBAAkB,kBAAkB;AAAA,EAClC,IAAI,IAAI;AAAA,EACR,MAAM,EAAE,mBAAmB;AAAA,EAC3B,aAAa,EAAE,mBAAmB;AAAA,EAClC,QAAQ,MAAM,OAAO,kCAAsB;AAAA,EAC3C,MAAM;AAAA,EACN,cAAc,CAAC,wCAAwC;AACzD,CAAC;"}
@@ -0,0 +1,87 @@
1
+ import { html } from "lit";
2
+ import { activeEditorSignal, File } from "@eclipse-lyra/core";
3
+ function isNotebookEditorLike(value) {
4
+ return Boolean(
5
+ value && typeof value.executeCell === "function" && typeof value.focusedCellIndex === "number"
6
+ );
7
+ }
8
+ const notebookExtension = ({ editorRegistry, commandRegistry, contributionRegistry }) => {
9
+ const INITIAL_NOTEBOOK_CONTENT = {
10
+ cells: [
11
+ {
12
+ cell_type: "markdown",
13
+ source: ["Press the **Run** button in the code cell below to execute it."],
14
+ metadata: {}
15
+ },
16
+ {
17
+ cell_type: "code",
18
+ source: ['print("Hello, World!")'],
19
+ execution_count: null,
20
+ outputs: [],
21
+ metadata: {}
22
+ }
23
+ ],
24
+ metadata: {},
25
+ nbformat: 4,
26
+ nbformat_minor: 4
27
+ };
28
+ commandRegistry.registerHandler("python", {
29
+ ranking: 10,
30
+ canExecute: (context) => {
31
+ const activeEditor = activeEditorSignal.get();
32
+ if (isNotebookEditorLike(activeEditor)) {
33
+ const cellIndex = context.params?.cellIndex;
34
+ if (cellIndex !== void 0) {
35
+ return cellIndex >= 0 && cellIndex < (activeEditor.notebook?.cells.length ?? 0);
36
+ }
37
+ return activeEditor.focusedCellIndex >= 0;
38
+ }
39
+ return false;
40
+ },
41
+ execute: async (context) => {
42
+ const activeEditor = activeEditorSignal.get();
43
+ if (isNotebookEditorLike(activeEditor)) {
44
+ const cellIndex = context.params?.cellIndex ?? activeEditor.focusedCellIndex;
45
+ if (cellIndex >= 0) {
46
+ await activeEditor.executeCell(cellIndex);
47
+ }
48
+ }
49
+ }
50
+ });
51
+ editorRegistry.registerEditorInputHandler({
52
+ editorId: "system.notebooeditor",
53
+ label: "Jupyter Notebook",
54
+ icon: "lyra jupyter",
55
+ lazyInit: () => import("./notebook-runtime-CFgw3UmB.js"),
56
+ canHandle: (input) => input instanceof File && input.getName().toLowerCase().endsWith(".ipynb"),
57
+ handle: async (input) => {
58
+ const editorInput = {
59
+ title: input.getName(),
60
+ data: input,
61
+ key: input.getName(),
62
+ icon: "lyra jupyter",
63
+ noOverflow: true,
64
+ state: {}
65
+ };
66
+ editorInput.widgetFactory = () => html`
67
+ <lyra-notebook-editor .input=${editorInput}></lyra-notebook-editor>`;
68
+ return editorInput;
69
+ },
70
+ ranking: 100
71
+ });
72
+ contributionRegistry.registerContribution("filebrowser.create", {
73
+ label: "Jupyter Notebook",
74
+ icon: "lyra jupyter",
75
+ command: "touch",
76
+ params: {
77
+ path: "notebook.ipynb",
78
+ extension: ".ipynb",
79
+ ask: true,
80
+ contents: JSON.stringify(INITIAL_NOTEBOOK_CONTENT, null, 2)
81
+ }
82
+ });
83
+ };
84
+ export {
85
+ notebookExtension as default
86
+ };
87
+ //# sourceMappingURL=notebook-extension-CIJUGgLe.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notebook-extension-CIJUGgLe.js","sources":["../src/notebook-types.ts","../src/notebook-extension.ts"],"sourcesContent":["export interface NotebookCell {\n cell_type: 'code' | 'markdown' | 'raw';\n source: string | string[];\n outputs?: any[];\n execution_count?: number | null;\n metadata?: any;\n}\n\nexport interface NotebookData {\n cells: NotebookCell[];\n metadata?: {\n required_packages?: string[];\n [key: string]: any;\n };\n nbformat?: number;\n nbformat_minor?: number;\n}\n\nexport interface NotebookEditorLike {\n notebook?: NotebookData;\n focusedCellIndex: number;\n executeCell(index: number): Promise<void>;\n}\n\nexport function isNotebookEditorLike(value: unknown): value is NotebookEditorLike {\n return Boolean(\n value &&\n typeof (value as NotebookEditorLike).executeCell === 'function' &&\n typeof (value as NotebookEditorLike).focusedCellIndex === 'number'\n );\n}\n\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 {NotebookData, isNotebookEditorLike} from \"./notebook-types\";\n\nexport default ({editorRegistry, commandRegistry, contributionRegistry}: any) => {\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: ['print(\"Hello, World!\")'],\n execution_count: null,\n outputs: [],\n metadata: {}\n }\n ],\n metadata: {},\n nbformat: 4,\n nbformat_minor: 4\n };\n commandRegistry.registerHandler('python', {\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.getName(),\n data: input,\n key: input.getName(),\n icon: \"lyra jupyter\",\n noOverflow: true,\n state: {},\n } as EditorInput;\n editorInput.widgetFactory = () => html`\n <lyra-notebook-editor .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"],"names":[],"mappings":";;AAwBO,SAAS,qBAAqB,OAA6C;AAC9E,SAAO;AAAA,IACH,SACA,OAAQ,MAA6B,gBAAgB,cACrD,OAAQ,MAA6B,qBAAqB;AAAA,EAAA;AAElE;ACvBA,MAAA,oBAAe,CAAC,EAAC,gBAAgB,iBAAiB,2BAA+B;AAC7E,QAAM,2BAAyC;AAAA,IAC3C,OAAO;AAAA,MACH;AAAA,QACI,WAAW;AAAA,QACX,QAAQ,CAAC,gEAAgE;AAAA,QACzE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,kBAAY,gBAAgB,MAAM;AAAA,+CACC,WAAW;AAC9C,aAAO;AAAA,IACX;AAAA,IACA,SAAS;AAAA,EAAA,CACZ;AAED,uBAAqB,qBAAqB,sBAAsB;AAAA,IAC5D,OAAO;AAAA,IACP,MAAM;AAAA,IACN,SAAS;AAAA,IACT,QAAQ;AAAA,MACJ,MAAM;AAAA,MACN,WAAW;AAAA,MACX,KAAK;AAAA,MACL,UAAU,KAAK,UAAU,0BAA0B,MAAM,CAAC;AAAA,IAAA;AAAA,EAC9D,CACH;AACL;"}
@@ -0,0 +1,3 @@
1
+ declare const _default: ({ editorRegistry, commandRegistry, contributionRegistry }: any) => void;
2
+ export default _default;
3
+ //# sourceMappingURL=notebook-extension.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notebook-extension.d.ts","sourceRoot":"","sources":["../src/notebook-extension.ts"],"names":[],"mappings":"yBAOgB,2DAAyD,GAAG;AAA5E,wBA6EE"}