Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private connect_socket(options: ISocketConnectionOptions): LSPConnection {
let { virtual_document, language } = options;
const wsBase = PageConfig.getBaseUrl().replace(/^http/, 'ws');
const rootUri = PageConfig.getOption('rootUri');
const documentUri = URLExt.join(rootUri, virtual_document.uri);
const serverUri = URLExt.join('ws://jupyter-lsp', language);
let socket = new WebSocket(URLExt.join(wsBase, 'lsp', language));
let connection = new LSPConnection({
languageId: language,
serverUri,
rootUri,
documentUri,
documentText: () => {
// NOTE: Update is async now and this is not really used, as an alternative method
// which is compatible with async is used.
// This should be only used in the initialization step.
// if (main_connection.isConnected) {
// console.warn('documentText is deprecated for use in JupyterLab LSP');
// }
let wFactory = new NotebookWidgetFactory({
name: 'Notebook',
modelName: 'notebook',
fileTypes: ['notebook'],
defaultFor: ['notebook'],
preferKernel: true,
canStartKernel: true,
rendermime,
contentFactory,
mimeTypeService: editorServices.mimeTypeService
});
docRegistry.addModelFactory(mFactory);
docRegistry.addWidgetFactory(wFactory);
let notebookPath = PageConfig.getOption('notebookPath');
let nbWidget = docManager.open(notebookPath) as NotebookPanel;
let palette = new CommandPalette({ commands });
const editor =
nbWidget.content.activeCell && nbWidget.content.activeCell.editor;
const model = new CompleterModel();
const completer = new Completer({ editor, model });
const connector = new KernelConnector({ session: nbWidget.session });
const handler = new CompletionHandler({ completer, connector });
// Set the handler's editor.
handler.editor = editor;
// Listen for active cell changes.
nbWidget.content.activeCellChanged.connect((sender, cell) => {
handler.editor = cell && cell.editor;
let useCapture = true;
// Setup the keydown listener for the document.
document.addEventListener(
'keydown',
event => {
commands.processKeydownEvent(event);
},
useCapture
);
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 wFactory = new NotebookWidgetFactory({
name: 'Notebook',
modelName: 'notebook',
fileTypes: ['notebook'],
defaultFor: ['notebook'],
preferKernel: true,
canStartKernel: true,
rendermime,
contentFactory,
mimeTypeService: editorServices.mimeTypeService
});
docRegistry.addModelFactory(mFactory);
docRegistry.addWidgetFactory(wFactory);
let notebookPath = PageConfig.getOption('notebookPath');
let nbWidget = docManager.open(notebookPath) as NotebookPanel;
// Create menu bar.
let menuBar = new MenuBar();
menuBar.addClass('notebookMenuBar');
const editor =
nbWidget.content.activeCell && nbWidget.content.activeCell.editor;
const model = new CompleterModel();
const completer = new Completer({ editor, model });
const connector = new KernelConnector({ session: nbWidget.session });
const handler = new CompletionHandler({ completer, connector });
// Set the handler's editor.
handler.editor = editor;
readonly defaultWorkspace: string;
}
/**
* The default application info.
*/
export const defaultInfo: IInfo = {
name: PageConfig.getOption('appName') || 'JupyterLab',
namespace: PageConfig.getOption('appNamespace'),
version: PageConfig.getOption('appVersion') || 'unknown',
devMode: PageConfig.getOption('devMode').toLowerCase() === 'true',
deferred: { patterns: [], matches: [] },
disabled: { patterns: [], matches: [] },
mimeExtensions: [],
urls: {
base: PageConfig.getOption('baseUrl'),
page: PageConfig.getOption('pageUrl'),
public: PageConfig.getOption('publicUrl'),
settings: PageConfig.getOption('settingsUrl'),
themes: PageConfig.getOption('themesUrl'),
tree: PageConfig.getOption('treeUrl'),
workspaces: PageConfig.getOption('workspacesUrl')
},
directories: {
appSettings: PageConfig.getOption('appSettingsDir'),
schemas: PageConfig.getOption('schemasDir'),
static: PageConfig.getOption('staticDir'),
templates: PageConfig.getOption('templatesDir'),
themes: PageConfig.getOption('themesDir'),
userSettings: PageConfig.getOption('userSettingsDir'),
serverRoot: PageConfig.getOption('serverRoot'),
workspaces: PageConfig.getOption('workspacesDir')
devMode: PageConfig.getOption('devMode').toLowerCase() === 'true',
deferred: { patterns: [], matches: [] },
disabled: { patterns: [], matches: [] },
mimeExtensions: [],
urls: {
base: PageConfig.getOption('baseUrl'),
page: PageConfig.getOption('pageUrl'),
public: PageConfig.getOption('publicUrl'),
settings: PageConfig.getOption('settingsUrl'),
themes: PageConfig.getOption('themesUrl'),
tree: PageConfig.getOption('treeUrl'),
workspaces: PageConfig.getOption('workspacesUrl')
},
directories: {
appSettings: PageConfig.getOption('appSettingsDir'),
schemas: PageConfig.getOption('schemasDir'),
static: PageConfig.getOption('staticDir'),
templates: PageConfig.getOption('templatesDir'),
themes: PageConfig.getOption('themesDir'),
userSettings: PageConfig.getOption('userSettingsDir'),
serverRoot: PageConfig.getOption('serverRoot'),
workspaces: PageConfig.getOption('workspacesDir')
},
filesCached: PageConfig.getOption('cacheFiles').toLowerCase() === 'true',
workspace: '',
defaultWorkspace: ''
};
/**
* The interface for a module that exports a plugin or plugins as
* the default value.
*/
private _setupLab() {
let version : string = PageConfig.getOption('appVersion') || 'unknown';
if (version[0] === 'v') {
version = version.slice(1);
}
if (this.props.options.platform === 'win32') {
PageConfig.setOption('terminalsAvailable', 'false');
}
this._lab = new ElectronJupyterLab({
version: version,
mimeExtensions: extensions.mime,
disabled: extensions.disabled,
deferred: extensions.deferred,
platform: this.props.options.platform,
uiState: this.props.options.uiState
});
get shouldCheck(): boolean {
return PageConfig.getOption('buildCheck').toLowerCase() === 'true';
}
*/
export const defaultPaths: JupyterFrontEnd.IPaths = {
urls: {
base: PageConfig.getOption('baseUrl'),
defaultWorkspace: PageConfig.getOption('defaultWorkspace'),
notFound: PageConfig.getOption('notFoundUrl'),
page: PageConfig.getOption('pageUrl'),
public: PageConfig.getOption('publicUrl'),
settings: PageConfig.getOption('settingsUrl'),
themes: PageConfig.getOption('themesUrl'),
tree: PageConfig.getOption('treeUrl'),
workspaces: PageConfig.getOption('workspacesUrl')
},
directories: {
appSettings: PageConfig.getOption('appSettingsDir'),
schemas: PageConfig.getOption('schemasDir'),
static: PageConfig.getOption('staticDir'),
templates: PageConfig.getOption('templatesDir'),
themes: PageConfig.getOption('themesDir'),
userSettings: PageConfig.getOption('userSettingsDir'),
serverRoot: PageConfig.getOption('serverRoot'),
workspaces: PageConfig.getOption('workspacesDir')
}
};
/**
* The interface for a module that exports a plugin or plugins as
* the default value.
*/
export interface IPluginModule {
/**
* The default export.
disabled: { patterns: [], matches: [] },
mimeExtensions: [],
filesCached: PageConfig.getOption('cacheFiles').toLowerCase() === 'true'
};
/**
* The default JupyterLab application paths.
*/
export const defaultPaths: JupyterFrontEnd.IPaths = {
urls: {
base: PageConfig.getOption('baseUrl'),
notFound: PageConfig.getOption('notFoundUrl'),
app: PageConfig.getOption('appUrl'),
static: PageConfig.getOption('staticUrl'),
settings: PageConfig.getOption('settingsUrl'),
themes: PageConfig.getOption('themesUrl'),
tree: PageConfig.getOption('treeUrl'),
workspaces: PageConfig.getOption('workspacesUrl'),
hubHost: PageConfig.getOption('hubHost') || undefined,
hubPrefix: PageConfig.getOption('hubPrefix') || undefined,
hubUser: PageConfig.getOption('hubUser') || undefined,
hubServerName: PageConfig.getOption('hubServerName') || undefined
},
directories: {
appSettings: PageConfig.getOption('appSettingsDir'),
schemas: PageConfig.getOption('schemasDir'),
static: PageConfig.getOption('staticDir'),
templates: PageConfig.getOption('templatesDir'),
themes: PageConfig.getOption('themesDir'),
userSettings: PageConfig.getOption('userSettingsDir'),
serverRoot: PageConfig.getOption('serverRoot'),
workspaces: PageConfig.getOption('workspacesDir')