Skip to content

Commit

Permalink
Update lab components
Browse files Browse the repository at this point in the history
  • Loading branch information
trungleduc committed Nov 2, 2023
1 parent 2bcf4f6 commit b35b01a
Show file tree
Hide file tree
Showing 11 changed files with 13,194 additions and 8,841 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,4 @@ dmypy.json
_temp_extension
junit.xml
[uU]ntitled*
.yarn/
1 change: 1 addition & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodeLinker: node-modules
68 changes: 32 additions & 36 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@
"url": "https://github.com/voila-dashboards/voila-gridstack/issues"
},
"license": "BSD-3-Clause",
"author": {
"name": "Voila Development Team",
"email": ""
},
"author": "Voila Development Team",
"keywords": [
"jupyter",
"jupyterlab",
Expand Down Expand Up @@ -56,47 +53,46 @@
"watch:labextension": "jupyter labextension watch ."
},
"dependencies": {
"@jupyter-widgets/base": "^6.0.4",
"@jupyter-widgets/jupyterlab-manager": "^5.0.7",
"@jupyter/ydoc": "^0.2.3",
"@jupyterlab/application": "^3.6.3",
"@jupyterlab/apputils": "^3.6.3",
"@jupyterlab/cells": "^3.6.3",
"@jupyterlab/codeeditor": "^3.6.3",
"@jupyterlab/coreutils": "^5.6.3",
"@jupyterlab/docregistry": "^3.6.3",
"@jupyterlab/mainmenu": "^3.6.3",
"@jupyterlab/notebook": "^3.6.3",
"@jupyterlab/observables": "^4.6.3",
"@jupyterlab/outputarea": "^3.6.3",
"@jupyterlab/rendermime": "^3.6.3",
"@jupyterlab/ui-components": "^3.6.3",
"@lumino/algorithm": "^1.9.0",
"@lumino/commands": "^1.19.0",
"@lumino/coreutils": "^1.11.0",
"@lumino/disposable": "^1.10.0",
"@lumino/dragdrop": "^1.13.0",
"@lumino/messaging": "^1.10.0",
"@lumino/signaling": "^1.10.0",
"@lumino/widgets": "^1.37.2",
"@jupyter-widgets/base": "^6.0.6",
"@jupyter-widgets/jupyterlab-manager": "^5.0.9",
"@jupyter/ydoc": "~1.0.2",
"@jupyterlab/application": "^4.0.0",
"@jupyterlab/apputils": "^4.0.0",
"@jupyterlab/cells": "^4.0.0",
"@jupyterlab/codeeditor": "^4.0.0",
"@jupyterlab/coreutils": "^6.0.0",
"@jupyterlab/docregistry": "^4.0.0",
"@jupyterlab/mainmenu": "^4.0.0",
"@jupyterlab/notebook": "^4.0.0",
"@jupyterlab/observables": "^5.0.7",
"@jupyterlab/outputarea": "^4.0.0",
"@jupyterlab/rendermime": "^4.0.0",
"@jupyterlab/ui-components": "^4.0.0",
"@lumino/algorithm": "^2.0.0",
"@lumino/commands": "^2.0.0",
"@lumino/coreutils": "^2.0.0",
"@lumino/disposable": "^2.0.0",
"@lumino/dragdrop": "^2.0.0",
"@lumino/messaging": "^2.0.0",
"@lumino/signaling": "^2.0.0",
"@lumino/widgets": "^2.0.0",
"gridstack": "^7.3.0",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"yjs": "^13.5.17"
},
"devDependencies": {
"@babel/core": "^7.10.2",
"@babel/preset-env": "^7.10.2",
"@jupyterlab/builder": "^3.6.3",
"@jupyterlab/testutils": "3.6.3",
"@types/codemirror": "^0.0.97",
"@jupyterlab/builder": "^4.0.0",
"@jupyterlab/testutils": "^4.0.0",
"@types/jest": "^26.0.24",
"@typescript-eslint/eslint-plugin": "^5.2.0",
"@typescript-eslint/parser": "^5.2.0",
"eslint": "^8.1.0",
"eslint-plugin-jest": "^25.2.2",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-jest": "^27.2.1",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-react": "^7.26.1",
"husky": "^3",
"jest": "^26.4.2",
Expand All @@ -109,7 +105,7 @@
"rimraf": "^3.0.2",
"shell-quote": "^1.7.2",
"ts-jest": "^26.4.4",
"typescript": "~4.1.3"
"typescript": "~5.0.2"
},
"publishConfig": {
"access": "public"
Expand All @@ -133,4 +129,4 @@
"pre-commit": "lint-staged"
}
}
}
}
49 changes: 24 additions & 25 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
[build-system]
requires = ["hatchling>=1.9.0", "hatch-nodejs-version", "jupyterlab~=3.6", "jupyterlab_widgets~=3.0", "voila>=0.2,<0.5"]
requires = [
"hatchling>=1.9.0",
"hatch-nodejs-version",
"jupyterlab>=4.0.0,<5",
"jupyterlab_widgets~=3.0",
"voila>=0.2,<0.6",
]
build-backend = "hatchling.build"

