Skip to content

Commit a099c3a

Browse files
authored
Migrate datalayer specific code to core, update collaboration, state and kernels! (#389)
1 parent dde14ec commit a099c3a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1227
-1176
lines changed

CLAUDE.md

Lines changed: 49 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,66 @@
1-
# Jupyter UI - AI Assistant Guide
1+
# Jupyter UI - Quick Reference
22

3-
## Quick Overview
3+
## Overview
44

5-
React component library for Jupyter notebooks. Monorepo with 4 packages managed by Lerna.
5+
React component library for Jupyter notebooks. Monorepo with 4 main packages.
66

7-
## Core Packages
8-
9-
- `@datalayer/jupyter-react` - React components for notebooks, cells, terminals
10-
- `@datalayer/jupyter-lexical` - Rich text editor integration
11-
- `@datalayer/jupyter-docusaurus-plugin` - Docusaurus plugin
12-
- `datalayer-jupyter-vscode` - VS Code extension
13-
14-
## Essential Commands
7+
## Commands
158

169
```bash
17-
npm install # Install dependencies
18-
npm run build # Build all packages
19-
npm run jupyter:server # Start Jupyter server (port 8686)
20-
npm run storybook # Start Storybook (port 6006)
21-
npm run lint # Check errors only (--quiet)
22-
npm run lint:fix # Auto-fix issues
23-
npm run format # Format code
24-
npm run type-check # TypeScript checking
25-
npm run check # Run all checks (format, lint, type)
26-
npm run check:fix # Auto-fix and check all
27-
npm test # Run tests
10+
# Setup
11+
npm install
12+
npm run build
13+
14+
# Development
15+
npm run jupyter:server # Start Jupyter (port 8686)
16+
npm run storybook # Start Storybook (port 6006)
17+
18+
# React package dev (cd packages/react)
19+
npm run start # Remote server config
20+
npm run start-local # Local server (webpack + jupyter)
21+
npm run start-local:webpack # Only webpack
22+
23+
# Code quality
24+
npm run check # Format, lint, type-check
25+
npm run check:fix # Auto-fix and check
2826
```
2927

30-
## Requirements
28+
## Key Info
3129

32-
- Node.js >= 20.0.0 (use .nvmrc)
33-
- npm (not yarn)
34-
- Server token: `60c1661cc408f978c309d04157af55c9588ff9557c9380e4fb50785750703da6`
30+
- **Node.js**: >= 20.0.0 (use .nvmrc)
31+
- **Server token**: `60c1661cc408f978c309d04157af55c9588ff9557c9380e4fb50785750703da6`
32+
- **Webpack entry**: Edit `packages/react/webpack.config.js``ENTRY` variable
33+
- **Jupyter config**: `dev/config/jupyter_server_config.py`
3534

36-
## Key Files
35+
## Collaboration Setup
3736

38-
- `eslint.config.js` - ESLint v9 flat config
39-
- `.prettierrc.json` - Formatter config
40-
- `.prettierignore` - Excludes MDX files
41-
- `patches/` - Third-party fixes (auto-applied)
42-
- `packages/react/webpack.config.js` - Build config
37+
1. Install: `pip install jupyter-collaboration jupyterlab`
38+
2. Enable: Set `c.LabApp.collaborative = True` in jupyter config
39+
3. Test: Open http://localhost:3208/ in multiple windows
4340

44-
## Recent Fixes (2024)
41+
## Collaboration Providers
4542

46-
- MDX comments: `{/_``{/** **/}` in 13 files
47-
- Node requirement: 18 → 20+
48-
- Webpack warnings: 7 → 2 (source-map exclusions)
49-
- @jupyterlite patch for missing logos
50-
- ESLint v9 flat config migration
51-
- React 18 deprecations fixed
52-
- Storybook CI: Added wait-on and --url for test reliability
53-
- Terminal component: Fixed BoxPanel initialization issue
43+
```tsx
44+
// Basic usage
45+
const provider = new JupyterCollaborationProvider();
46+
<Notebook collaborationProvider={provider} path="notebook.ipynb" />;
47+
48+
// With config
49+
const provider = new JupyterCollaborationProvider({
50+
path: 'notebook.ipynb',
51+
serverSettings: mySettings,
52+
});
53+
```
5454

55-
## Common Issues
55+
## Troubleshooting
5656

57-
1. **Storybook errors**: Check MDX syntax, run `npx patch-package`
58-
2. **Node version**: Use Node 20+ (`nvm use`)
59-
3. **Lint errors**: Run `npm run lint:fix`
60-
4. **Build fails**: Run `npm run type-check`
57+
- **Build fails**: Run `npm run type-check`
58+
- **Lint errors**: Run `npm run lint:fix`
59+
- **Node version**: Use Node 20+ (`nvm use`)
60+
- **Collaboration issues**: Check WebSocket connections and jupyter-collaboration installation
6161

62-
## AI Assistant Notes
62+
## Development Tips
6363

64-
- Always use npm, not yarn
64+
- Use npm, not yarn
6565
- Prefer editing over creating files
66-
- Run lint/type checks before committing
66+
- Run checks after changes: `npm run check:fix`

README.md

Lines changed: 69 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ Jupyter UI is a set of [React.js](https://react.dev) components that allow a fro
2020

2121
## 📦 Packages
2222

23-
| Package | Version | Description |
24-
| -------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------- |
25-
| [@datalayer/jupyter-react](./packages/react) | [![npm](https://img.shields.io/npm/v/@datalayer/jupyter-react)](https://www.npmjs.com/package/@datalayer/jupyter-react) | Core React components for Jupyter integration |
26-
| [@datalayer/jupyter-lexical](./packages/lexical) | [![npm](https://img.shields.io/npm/v/@datalayer/jupyter-lexical)](https://www.npmjs.com/package/@datalayer/jupyter-lexical) | Rich text editor with Lexical framework |
27-
| [@datalayer/jupyter-docusaurus-plugin](./packages/docusaurus-plugin) | [![npm](https://img.shields.io/npm/v/@datalayer/jupyter-docusaurus-plugin)](https://www.npmjs.com/package/@datalayer/jupyter-docusaurus-plugin) | Docusaurus plugin for Jupyter notebooks |
28-
| [datalayer-jupyter-vscode](./packages/vscode) | [![marketplace](https://img.shields.io/visual-studio-marketplace/v/datalayer.datalayer-jupyter-vscode)](https://marketplace.visualstudio.com/items?itemName=datalayer.datalayer-jupyter-vscode) | VS Code extension |
23+
| Package | Version | Description |
24+
| -------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------- |
25+
| [@datalayer/jupyter-react](./packages/react) | [![npm](https://img.shields.io/npm/v/@datalayer/jupyter-react)](https://www.npmjs.com/package/@datalayer/jupyter-react) | Generic React components for Jupyter |
26+
| [@datalayer/jupyter-lexical](./packages/lexical) | [![npm](https://img.shields.io/npm/v/@datalayer/jupyter-lexical)](https://www.npmjs.com/package/@datalayer/jupyter-lexical) | Rich text editor with Lexical framework |
27+
| [@datalayer/jupyter-docusaurus-plugin](./packages/docusaurus-plugin) | [![npm](https://img.shields.io/npm/v/@datalayer/jupyter-docusaurus-plugin)](https://www.npmjs.com/package/@datalayer/jupyter-docusaurus-plugin) | Docusaurus plugin for Jupyter notebooks |
28+
| [datalayer-jupyter-vscode](./packages/vscode) | [![marketplace](https://img.shields.io/visual-studio-marketplace/v/datalayer.datalayer-jupyter-vscode)](https://marketplace.visualstudio.com/items?itemName=datalayer.datalayer-jupyter-vscode) | VS Code extension |
2929

3030
## 🚀 Quick Start
3131

@@ -38,21 +38,65 @@ npm install @datalayer/jupyter-react
3838
### Basic Usage
3939

4040
```tsx
41-
import { Jupyter, Notebook } from '@datalayer/jupyter-react';
41+
import { JupyterReactTheme, Notebook } from '@datalayer/jupyter-react';
4242

4343
function App() {
4444
return (
45-
<Jupyter
46-
jupyterServerUrl="http://localhost:8686"
47-
jupyterServerToken="your-token"
48-
startDefaultKernel
49-
>
50-
<Notebook />
51-
</Jupyter>
45+
<JupyterReactTheme>
46+
<Notebook path="notebook.ipynb" id="notebook-id" startDefaultKernel />
47+
</JupyterReactTheme>
5248
);
5349
}
5450
```
5551

52+
### Collaborative Editing
53+
54+
Jupyter UI supports real-time collaboration through a pluggable provider system:
55+
56+
```tsx
57+
import {
58+
Notebook,
59+
JupyterCollaborationProvider,
60+
} from '@datalayer/jupyter-react';
61+
62+
function CollaborativeNotebook() {
63+
const collaborationProvider = new JupyterCollaborationProvider();
64+
65+
return (
66+
<Notebook
67+
path="notebook.ipynb"
68+
collaborationProvider={collaborationProvider}
69+
/>
70+
);
71+
}
72+
```
73+
74+
#### Creating Custom Collaboration Providers
75+
76+
You can create your own collaboration provider by extending `CollaborationProviderBase`:
77+
78+
```tsx
79+
import { CollaborationProviderBase } from '@datalayer/jupyter-react';
80+
81+
class MyCustomProvider extends CollaborationProviderBase {
82+
constructor(config) {
83+
super('my-provider-type');
84+
// Initialize your provider
85+
}
86+
87+
async connect(sharedModel, documentId, options) {
88+
// Implement your connection logic
89+
// Set up WebSocket, authenticate, etc.
90+
}
91+
}
92+
93+
// Use it with any Notebook component
94+
const provider = new MyCustomProvider({
95+
/* config */
96+
});
97+
<Notebook collaborationProvider={provider} path="notebook.ipynb" />;
98+
```
99+
56100
### Development Setup
57101

58102
As a developer start with the [setup of your environment](https://jupyter-ui.datalayer.tech/docs/develop/setup) and try [one of the examples](https://jupyter-ui.datalayer.tech/docs/category/examples). We have [documentation](https://jupyter-ui.datalayer.tech) for more details.
@@ -100,12 +144,21 @@ We host a Storybook on ✨ https://jupyter-ui-storybook.datalayer.tech that show
100144
### Advanced Features
101145

102146
- **🔌 IPyWidgets Support** - Full support for interactive widgets
103-
- **👥 Collaborative Editing** - Real-time collaboration using Y.js
147+
- **👥 Collaborative Editing** - Pluggable provider system supporting:
148+
- Jupyter collaboration (WebSocket-based with Y.js)
149+
- Custom providers via `ICollaborationProvider` interface
104150
- **🎨 Theming** - JupyterLab theme support with dark/light modes
105151
- **🔧 Extensible** - Plugin system for custom functionality
106152
- **🚀 Performance** - Virtual scrolling, lazy loading, and optimizations
107153
- **🔒 Security** - Token authentication, CORS, XSS protection
108154

155+
### Architecture Highlights
156+
157+
- **🏗️ Clean Architecture** - Modular, composable components with clear interfaces
158+
- **🔄 Composition Pattern** - Components compose rather than inherit for maximum flexibility
159+
- **🔌 Provider System** - Pluggable collaboration providers for different backends
160+
- **📦 One-way Dependencies** - Core depends on jupyter-react, not vice versa
161+
109162
<div align="center" style="text-align: center">
110163
<img alt="Jupyter UI Gallery" src="https://datalayer-jupyter-examples.s3.amazonaws.com/jupyter-react-gallery.gif" />
111164
</div>
@@ -151,7 +204,7 @@ We maintain a plugin for [Docusaurus](https://docusaurus.io) in the [docusaurus-
151204

152205
## 📋 Requirements
153206

154-
- **Node.js** >= 18.0.0
207+
- **Node.js** >= 20.0.0
155208
- **npm** >= 8.0.0
156209
- **Python** >= 3.8 (for Jupyter server)
157210
- **JupyterLab** >= 4.0.0

SUMMARY.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@
44

55
Jupyter UI is an open-source React.js component library that bridges the gap between the Jupyter ecosystem and modern web development frameworks. It provides React components that are 100% compatible with Jupyter, allowing developers to build custom data products without being constrained by the traditional JupyterLab interface.
66

7+
## Recent Updates (January 2025)
8+
9+
### Collaboration Provider System
10+
11+
- Implemented plugin-based architecture for extensible collaboration
12+
- Built-in providers: `JupyterCollaborationProvider`, `NoOpCollaborationProvider`
13+
- Direct instantiation pattern for simplicity
14+
- Added collaboration support to `Notebook2` component
15+
716
### Core Problem Solved
817

918
Traditional JupyterLab uses the Lumino widget toolkit, an imperative UI framework that isn't compatible with modern declarative frameworks like React. This forces developers to either:
@@ -23,7 +32,7 @@ The project uses Lerna to manage a monorepo structure with the following organiz
2332
```
2433
jupyter-ui/
2534
├── packages/ # Core library packages
26-
│ ├── react/ # Main React component library
35+
│ ├── react/ # Main React component library (generic)
2736
│ ├── lexical/ # Rich text editor integration
2837
│ ├── docusaurus-plugin/ # Docusaurus integration
2938
│ └── vscode/ # VS Code extension
@@ -60,12 +69,15 @@ The main package providing React components for Jupyter functionality.
6069
- Provides React context providers for state management
6170
- Supports both local and remote Jupyter servers
6271
- Implements WebSocket communication for real-time updates
72+
- Plugin-based collaboration provider system
73+
- Extensible without platform-specific code
6374

6475
**Key Files:**
6576

6677
- `src/jupyter/JupyterContext.tsx` - Core context provider
67-
- `src/components/notebook/Notebook.tsx` - Main notebook component
78+
- `src/components/notebook/Notebook.tsx` - Main notebook component (accepts collaborationProvider)
6879
- `src/providers/ServiceManagerProvider.tsx` - Service management
80+
- `src/jupyter/collaboration/ICollaborationProvider.ts` - Provider interface
6981

7082
### 2. @datalayer/jupyter-lexical (v1.0.3)
7183

@@ -454,11 +466,11 @@ The repository includes several example implementations:
454466

455467
## Community & Ecosystem
456468

457-
- Active development by Datalayer, Inc.
458469
- MIT licensed
459470
- Integration with major React frameworks
460471
- Storybook for component documentation
461472
- Comprehensive documentation site
473+
- Active development by Datalayer, Inc.
462474

463475
## Future Roadmap (Based on Code Structure)
464476

dev/config/jupyter_server_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,4 +106,4 @@
106106
# JupyterLab
107107
#################
108108

109-
c.LabApp.collaborative = False
109+
c.LabApp.collaborative = True

dev/notebooks/collaboration.ipynb

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"# Collaboration Example\n",
8+
"This notebook is for testing real-time collaboration."
9+
]
10+
},
11+
{
12+
"cell_type": "code",
13+
"execution_count": 1,
14+
"metadata": {
15+
"execution": {
16+
"iopub.execute_input": "2025-08-18T06:03:49.869760Z",
17+
"iopub.status.busy": "2025-08-18T06:03:49.869446Z",
18+
"iopub.status.idle": "2025-08-18T06:03:49.875095Z",
19+
"shell.execute_reply": "2025-08-18T06:03:49.874611Z",
20+
"shell.execute_reply.started": "2025-08-18T06:03:49.869729Z"
21+
}
22+
},
23+
"outputs": [
24+
{
25+
"name": "stdout",
26+
"output_type": "stream",
27+
"text": [
28+
"Hello from collaboration notebook!\n"
29+
]
30+
}
31+
],
32+
"source": [
33+
"print('Hello from collaboration notebook!')"
34+
]
35+
},
36+
{
37+
"cell_type": "code",
38+
"execution_count": 2,
39+
"metadata": {
40+
"execution": {
41+
"iopub.execute_input": "2025-08-18T06:03:51.258535Z",
42+
"iopub.status.busy": "2025-08-18T06:03:51.258136Z",
43+
"iopub.status.idle": "2025-08-18T06:03:51.262464Z",
44+
"shell.execute_reply": "2025-08-18T06:03:51.261483Z",
45+
"shell.execute_reply.started": "2025-08-18T06:03:51.258506Z"
46+
}
47+
},
48+
"outputs": [
49+
{
50+
"name": "stdout",
51+
"output_type": "stream",
52+
"text": [
53+
"x + y = 30\n"
54+
]
55+
}
56+
],
57+
"source": [
58+
"# Test collaboration by editing this cell\n",
59+
"x = 10\n",
60+
"y = 20\n",
61+
"print(f'x + y = {x + y}')"
62+
]
63+
},
64+
{
65+
"cell_type": "code",
66+
"execution_count": null,
67+
"metadata": {},
68+
"outputs": [],
69+
"source": []
70+
}
71+
],
72+
"metadata": {
73+
"kernelspec": {
74+
"display_name": "Python 3 (ipykernel)",
75+
"language": "python",
76+
"name": "python3"
77+
},
78+
"language_info": {
79+
"codemirror_mode": {
80+
"name": "ipython",
81+
"version": 3
82+
},
83+
"file_extension": ".py",
84+
"mimetype": "text/x-python",
85+
"name": "python",
86+
"nbconvert_exporter": "python",
87+
"pygments_lexer": "ipython3",
88+
"version": "3.12.7"
89+
}
90+
},
91+
"nbformat": 4,
92+
"nbformat_minor": 4
93+
}

0 commit comments

Comments
 (0)