Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function activateConsole(app: JupyterLab, mainMenu: IMainMenu, palette: ICommandPalette, contentFactory: ConsolePanel.IContentFactory, editorServices: IEditorServices, restorer: ILayoutRestorer, browserFactory: IFileBrowserFactory, rendermime: IRenderMimeRegistry, settingRegistry: ISettingRegistry, launcher: ILauncher | null): IConsoleTracker {
const manager = app.serviceManager;
const { commands, shell } = app;
const category = 'Console';
// Create an instance tracker for all console panels.
const tracker = new InstanceTracker({ namespace: 'console' });
// Handle state restoration.
restorer.restore(tracker, {
command: CommandIDs.open,
args: panel => ({
path: panel.console.session.path,
name: panel.console.session.name
}),
name: panel => panel.console.session.path,
when: manager.ready
});
// The launcher callback.
let callback = (cwd: string, name: string) => {
return createConsole({ basePath: cwd, kernelPreference: { name } });
};
app.shell.activateById(experimentPaneWidget.id);
}
});
// Add the command to the palette.
palette.addItem({command: open_project_command, category: 'TAU Commander'});
palette.addItem({command: open_experiment_command, category: 'TAU Commander'});
// Track and restore the widget state
let proj_tracker = new InstanceTracker({namespace: project_widget_id});
restorer.restore(proj_tracker, {
command: open_project_command,
args: () => JSONExt.emptyObject,
name: () => 'project-view'
});
let exp_tracker = new InstanceTracker({namespace: experiment_widget_id});
restorer.restore(exp_tracker, {
command: open_experiment_command,
args: () => JSONExt.emptyObject,
name: () => 'experiment-view'
});
// Add a sidebar to select and run analyses
let analysisSidebarWidget : AnalysisSidebarWidget;
analysisSidebarWidget = new AnalysisSidebarWidget(app);
window.defaultAnalysisSidebar = analysisSidebarWidget;
app.shell.addToLeftArea(analysisSidebarWidget, {rank: 2000});
restorer.add(analysisSidebarWidget, analysis_widget_id);
}
function activate(
app: JupyterFrontEnd,
restorer: ILayoutRestorer,
rendermime: IRenderMimeRegistry,
settingRegistry: ISettingRegistry
): IMarkdownViewerTracker {
const { commands, docRegistry } = app;
// Add the markdown renderer factory.
rendermime.addFactory(markdownRendererFactory);
const namespace = 'markdownviewer-widget';
const tracker = new InstanceTracker({
namespace
});
let config: Partial = {
...MarkdownViewer.defaultConfig
};
/**
* Update the settings of a widget.
*/
function updateWidget(widget: MarkdownViewer): void {
Object.keys(config).forEach((k: keyof MarkdownViewer.IConfig) => {
widget.setOption(k, config[k]);
});
}
function activate(
app: JupyterFrontEnd,
palette: ICommandPalette | null,
restorer: ILayoutRestorer | null
): IImageTracker {
const namespace = 'image-widget';
const factory = new ImageViewerFactory({
name: FACTORY,
modelName: 'base64',
fileTypes: FILE_TYPES,
defaultFor: FILE_TYPES,
readOnly: true
});
const tracker = new InstanceTracker>({
namespace
});
if (restorer) {
// Handle state restoration.
restorer.restore(tracker, {
command: 'docmanager:open',
args: widget => ({ path: widget.context.path, factory: FACTORY }),
name: widget => widget.context.path
});
}
app.docRegistry.addWidgetFactory(factory);
factory.widgetCreated.connect((sender, widget) => {
// Notify the instance tracker if restore data needs to update.
function activate(app: JupyterLab, linker: ICommandLinker, palette: ICommandPalette, services: IServiceManager, restorer: ILayoutRestorer): void {
const { commands, shell } = app;
const category = 'Help';
const command = CommandIDs.open;
const model = new LandingModel(
services.terminals.isAvailable(), app.info.version
);
const tracker = new InstanceTracker({
namespace: 'landing',
shell
});
// Handle state restoration.
restorer.restore(tracker, {
command,
args: () => null,
name: () => 'landing'
});
let widget: LandingWidget;
function newWidget(): LandingWidget {
let widget = new LandingWidget(linker);
widget.model = model;
launcher: ILauncher | null,
menu: IMainMenu | null,
restorer: ILayoutRestorer | null
): IEditorTracker {
const id = plugin.id;
const namespace = 'editor';
const factory = new FileEditorFactory({
editorServices,
factoryOptions: {
name: FACTORY,
fileTypes: ['markdown', '*'], // Explicitly add the markdown fileType so
defaultFor: ['markdown', '*'] // it outranks the defaultRendered viewer.
}
});
const { commands, restored, shell } = app;
const tracker = new InstanceTracker>({
namespace
});
const isEnabled = () =>
tracker.currentWidget !== null &&
tracker.currentWidget === shell.currentWidget;
let config = { ...CodeEditor.defaultConfig };
// Handle state restoration.
if (restorer) {
restorer.restore(tracker, {
command: 'docmanager:open',
args: widget => ({ path: widget.context.path, factory: FACTORY }),
name: widget => widget.context.path
});
}
function activate(app: JupyterLab, restorer: ILayoutRestorer, rendermime: IRenderMimeRegistry) {
const primaryFileType = app.docRegistry.getFileType('markdown');
const factory = new MimeDocumentFactory({
name: FACTORY,
primaryFileType,
fileTypes: ['markdown'],
rendermime
});
const { commands } = app;
const namespace = 'rendered-markdown';
const tracker = new InstanceTracker>({ namespace });
app.docRegistry.addWidgetFactory(factory);
// Handle state restoration.
restorer.restore(tracker, {
command: 'docmanager:open',
args: widget => ({ path: widget.context.path, factory: FACTORY }),
name: widget => widget.context.path
});
factory.widgetCreated.connect((sender, widget) => {
// Notify the instance tracker if restore data needs to update.
widget.context.pathChanged.connect(() => { tracker.save(widget); });
tracker.add(widget);
});
function activate(
app: JupyterFrontEnd,
restorer: ILayoutRestorer,
registry: ISettingRegistry,
editorServices: IEditorServices,
state: IStateDB,
rendermime: IRenderMimeRegistry,
palette: ICommandPalette
): ISettingEditorTracker {
const { commands, shell } = app;
const namespace = 'setting-editor';
const factoryService = editorServices.factoryService;
const editorFactory = factoryService.newInlineEditor;
const tracker = new InstanceTracker>({
namespace
});
let editor: SettingEditor;
// Handle state restoration.
restorer.restore(tracker, {
command: CommandIDs.open,
args: widget => ({}),
name: widget => namespace
});
commands.addCommand(CommandIDs.debug, {
execute: () => {
tracker.currentWidget.content.toggleDebug();
},
iconClass: 'jp-MaterialIcon jp-BugIcon',
beforeEach(() => {
wodget = new Wodget();
menu = new KernelMenu({ commands });
tracker = new InstanceTracker({ namespace: 'wodget' });
void tracker.add(wodget);
});
},
index
);
const factory = new DocWidgetFactory({
fileExtensions: EXTENSIONS,
defaultFor: DEFAULT_EXTENSIONS,
name: FACTORY
});
/**
* Add document renderer for .table.json files
*/
registry.addWidgetFactory(factory);
const tracker = new InstanceTracker({
namespace: 'JSONTable',
shell: app.shell
});
/**
* Handle widget state deserialization
*/
restorer.restore(tracker, {
command: 'file-operations:open',
args: widget => ({ path: widget.context.path, factory: FACTORY }),
name: widget => widget.context.path
});
/**
* Serialize widget state
*/