扩展迁移指南#

JupyterLab 4.3 到 4.4#

图标#

@jupyterlab/debugger 的图标被移动到 @jupyterlab/ui-components正在使用的图标位于 ui-components/style/icons/debugger 文件夹中,而 未使用的图标@jupyterlab/debugger 包中位于 ui-components/style/unused/ 文件夹中。

Updated imports#

之前

之后

import { closeAllIcon } from '@jupyterlab/debugger/lib/icons';

import { closeAllIcon } from '@jupyterlab/ui-components';

import { continueIcon } from '@jupyterlab/debugger/lib/icons';

import { runIcon } from '@jupyterlab/ui-components';import { runIcon as continueIcon } from '@jupyterlab/ui-components';

import { exceptionIcon } from '@jupyterlab/debugger/lib/icons';

import { exceptionsIcon } from '@jupyterlab/ui-components';import { exceptionsIcon as exceptionIcon } from '@jupyterlab/ui-components';

import { openKernelSourceIcon } from '@jupyterlab/debugger/lib/icons';

import { openKernelSourceIcon } from '@jupyterlab/ui-components';

import { pauseIcon } from '@jupyterlab/debugger/lib/icons';

import { pauseIcon } from '@jupyterlab/ui-components';

import { stepIntoIcon } from '@jupyterlab/debugger/lib/icons';

import { stepIntoIcon } from '@jupyterlab/ui-components';

import { stepOutIcon } from '@jupyterlab/debugger/lib/icons';

import { stepOutIcon } from '@jupyterlab/ui-components';

import { stepOverIcon } from '@jupyterlab/debugger/lib/icons';

import { stepOverIcon } from '@jupyterlab/ui-components';

import { stopIcon } from '@jupyterlab/debugger/lib/icons';

import { stopIcon } from '@jupyterlab/ui-components';import { stopIcon as terminateIcon } from '@jupyterlab/ui-components';

import { variableIcon } from '@jupyterlab/debugger/lib/icons';

import { variableIcon } from '@jupyterlab/ui-components';

import { viewBreakpointIcon } from '@jupyterlab/debugger/lib/icons';

import { viewBreakpointIcon } from '@jupyterlab/ui-components';

JupyterLab 4.2 到 4.3#

CSS样式#

以前JupyterLab会全局泄漏CSS规则。从4.3版本开始,这种情况不再发生。对扩展的副作用是:

  • 附加在应用程序外壳之外的DOM元素可能会有样式损坏。要修复这个问题,你应该将类jp-ThemedContainer添加到应用程序外壳之外添加的DOM元素中。

  • DOM元素 code, kbd, pre, samptt 的样式可能会出现问题。要修复这个问题,可以在你的规则前加上类 .jp-ThemedContainer;例如,.jp-Inspector-content pre 变为 .jp-ThemedContainer .jp-Inspector-content pre

jp-Inspector-default-content 类已重命名为 jp-Inspector-placeholderContent。这个上下文帮助类的名称现在与等效的目录和属性检查器类保持一致。

JupyterLab 4.3 更新了其对 @lumino/widget 的依赖到 2.5.0 版本,该版本移除了以下小部件的全局样式:

.lm-Widget {
  overflow: hidden;
}

如果您注意到扩展的样式存在一些不一致,您可能需要将此通用规则添加回扩展的CSS中,或者(更可取的是)将其限定为相关的小部件。

使用Galata进行测试#

Playwright 已更新至版本 1.46.1(或更高)。版本 1.46.0 的变更日志提到,在定义对象数组的 fixture 值时可能存在破坏性更改。

查看Playwright 1.46.0 发布说明以获取更多信息。

共享模型#

共享单元格模型上设置的输出现在需要包装在Y.Map对象中,而不是作为普通对象提供(或在后端设置时使用pycrdt Map对象而不是字典)。此外,"text"条目现在必须指定为Array对象,用于"stream"类型的输出,以提高性能。使用普通对象已被弃用,并将在未来的版本中停止工作。有关参考,请参见PRs:

JupyterLab 4.1 到 4.2#

API更新#

  • CodeEditor.ICoordinate 接口已修正,不再包含 toJSON()xywidthheight;这些属性从未被返回 ICoordinate 的方法设置, 也从未被接受它的方法使用。

  • CodeEditor.getCoordinateForPosition 的返回类型已更正,以明确它可以返回 null;之前尽管返回类型表明它总是返回一个非空的 ICoordinate 值,但实际上可能会返回 null

  • 命令 workspace-ui:saveworkspace-ui:save-as 已从 @jupyterlab/apputils-extension:workspaces 插件移至一个新的专用 @jupyterlab/workspaces-extension 包中,并且可以通过请求 IWorkspaceCommands 令牌来显式要求。此令牌默认由新的 @jupyterlab/workspaces-extension:commands 插件提供。@jupyterlab/apputils-extension:workspaces 插件现在仅定义了用于打开带有 .jupyterlab-workspace 扩展名的文件作为 JupyterLab 工作区的 MIME 类型渲染器。

  • 单元格工具栏节点已从单元格节点移动到单元格输入节点。 因此,单元格工具栏的父节点已更改,不能再直接用于检索相应的单元格节点。

快捷方式扩展重做#

@jupyterlab/shortcuts-extension 包被重新设计以修复多个错误并增加类型安全性。 虽然这个包没有暴露任何编程API,并且主题更改很少, 但包的版本号被提升到5.0以反映更改的范围。

扩展作者不需要采取任何行动(除非您使用了/lib中的非公开组件), 但是,鼓励基于JupyterLab组件构建的应用程序的作者升级到这个新版本,因为它可以显著改善用户体验。

JupyterLab 4.0 到 4.1#

插件管理器和扩展锁定#

在JupyterLab 4.1之前,没有以下机制: - 供用户禁用/启用单个插件(而不是整个扩展) - 供管理员完全阻止用户启用/禁用某些扩展

这个版本的JupyterLab通过添加插件管理器来实现这两者。

如果您的安装中有任何插件被禁用,这些插件将在首次启动时自动锁定,以确保用户暴露的功能没有变化。插件管理器本身可以使用jupyter labextension命令禁用和锁定,但我们建议根据需要锁定单个插件。

如果您的扩展程序之前包含自定义的启用/禁用设置,您可能可以将其替换为指向用户使用插件管理器的说明。但是,请考虑您的扩展程序是否可能在不包含插件管理器或已禁用的发行版中使用。

使用UI工具包中的Toolbar和ToolbarButtonComponent#

工具栏和ToolbarButtonComponent(来自ui-components包)现在依赖于外部库 jupyter-ui-toolkit

这个库使用了Web组件技术(https://developer.mozilla.org/en-US/docs/Web/API/Web_components),并且基于微软的FAST库。

有关更改的更多背景信息,请参见 jupyterlab/frontends-team-compass#143

  • 更改了ToolbarToolbarButtonComponent的选择器。

    • Toolbar的DOM现在是一个jp-toolbar组件,而不是一个div

    • ToolbarButtonComponent的DOM现在是jp-button元素,而不是一个button

      必须考虑到这一点,因为按钮本身位于jp-button组件的影子DOM中,无法作为工具栏组件的子元素访问。

    • ToolbarButtonComponent中的图标是jp-button组件的直接子元素。

      图标之前封装在一个带有类.jp-ToolbarButtonComponent-icon的span中。现在访问该图标以更改其属性需要类似jp-button > svg的方式。

  • 如果您正在使用 jest 来测试您的扩展程序,JupyterLab 中添加了一些新的 ES6 包依赖项。

    在使用 Jest 转换代码时,需要忽略这些依赖项。您需要更新 transformIgnorePatterns 以添加:

    const esModules = [
      '@microsoft',
      '@jupyter/react-components',
      '@jupyter/web-components',
      'exenv-es6',
      ...
    ].join('|');
    
  • 为了向后兼容,保留了一些针对带有类 .jp-ToolbarButtonComponentbutton 的 CSS 规则。

    这些规则现在已被弃用,并将在 Jupyterlab 5 中移除。 工具栏中的 button 元素必须更新为 jp-button,来自 jupyter-ui-toolkit

StaticNotebook的超类WindowedList中更改CSS类名#

  • .jp-WindowedPanel-window 已更名为 .jp-WindowedPanel-viewport

  • 笔记本滚动容器现在是 .jp-WindowedPanel-outer 而不是 .jp-Notebook

  • Galata 笔记本助手 getCellgetCellCount 已相应更新

笔记本焦点处理的变化影响命令模式快捷键选择器#

以前,在切换到命令模式时,笔记本中的焦点会返回到笔记本的HTML节点,这阻止了在单元格之间使用Tab键进行导航,特别是影响了有辅助功能需求的用户。在JupyterLab 4.1+中,切换到命令模式时焦点保持在活动单元格上;这要求所有快捷键选择器按如下方式调整:

  • .jp-Notebook:focus.jp-mod-commandMode, .jp-Notebook:focus, 和 [data-jp-traversable]:focus 应该被替换为: - .jp-Notebook.jp-mod-commandMode :focus:not(:read-write) 适用于 JupyterLab 4.1.0+ - .jp-Notebook.jp-mod-commandMode:not(.jp-mod-readWrite) :focus 适用于 JupyterLab 4.1.1+

  • [data-jp-kernel-user]:focus 应替换为: - [data-jp-kernel-user] :focus:not(:read-write) 适用于 JupyterLab 4.1.0+ - [data-jp-kernel-user]:not(.jp-mod-readWrite) :focus:not(:read-write) 适用于 JupyterLab 4.1.1+

请注意,:not(:read-write)片段在文本字段(如单元格编辑器)获得焦点时禁用快捷方式,以避免拦截用户输入到文本字段中的字符,但如果您的快捷方式不对应任何键/印刷字符(例如大多数带有Ctrl修饰符的快捷方式),如果您希望快捷方式在文本字段中保持活动状态,您可能更愿意删除此片段。

此外,JupyterLab 4.1.1 引入了指示器类 .jp-mod-readWrite,当活动元素接受键盘输入时,该类会应用于笔记本节点,如 :read-write 选择器所定义。此指示器类用于检测嵌套在开放影子 DOM 中的 :read-write 元素(例如 Panel 框架小部件)。

如果你的框架使用了封闭的影子DOM,或者期望在浏览器启发式:read-write选择器不识别为可编辑的元素上进行键盘交互,你需要在外部宿主元素上设置一个数据属性lm-suppress-shortcuts来抑制快捷键。

为了防止破坏用户体验,这些更改在后台透明地进行,但会发出警告,扩展开发者应在下一个主要JupyterLab版本发布之前在源代码中进行更改。

在高倍放大下StatusBar元素的可见性#

  • 状态栏项目现在在高放大率/低分辨率下默认隐藏,以防止在高放大率下使用应用程序时发生重叠。

  • IStatusBar.registerStatusItem方法的选项中添加了一个额外的priority属性,以允许状态栏项目保持可见; 预期用途是用于那些在高缩放时特别有用或否则无法访问的小状态栏项目。

JupyterLab 3.x 到 4.x#

由于从JupyterLab 3.x到4.x的重大类型变化,我们建议发布一个新的主要版本的扩展以与每个主要版本的JupyterLab兼容。有关使用不同主要版本的Lab 3和Lab 4的扩展示例,请参见jupyterlab-vimjupyter-ai

使用升级脚本升级扩展#

JupyterLab 4.x 提供了一个脚本来升级现有扩展,以使用新的扩展系统和打包方式。

注意

备份您的扩展 - 最好使用像git这样的版本控制,并在新分支上工作。

首先,确保更新到 JupyterLab 4 并安装 copier 和一些依赖项。使用 pip

pip install -U jupyterlab[upgrade-extension]

或者使用 conda

conda install -c conda-forge jupyterlab=4 "copier=9" jinja2-time

然后在扩展的根文件夹中运行:

python -m jupyterlab.upgrade_extension .

升级脚本为将JupyterLab扩展打包为Python包创建必要的文件。 脚本会询问你是否要覆盖所有文件。默认情况下,配置文件将被新版本覆盖。特别是,如果你使用的是Python setuptools(即setup.py 和/或setup.cfg),你可能需要更新pyproject.toml文件(参见 PEP示例)。

升级脚本还将package.json中的依赖项更新为^4.0.0包。

有关扩展的新文件结构和打包的更多详细信息,请查看扩展教程:扩展教程

注意

如果您的扩展受到以下提到的API更改的影响,您将需要修改扩展的代码。

jlpm#

实用工具 jlpm 使用 Yarn 3(之前是 Yarn 1)。这将需要更新您的包配置。

  • 创建一个文件 .yarnrc.yml 包含以下内容:

enableImmutableInstalls: false
nodeLinker: node-modules
  • 添加到 .gitignore

.yarn/
  • 运行 jlpm install 这将重置您的 yarn.lock 内容,因为其格式已更改。

注意

你可以在Yarn文档中找到更多关于从Yarn版本1升级到版本3的信息。

如果你遇到了同一个包的多个版本(如@lumino/widgets),TypeScript可能会抱怨类型不匹配。一个可能的解决方案是强制使用包去重:

jlpm dlx yarn-berry-deduplicate

API重大变更#

注意

随着JupyterLab 4.x的发布,npm包的版本策略发生了变化,不再与Python包的主要版本同步更新,除非为了简化扩展兼容性而需要这样做。

以下是遇到API更改并因此增加了主要版本(遵循semver约定)的JupyterLab npm包列表。我们特别想指出的是@jupyterlab/documentsearch@jupyterlab/toc API,它们已经完全重新设计。

  • @jupyterlab/application 从 3.x 到 4.x
    • 主要版本升级,以允许在 JupyterFrontEnd 中使用替代的 ServiceManager 实现。 具体来说,这允许使用模拟管理器。 这也使得 JupyterLab.IOptions 更加宽松,当提供选项时不需要 shell,并允许符合 ILabShell 接口的 shell。 因此,所有其他 @jupyterlab/ 包的主要版本也进行了升级。 更多详情请参见 jupyterlab/jupyterlab#11537

    • 将令牌 @jupyterlab/apputils:IConnectionLost 重命名为 @jupyterlab/application:IConnectionLost

  • @jupyterlab/apputils 从 3.x 到 4.x
    • IToolbarWidgetRegistry.registerFactory 重命名为 IToolbarWidgetRegistry.addFactory

    • ISanitizerISanitizer.IOptions 已被弃用,推荐使用 @jupyterlab/rendermime-interfaces 中的 IRenderMime.ISanitizerIRenderMime.ISanitizerOptions

    • 全局的 sessionContextDialogs 已被移除;你应该请求 ISessionContextDialogs 的 token(来自 @jupyterlab/apputils)。

  • @jupyterlab/attachments 从 3.x 到 4.x

    IAttachmentsModel.IOptions 中移除了 modelDB

  • @jupyterlab/buildutils 从 3.x 到 4.x
    • create-theme 脚本已被移除。如果你想创建一个新的主题扩展,你应该使用 TypeScript 扩展模板 (选择 theme 作为 kind)来代替。

    • add-sibling 脚本已被移除。请查看 源扩展的开发工作流程 来代替。

    • exitOnUuncaughtException 工具函数已更名为 exitOnUncaughtException(拼写错误修复)。

  • @jupyterlab/cells from 3.x to 4.x
    • MarkdownCell.toggleCollapsedSignal renamed MarkdownCell.headingCollapsedChanged To support notebook windowing, cell widget children (e.g. the editor or the output area) are not instantiated when the cell is attached to the notebook. You can test for isPlaceholder() to see if the cell has been fully instantiated or wait for the promise ready to be resolved. Additionally an attribute inViewport and a signal inViewportChanged are available to test if the cell is attached to the DOM. If you instantiate standalone cells outside of a notebook, you will probably need to set the constructor option placeholder to false to ensure direct rendering of the cell.

    • InputArea.defaultContentFactory and Cell.defaultContentFactory have been removed. If you need it, you can request the token IEditorServices from @jupyterlab/codeeditor. Then you can use new Cell.ContentFactory({ editorFactory: token.factoryService.newInlineEditor });.

  • @jupyterlab/celltags 从 3.x 到 4.0 @jupyterlab/celltags 包已被移除,并由 @jupyterlab/celltags-extension 中的一个小部件替代。 这个小部件现在使用 @jupyterlab/metadataform 进行渲染。

  • @jupyterlab/codeeditor from 3.x to 4.0
    • CodeEditor.IEditor has changed:
      • resizeToFit() is removed

      • addKeydownHandler() is removed - you should add a CodeMirror extension EditorView.domEventHandlers with

        Prec.high (to ensure it is not captured by keyboard shortcuts).

      • injectExtension() added as experimental to inject a CodeMirror extension - you should prefer registering

        new extensions with IEditorExtensionRegistry.

    • CodeEditor.IOptions has two new optional attributes:
      • extensions?: Extensions[] to provide custom extensions at editor instantiation

      • inline?: boolean whether the editor is a subpart of a document (like the notebook) or not.

    • CodeEditorWrapper.IOptions has changed to { factory, model, editorOptions }.

    • CodeViewerWidget.IOptions has changed to { factory, model, editorOptions }.

  • @jupyterlab/codemirror from 3.x to 4.0
    • Configuration parameters changes:
      • fontFamily, fontSize and lineHeight: grouped in a subdictionnary customStyles.

      • insertSpaces: changed for indentUnit that can take a value within [‘Tab’, ‘1’, ‘2’, ‘4’, ‘8’]

      • lineWrap: changed - it is now a boolean.

      • showTrailingSpace: renamed highlightTrailingWhitespace

      • coverGutterNextToScrollbar: removed

      • electricChars: removed

      • extraKeys: removed - you should register new keymap using the CodeMirror extension keymap.of(KeyBinding[])

      • handlePaste: removed

      • keymap: removed

      • lineSeparator: removed - Line separator are normalized to \n

      • lineWiseCopyCut: removed - this is the default behavior

      • scrollbarStyle: removed

      • styleSelectedText: removed

      • selectionPointer: removed

      • wordWrapColumn: removed

    • Mode has been removed. You can instead request the token IEditorLanguageHandler. That provides similar API: - Mode.registerModeInfo -> IEditorLanguageHandler.addLanguage - Mode.ensure() -> IEditorLanguageHandler.getLanguage() - Mode.modeList -> IEditorLanguageHandler.getLanguages() - Mode.run() -> IEditorLanguageHandler.highlight() - Mode.findBest() -> IEditorLanguageHandler.findBest() - Mode.findByName() -> IEditorLanguageHandler.findByName() - Mode.findByMIME() -> IEditorLanguageHandler.findByMIME() - Mode.findByExtension() -> IEditorLanguageHandler.findByExtension()

    • EditorSyntaxStatus moved to @jupyterlab/fileeditor

  • @jupyterlab/codemirror-extension from 3.x to 4.0
    • Moved commands: - codemirror:change-theme -> fileeditor:change-theme (moved to @juptyerlab/fileeditor-extension) - codemirror:change-mode -> fileeditor:change-language (moved to @juptyerlab/fileeditor-extension) - codemirror:find -> fileeditor:find (moved to @juptyerlab/fileeditor-extension) - codemirror:go-to-line -> fileeditor:go-to-line (moved to @juptyerlab/fileeditor-extension)

    • Removed command: codemirror:change-keymap

    • Moved plugins: - @jupyterlab/codemirror-extension:commands integrated within @jupyterlab/fileeditor-extension:plugin - @jupyterlab/codemirror-extension:editor-syntax-status -> @jupyterlab/fileeditor-extension:editor-syntax-status - @jupyterlab/codemirror-extension:editor-syntax-status -> @jupyterlab/fileeditor-extension:editor-syntax-status

  • @jupyterlab/completer from 3.x to 4.x

    Major version was bumped following major refactor aimed at performance improvements and enabling easier third-party integration.

    • Adding custom completion suggestions (items):
      • In 3.x and earlier adding custom completion items required re-registering the completer connector for each file/cell using register method of old manager provided by ICompletionManager token; in 4.x this token and associated ICompletableAttributes interface was removed and a proper method of registering a custom source of completions (a provider of completions) was added. To create a completer provider for JupyterLab, users need to implement the ICompletionProvider interface and then register this provider with ICompletionProviderManager token.

      • In 3.x merging completions from different sources had to be performed by creating a connector internally merging results from other connectors. in 4.x IProviderReconciliator is used to merge completions from multiple providers, and can be customised in constructor for custom completion handlers (CompletionHandler); customizing reconciliator in JupyterLab-managed completers is not yet possible.

    • Rendering with Completer.IRenderer:
      • In 3.x it was not possible to easily swap the renderer of JupyterLab-managed completers. In 4.x the renderer from the completion provider with highest rank is now used for all JupyterLab-managed completers. This behaviour is subject to revision in the future (please leave feedback).

      • Completer box is now using delayed rendering for off-screen content to improve time to first paint for top suggestions. To position the completer without rendering all items we search for the widest item using heuristic which can be adjusted in custom renderers (itemWidthHeuristic).

      • The documentation panel now implements a loading indicator (a progress bar) customizable via optional createLoadingDocsIndicator renderer method.

      • createItemNode was removed in favour of createCompletionItemNode which is now required.

      • createCompletionItemNode is no longer responsible for sanitization of labels which is now a responsibility of the model (see below).

    • Model:
      • In 3.x it was not possible to easily swap the model of JupyterLab-managed completers. In 4.x the model factory from the completion provider with highest rank is now used for JupyterLab-managed completers. This behaviour is subject to revision in the future (please leave feedback).

      • Old methods for updating and accessing the completion items: setOptions, options, and items were removed in favour of completionItems and setCompletionItems which are now required members of Completer.IModel.

      • New signal queryChanged was added and has to be emitted by models.

      • Model is now responsible for sanitization of labels and preserving original label on insertText attribute (if not already defined); this change was required to properly handle escaping of HTML tags.

  • @jupyterlab/codeeditor 从 3.x 到 4.x
    • 移除 ISelectionStyle(以及 defaultSelectionStyleIEditor.selectionStyle)。这是为实时协作设计的。但在最终实现中并未使用。

  • @jupyterlab/console 从 3.x 到 4.x

    IConsoleHistory.sessionContext 的类型已更新为 ISessionContext | null,而不是 ISessionContext。 这可能会破坏从 ConsoleHistory 访问 sessionContext 的插件的编译,特别是那些启用了严格空值检查的插件。

  • @jupyterlab/coreutils 从 3.x 到 4.x

    Time 命名空间不再使用 moment 库来管理日期。相反,它现在使用现代网络浏览器中可用的 Intl API。Time.format 函数仍然可用,但不再接受 timeFormat 参数。

  • @jupyterlab/debugger 从 3.x 到 4.x
    • 命令 debugger:pause 的命令 ID 已重命名为 debugger:pause-on-exceptions,以避免与暂停当前运行线程的命令产生歧义。

  • @jupyterlab/docmanager 从 3.x 到 4.x
    • renameDialog 现在接收 DocumentRegistry.Context 而不是路径。

    • 接口 DocumentManager.IWidgetOpener 现在改为 IDocumentWidgetOpener,并且由一个新的插件 @jupyterlab/docmanager-extension:opener 提供。 IDocumentWidgetOpener 接口现在还定义了一个 `opened` 信号,当一个小部件被打开时发出。

    • 从接口 DocumentManager.IOptions 中移除了属性 docProviderFactory

  • @jupyterlab/docregister 从 3.x 到 4.x
    • TextModelFactory.preferredLanguage(path: string) 将始终返回 ''。编辑器语言无法全局提供。 如果需要,您可以通过从 @jupyterlab/codemirror 请求令牌 IEditorLanguageHandler 来恢复此功能。然后您可以使用 token.findByFileName(widget.context.path)?.name ?? ''

  • @jupyterlab/docprovider 从 3.x 到 4.x

    此包在 JupyterLab 中不再存在。有关实时协作的文档,请查看 RTC 的文档

  • @jupyterlab/docregistry 从 3.x 到 4.x
    • 从接口 Context.IOptions 中移除了属性 docProviderFactory

    • DocumentModel 的构造函数接收一个参数 DocumentModel.IOptions

    • 方法 IModelFactory.createNew 接收一个参数 DocumentRegistry.IModelOptions

    • 方法 TextModelFactory.createNew 接收一个参数 DocumentModel.IOptions

  • @jupyterlab/documentsearch 从 3.x 到 4.x
    • @jupyterlab/documentsearch:plugin 已重命名为 @jupyterlab/documentsearch-extension:plugin

    • @jupyterlab/documentsearch:labShellWidgetListener 已重命名为 @jupyterlab/documentsearch-extension:labShellWidgetListener

    这可能会影响应用程序配置(例如,如果插件被禁用)。 搜索提供者 API 已经完全重新设计。但逻辑是相似的,对于新类型的文档, 您需要向 ISearchProviderRegistry 注册一个 ISearchProviderFactory。 该工厂将为文档小部件构建一个 ISearchProvider

  • @jupyterlab/extensionmanager 从 3.x 到 4.x

    前端 API 已大幅减少,以从后端获取所有信息。现在建议您根据需求实现自定义的 ExtensionManager 类,而不是覆盖前端插件。 请参阅 jupyterlab/extensions/pypi.py 以获取使用 PyPI.org 和 pip 的示例。然后,您可以通过在 Python 包中定义一个入口点来注册您的管理器;请参阅 pyproject.toml::project.entry-points."jupyterlab.extension_manager_v1"

  • @jupyterlab/fileeditor 从 3.x 到 4.x

    移除类 FileEditorCodeWrapper,相反,你可以使用来自 @jupyterlab/codeeditorCodeEditorWrapper

  • @jupyterlab/filebrowser 从 3.x 到 4.x
    • 从接口 IFileBrowserFactory 中移除属性 defaultBrowser。默认浏览器现在由其自己的插件通过要求令牌 IDefaultFileBrowser 提供。

    • FileBrowser 类中移除 useFuzzyFilter 设置器。

  • @jupyterlab/filebrowser-extension 从 3.x 到 4.x

    移除命令 filebrowser:create-main-launcher。你可以用 launcher:create 替换(行为相同) 所有的启动器创建操作都已移至 @jupyterlab/launcher-extension

  • @jupyterlab/imageviewer-extension 从 3.x 到 4.x

    从公共 API 中移除了 addCommands

  • @jupyterlab/mainmenu 从 3.x 到 4.x
    • IMainMenu.addMenu 的签名从 addMenu(menu: Menu, options?: IMainMenu.IAddOptions): void 更改为 addMenu(menu: Menu, update?: boolean, options?: IMainMenu.IAddOptions): void

    • 从公共 API 中移除了 createEditMenu, createFileMenu, createKernelMenu, createViewMenu, createRunMenu, createTabsMenu, createHelpMenu

  • @jupyterlab/notebook from 3.x to 4.x
    • NotebookWidgetFactory.IOptions has no sessionDialogs option any more.

    • The NotebookPanel._onSave method is now private.

    • NotebookActions.collapseAll method renamed to NotebookActions.collapseAllHeadings.

    • Command Collapsible_Headings:Toggle_Collapse renamed to notebook:toggle-heading-collapse.

    • Command Collapsible_Headings:Collapse_All renamed to notebook:collapse-all-headings.

    • Command Collapsible_Headings:Expand_All renamed to notebook:expand-all-headings.

    • To support windowing, a new method scrollToItem(index, behavior) is available to scroll to any cell that may or may not be in the DOM. And new cellInViewportChanged signal is available to listen for cells entering or leaving the viewport (in windowing mode). And scrollToCell(cell) is now returning a Promise<void> calling internally scrollToItem.

    • fullyRendered, placeholderCellRendered and remainingCellToRenderCount have been removed. The defer rendering mode still exists. It will render some cells during spare CPU Idle time.

    • Settings numberCellsToRenderDirectly, remainingTimeBeforeRescheduling, renderCellOnIdle, observedTopMargin and observedBottomMargin have been removed. Instead a windowingMode with value of defer, full or none and overscanCount have been added to manage the rendering mode.

    • Added the property sharedModel to the interface NotebookModel.IOptions.

    • The method NotebookModelFactory.createNew receives a parameter NotebookModelFactory.IModelOptions.

    • The default Notebook toolbar’s restart-and-run button now refers to the command notebook:restart-run-all instead of runmenu:restart-and-run-all.

    • StaticNotebook.defaultContentFactory has been removed. If you need it, you can request the token IEditorServices from @jupyterlab/codeeditor. You can obtain it by requested new NotebookPanel.ContentFactory({ editorFactory: token.factoryService.newInlineEditor });

    • notebooktools module does not provides anymore the ActiveCellTool, the NotebookMetadataEditorTool and the CellMetadataEditorTool. All these widget are replaced by widgets in @jupyterlab/notebook-extension, and are rendered using @jupyterlab/metadataform. The KeySelector has also been removed as not used anymore, replaced by the use of @jupyterlab/metadataform to provides selection for metadata keys.

  • @jupyterlab/rendermime 从 3.x 到 4.x
    • Markdown 解析器已被提取到其自己的插件 @jupyterlab/markedparser-extension:plugin 中, 该插件提供了一个新的令牌 IMarkdownParser(在 @jupyterlab/rendermime 中定义)。 因此,IRendererFactory.createRenderer 有一个新的选项 markdownParser

    • [非破坏性] IRenderMime.IExtension 有一个新的可选属性 description: string 用于文档。

  • @jupyterlab/rendermime-interfaces 从 3.x 到 4.x 移除 IRenderMime.IRenderer.translator? 属性;如果需要,翻译器对象仍然会传递给渲染器工厂的构造函数。

  • @jupyterlab/services 从 6.x 到 7.x
    • 移除 Contents.IDrive.modelDBFactoryContents.IManager.getModelDBFactory

    • 添加了 Contents.IDrive.sharedModelFactoryContents.IManager.getsharedModelFactory

  • @jupyterlab/shared-models 从 3.x 到 4.x

    此包在 JupyterLab 中不再存在。有关共享模型的文档, 请查看 @jupyter/ydoc 文档

  • @jupyterlab/statusbar from 3.x to 4.x
    • Setting @jupyterlab/statusbar-extension:plugin . startMode moved to @jupyterlab/application-extension:shell . startMode

    • Plugin @jupyterlab/statusbar-extension:mode-switch renamed to @jupyterlab/application-extension:mode-switch

    • Plugin @jupyterlab/statusbar-extension:kernel-status renamed to @jupyterlab/apputils-extension:kernel-status

    • Plugin @jupyterlab/statusbar-extension:running-sessions-status renamed to @jupyterlab/apputils-extension:running-sessions-status

    • Plugin @jupyterlab/statusbar-extension:line-col-status renamed to @jupyterlab/codemirror-extension:line-col-status

    • HoverBox component moved from @jupyterlab/apputils to @jupyterlab/ui-components.

    • Removed STATUSBAR_PLUGIN_ID from public API.

  • @jupyterlab/terminal 从 3.x 升级到 4.x
    • Xterm.js 从 4.x 升级到 5.x

    • IThemeObject.selection 重命名为 selectionBackground

  • @jupyterlab/terminal-extension 从 3.x 到 4.x

    从公共 API 中移除了 addCommands

  • @jupyterlab/toc 从 3.x 到 4.x

    @jupyterlab/toc:plugin 重命名为 @jupyterlab/toc-extension:registry 这可能会影响应用程序配置(例如,如果插件被禁用)。 命名空间 TableOfContentsRegistry 已重命名为 TableOfContents。 API 已经完全重新设计。新的目录提供者必须实现一个工厂 TableOfContents.IFactory,该工厂将为支持的 widget 创建一个模型 TableOfContents.IModel。 该模型提供了一个由 textlevel 描述的标题列表,以及可选的 prefixcollapsed 状态和 dataset(数据 DOM 属性字典)。

  • @jupyterlab/ui-components from 3.x to 4.x
    • Major version bumped following removal of Blueprint JS dependency. Extensions using proxied components like Checkbox, Select or Intent will need to import them explicitly from Blueprint JS library. Extensions using Button, Collapse or InputGroup may need to switch to the Blueprint components as the interfaces of those components in JupyterLab do not match those of Blueprint JS.

    • Remove Collapse React component.

    • Form component registry changes:
      • Rename the plugin '@jupyterlab/ui-components-extension:form-component-registry' to '@jupyterlab/ui-components-extension:form-renderer-registry'

      • Rename the IFormComponentRegistry token to IFormRendererRegistry, from @jupyterlab/ui-components:ISettingEditorRegistry to @jupyterlab/ui-components:IFormRendererRegistry.

      • The FormRendererRegistry registers IFormRenderer instead of Field renderers. A IFormRenderer defines a fieldRenderer (this is the renderer to set for backward compatibility) or a widgetRenderer. The renderer id must follow the convention <ISettingRegistry.IPlugin.id>.<propertyName>. This is to ensure a custom renderer is not used for property with the same name but different schema.

  • @jupyterlab/translation 从 3.x 到 4.x 在 NullTranslator 中将方法 locale 重命名为属性 languageCode

  • @jupyterlab/vdom@jupyterlab/vdom-extension 已被移除。 底层的 vdom Python 包无人维护。 因此决定将其从核心包中移除。

  • jupyter.extensions.hub-extension 从 3.x 到 4.x
    • jupyter.extensions.hub-extension 重命名为 @jupyterlab/hub-extension:plugin

    • jupyter.extensions.hub-extension:plugin 重命名为 @jupyterlab/hub-extension:menu

  • TypeScript 5.0 更新 由于更新到 TypeScript 5.0,一些接口的定义发生了变化。 HoverBox.IOptionsanchor 参数现在是一个 DOMRect 而不是 ClientRectCodeEditor.ICoordinate 接口现在扩展了 DOMRectReadOnly 而不是 JSONObject, ClientRect

  • React 18.2.0 更新 从 17.0.1 更新到 React 18.2.0 的更新也应传播到扩展程序。 这里是关于 迁移到 react 18 的文档。

使用Jest进行测试#

Jest 已更新至 29.2.0(且 ts-jest 更新至 29.0.0)。因此,由 @jupyterlab/testutils 提供的 jest 配置与该版本兼容。具体来说:

  • 未维护的报告器 jest-summary-reporter 已被新的默认报告器 github-actions 取代。

  • 辅助工具 flakyIt 已被移除。你可以使用新的 jest.retryTimes 来代替。

在JupyterLab 4中,我们修复了由于testutils包导致的循环依赖问题。因此,现在它只是一个从各种核心包中导出帮助程序的接口。导出的帮助程序与之前相同,除了:

  • NBTestUtils.DEFAULT_CONTENT: 已移除 - 你可以从 @jupyterlab/notebook/lib/testutils 导入,但我们强烈建议不要这样做,而是使用你自己的测试数据。

  • NBTestUtils.DEFAULT_CONTENT_45: 已移除

使用Galata进行测试#

页面内的助手现在位于一个JupyterLab扩展中,以便在公共的Webpack共享范围内运行。这个新扩展包含在JupyterLab的python包中,位于jupyterlab.galata。它需要通过添加以下行来更新您的Jupyter服务器配置:

import jupyterlab
c.LabApp.extra_labextensions_path = str(Path(jupyterlab.__file__).parent / "galata")

注意

为了简化配置,我们引入了一个新的辅助函数 jupyterlab.galata.configure_jupyter_server。因此,你可以将服务器配置简化为 jupyterlab.galata.configure_jupyter_server(c)

Here are the changes in the Javascript package @jupyterlab/galata from 4.x to 5.x:
  • ContentsHelpergalata.newContentsHelper 现在有新的构造函数参数来使用 Playwright API 请求对象: new ContentsHelper(baseURL, page?, request?) -> new ContentsHelper(request?, page?) galata.newContentsHelper(baseURL, page?, request?) -> galata.newContentsHelper(request?, page?) 你需要提供 requestpage;它们都是由 Playwright 提供的 fixtures。

  • galata.Mock.clearRunners(baseURL, runners, type) -> galata.Mock.clearRunners(request, runners, type)

  • 页面内的助手现在定义在扩展中,位于 jupyterlab/galata/extension 并存储在 @jupyterlab/galata/lib/extension。全局对象已重命名为 window.galata 而不是 window.galataip(它仍然存在,但已被弃用)。

已移除的弃用代码#

以下已弃用的API已被移除:

  • @jupyterlab/csvviewer: CSVDelimiter.delimiterChanged 已被移除 - 死代码。你可以直接从 CSVViewer 小部件访问分隔符。

  • @jupyterlab/mainmenu: IJupyterLabMenuJupyterLabMenu 已被移除。你可以直接使用 @jupyterlab/ui-components 中的 IRankedMenuRankedMenu

  • @jupyterlab/notebook: NotebookWidgetFactory 默认工具栏现在为空,因为按钮助手已被弃用。

  • @jupyterlab/rendermime: RenderMimeRegistry.IUrlResolverOptions 不接受 session;你必须设置 path(可通过 session.path 访问)。

  • @jupyterlab/ui-components:
    • RankedMenu.menu : Menu 已被移除,因为 RankedMenu 继承自 Menu

    • LabIconStyle.IProps 不再接受 kindjustify。你应该分别使用 stylesheetelementPosition

扩展开发变更#

  • dev_mode/package.json文件中对应于@jupyterlab/application-topexternalExtensions字段在4.0版本中已被移除。如果您曾使用此字段来针对JupyterLab的开发版本开发源扩展,您应该转而使用联邦扩展系统(通过--extensions-in-dev-mode标志)或使用--splice-source选项。更多信息请参见开发预构建扩展源扩展的开发工作流程

  • @jupyterlab/builder 中的 webpack 依赖已更新至 5.72(或更高版本)。基本规则已更新为使用 Asset Modules 而不是之前的 file-loaderraw-loaderurl-loader。 如果第三方扩展依赖于这些加载器的特定行为,这可能会影响它们。

  • 在 JupyterLab 3.x 中,即使预构建扩展被禁用,其 CSS 仍然会加载到页面上。在 JupyterLab 4.0 中,这种情况不再存在。

  • window.jupyterlab 在使用 --expose-app-in-browser 标志启动 JupyterLab 时不再暴露。 请改用 window.jupyterapp

JupyterLab 3.5 到 3.6#

异步可迭代支持#

对于事件服务,我们使用了ES2018中引入的JavaScript特性。如果你的代码使用TypeScript并以ES2017为目标(如JupyterLab 3.6),你需要将目标更新为ES2018或在TypeScript库选项中添加"ES2018"

注意

JupyterLab 3.6.0 发布时更新了目标为“ES2018”。我们强烈建议更新到 3.6.1 版本,该版本将目标恢复为“ES2017”。

Jest 配置更新#

如果您正在使用 jest 来测试您的扩展程序,JupyterLab 3.6 中添加了一些新的 ES6 包依赖项。在使用 Jest 转换代码时,需要忽略这些依赖项。您需要更新 transformIgnorePatterns 以匹配:

const esModules = [
  '@jupyterlab/',
  '@jupyter/ydoc',
  'lib0',
  'y\\-protocols',
  'y\\-websocket',
  'yjs'
].join('|');

// ...

transformIgnorePatterns: [`/node_modules/(?!${esModules}).+`]

欲了解更多信息,请查看测试您的扩展

实时协作#

在 JupyterLab v3.6 中,必须安装 Jupyter Server v2.0 才能使用实时协作功能。 引入此要求是为了利用 Jupyter Server v2.0 中的新身份 API。

另一方面,我们还改变了JupyterLab加载文档的方式(仅在协作模式下)。 现在,提供者不再使用内容API,而是打开一个与YDocWebSocketHandler的WebSocket连接,该连接是在外部的jupyter server extension中实现的。

此外,共享模型的包被移到了一个名为@jupyter/ydoc的外部包中。所有依赖于@jupyterlab/shared-models的扩展都需要更新为依赖于@jupyter/ydoc@~0.2.2;API应该保持不变。

API 变更: 为了能够修复 RTC 并使其稳定,有必要更改 API 并进行一些破坏性更改。 这些更改不应影响绝大多数扩展。它们只会影响一些专注于 RTC 的扩展。

有必要改变JupyterLab加载文档的范式,并替换后端的锁定机制。现在,它不再识别第一个打开文档的客户端,而是通过在后端实例化一个YDoc客户端来集中处理这个过程。这个客户端是唯一一个将文档内容加载到内存中并与每个连接的其他客户端共享的客户端。

涉及的包有:

  • @jupyterlab/docprovider:
    • The interface IDocumentProvider, now extends from IDisposable. Removed: acquireLock, releaseLock, setPath, destroy, requestInitialContent and putInitializedState. Added: ready and isDisposed.

    • IDocumentProviderFactory.IOptions is now templated with T extends ISharedDocument = ISharedDocument. And the ymodel attribute has been renamed model typed T (relaxing typing from YDocument to ISharedDocument).

    • WebSocketProviderWithLocks has been renamed to WebSocketProvider. It does not extend WebSocketProvider from y-websocket anymore.

    • WebSocketProvider.IOptions has a new optional attribute, user.

  • @jupyterlab/services:
    • 接口 IManager 有一个新的可选属性 user,它实现了 User.IManager

    • ServiceManager 类实现了来自 IManager 的可选属性 user

JupyterLab 3.0 到 3.1#

新的主菜单和上下文菜单自定义#

JupyterLab 3.1 引入了一种新的方式,将命令挂钩到 主菜单上下文菜单。 它允许最终用户通过设置自定义这些菜单,就像已经可以对快捷键进行设置一样。 除了创建动态菜单外,不再建议使用 API。

Jest 配置更新#

如果您正在使用 jest 来测试您的扩展程序,JupyterLab 中添加了一些新的 ES6 包依赖项。在使用 Jest 转换代码时,需要忽略这些依赖项。您需要更新 transformIgnorePatterns 以匹配:

const esModules = [
  '@jupyterlab/',
  'lib0',
  'y\\-protocols',
  'y\\-websocket',
  'yjs'
].join('|');

// ...

transformIgnorePatterns: [`/node_modules/(?!${esModules}).+`]

欲了解更多信息,请查看测试您的扩展

注意

这里是一个更新到JupyterLab 3.1的拉取请求示例,位于@jupyterlab/git扩展中: jupyterlab/jupyterlab-git#files

JupyterLab 2.x 到 3.x#

以下是一些将扩展从JupyterLab 2.x迁移到JupyterLab 3.x的有用提示。

手动升级库版本#

为了使扩展与3.0版本兼容,请更新package.json@jupyterlab依赖项的兼容性范围。差异应类似于:

index 6f1562f..3fcdf37 100644
^^^ a/package.json
+++ b/package.json
   "dependencies": {
-    "@jupyterlab/application": "^2.0.0",
+    "@jupyterlab/application": "^3.0.0",

使用升级脚本升级库版本#

JupyterLab 3.0 提供了一个脚本来升级现有扩展,以使用新的扩展系统和打包方式。

首先,确保更新到 JupyterLab 3.0 并安装 jupyter-packagingcookiecutter。使用 pip

pip install jupyterlab -U
pip install jupyter-packaging cookiecutter

或者使用 conda

conda install -c conda-forge jupyterlab=3 jupyter-packaging cookiecutter

然后在扩展的根文件夹中运行:

python -m jupyterlab.upgrade_extension .

升级脚本创建了将JupyterLab扩展打包为Python包所需的文件,例如 setup.pypyproject.toml

升级脚本还会将package.json中的依赖项更新为^3.0.0包。以下是一个示例差异:

index 6f1562f..3fcdf37 100644
^^^ a/package.json
+++ b/package.json
@@ -29,9 +29,13 @@
   "scripts": {
-    "build": "tsc",
-    "build:labextension": "npm run clean:labextension && mkdirp myextension/labextension && cd myextension/labextension && npm pack ../..",
-    "clean": "rimraf lib tsconfig.tsbuildinfo",
+    "build": "jlpm run build:lib && jlpm run build:labextension:dev",
+    "build:prod": "jlpm run build:lib && jlpm run build:labextension",
+    "build:lib": "tsc",
+    "build:labextension": "jupyter labextension build .",
+    "build:labextension:dev": "jupyter labextension build --development True .",
+    "clean": "rimraf lib tsconfig.tsbuildinfo myextension/labextension",
+    "clean:all": "jlpm run clean:lib && jlpm run clean:labextension",
   "clean:labextension": "rimraf myextension/labextension",
   "eslint": "eslint . --ext .ts,.tsx --fix",
   "eslint:check": "eslint . --ext .ts,.tsx",
@@ -59,12 +63,12 @@
   ]
   },
   "dependencies": {
-    "@jupyterlab/application": "^2.0.0",
-    "@jupyterlab/apputils": "^2.0.0",
-    "@jupyterlab/observables": "^3.0.0",
+    "@jupyterlab/builder": "^3.0.0",
+    "@jupyterlab/application": "^3.0.0",
+    "@jupyterlab/apputils": "^3.0.0",
+    "@jupyterlab/observables": "^3.0.0",
   "@lumino/algorithm": "^1.2.3",
   "@lumino/commands": "^1.10.1",
   "@lumino/disposable": "^1.3.5",
@@ -99,6 +103,13 @@
-    "typescript": "~3.8.3"
+    "typescript": "~4.0.1"
   },
   "jupyterlab": {
-    "extension": "lib/plugin"
+    "extension": "lib/plugin",
+    "outputDir": "myextension/labextension/"
   }
}

