extensions.md 4.6 KB

Plugins

JupyterLab can be extended in two ways via:

  • application plugins (top level): Application plugins extend the functionality of JupyterLab itself, and this tutorial focuses on them.
  • document widget extensions (lower level): Document widget extensions extend the functionality of document widgets added to the application, and we cover them in the "Documents" tutorial.

A JupyterLab application is comprised of several parts:

  • Service Providers
  • Extensions
  • a core Application object

A full example of an application is contained here. Looking at the index.js file, you can see the extensions and service providers used in the tutorial example.

Services

A service provider adds a core functionality to the application:

  • A service provider does not use the Application object.
  • A Service provider can require other services for operation.
  • Extensions can use providers to offer additional functionality to the user.
  • A Service provider is activated when it is needed by other services or extensions.

The default services providers in the JupyterLab application include:

  • Services - An application-specific interface to jupyter-js-services.
  • RenderMime - The registry for adding kernel display_data renderers.
  • Document Registry - Used to add functionality around widgets backed by files.
  • Clipboard - The application-wide clipboard for arbitrary MIME data.

Extensions

Extensions use the Application object and optionally other services to provide functionality to the application.

  • Extensions provided to the application on startup are activated immediately.
  • Extensions can also be activated explicitly at runtime through the Application instance.

The default extensions in the application include:

  • Widget manager - Manages comm channels for ipywidgets.
  • Terminal - Adds the ability to create command prompt terminals.
  • Shortcuts - Provides the default set of shortcuts for the application.
  • Images - Adds a widget factory for displaying image files.
  • Help - Adds a side bar widget for displaying external documentation.
  • File Browser - Creates the file browser and the document manager and the file browser to the side bar.
  • Editor - Add a widget factory for displaying editable source files.
  • Console - Adds the ability to launch Jupyter Console instances for interactive kernel console sessions.

Command Palette

The command palette, as a part of the application object, is intended to be the primary way to display and execute commands in the application. Many of the default extensions add new commands to the command palette to provide actions such as executing a notebook cell or launching a new terminal instance.

Phosphor

The Phosphor library is used as the underlying architecture of JupyterLab and provides many of the low level primitives and widget structure used in the application. Phosphor provides a rich set of widgets for developing desktop-like applications in the browser, as well as patterns and objects for writing clean, well-abstracted code. The widgets in the application are primarily Phosphor widgets, and Phosphor concepts, like message passing and signals, are used throughout. Phosphor messages are a many-to-one interaction that allows information like resize events to flow through the widget hierarchy in the application. Phosphor signals are a one-to-many interaction that allow listeners to react to changes in an observed object.