Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function startApp(path: string, manager: ServiceManager.IManager) {
console.log('starting app');
// Initialize the command registry with the key bindings.
let commands = new CommandRegistry();
// Setup the keydown listener for the document.
document.addEventListener('keydown', event => {
commands.processKeydownEvent(event);
});
let rendermime = new RenderMimeRegistry({ initialFactories });
let editorFactory = editorServices.factoryService.newInlineEditor;
let contentFactory = new ConsolePanel.ContentFactory({ editorFactory });
let consolePanel = new ConsolePanel({
rendermime,
manager,
path,
contentFactory,
mimeTypeService: editorServices.mimeTypeService
function main(): void {
const manager = new SessionManager();
const session = new ClientSession({ manager, name: 'Example' });
const mimeService = new CodeMirrorMimeTypeService();
// Initialize the command registry with the bindings.
const commands = new CommandRegistry();
const useCapture = true;
// Setup the keydown listener for the document.
document.addEventListener(
'keydown',
event => {
commands.processKeydownEvent(event);
},
useCapture
);
// Create the cell widget with a default rendermime instance.
const rendermime = new RenderMimeRegistry({ initialFactories });
const cellWidget = new CodeCell({
rendermime,
mimeTypeService: new CodeMirrorMimeTypeService()
};
let wFactory = new FileEditorFactory({
editorServices,
factoryOptions: {
name: 'Editor',
modelName: 'text',
fileTypes: ['*'],
defaultFor: ['*'],
preferKernel: false,
canStartKernel: true
}
});
docRegistry.addWidgetFactory(wFactory);
let commands = new CommandRegistry();
let fbModel = new FileBrowserModel({
manager: docManager,
iconRegistry: defaultIconRegistry
});
let fbWidget = new FileBrowser({
id: 'filebrowser',
model: fbModel
});
// Add a creator toolbar item.
let creator = new ToolbarButton({
iconClassName: 'jp-AddIcon jp-Icon jp-Icon-16',
onClick: () => {
void docManager
.newUntitled({
constructor(options: Application.IOptions) {
// Create the application command registry.
let commands = new CommandRegistry();
// Create the application context menu.
let renderer = options.contextMenuRenderer;
let contextMenu = new ContextMenu({ commands, renderer });
// Initialize the application state.
this.commands = commands;
this.contextMenu = contextMenu;
this.shell = options.shell;
}
it('should restore the widgets in a tracker', async () => {
const tracker = new WidgetTracker({ namespace: 'foo-widget' });
const registry = new CommandRegistry();
const state = new StateDB();
const ready = new PromiseDelegate();
const restorer = new LayoutRestorer({
connector: state,
first: ready.promise,
registry
});
let called = false;
const key = `${tracker.namespace}:${tracker.namespace}`;
registry.addCommand(tracker.namespace, {
execute: () => {
called = true;
}
});
await state.save(key, { data: null });
it('should add a widget to be tracked by the restorer', async () => {
const ready = new PromiseDelegate();
const restorer = new LayoutRestorer({
connector: new StateDB(),
first: ready.promise,
registry: new CommandRegistry()
});
const currentWidget = new Widget();
const mode: DockPanel.Mode = 'single-document';
const dehydrated: ILabShell.ILayout = {
mainArea: { currentWidget, dock: null, mode },
leftArea: { collapsed: true, currentWidget: null, widgets: null },
rightArea: { collapsed: true, currentWidget: null, widgets: null }
};
restorer.add(currentWidget, 'test-one');
ready.resolve(void 0);
await restorer.restored;
await restorer.save(dehydrated);
const layout = await restorer.fetch();
expect(layout.mainArea.currentWidget).to.equal(currentWidget);
expect(layout.mainArea.mode).to.equal(mode);
});
beforeAll(() => {
commands = new CommandRegistry();
});
beforeAll(() => {
commands = new CommandRegistry();
});
beforeAll(() => {
commands = new CommandRegistry();
commands.addCommand('run1', {
label: 'Run 1',
execute: () => void 0
});
commands.addCommand('run2', {
label: 'Run 2',
execute: () => void 0
});
commands.addCommand('run3', {
label: 'Run 3',
execute: () => void 0
});
commands.addCommand('run4', {
label: 'Run 4',
execute: () => void 0
});
beforeAll(() => {
commands = new CommandRegistry();
});