New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support comparing semver ranges that have top-level ||
operators.
#7919
Conversation
This allows us to have an extension that supports multiple versions of JLab (i.e., ^1 || ^2)
Thanks for making a pull request to JupyterLab! To try out this branch on binder, follow this link: |
The test failures look totally unrelated, but on the other hand I haven't seen these particular test failures before. Thoughts? |
The usage test failure is an intermittent one. Unfortunately we can't restart the job until the other ones finish... |
If we can merge this, I can push out another rc so we can test extensions targeting jlab 1 and 2, as well as the icon stuff just merged. |
With this PR on top of jlab 2.0.0rc1, I can generate an extension from the ts cookiecutter, apply the following diff, and have an extension that works in jlab 1.2.6 and jlab 2.0: diff --git a/package.json b/package.json
index 95c6095..256226c 100644
--- a/package.json
+++ b/package.json
@@ -31,11 +31,13 @@
"watch": "tsc -w"
},
"dependencies": {
- "@jupyterlab/application": "^1.0.0"
+ "@jupyterlab/application": "^1.2.1 || ^2.0.0-rc.0",
+ "@jupyterlab/apputils": "^1.2.1 || ^2.0.0-rc.0",
+ "@phosphor/widgets": "^1.9.3"
},
"devDependencies": {
"rimraf": "^2.6.1",
- "typescript": "~3.5.2"
+ "typescript": "~3.7.2"
},
"sideEffects": [
"style/*.css"
diff --git a/src/index.ts b/src/index.ts
index 8952150..600acb0 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -1,16 +1,45 @@
import {
- JupyterFrontEnd, JupyterFrontEndPlugin
-} from '@jupyterlab/application';
+ JupyterFrontEnd,
+ JupyterFrontEndPlugin,
+ ILabShell,
+} from "@jupyterlab/application";
+import {
+ MainAreaWidget
+} from "@jupyterlab/apputils";
+
+import { Widget } from "@phosphor/widgets";
/**
* Initialization data for the myextension extension.
*/
const extension: JupyterFrontEndPlugin<void> = {
- id: 'myextension',
+ id: "myextension",
autoStart: true,
- activate: (app: JupyterFrontEnd) => {
- console.log('JupyterLab extension myextension is activated!');
+ requires: [ILabShell],
+ activate: (app: JupyterFrontEnd, labShell: ILabShell) => {
+ const w = new Widget();
+ w.id = 'My widget';
+ w.title.label = 'My Widget';
+ w.node.textContent = "My widget!";
+ const mw = new MainAreaWidget({content: w as any});
+ app.restored.then(() => {
+ labShell.add(mw, 'main');
+ })
+
+ const w2 = new Widget();
+ w2.id = 'My widget2';
+ w2.title.label = 'My Widget2';
+ w2.node.textContent = "My widget2!";
+ labShell.add(w2 as any, 'right');
+
+ const w3 = new Widget();
+ w3.id = 'My widget3';
+ w3.title.label = 'My Widget3';
+ w3.node.textContent = "My widget3!";
+ labShell.add(w3 as any, 'right');
+
+ console.log('my widget added!');
}
};
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Nice, and thanks for taking on the publish step! |
References
When working on supporting multiple versions of jlab with a single extension codebase (see #7893), I ran into a problem that JupyterLab tries to check compatibility of extensions, but cannot handle an
||
top-level operator.Code changes
This allows us to have an extension that supports multiple versions of JLab (i.e., a semver range of
^1 || ^2
for a jlab dependency)User-facing changes
Should be none
Backwards-incompatible changes
Should be none.