Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('should be resilient to a slow initial fetch', async () => {
let delayedServiceManager = new ServiceManager();
(delayedServiceManager as any).contents = new DelayedContentsManager();
let manager = new DocumentManager({
registry,
opener,
manager: delayedServiceManager
});
model = new FileBrowserModel({ manager, state });
const paths: string[] = [];
// An initial refresh is called in the constructor.
// If it is too slow, it can come in after the directory change,
// causing a directory set by, e.g., the tree handler to be wrong.
// This checks to make sure we are handling that case correctly.
const refresh = model.refresh().then(() => paths.push(model.path));
const cd = model.cd('src').then(() => paths.push(model.path));
await Promise.all([refresh, cd]);
expect(model.path).to.equal('src');
expect(paths).to.eql(['', 'src']);
if (!widget.isAttached) {
shell.add(widget, 'main', options || {});
}
shell.activateById(widget.id);
// Handle dirty state for open documents.
let context = docManager.contextForWidget(widget);
if (!contexts.has(context)) {
handleContext(status, context);
contexts.add(context);
}
}
};
const registry = app.docRegistry;
const when = app.restored.then(() => void 0);
const docManager = new DocumentManager({
registry,
manager,
opener,
when,
setBusy: status.setBusy.bind(app)
});
// Register the file operations commands.
addCommands(
app,
docManager,
opener,
settingRegistry,
labShell,
palette,
mainMenu
document.addEventListener('keydown', event => {
commands.processKeydownEvent(event);
}, useCapture);
let rendermime = new RenderMime({
initialFactories: defaultRendererFactories
});
let opener = {
open: (widget: Widget) => {
// Do nothing for sibling widgets for now.
}
};
let docRegistry = new DocumentRegistry();
let docManager = new DocumentManager({
registry: docRegistry,
manager,
opener
});
let mFactory = new NotebookModelFactory({});
let editorFactory = editorServices.factoryService.newInlineEditor.bind(
editorServices.factoryService);
let contentFactory = new NotebookPanel.ContentFactory({ editorFactory });
let wFactory = new NotebookWidgetFactory({
name: 'Notebook',
modelName: 'notebook',
fileExtensions: ['.ipynb'],
defaultFor: ['.ipynb'],
preferKernel: true,
canStartKernel: true,
let rendermime = new RenderMimeRegistry({
initialFactories: initialFactories,
latexTypesetter: new MathJaxTypesetter({
url: PageConfig.getOption('mathjaxUrl'),
config: PageConfig.getOption('mathjaxConfig')
})
});
let opener = {
open: (widget: Widget) => {
// Do nothing for sibling widgets for now.
}
};
let docRegistry = new DocumentRegistry();
let docManager = new DocumentManager({
registry: docRegistry,
manager,
opener
});
let mFactory = new NotebookModelFactory({});
let editorFactory = editorServices.factoryService.newInlineEditor;
let contentFactory = new NotebookPanel.ContentFactory({ editorFactory });
let wFactory = new NotebookWidgetFactory({
name: 'Notebook',
modelName: 'notebook',
fileTypes: ['notebook'],
defaultFor: ['notebook'],
preferKernel: true,
canStartKernel: true,
rendermime,
if (!widget.isAttached) {
shell.add(widget, 'main', options || {});
}
shell.activateById(widget.id);
// Handle dirty state for open documents.
let context = docManager.contextForWidget(widget);
if (!contexts.has(context)) {
handleContext(status, context);
contexts.add(context);
}
}
};
const registry = app.docRegistry;
const when = app.restored.then(() => void 0);
const docManager = new DocumentManager({
registry,
manager,
opener,
when,
setBusy: status && (() => status.setBusy())
});
// Register the file operations commands.
addCommands(
app,
docManager,
opener,
settingRegistry,
labShell,
palette,
mainMenu
let rendermime = new RenderMimeRegistry({
initialFactories: initialFactories,
latexTypesetter: new MathJaxTypesetter({
url: PageConfig.getOption('mathjaxUrl'),
config: PageConfig.getOption('mathjaxConfig')
})
});
let opener = {
open: (widget: Widget) => {
// Do nothing for sibling widgets for now.
}
};
let docRegistry = new DocumentRegistry();
let docManager = new DocumentManager({
registry: docRegistry,
manager,
opener
});
let mFactory = new NotebookModelFactory({});
let editorFactory = editorServices.factoryService.newInlineEditor;
let contentFactory = new NotebookPanel.ContentFactory({ editorFactory });
let wFactory = new NotebookWidgetFactory({
name: 'Notebook',
modelName: 'notebook',
fileTypes: ['notebook'],
defaultFor: ['notebook'],
preferKernel: true,
canStartKernel: true,
rendermime,
document.addEventListener(
'keydown',
event => {
this.commands.processKeydownEvent(event);
},
useCapture
);
let opener = {
open: (widget: Widget) => {
// Do nothing for sibling widgets for now.
}
};
let docRegistry = new DocumentRegistry();
let docManager = new DocumentManager({
registry: docRegistry,
manager: this.props.serviceManager,
opener
});
let mFactory = new NotebookModelFactory({});
let editorFactory = editorServices.factoryService.newInlineEditor;
let contentFactory = new NotebookPanel.ContentFactory({ editorFactory });
let wFactory = new NotebookWidgetFactory({
name: 'Notebook',
modelName: 'notebook',
fileTypes: ['notebook'],
defaultFor: ['notebook'],
preferKernel: true,
canStartKernel: true,
rendermime: this.props.rendermime,
constructor(props: FileBrowserPageProps) {
super(props);
this.state = {
currentPath: this.props.startingPath
};
let opener = {
open: (widget: Widget) => {
console.log(widget);
}
}
let docRegistry = new DocumentRegistry();
this.docManager = new DocumentManager({
registry: docRegistry,
manager: this.props.serviceManager,
opener
});
let fbModel = new FileBrowserModel({
manager: this.docManager,
});
fbModel.cd(this.state.currentPath);
this.fileBrowser = new FileBrowser({
id: 'filebrowser',
model: fbModel
});
fbModel.pathChanged.connect(this.pathChanged);
}
open: (widget: Widget) => {
if (widgets.indexOf(widget) === -1) {
dock.addWidget(widget, { mode: 'tab-after' });
widgets.push(widget);
}
dock.activateWidget(widget);
activeWidget = widget;
widget.disposed.connect((w: Widget) => {
let index = widgets.indexOf(w);
widgets.splice(index, 1);
});
}
};
let docRegistry = new DocumentRegistry();
let docManager = new DocumentManager({
registry: docRegistry,
manager,
opener
});
let editorServices = {
factoryService: new CodeMirrorEditorFactory(),
mimeTypeService: new CodeMirrorMimeTypeService()
};
let wFactory = new FileEditorFactory({
editorServices,
factoryOptions: {
name: 'Editor',
modelName: 'text',
fileTypes: ['*'],
defaultFor: ['*'],
preferKernel: false,
open: (widget: Widget) => {
if (widgets.indexOf(widget) === -1) {
dock.addWidget(widget, { mode: 'tab-after' });
widgets.push(widget);
}
dock.activateWidget(widget);
activeWidget = widget;
widget.disposed.connect((w: Widget) => {
let index = widgets.indexOf(w);
widgets.splice(index, 1);
});
}
};
let docRegistry = new DocumentRegistry();
let docManager = new DocumentManager({
registry: docRegistry,
manager,
opener
});
let editorServices = {
factoryService: new CodeMirrorEditorFactory(),
mimeTypeService: new CodeMirrorMimeTypeService()
};
let wFactory = new FileEditorFactory({
editorServices,
factoryOptions: {
name: 'Editor',
modelName: 'text',
fileTypes: ['*'],
defaultFor: ['*'],
preferKernel: false,