Skip to content
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

Rendermime Refactor #2555

Merged
merged 47 commits into from
Jul 4, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
8f95ec3
wip rendermime refactor
blink1073 Jun 29, 2017
e8f56ad
wip refactor mime renderer extensions
blink1073 Jun 29, 2017
a91b054
Remove docregistry and rendermime extensions
blink1073 Jun 29, 2017
d27aa2b
clean up
blink1073 Jun 29, 2017
7a0b1d1
Finish the mime extensions refactor
blink1073 Jun 29, 2017
bdd40d9
Fix handling of layout widget name changes
blink1073 Jun 29, 2017
db0e9de
Refactor the rendermime interface
blink1073 Jun 29, 2017
afa4621
Refactory document registry and vega extension
blink1073 Jun 29, 2017
54a0c19
Move trusted to options
blink1073 Jun 29, 2017
51c015f
Update the command name
blink1073 Jun 29, 2017
e0e16bf
Add a static method to populate the default factories
blink1073 Jun 29, 2017
8a9c295
wip update tests
blink1073 Jun 29, 2017
b439137
Update addFactory behavior
blink1073 Jun 30, 2017
c757d0e
Update tests
blink1073 Jun 30, 2017
c5d0426
Remove markdownviewer tests
blink1073 Jun 30, 2017
bd7ed12
Remove markdownviewer from package.json
blink1073 Jun 30, 2017
aca964b
whitespace
blink1073 Jun 30, 2017
bc1ff8a
Update class name
blink1073 Jun 30, 2017
29f9340
update tests
blink1073 Jun 30, 2017
aee5e16
Remove stale test
blink1073 Jun 30, 2017
582e7e1
more rendermime api adjustments
blink1073 Jun 30, 2017
d39a4e9
Update tests
blink1073 Jun 30, 2017
8dea523
cleanup
blink1073 Jun 30, 2017
828cc70
Update docs
blink1073 Jul 3, 2017
52c407a
Update the mime model interface
blink1073 Jul 3, 2017
76198e3
Update the rendermime objects
blink1073 Jul 3, 2017
a059803
Update the vega package
blink1073 Jul 3, 2017
2efeae5
Add a changed signal to the output model
blink1073 Jul 3, 2017
7e15fd4
Updates for new mime model api
blink1073 Jul 3, 2017
a0c7b3b
Update examples
blink1073 Jul 3, 2017
9479015
Update tests
blink1073 Jul 3, 2017
d8cc2be
Fix mimerenderer data handling
blink1073 Jul 3, 2017
fb992cc
Create a single setdata method for mime models
blink1073 Jul 3, 2017
2192659
Update rendermime interfaces
blink1073 Jul 3, 2017
c666548
Update rendermime
blink1073 Jul 3, 2017
34f198f
Update other packages
blink1073 Jul 3, 2017
3777651
More rendermime cleanup
blink1073 Jul 3, 2017
6bc8633
Update examples
blink1073 Jul 3, 2017
e400ac8
Update tests
blink1073 Jul 3, 2017
04f5098
Update the html test
blink1073 Jul 3, 2017
55f99d4
Add intial factories to app
blink1073 Jul 3, 2017
a10d3de
Fix test
blink1073 Jul 3, 2017
8eaf880
Rename irendererwidget -> irenderer
blink1073 Jul 3, 2017
9fc73aa
Update test
blink1073 Jul 3, 2017
a3c7c4a
Simplify preferredMimeType handler
blink1073 Jul 3, 2017
6fa8ae6
Address review comments
blink1073 Jul 4, 2017
8f232a8
Fix syntax
blink1073 Jul 4, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions examples/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ var mods = [
require('@jupyterlab/console-extension'),
require('@jupyterlab/csvviewer-extension'),
require('@jupyterlab/docmanager-extension'),
require('@jupyterlab/docregistry-extension'),
require('@jupyterlab/fileeditor-extension'),
require('@jupyterlab/faq-extension'),
require('@jupyterlab/filebrowser-extension'),
Expand All @@ -26,7 +25,6 @@ var mods = [
require('@jupyterlab/launcher-extension'),
require('@jupyterlab/markdownviewer-extension'),
require('@jupyterlab/notebook-extension'),
require('@jupyterlab/rendermime-extension'),
require('@jupyterlab/running-extension'),
require('@jupyterlab/services-extension'),
require('@jupyterlab/settingeditor-extension'),
Expand Down
2 changes: 0 additions & 2 deletions examples/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
"@jupyterlab/console-extension": "^0.7.0",
"@jupyterlab/csvviewer-extension": "^0.7.1",
"@jupyterlab/docmanager-extension": "^0.7.0",
"@jupyterlab/docregistry-extension": "^0.7.0",
"@jupyterlab/faq-extension": "^0.7.0",
"@jupyterlab/filebrowser-extension": "^0.7.0",
"@jupyterlab/fileeditor-extension": "^0.7.0",
Expand All @@ -24,7 +23,6 @@
"@jupyterlab/launcher-extension": "^0.7.1",
"@jupyterlab/markdownviewer-extension": "^0.7.0",
"@jupyterlab/notebook-extension": "^0.7.0",
"@jupyterlab/rendermime-extension": "^0.7.0",
"@jupyterlab/running-extension": "^0.7.0",
"@jupyterlab/services-extension": "^0.7.0",
"@jupyterlab/settingeditor-extension": "^0.2.0",
Expand Down
4 changes: 3 additions & 1 deletion examples/console/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ function startApp(path: string, manager: ServiceManager.IManager) {
commands.processKeydownEvent(event);
});

let rendermime = new RenderMime({ items: RenderMime.getDefaultItems() });
let initialFactories = RenderMime.getDefaultFactories();
let rendermime = new RenderMime({ initialFactories });

let editorFactory = editorServices.factoryService.newInlineEditor.bind(
editorServices.factoryService);
let contentFactory = new ConsolePanel.ContentFactory({ editorFactory });
Expand Down
4 changes: 3 additions & 1 deletion examples/notebook/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ function createApp(manager: ServiceManager.IManager): void {
commands.processKeydownEvent(event);
}, useCapture);