[project]
name = "voila-gridstack"
readme = "README.md"
license = { file = "LICENSE" }
requires-python = ">=3.7"
dependencies = ["jupyterlab_widgets~=3.0", "voila>=0.2.0,<0.5.0"]
dependencies = ["jupyterlab_widgets~=3.0", "voila>=0.2,<0.6"]
classifiers = [
"Framework :: Jupyter",
"Framework :: Jupyter :: JupyterLab",
"Framework :: Jupyter :: JupyterLab :: 3",
"Framework :: Jupyter :: JupyterLab :: 4",
"Framework :: Jupyter :: JupyterLab :: Extensions",
"Framework :: Jupyter :: JupyterLab :: Extensions :: Prebuilt",
"License :: OSI Approved :: BSD License",
Expand All @@ -25,24 +31,9 @@ classifiers = [
dynamic = ["version", "description", "authors", "urls", "keywords"]

[project.optional-dependencies]
dev = [
"click",
"jupyter_releaser",
"hatch",
"hatch-nodejs-version"
]
test = [
"ipykernel",
"lxml",
"nbconvert==6.5.0",
"pytest",
"pytest-tornasync",
]
docs = [
"sphinx",
"myst-parser",
"pydata-sphinx-theme"
]
dev = ["click", "jupyter_releaser", "hatch", "hatch-nodejs-version"]
test = ["ipykernel", "lxml", "nbconvert==6.5.0", "pytest", "pytest-tornasync"]
docs = ["sphinx", "myst-parser", "pydata-sphinx-theme"]

[tool.hatch.version]
source = "nodejs"
Expand All @@ -51,7 +42,12 @@ source = "nodejs"
fields = ["description", "authors", "urls"]

[tool.hatch.build.targets.sdist]
artifacts = ["/voila_gridstack/labextension", "/voila_gridstack/nbextension", "/voila_gridstack/template", "/voila_gridstack/config"]
artifacts = [
"/voila_gridstack/labextension",
"/voila_gridstack/nbextension",
"/voila_gridstack/template",
"/voila_gridstack/config",
]
exclude = ["/.github", "/binder", "node_modules"]

[tool.hatch.build.targets.wheel.shared-data]
Expand All @@ -66,7 +62,10 @@ exclude = ["/.github", "/binder", "node_modules"]
[tool.hatch.build.hooks.jupyter-builder]
dependencies = ["hatch-jupyter-builder>=0.6.2"]
build-function = "hatch_jupyter_builder.npm_builder"
ensured-targets = ["voila_gridstack/labextension/static/style.js", "voila_gridstack/labextension/package.json"]
ensured-targets = [
"voila_gridstack/labextension/static/style.js",
"voila_gridstack/labextension/package.json",
]
skip-if-exists = ["voila_gridstack/labextension/static/style.js"]

[tool.hatch.build.hooks.jupyter-builder.build-kwargs]
Expand All @@ -81,13 +80,13 @@ skip = ["check-links"]
before-build-npm = [
"python -m pip install jupyterlab~=3.6",
"jlpm",
"jlpm build:prod"
"jlpm build:prod",
]
before-build-python = [
# Build the assets
"jlpm build:prod",
# Clean the build artifacts to not include them in sdist
"jlpm clean:lib"
"jlpm clean:lib",
]

[tool.jupyter-releaser.options]
Expand Down
15 changes: 13 additions & 2 deletions src/editor/factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ import {
StaticNotebook,
} from '@jupyterlab/notebook';

import { IEditorMimeTypeService } from '@jupyterlab/codeeditor';
import {
IEditorFactoryService,
IEditorMimeTypeService,
} from '@jupyterlab/codeeditor';

import { IRenderMimeRegistry } from '@jupyterlab/rendermime';

Expand All @@ -32,7 +35,10 @@ export class VoilaGridStackWidgetFactory extends ABCWidgetFactory<
super(options);
this.rendermime = options.rendermime;
this.contentFactory =
options.contentFactory || NotebookPanel.defaultContentFactory;
options.contentFactory ||
new NotebookPanel.ContentFactory({
editorFactory: options.editorFactoryService.newInlineEditor,
});
this.mimeTypeService = options.mimeTypeService;
this._editorConfig =
options.editorConfig || StaticNotebook.defaultEditorConfig;
Expand Down Expand Up @@ -129,6 +135,11 @@ export namespace VoilaGridStackWidgetFactory {
*/
mimeTypeService: IEditorMimeTypeService;

/**
* The service used to create default panel.
*/
editorFactoryService: IEditorFactoryService;

/**
* The notebook cell editor configuration.
*/
Expand Down
14 changes: 8 additions & 6 deletions src/editor/gridstack/layout.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { Layout, Widget } from '@lumino/widgets';

import { IIterator, ArrayIterator } from '@lumino/algorithm';

import { Signal, ISignal } from '@lumino/signaling';

import { Message, MessageLoop } from '@lumino/messaging';
Expand Down Expand Up @@ -146,12 +144,16 @@ export class GridStackLayout extends Layout {
this._prepareGrid();
}

/**
/**
* Create an iterator over the widgets in the layout.
*
* @returns A new iterator over the widgets in the layout.
*/
iter(): IIterator<Widget> {
return new ArrayIterator(this._gridItems);
}
*[Symbol.iterator](): IterableIterator<Widget> {
for (const item of this._gridItems) {
yield item;
}
}

/**
* Remove a widget from the layout.
Expand Down
11 changes: 3 additions & 8 deletions src/editor/gridstack/model.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {
CellList,
INotebookModel,
NotebookPanel,
StaticNotebook,
Expand All @@ -22,8 +23,6 @@ import { DocumentRegistry } from '@jupyterlab/docregistry';

import { SimplifiedOutputArea } from '@jupyterlab/outputarea';

import { IObservableUndoableList } from '@jupyterlab/observables';

import { YNotebook, createMutex } from '@jupyter/ydoc';

import { Widget } from '@lumino/widgets';
Expand Down Expand Up @@ -205,7 +204,7 @@ export class GridStackModel {
/**
* The Notebook's cells.
*/
get cells(): IObservableUndoableList<ICellModel> {
get cells(): CellList {
return this._context.model.cells;
}

Expand Down Expand Up @@ -336,7 +335,6 @@ export class GridStackModel {
rendermime: this.rendermime,
contentFactory: this.contentFactory,
editorConfig: this._editorConfig.code,
updateEditorOnShow: true,
});

item = new SimplifiedOutputArea({
Expand All @@ -353,7 +351,6 @@ export class GridStackModel {
rendermime: this.rendermime,
contentFactory: this.contentFactory,
editorConfig: this._editorConfig.markdown,
updateEditorOnShow: false,
});
markdownCell.inputHidden = false;
markdownCell.rendered = true;
Expand All @@ -367,7 +364,6 @@ export class GridStackModel {
model: cellModel as RawCellModel,
contentFactory: this.contentFactory,
editorConfig: this._editorConfig.raw,
updateEditorOnShow: false,
});
rawCell.inputHidden = false;
Private.removeElements(rawCell.node, 'jp-Collapser');
Expand Down Expand Up @@ -403,11 +399,10 @@ export class GridStackModel {
rendermime: this.rendermime,
contentFactory: this.contentFactory,
editorConfig: this._editorConfig.code,
updateEditorOnShow: true,
});

SimplifiedOutputArea.execute(
cell.value.text,
cell.sharedModel.source,
codeCell.outputArea,
this._context.sessionContext
)
Expand Down
Loading

0 comments on commit b35b01a

Please sign in to comment.