From 18a7678563d00135dbe40f46ca79c13f57247961 Mon Sep 17 00:00:00 2001 From: "xunhe.lzy" Date: Thu, 17 Oct 2024 13:21:43 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20jupyter=E5=A2=9E=E5=8A=A0=E6=97=A0?= =?UTF-8?q?=E7=BC=96=E8=BE=91=E5=99=A8=E7=9A=84=E5=AF=BC=E5=87=BA=EF=BC=8C?= =?UTF-8?q?=E9=81=BF=E5=85=8D=E9=9B=86=E6=88=90=E6=96=B9webpack=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E9=9C=80=E8=A6=81=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/libro-jupyter/package.json | 4 + packages/libro-jupyter/src/index-noeditor.ts | 33 +++++ packages/libro-jupyter/src/module-noeditor.ts | 116 ++++++++++++++++++ .../src/toolbar/run-selector.tsx | 3 +- .../src/toolbar/side-toolbar-run-selector.tsx | 2 +- 5 files changed, 156 insertions(+), 2 deletions(-) create mode 100644 packages/libro-jupyter/src/index-noeditor.ts create mode 100644 packages/libro-jupyter/src/module-noeditor.ts diff --git a/packages/libro-jupyter/package.json b/packages/libro-jupyter/package.json index df468bd4..67209692 100644 --- a/packages/libro-jupyter/package.json +++ b/packages/libro-jupyter/package.json @@ -13,6 +13,10 @@ "typings": "./es/index.d.ts", "default": "./es/index.js" }, + "./noeditor": { + "typings": "./es/index-noeditor.d.ts", + "default": "./es/index-noeditor.js" + }, "./mock": { "typings": "./es/mock/index.d.ts", "default": "./es/mock/index.js" diff --git a/packages/libro-jupyter/src/index-noeditor.ts b/packages/libro-jupyter/src/index-noeditor.ts new file mode 100644 index 00000000..d231a7df --- /dev/null +++ b/packages/libro-jupyter/src/index-noeditor.ts @@ -0,0 +1,33 @@ +export * from '@difizen/libro-code-cell'; +export * from '@difizen/libro-code-editor'; +export * from '@difizen/libro-common'; +export * from '@difizen/libro-core'; +export * from '@difizen/libro-kernel'; +export * from '@difizen/libro-l10n'; +export * from '@difizen/libro-lsp'; +export * from '@difizen/libro-markdown-cell'; +export * from '@difizen/libro-output'; +export * from '@difizen/libro-raw-cell'; +export * from '@difizen/libro-rendermime'; +export * from '@difizen/libro-search'; +export * from '@difizen/libro-search-code-cell'; +export * from './add-between-cell/index.js'; +export * from './cell/index.js'; +export * from './command/index.js'; +export * from './components/index.js'; +export * from './config/index.js'; +export * from './contents/index.js'; +export * from './keybind-instructions/index.js'; +export * from './libro-jupyter-file-service.js'; +export * from './libro-jupyter-model.js'; +export * from './libro-jupyter-protocol.js'; +export * from './libro-jupyter-server-launch-manager.js'; +export * from './module-noeditor.js'; +export * from './output/index.js'; +export * from './rendermime/index.js'; +export * from './theme/index.js'; +export * from './toolbar/index.js'; +export * from './file/index.js'; +export * from './libro-jupyter-view.js'; +export * from './config/index.js'; +export * from './widget/index.js'; diff --git a/packages/libro-jupyter/src/module-noeditor.ts b/packages/libro-jupyter/src/module-noeditor.ts new file mode 100644 index 00000000..add0a0f1 --- /dev/null +++ b/packages/libro-jupyter/src/module-noeditor.ts @@ -0,0 +1,116 @@ +import { + CodeCellModule, + LibroCodeCellModel, + LibroCodeCellView, +} from '@difizen/libro-code-cell'; +import { + CellExecutionTimeProvider, + CellOutputBottomBlankProvider, + LibroAddCellModule, + LibroKeybindRegistry, + LibroModel, + LibroModule, + LibroToolbarModule, +} from '@difizen/libro-core'; +import { LibroKernelManageModule } from '@difizen/libro-kernel'; +import { MarkdownCellModule } from '@difizen/libro-markdown-cell'; +import { + DisplayDataOutputModule, + ErrorOutputModule, + StreamOutputModule, +} from '@difizen/libro-output'; +import { RawCellModule } from '@difizen/libro-raw-cell'; +import { LibroSearchModule } from '@difizen/libro-search'; +import { SearchCodeCellModule } from '@difizen/libro-search-code-cell'; +import { ManaModule } from '@difizen/mana-app'; + +import { LibroBetweenCellModule } from './add-between-cell/index.js'; +import { JupyterCodeCellModel, JupyterCodeCellView } from './cell/index.js'; +import { + LibroJupyterCommandContribution, + LibroJupyterKeybindingContribution, +} from './command/index.js'; +import { CellOutputBottomBlank } from './components/cell-output-bottom-blank.js'; +import { CellExecutionTip } from './components/index.js'; +import { + ConfigAppContribution, + LibroJupyterSettingContribution, +} from './config/index.js'; +import { LibroJupyterContentContribution } from './contents/index.js'; +import { LibroJupyterContentSaveContribution } from './contents/save-content-contribution.js'; +import { LibroJupyterFileModule } from './file/index.js'; +import { KeybindInstructionsModule } from './keybind-instructions/index.js'; +import { LibroJupyterFileService } from './libro-jupyter-file-service.js'; +import { LibroJupyterModel } from './libro-jupyter-model.js'; +import { KernelStatusAndSelectorProvider } from './libro-jupyter-protocol.js'; +import { JupyterServerLaunchManager } from './libro-jupyter-server-launch-manager.js'; +import { LibroJupyterView } from './libro-jupyter-view.js'; +import { LibroJupyterOutputArea } from './output/index.js'; +import { PlotlyModule } from './rendermime/index.js'; +import { LibroJupyterColorContribution } from './theme/index.js'; +import { + KernelStatusSelector, + LibroJupyterToolbarContribution, + SaveFileErrorContribution, +} from './toolbar/index.js'; +import { WidgetModule } from './widget/index.js'; + +/** + * 去除editor和lsp依赖的jupyter module,在opensumi场景使用 + */ +export const LibroJupyterNoEditorModule = ManaModule.create() + .register( + LibroJupyterFileService, + LibroJupyterCommandContribution, + LibroJupyterKeybindingContribution, + LibroJupyterToolbarContribution, + ConfigAppContribution, + SaveFileErrorContribution, + LibroKeybindRegistry, + LibroJupyterContentContribution, + LibroJupyterContentSaveContribution, + LibroJupyterOutputArea, + LibroJupyterColorContribution, + LibroJupyterSettingContribution, + JupyterServerLaunchManager, + LibroJupyterView, + { + token: CellExecutionTimeProvider, + useValue: CellExecutionTip, + }, + { + token: CellOutputBottomBlankProvider, + useValue: CellOutputBottomBlank, + }, + { + token: KernelStatusAndSelectorProvider, + useValue: KernelStatusSelector, + }, + { + token: LibroModel, + useClass: LibroJupyterModel, + }, + { token: LibroCodeCellModel, useClass: JupyterCodeCellModel }, + { token: LibroCodeCellView, useClass: JupyterCodeCellView }, + ) + .dependOn( + LibroModule, + CodeCellModule, + MarkdownCellModule, + RawCellModule, + StreamOutputModule, + ErrorOutputModule, + DisplayDataOutputModule, + LibroToolbarModule, + LibroKernelManageModule, + LibroSearchModule, + SearchCodeCellModule, + LibroAddCellModule, + + // custom module + LibroBetweenCellModule, + KeybindInstructionsModule, + PlotlyModule, + LibroJupyterFileModule, + WidgetModule, + ); diff --git a/packages/libro-jupyter/src/toolbar/run-selector.tsx b/packages/libro-jupyter/src/toolbar/run-selector.tsx index e1753a02..60ac2109 100644 --- a/packages/libro-jupyter/src/toolbar/run-selector.tsx +++ b/packages/libro-jupyter/src/toolbar/run-selector.tsx @@ -1,6 +1,7 @@ import { PlayCircleOutlined } from '@ant-design/icons'; import type { LibroToolbarArags, LibroView } from '@difizen/libro-core'; import { NotebookCommands, ExecutableCellModel } from '@difizen/libro-core'; +import { ServerManager } from '@difizen/libro-kernel'; import { useInject, ToolbarInstance, @@ -15,7 +16,7 @@ import { Menu, Dropdown, Tooltip } from 'antd'; import type { MenuProps } from 'antd'; import { useEffect, useState } from 'react'; -import { LibroJupyterConfiguration, ServerManager } from '../index.js'; +import { LibroJupyterConfiguration } from '../config/config.js'; import type { LibroJupyterModel } from '../libro-jupyter-model.js'; import { kernelPrepared } from '../utils/index.js'; diff --git a/packages/libro-jupyter/src/toolbar/side-toolbar-run-selector.tsx b/packages/libro-jupyter/src/toolbar/side-toolbar-run-selector.tsx index b4908691..1195c205 100644 --- a/packages/libro-jupyter/src/toolbar/side-toolbar-run-selector.tsx +++ b/packages/libro-jupyter/src/toolbar/side-toolbar-run-selector.tsx @@ -7,7 +7,7 @@ import { l10n } from '@difizen/mana-l10n'; import { Popover, Tooltip } from 'antd'; import { useEffect, useState } from 'react'; -import { LibroJupyterConfiguration } from '../index.js'; +import { LibroJupyterConfiguration } from '../config/index.js'; import type { LibroJupyterModel } from '../libro-jupyter-model.js'; import { kernelPrepared } from '../utils/index.js';