let rendermime = new RenderMime({ items: RenderMime.getDefaultItems() });
let initialFactories = RenderMime.getDefaultFactories();
let rendermime = new RenderMime({ initialFactories });

let opener = {
open: (widget: Widget) => {
// Do nothing for sibling widgets for now.
Expand Down
31 changes: 20 additions & 11 deletions jupyterlab/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ require('font-awesome/css/font-awesome.min.css');
require('@jupyterlab/theming/style/index.css');

var app = require('@jupyterlab/application').JupyterLab;
var RenderMime = require('@jupyterlab/rendermime').RenderMime;

function main() {
var version = PageConfig.getOption('appVersion') || 'unknown';
Expand All @@ -22,6 +21,8 @@ function main() {
if (version[0] === 'v') {
version = version.slice(1);
}

// Get the disabled extensions.
var disabled = [];
try {
var option = PageConfig.getOption('disabledExtensions');
Expand All @@ -30,14 +31,29 @@ function main() {
// No-op
}

// Handle the registered mime extensions.
var mimeExtensions = [];
{{#each jupyterlab_mime_extensions}}
try {
if (disabled.indexOf('{{this}}') === -1) {
mimeExtensions.push(require('{{this}}'));
}
} catch (e) {
console.error(e);
}
{{/each}}

lab = new app({
namespace: namespace,
name: name,
version: version,
devMode: devMode.toLowerCase() === 'true',
settingsDir: settingsDir,
assetsDir: assetsDir
assetsDir: assetsDir,
mimeExtensions: mimeExtensions
});

// Handled the registered standard extensions.
{{#each jupyterlab_extensions}}
try {
if (disabled.indexOf('{{this}}') === -1) {
Expand All @@ -47,15 +63,8 @@ function main() {
console.error(e);
}
{{/each}}
{{#each jupyterlab_mime_extensions}}
try {
if (disabled.indexOf('{{this}}') === -1) {
RenderMime.registerExtensionModule(require('{{this}}'));
}
} catch (e) {
console.error(e);
}
{{/each}}

// Handle the ignored plugins.
var ignorePlugins = [];
try {
var option = PageConfig.getOption('ignorePlugins');
Expand Down
5 changes: 0 additions & 5 deletions jupyterlab/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
"@jupyterlab/docmanager": "^0.7.0",
"@jupyterlab/docmanager-extension": "^0.7.0",
"@jupyterlab/docregistry": "^0.7.0",
"@jupyterlab/docregistry-extension": "^0.7.0",
"@jupyterlab/faq-extension": "^0.7.0",
"@jupyterlab/filebrowser": "^0.7.0",
"@jupyterlab/filebrowser-extension": "^0.7.0",
Expand All @@ -39,13 +38,11 @@
"@jupyterlab/inspector-extension": "^0.7.0",
"@jupyterlab/launcher": "^0.7.0",
"@jupyterlab/launcher-extension": "^0.7.1",
"@jupyterlab/markdownviewer": "^0.7.0",
"@jupyterlab/markdownviewer-extension": "^0.7.0",
"@jupyterlab/notebook": "^0.7.0",
"@jupyterlab/notebook-extension": "^0.7.0",
"@jupyterlab/outputarea": "^0.7.0",
"@jupyterlab/rendermime": "^0.7.0",
"@jupyterlab/rendermime-extension": "^0.7.0",
"@jupyterlab/running": "^0.7.0",
"@jupyterlab/running-extension": "^0.7.0",
"@jupyterlab/services": "^0.46.0",
Expand Down Expand Up @@ -117,7 +114,6 @@
"@jupyterlab/console-extension",
"@jupyterlab/csvviewer-extension",
"@jupyterlab/docmanager-extension",
"@jupyterlab/docregistry-extension",
"@jupyterlab/fileeditor-extension",
"@jupyterlab/faq-extension",
"@jupyterlab/filebrowser-extension",
Expand All @@ -127,7 +123,6 @@
"@jupyterlab/launcher-extension",
"@jupyterlab/markdownviewer-extension",
"@jupyterlab/notebook-extension",
"@jupyterlab/rendermime-extension",
"@jupyterlab/running-extension",
"@jupyterlab/services-extension",
"@jupyterlab/settingeditor-extension",
Expand Down
3 changes: 0 additions & 3 deletions packages/all-packages/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
"@jupyterlab/docmanager": "^0.7.0",
"@jupyterlab/docmanager-extension": "^0.7.0",
"@jupyterlab/docregistry": "^0.7.0",
"@jupyterlab/docregistry-extension": "^0.7.0",
"@jupyterlab/faq-extension": "^0.7.0",
"@jupyterlab/filebrowser": "^0.7.0",
"@jupyterlab/filebrowser-extension": "^0.7.0",
Expand All @@ -46,13 +45,11 @@
"@jupyterlab/inspector-extension": "^0.7.0",
"@jupyterlab/launcher": "^0.7.0",
"@jupyterlab/launcher-extension": "^0.7.1",
"@jupyterlab/markdownviewer": "^0.7.0",
"@jupyterlab/markdownviewer-extension": "^0.7.0",
"@jupyterlab/notebook": "^0.7.0",
"@jupyterlab/notebook-extension": "^0.7.0",
"@jupyterlab/outputarea": "^0.7.0",
"@jupyterlab/rendermime": "^0.7.0",
"@jupyterlab/rendermime-extension": "^0.7.0",
"@jupyterlab/running": "^0.7.0",
"@jupyterlab/running-extension": "^0.7.0",
"@jupyterlab/services": "^0.46.0",
Expand Down
3 changes: 0 additions & 3 deletions packages/all-packages/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import "@jupyterlab/csvviewer-extension";
import "@jupyterlab/docmanager";
import "@jupyterlab/docmanager-extension";
import "@jupyterlab/docregistry";
import "@jupyterlab/docregistry-extension";
import "@jupyterlab/fileeditor";
import "@jupyterlab/fileeditor-extension";
import "@jupyterlab/faq-extension";
Expand All @@ -34,13 +33,11 @@ import "@jupyterlab/inspector";
import "@jupyterlab/inspector-extension";
import "@jupyterlab/launcher";
import "@jupyterlab/launcher-extension";
import "@jupyterlab/markdownviewer";
import "@jupyterlab/markdownviewer-extension";
import "@jupyterlab/notebook";
import "@jupyterlab/notebook-extension";
import "@jupyterlab/outputarea";
import "@jupyterlab/rendermime";
import "@jupyterlab/rendermime-extension";
import "@jupyterlab/running";
import "@jupyterlab/running-extension";
import "@jupyterlab/services";
Expand Down
3 changes: 3 additions & 0 deletions packages/application/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
"dependencies": {
"@jupyterlab/apputils": "^0.7.0",
"@jupyterlab/coreutils": "^0.7.0",
"@jupyterlab/docregistry": "^0.7.0",
"@jupyterlab/rendermime": "^0.7.0",
"@jupyterlab/rendermime-interfaces": "^0.1.0",
"@phosphor/algorithm": "^1.1.1",
"@phosphor/application": "^1.3.0",
"@phosphor/coreutils": "^1.1.1",
Expand Down
62 changes: 62 additions & 0 deletions packages/application/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,26 @@
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.

import {
CommandLinker
} from '@jupyterlab/apputils';

import {
Base64ModelFactory, DocumentRegistry, TextModelFactory
} from '@jupyterlab/docregistry';

import {
IRenderMime, RenderMime
} from '@jupyterlab/rendermime';

import {
Application, IPlugin
} from '@phosphor/application';

import {
createRendermimePlugins
} from './mimerenderers';

import {
ApplicationShell
} from './shell';
Expand Down Expand Up @@ -42,8 +58,49 @@ class JupyterLab extends Application<ApplicationShell> {
if (options.devMode) {
this.shell.addClass('jp-mod-devMode');
}
let linker = new CommandLinker({ commands: this.commands });
this.commandLinker = linker;

let linkHandler = {
handleLink: (node: HTMLElement, path: string) => {
linker.connectNode(node, 'file-operations:open', { path });
}
};
let initialFactories = RenderMime.getDefaultFactories();
this.rendermime = new RenderMime({ initialFactories, linkHandler });

let registry = this.docRegistry = new DocumentRegistry();
registry.addModelFactory(new TextModelFactory());
registry.addModelFactory(new Base64ModelFactory());
registry.addFileType({
name: 'Text',
extension: '.txt',
contentType: 'file',
fileFormat: 'text'
});
registry.addCreator({ name: 'Text File', fileType: 'Text', });

if (options.mimeExtensions) {
let plugins = createRendermimePlugins(options.mimeExtensions);
plugins.forEach(plugin => { this.registerPlugin(plugin); });
}
}

/**
* The document registry instance used by the application.
*/
readonly docRegistry: DocumentRegistry;

/**
* The rendermime instance used by the application.
*/
readonly rendermime: RenderMime;

/**
* The command linker used by the application.
*/
readonly commandLinker: CommandLinker;

/**
* The information about the application.
*/
Expand Down Expand Up @@ -136,6 +193,11 @@ namespace JupyterLab {
* The assets directory of the app on the server.
*/
assetsDir?: string;

/**
* The mime renderer extensions.
*/
mimeExtensions?: IRenderMime.IExtensionModule[];
}

/**
Expand Down
10 changes: 10 additions & 0 deletions packages/application/src/layoutrestorer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,16 @@ class LayoutRestorer implements ILayoutRestorer {
}
}, this);

// Whenever a widget is updated, get its new name.
tracker.widgetUpdated.connect((sender, widget) => {
const widgetName = name(widget);
if (widgetName) {
let name = `${namespace}:${widgetName}`;
Private.nameProperty.set(widget, name);
this._widgets.set(name, widget);
}
});

const first = this._first;
const promise = tracker.restore({
args, command, name,
Expand Down
Loading