在上面的差异中,我们看到还添加了额外的开发脚本,因为它们被新的扩展系统工作流使用。

差异还显示了新的@jupyterlab/builder作为devDependency@jupyterlab/builder是一个包,用于将扩展构建为联合(预构建)扩展。 它隐藏了内部依赖项,如webpack,并生成可以作为Python包的一部分分发的资产。

扩展开发者不需要直接与@jupyterlab/builder交互,而是可以使用jupyter labextension build命令。这个命令作为build脚本的一部分自动运行(jlpm run build)。

有关扩展的新文件结构和打包的更多详细信息,请查看扩展教程:扩展教程

将扩展发布到PyPI和conda-forge#

从 JupyterLab 3.0 开始,扩展可以作为 Python 包分发。

扩展教程提供了如何打包扩展的解释,以便它可以发布在PyPI和conda forge上:发布你的扩展

注意

虽然发布到 PyPI 是向用户分发扩展的新推荐方式,但继续将扩展发布到 npm 仍然有用,这样其他开发者可以在他们自己的扩展中扩展它们。

JupyterLab 1.x 到 2.x#

以下是一些将扩展从 JupyterLab 1.x 迁移到 JupyterLab 2.x 的有用提示。我们将看两个扩展的示例,这些示例涵盖了扩展作者可能使用的大多数 API:

