-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Merge JupyterDash with Dash #2530
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
27b7d43
Merge JupyterDash with Dash
T4rk1n 26ee9b6
Add typing extensions to requires-install.txt
T4rk1n 9158f85
Build jupyterlab in build.sequential
T4rk1n e7b3a60
Create jupyterlab extension directory.
T4rk1n 27c2ad8
Lint fix
T4rk1n b662b92
Merge branch 'dev' into jupyter
T4rk1n 4c105ab
Add dep installed check to jupyter active check
T4rk1n 888be13
Merge branch 'dev' into jupyter
T4rk1n a54d3d7
Fix lab extension build.
T4rk1n 79bc4db
Lock jupyterlab<4.0.0 for build
T4rk1n 975026c
Update @plotly/dash-jupyterlab/package.json
T4rk1n a615bbe
Fix jupyter default mode
T4rk1n cd0972e
refactor get_ipython
T4rk1n d4a90e6
Remove requires-jupyter
T4rk1n 08b038d
Add `_none` jupyter mode.
T4rk1n 834aa06
Merge branch 'dev' into jupyter
T4rk1n c6a48a9
build
T4rk1n 07721d2
Update changelog.
T4rk1n 5443d0c
Merge branch 'dev' into jupyter
T4rk1n File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 12 additions & 12 deletions
24
@plotly/dash-generator-test-component-typescript/package-lock.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"singleQuote": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { JupyterFrontEndPlugin } from '@jupyterlab/application'; | ||
import '../style/index.css'; | ||
/** | ||
* Initialization data for the jupyterlab-dash extension. | ||
*/ | ||
declare const extension: JupyterFrontEndPlugin<void>; | ||
export default extension; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const application_1 = require("@jupyterlab/application"); | ||
const coreutils_1 = require("@jupyterlab/coreutils"); | ||
const notebook_1 = require("@jupyterlab/notebook"); | ||
const console_1 = require("@jupyterlab/console"); | ||
const widgets_1 = require("@lumino/widgets"); | ||
require("../style/index.css"); | ||
class DashIFrameWidget extends widgets_1.Widget { | ||
/** | ||
* Construct a new DashIFrameWidget. | ||
*/ | ||
constructor(port, url) { | ||
super(); | ||
this.id = port; | ||
this.title.label = `Dash (port: ${port})`; | ||
this.title.closable = true; | ||
this.addClass('jp-dashWidget'); | ||
// Add jp-IFrame class to keep drag events from being lost to the iframe | ||
// See https://github.com/phosphorjs/phosphor/issues/305 | ||
// See https://github.com/jupyterlab/jupyterlab/blob/master/packages/apputils/style/iframe.css#L17-L35 | ||
this.addClass('jp-IFrame'); | ||
const serviceUrl = url; | ||
const iframeElement = document.createElement('iframe'); | ||
iframeElement.setAttribute('baseURI', serviceUrl); | ||
this.iframe = iframeElement; | ||
this.iframe.src = serviceUrl; | ||
this.iframe.id = 'iframe-' + this.id; | ||
this.node.appendChild(this.iframe); | ||
} | ||
/** | ||
* Handle update requests for the widget. | ||
*/ | ||
onUpdateRequest(msg) { | ||
this.iframe.src += ''; | ||
} | ||
} | ||
function activate(app, restorer, notebooks, consoles) { | ||
// Declare a widget variable | ||
let widgets = new Map(); | ||
// Watch notebook creation | ||
notebooks.widgetAdded.connect((sender, nbPanel) => { | ||
// const session = nbPanel.session; | ||
const sessionContext = nbPanel.sessionContext; | ||
sessionContext.ready.then(() => { | ||
const session = sessionContext.session; | ||
let kernel = session.kernel; | ||
registerCommTarget(kernel, widgets, app); | ||
}); | ||
}); | ||
// Watch console creation | ||
consoles.widgetAdded.connect((sender, consolePanel) => { | ||
const sessionContext = consolePanel.sessionContext; | ||
sessionContext.ready.then(() => { | ||
const session = sessionContext.session; | ||
let kernel = session.kernel; | ||
registerCommTarget(kernel, widgets, app); | ||
}); | ||
}); | ||
} | ||
function registerCommTarget(kernel, widgets, app) { | ||
kernel.registerCommTarget('dash', (comm, msg) => { | ||
comm.onMsg = (msg) => { | ||
let msgData = msg.content.data; | ||
if (msgData.type === 'show') { | ||
let widget; | ||
if (!widgets.has(msgData.port)) { | ||
// Create a new widget | ||
widget = new DashIFrameWidget(msgData.port, msgData.url); | ||
widget.update(); | ||
widgets.set(msgData.port, widget); | ||
// Add instance tracker stuff | ||
} | ||
else { | ||
widget = widgets.get(msgData.port); | ||
} | ||
if (!widget.isAttached) { | ||
// Attach the widget to the main work area | ||
// if it's not there | ||
app.shell.add(widget, 'main'); | ||
widget.update(); | ||
} | ||
else { | ||
// Refresh the widget | ||
widget.update(); | ||
} | ||
// Activate the widget | ||
app.shell.activateById(widget.id); | ||
} | ||
else if (msgData.type === 'base_url_request') { | ||
// Build server url and base subpath. | ||
const baseUrl = coreutils_1.PageConfig.getBaseUrl(); | ||
const baseSubpath = coreutils_1.PageConfig.getOption('baseUrl'); | ||
const n = baseUrl.lastIndexOf(baseSubpath); | ||
const serverUrl = baseUrl.slice(0, n); | ||
comm.send({ | ||
type: 'base_url_response', | ||
server_url: serverUrl, | ||
base_subpath: baseSubpath, | ||
frontend: "jupyterlab", | ||
}); | ||
} | ||
}; | ||
}); | ||
} | ||
/** | ||
* Initialization data for the jupyterlab-dash extension. | ||
*/ | ||
const extension = { | ||
id: 'jupyterlab_dash', | ||
autoStart: true, | ||
requires: [application_1.ILayoutRestorer, notebook_1.INotebookTracker, console_1.IConsoleTracker], | ||
activate: activate | ||
}; | ||
exports.default = extension; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
{ | ||
"name": "@plotly/dash-jupyterlab", | ||
"version": "0.4.3", | ||
"description": "A JupyterLab extension for rendering Plotly Dash apps", | ||
"keywords": [ | ||
"jupyter", | ||
"jupyterlab", | ||
"jupyterlab-extension" | ||
], | ||
"homepage": "https://github.com/plotly/dash", | ||
"bugs": { | ||
"url": "https://github.com/plotly/dash/issues" | ||
}, | ||
"license": "MIT", | ||
"author": "Plotly", | ||
"files": [ | ||
"lib/**/*.{d.ts,eot,gif,html,jpg,js,js.map,json,png,svg,woff2,ttf}", | ||
"style/**/*.{css,eot,gif,html,jpg,json,png,svg,woff2,ttf}" | ||
], | ||
"main": "lib/index.js", | ||
"types": "lib/index.d.ts", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/plotly/dash.git" | ||
}, | ||
"scripts": { | ||
"build": "tsc", | ||
"build:pack": "jlpm run prepare && jlpm pack --filename ../../dash/labextension/dist/dash-jupyterlab.tgz && jlpm run build:copy", | ||
"build:copy": "cp package.json ../../dash/labextension/dist/package.json", | ||
"clean": "rimraf lib", | ||
"prepare": "mkdir -p ../../dash/labextension/dist && jlpm run clean && jlpm run build", | ||
"prettier": "prettier --write '{!(package),src/**,!(lib)/**}{.js,.jsx,.ts,.tsx,.css,.json,.md}'", | ||
"watch": "tsc -w" | ||
}, | ||
"dependencies": { | ||
"@jupyterlab/application": "^2.0.0 || ^3.0.0", | ||
"@jupyterlab/notebook": "^2.0.0 || ^3.0.0", | ||
"@jupyterlab/console": "^2.0.0 || ^3.0.0" | ||
}, | ||
"devDependencies": { | ||
"prettier": "2.0.5", | ||
"rimraf": "3.0.2", | ||
"typescript": "3.9.3" | ||
}, | ||
"jupyterlab": { | ||
"extension": true | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This is currently published to npm as jupyterlab-dash - is that published version used for anything? Is there a reason to change its name and scoping here?
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.
It uses the tar bundle included in the Python package, that needs to be built the first time you open jupyterlab. Not sure if the npm package is used for anything, the jupyterlab docs says it can be directly to jupyterlab with npm but I am not sure the user really want to do that. https://jupyterlab.readthedocs.io/en/latest/extension/extension_tutorial.html#publishing-your-extension
I changed the name to avoid conflict if jupyter-dash is installed.