Skip to content

Add @perspective-dev/anywidget for vscode/jupyter#3192

Open
texodus wants to merge 1 commit into
masterfrom
anywidget
Open

Add @perspective-dev/anywidget for vscode/jupyter#3192
texodus wants to merge 1 commit into
masterfrom
anywidget

Conversation

@texodus

@texodus texodus commented Jun 25, 2026

Copy link
Copy Markdown
Member

This PR replaces the dual-package ipywidgets + JupyterLab labextension architecture for PerspectiveWidget with a single AnyWidget-based widget shipped entirely from the perspective-python wheel. The widget now runs identically in JupyterLab, classic Jupyter Notebook, VSCode notebooks, Colab, Marimo, etc. — with no per-host labextension install.

@perspective-dev/jupyterlab is retained, but slimmed down to a renderers-only labextension (the CSV/JSON/Arrow "Open With → Perspective" file viewers); it no longer ships the widget (and is optional to install if you do not want this feature).

  • New package: @perspective-dev/anywidget, a single esbuild step bundles @perspective-dev/{client,server,viewer,viewer-datagrid,viewer-charts} (wasm inlined) into perspective-anywidget.{js,css}, emitted directly into the Python package at rust/perspective-python/perspective/widget/static/.
  • PerspectiveWidget(anywidget.AnyWidget, PerspectiveViewer) with _esm = static/perspective-anywidget.js and _css = static/perspective-anywidget.css; all _model_* / _view_* traitlets removed.
  • anywidget added to the [jupyter] optional dependency and to requirements.txt; [tool.maturin].include ships the bundle; dropped the dead perspective/extension include and finos-perspective-nbextension.json.
  • Deleted the widget stack: model.js, view.js, widget.js, psp_widget.js, plugin.js, notebook/*, version.js, webpack.config.js, and the resize test/fixture.
  • index.js now registers only PerspectiveRenderers; renderer.js lazy-loads the runtime from @perspective-dev/anywidget on first file-open.
  • Dropped a ton of dependencies.
  • viewer-charts, viewer-datagrid, and the viewer's custom_element.rs bootstrap now skip and console.warn instead of throwing when a custom element is already defined. This lets the widget bundle and the renderers labextension (two copies of the runtime) coexist on one page without "… has already been used with this registry" crashes. You should never do this in practice, however the design of Jupyter's ecosystem makes this difficult to avoid.

Fixes #2783
Fixes #3042
Fixes #3056

@texodus texodus added the enhancement Feature requests or improvements label Jun 25, 2026
@texodus texodus linked an issue Jun 25, 2026 that may be closed by this pull request
Signed-off-by: Andrew Stein <steinlink@gmail.com>

# Conflicts:
#	packages/jupyterlab/package.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Feature requests or improvements

1 participant