升级库版本#

JupyterLab 1.x 使用的 @phosphor/* 库已更名为 @lumino/*。更新您的 package.json 非常简单。最简单的方法是查看 JupyterLab 核心包代码库 并直接采用那里使用的相关库的版本。

package.json中更新调试器扩展的库#

package.json中更新快捷方式UI扩展的库#

提示

在这些示例中,请注意我们使用的是许多库的2.0.0-beta.x版本。这是为了在最终版本发布之前测试这些扩展与JupyterLab 2.0 beta版本的兼容性。对于最终版本,您的package.json应该依赖于这些包的^2.0.0版本。

@phosphor 迁移到 @lumino ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-

JupyterLab 使用的基础包现在都带有 NPM 命名空间 @lumino 而不是 @phosphor。这些包的 API 没有变化。需要将 @phosphor 命名空间的导入更新为新的 @lumino 命名空间包:

Update from @phosphor/... to @lumino/...#

@phosphor/application

@lumino/application

@phosphor/collections

@lumino/collections

@phosphor/commands

@lumino/commands

@phosphor/coreutils

@lumino/coreutils

@phosphor/datagrid

@lumino/datagrid

@phosphor/datastore

@lumino/datastore

@phosphor/default-theme

@lumino/default-theme

@phosphor/disposable

@lumino/disposable

@phosphor/domutils

@lumino/domutils

@phosphor/dragdrop

@lumino/dragdrop

@phosphor/keyboard

@lumino/keyboard

@phosphor/messaging

@lumino/messaging

@phosphor/properties

@lumino/properties

@phosphor/signaling

@lumino/signaling

@phosphor/virtualdom

@lumino/virtualdom

@phosphor/widgets

@lumino/widgets

警告

p- 前缀的 CSS 类、data-p- 属性和 p- DOM 事件 已被弃用。它们将继续工作,直到 Lumino 的下一个主要版本发布。

  • .p- CSS类如.p-Widget应更新为.lm-, 例如.lm-Widget

  • data-p- 属性,例如 data-p-dragscroll 应更新为 data-lm-,例如 data-lm-dragscroll

  • p- DOM事件,如p-dragenter应更新为lm-, 例如lm-dragenter

更新以前的 @jupyterlab/coreutils 导入 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-

JupyterLab 2.0 引入了几个新的包,这些包中的类和令牌已经从 @jupyterlab/coreutils 移出到它们自己的包中。这些导出已经被移动。

提示

在更新这些库时,删除 node_modulesyarn.lock 可能会有帮助。

导出

DataConnector

@jupyterlab/statedb

Debouncer

@lumino/polling

DefaultSchemaValidator

@jupyterlab/settingregistry

IDataConnector

@jupyterlab/statedb

IObjectPool

@jupyterlab/statedb

IPoll

@lumino/polling

IRateLimiter

@lumino/polling

IRestorable

@jupyterlab/statedb

IRestorer

@jupyterlab/statedb

ISchemaValidator

@jupyterlab/settingregistry

ISettingRegistry

@jupyterlab/settingregistry

IStateDB

@jupyterlab/statedb

nbformat

@jupyterlab/nbformat

Poll

@lumino/polling

RateLimiter

@lumino/polling

RestorablePool

@jupyterlab/statedb

SettingRegistry

@jupyterlab/settingregistry

设置

@jupyterlab/settingregistry

StateDB

@jupyterlab/statedb

Throttler

@lumino/polling

使用SessionSessionContext来管理内核会话#

注意

有关完整的API文档以及如何使用 @jupyterlab/services的示例, 请查阅存储库

ConsolePanelNotebookPanel 现在暴露了一个 sessionContext: ISessionContext 属性,允许以统一的方式与内核会话进行交互。

任何匹配interface IDocumentWidget的小部件都有一个 context: DocumentRegistry.IContext属性,该属性包含一个 sessionContext: ISessionContext属性。

例如,考虑@jupyterlab/debugger扩展的 DebuggerService如何更新其isAvailable()方法。

来自将调试器扩展迁移到JupyterLab 2.0的PR#

注意

await kernel.ready 在可以使用 kernel 之前不再是必要的。内核消息将在内核连接上线时根据需要缓冲,因此您应该能够立即使用内核连接。如果您想检索内核信息(或者出于其他原因,您想等待至少一条消息从新内核连接返回),您可以执行 await kernel.info

使用新的图标系统和LabIcon#

注意

有关如何使用基于LabIcon的新图标支持的完整API文档和示例,请参阅@jupyterlab/ui-components查看存储库