-
-
Notifications
You must be signed in to change notification settings - Fork 128
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
Conditional Lumino plugin load #601
Comments
Thank you for opening your first issue in this project! Engagement like this is essential for open source projects! 🤗 |
Discussion notes: https://hackmd.io/DBlDBDszSVSjYK9ieg1mZA |
Note This is a proposal to help kicking off an implementation VocabularyWhat is a plugin entrypoint?An plugin entrypoint is no-code model defined as JSON that describes enough about a type of application feature to create a placeholder in the user interface.Then if the user interact with the placeholder, the JavaScript of the plugin will be loaded and its activate function will be called to replace all placeholders (for that plugin) with the real implementation. What is a plugin?It is object providing features in the application.What is an extension?It is a NPM package providing one or more plugins.Generic logicA type of application feature is defined by an object provided by a plugin through a Therefore the generic logic to use entrypoints is the following:
A specific caseLet take the example of a new document viewer for CSV (interface IWidgetFactory) that is added to the DocRegistry using addWidgetFactory. If the JSON schema of {
defaultFor?: readonly string[];
defaultRendered?: readonly string[];
fileTypes: readonly string[];
label?: string;
modelName?: string;
name: string;
} The placeholder interface will be something like: interface IPlaceholder extends IObservableDisposable {}
The example could be {
"name": "CSVTable",
"label": "CSV Viewer",
"fileTypes": ["csv"],
"defaultFor": ["csv"]
} class WidgetFactoryPlaceholder implements IWidgetFactory, IPlaceholder {
constructor(entrypoint: IWidgetFactoryPlaceholder) {
// ...
}
createNew() {
// This is actually this method that when triggered should load the plugin
}
} The app.docRegistry.addWidgetFactory(new WidgetFactoryPlaceholder(entrypoint)); Note One of the technical difficulty is to be able to redo the action triggered on the placeholder with the real code once the plugin is loaded. For the aforementioned example, this materializes in how to trigger the widget factory |
To reduce the start-up time of JupyterLab, we could be smarter about plugin loading logic. For now, a Lumino plugin can be started automatically or not using the autoStart flag. But there is no way to specify conditions for which a plugin should start.
Before laying down a plan for Lumino plugin, here is an analysis of VS Code extension API that allows to conditionally load plugins. There are two key points:
In VS Code, those elements are defined in the extension package.json. The entry points are for example (see contributions documentation):
The trigger events are for example (see activation events documentation):
onCommand
: When a command of the extension is triggeredonView
: When a specific view is restoredonStartupFinished
: After the application has startedThe side effect of defining the contributed element in a no-code format raises the need to have an evaluable string to determine if an element is activable or not. This is called
when
clause in VS Code.Back to JupyterLab and Lumino, the equivalent of
onStartupFinished
could be implemented quickly. But it may result in unwanted side effects; e.g. if the plugin is providing a widget and that widget is used in a notebook output that is loaded at startup, the widget may or may not be rendered. To ensure robustness, other events should be available; for example the widget plugin should load before opening a notebook.Plugins adding new panels in the main area or in the side panel, like jupyterlab-git, are probably the best candidates for optimization. This requires defining side panels and main area widgets in a no-code way. In JupyterLab, we introduced the definition of keyboard shortcuts and menus in setting schema files. So it seems a more natural place than the extension
package.json
.To be able to add a panel, widget titles need to be defined in a no-code way. This requires in particular the definition of icons in a no-code way.
Some first actions could be:
autoStart
to be a boolean or ‘"defer"’ (done in Add a 'defer' option to the autoStart argument #588)The text was updated successfully, but these errors were encountered: