diff --git a/news/3 Code Health/11297.md b/news/3 Code Health/11297.md new file mode 100644 index 000000000000..7d31e59e7f00 --- /dev/null +++ b/news/3 Code Health/11297.md @@ -0,0 +1 @@ +Lazy load types from `jupyterlab/services` and similar `npm modules`. diff --git a/src/client/datascience/baseJupyterSession.ts b/src/client/datascience/baseJupyterSession.ts index 0331a14b2f8e..947232f9562f 100644 --- a/src/client/datascience/baseJupyterSession.ts +++ b/src/client/datascience/baseJupyterSession.ts @@ -2,8 +2,8 @@ // Licensed under the MIT License. 'use strict'; import type { Kernel, KernelMessage, Session } from '@jupyterlab/services'; -import { JSONObject } from '@phosphor/coreutils'; -import { Slot } from '@phosphor/signaling'; +import type { JSONObject } from '@phosphor/coreutils'; +import type { Slot } from '@phosphor/signaling'; import { Observable } from 'rxjs/Observable'; import { ReplaySubject } from 'rxjs/ReplaySubject'; import { Event, EventEmitter } from 'vscode'; diff --git a/src/client/datascience/codeCssGenerator.ts b/src/client/datascience/codeCssGenerator.ts index 8e2d615a3fd0..c9738998dbfb 100644 --- a/src/client/datascience/codeCssGenerator.ts +++ b/src/client/datascience/codeCssGenerator.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. 'use strict'; -import { JSONArray, JSONObject } from '@phosphor/coreutils'; +import type { JSONArray, JSONObject } from '@phosphor/coreutils'; import { inject, injectable } from 'inversify'; import { parse } from 'jsonc-parser'; import * as monacoEditor from 'monaco-editor/esm/vs/editor/editor.api'; diff --git a/src/client/datascience/common.ts b/src/client/datascience/common.ts index 65dd0914b227..7d0235a0bd6d 100644 --- a/src/client/datascience/common.ts +++ b/src/client/datascience/common.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. 'use strict'; -import { nbformat } from '@jupyterlab/coreutils'; +import type { nbformat } from '@jupyterlab/coreutils'; import { Memento } from 'vscode'; import { splitMultilineString } from '../../datascience-ui/common'; import { noop } from '../common/utils/misc'; diff --git a/src/client/datascience/data-viewing/types.ts b/src/client/datascience/data-viewing/types.ts index 6e20d7e6ad4f..35372910d149 100644 --- a/src/client/datascience/data-viewing/types.ts +++ b/src/client/datascience/data-viewing/types.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. 'use strict'; -import { JSONObject } from '@phosphor/coreutils'; +import type { JSONObject } from '@phosphor/coreutils'; import { SharedMessages } from '../messages'; import { IJupyterVariable } from '../types'; diff --git a/src/client/datascience/datascience.ts b/src/client/datascience/datascience.ts index eab7315fe283..435467598e55 100644 --- a/src/client/datascience/datascience.ts +++ b/src/client/datascience/datascience.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. 'use strict'; -import { JSONObject } from '@phosphor/coreutils'; +import type { JSONObject } from '@phosphor/coreutils'; import { inject, injectable } from 'inversify'; import * as vscode from 'vscode'; import { ICommandManager, IDocumentManager, IWorkspaceService } from '../common/application/types'; diff --git a/src/client/datascience/interactive-common/interactiveBase.ts b/src/client/datascience/interactive-common/interactiveBase.ts index 6e99746d57fb..e52db95dbc99 100644 --- a/src/client/datascience/interactive-common/interactiveBase.ts +++ b/src/client/datascience/interactive-common/interactiveBase.ts @@ -3,7 +3,7 @@ 'use strict'; import '../../common/extensions'; -import { nbformat } from '@jupyterlab/coreutils'; +import type { nbformat } from '@jupyterlab/coreutils'; import type { KernelMessage } from '@jupyterlab/services'; import { injectable, unmanaged } from 'inversify'; import * as os from 'os'; diff --git a/src/client/datascience/interactive-ipynb/nativeEditor.ts b/src/client/datascience/interactive-ipynb/nativeEditor.ts index b504b05d2a5d..2515441006c0 100644 --- a/src/client/datascience/interactive-ipynb/nativeEditor.ts +++ b/src/client/datascience/interactive-ipynb/nativeEditor.ts @@ -79,7 +79,7 @@ import { } from '../types'; import { NativeEditorSynchronizer } from './nativeEditorSynchronizer'; -import { nbformat } from '@jupyterlab/coreutils'; +import type { nbformat } from '@jupyterlab/coreutils'; // tslint:disable-next-line: no-require-imports import cloneDeep = require('lodash/cloneDeep'); import { concatMultilineStringInput } from '../../../datascience-ui/common'; diff --git a/src/client/datascience/interactive-ipynb/nativeEditorStorage.ts b/src/client/datascience/interactive-ipynb/nativeEditorStorage.ts index 59c93bda2553..b522323b1620 100644 --- a/src/client/datascience/interactive-ipynb/nativeEditorStorage.ts +++ b/src/client/datascience/interactive-ipynb/nativeEditorStorage.ts @@ -1,4 +1,4 @@ -import { nbformat } from '@jupyterlab/coreutils'; +import type { nbformat } from '@jupyterlab/coreutils'; import * as fastDeepEqual from 'fast-deep-equal'; import { inject, injectable, named } from 'inversify'; import * as path from 'path'; diff --git a/src/client/datascience/interactive-window/interactiveWindow.ts b/src/client/datascience/interactive-window/interactiveWindow.ts index 5471bf75b113..532d684340b8 100644 --- a/src/client/datascience/interactive-window/interactiveWindow.ts +++ b/src/client/datascience/interactive-window/interactiveWindow.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. 'use strict'; -import { nbformat } from '@jupyterlab/coreutils'; +import type { nbformat } from '@jupyterlab/coreutils'; import { inject, injectable, multiInject, named } from 'inversify'; import * as path from 'path'; import { Event, EventEmitter, Memento, Uri, ViewColumn } from 'vscode'; diff --git a/src/client/datascience/jupyter/jupyterCellOutputMimeTypeTracker.ts b/src/client/datascience/jupyter/jupyterCellOutputMimeTypeTracker.ts index 98a597f3901b..0f2692dd8fd3 100644 --- a/src/client/datascience/jupyter/jupyterCellOutputMimeTypeTracker.ts +++ b/src/client/datascience/jupyter/jupyterCellOutputMimeTypeTracker.ts @@ -2,7 +2,7 @@ // Licensed under the MIT License. 'use strict'; -import { nbformat } from '@jupyterlab/coreutils'; +import type { nbformat } from '@jupyterlab/coreutils'; import { sha256 } from 'hash.js'; import { inject, injectable } from 'inversify'; import { IExtensionSingleActivationService } from '../../activation/types'; diff --git a/src/client/datascience/jupyter/jupyterDebugger.ts b/src/client/datascience/jupyter/jupyterDebugger.ts index a215d75bf3a3..29413db006e7 100644 --- a/src/client/datascience/jupyter/jupyterDebugger.ts +++ b/src/client/datascience/jupyter/jupyterDebugger.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. 'use strict'; -import { nbformat } from '@jupyterlab/coreutils'; +import type { nbformat } from '@jupyterlab/coreutils'; import { inject, injectable } from 'inversify'; import * as path from 'path'; import * as uuid from 'uuid/v4'; diff --git a/src/client/datascience/jupyter/jupyterExporter.ts b/src/client/datascience/jupyter/jupyterExporter.ts index 37c8264c55de..8aca6c9fb51c 100644 --- a/src/client/datascience/jupyter/jupyterExporter.ts +++ b/src/client/datascience/jupyter/jupyterExporter.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. 'use strict'; -import { nbformat } from '@jupyterlab/coreutils'; +import type { nbformat } from '@jupyterlab/coreutils'; import { inject, injectable } from 'inversify'; import * as os from 'os'; import * as path from 'path'; diff --git a/src/client/datascience/jupyter/jupyterImporter.ts b/src/client/datascience/jupyter/jupyterImporter.ts index 6b5bf7ffbe84..5090833b02d9 100644 --- a/src/client/datascience/jupyter/jupyterImporter.ts +++ b/src/client/datascience/jupyter/jupyterImporter.ts @@ -3,7 +3,7 @@ 'use strict'; import '../../common/extensions'; -import { nbformat } from '@jupyterlab/coreutils'; +import type { nbformat } from '@jupyterlab/coreutils'; import { inject, injectable } from 'inversify'; import * as os from 'os'; import * as path from 'path'; diff --git a/src/client/datascience/jupyter/jupyterNotebook.ts b/src/client/datascience/jupyter/jupyterNotebook.ts index a3617f07e4ed..bf4c87ddc0b4 100644 --- a/src/client/datascience/jupyter/jupyterNotebook.ts +++ b/src/client/datascience/jupyter/jupyterNotebook.ts @@ -1,8 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -import { nbformat } from '@jupyterlab/coreutils'; +import type { nbformat } from '@jupyterlab/coreutils'; import type { Kernel, KernelMessage } from '@jupyterlab/services'; -import { JSONObject } from '@phosphor/coreutils'; +import type { JSONObject } from '@phosphor/coreutils'; import { Observable } from 'rxjs/Observable'; import { Subscriber } from 'rxjs/Subscriber'; import * as uuid from 'uuid/v4'; diff --git a/src/client/datascience/jupyter/jupyterServer.ts b/src/client/datascience/jupyter/jupyterServer.ts index b411a47bb444..e9b74fb662fe 100644 --- a/src/client/datascience/jupyter/jupyterServer.ts +++ b/src/client/datascience/jupyter/jupyterServer.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. 'use strict'; -import { nbformat } from '@jupyterlab/coreutils'; +import type { nbformat } from '@jupyterlab/coreutils'; import * as uuid from 'uuid/v4'; import { Disposable, Uri } from 'vscode'; import { CancellationToken } from 'vscode-jsonrpc'; diff --git a/src/client/datascience/jupyter/jupyterServerWrapper.ts b/src/client/datascience/jupyter/jupyterServerWrapper.ts index f4a158be7289..fc300f0c7c8a 100644 --- a/src/client/datascience/jupyter/jupyterServerWrapper.ts +++ b/src/client/datascience/jupyter/jupyterServerWrapper.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. 'use strict'; -import { nbformat } from '@jupyterlab/coreutils'; +import type { nbformat } from '@jupyterlab/coreutils'; import { inject, injectable, named } from 'inversify'; import * as uuid from 'uuid/v4'; import { Uri } from 'vscode'; diff --git a/src/client/datascience/jupyter/jupyterSession.ts b/src/client/datascience/jupyter/jupyterSession.ts index c738523b6b7e..c3af290cb2de 100644 --- a/src/client/datascience/jupyter/jupyterSession.ts +++ b/src/client/datascience/jupyter/jupyterSession.ts @@ -10,8 +10,8 @@ import type { Session, SessionManager } from '@jupyterlab/services'; -import { JSONObject } from '@phosphor/coreutils'; -import { Slot } from '@phosphor/signaling'; +import type { JSONObject } from '@phosphor/coreutils'; +import type { Slot } from '@phosphor/signaling'; import * as uuid from 'uuid/v4'; import { CancellationToken } from 'vscode-jsonrpc'; import { Cancellation } from '../../common/cancellation'; diff --git a/src/client/datascience/jupyter/jupyterSessionManager.ts b/src/client/datascience/jupyter/jupyterSessionManager.ts index 47ef8d7ecca6..f28f364075f1 100644 --- a/src/client/datascience/jupyter/jupyterSessionManager.ts +++ b/src/client/datascience/jupyter/jupyterSessionManager.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. 'use strict'; -import { ContentsManager, Kernel, ServerConnection, Session, SessionManager } from '@jupyterlab/services'; +import type { ContentsManager, ServerConnection, Session, SessionManager } from '@jupyterlab/services'; import { Agent as HttpsAgent } from 'https'; import { CancellationToken } from 'vscode-jsonrpc'; @@ -29,7 +29,14 @@ export class JupyterSessionManager implements IJupyterSessionManager { private contentsManager: ContentsManager | undefined; private connInfo: IJupyterConnection | undefined; private serverSettings: ServerConnection.ISettings | undefined; - + private _jupyterlab?: typeof import('@jupyterlab/services'); + private get jupyterlab(): typeof import('@jupyterlab/services') { + if (!this._jupyterlab) { + // tslint:disable-next-line: no-require-imports + this._jupyterlab = require('@jupyterlab/services'); + } + return this._jupyterlab!; + } constructor( private jupyterPasswordConnect: IJupyterPasswordConnect, _config: IConfigurationService, @@ -78,8 +85,8 @@ export class JupyterSessionManager implements IJupyterSessionManager { public async initialize(connInfo: IJupyterConnection): Promise { this.connInfo = connInfo; this.serverSettings = await this.getServerConnectSettings(connInfo); - this.sessionManager = new SessionManager({ serverSettings: this.serverSettings }); - this.contentsManager = new ContentsManager({ serverSettings: this.serverSettings }); + this.sessionManager = new this.jupyterlab.SessionManager({ serverSettings: this.serverSettings }); + this.contentsManager = new this.jupyterlab.ContentsManager({ serverSettings: this.serverSettings }); } public async getRunningSessions(): Promise { @@ -102,7 +109,7 @@ export class JupyterSessionManager implements IJupyterSessionManager { } public async getRunningKernels(): Promise { - const models = await Kernel.listRunning(this.serverSettings); + const models = await this.jupyterlab.Kernel.listRunning(this.serverSettings); // Remove duplicates. const dup = new Set(); return models @@ -246,6 +253,6 @@ export class JupyterSessionManager implements IJupyterSessionManager { ) as any }; - return ServerConnection.makeSettings(serverSettings); + return this.jupyterlab.ServerConnection.makeSettings(serverSettings); } } diff --git a/src/client/datascience/jupyter/jupyterVariables.ts b/src/client/datascience/jupyter/jupyterVariables.ts index 66d2d691d1ba..e44fb3452bb5 100644 --- a/src/client/datascience/jupyter/jupyterVariables.ts +++ b/src/client/datascience/jupyter/jupyterVariables.ts @@ -1,8 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. 'use strict'; -import { nbformat } from '@jupyterlab/coreutils'; -import { JSONObject } from '@phosphor/coreutils'; +import type { nbformat } from '@jupyterlab/coreutils'; +import type { JSONObject } from '@phosphor/coreutils'; import { inject, injectable } from 'inversify'; import * as path from 'path'; import stripAnsi from 'strip-ansi'; diff --git a/src/client/datascience/jupyter/kernels/jupyterKernelSpec.ts b/src/client/datascience/jupyter/kernels/jupyterKernelSpec.ts index 792541347135..6285671b7712 100644 --- a/src/client/datascience/jupyter/kernels/jupyterKernelSpec.ts +++ b/src/client/datascience/jupyter/kernels/jupyterKernelSpec.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. 'use strict'; -import { Kernel } from '@jupyterlab/services'; +import type { Kernel } from '@jupyterlab/services'; import * as path from 'path'; import { CancellationToken } from 'vscode'; import { createPromiseFromCancellation } from '../../../common/cancellation'; diff --git a/src/client/datascience/jupyter/kernels/kernelSelector.ts b/src/client/datascience/jupyter/kernels/kernelSelector.ts index 9bff05b81885..b45c7f91c6a0 100644 --- a/src/client/datascience/jupyter/kernels/kernelSelector.ts +++ b/src/client/datascience/jupyter/kernels/kernelSelector.ts @@ -2,8 +2,8 @@ // Licensed under the MIT License. import '../../../common/extensions'; -import { nbformat } from '@jupyterlab/coreutils'; -import { Kernel } from '@jupyterlab/services'; +import type { nbformat } from '@jupyterlab/coreutils'; +import type { Kernel } from '@jupyterlab/services'; import { inject, injectable } from 'inversify'; import { CancellationToken } from 'vscode-jsonrpc'; diff --git a/src/client/datascience/jupyter/kernels/kernelService.ts b/src/client/datascience/jupyter/kernels/kernelService.ts index 3dd0d054d9cb..2b0ce4898826 100644 --- a/src/client/datascience/jupyter/kernels/kernelService.ts +++ b/src/client/datascience/jupyter/kernels/kernelService.ts @@ -3,8 +3,8 @@ 'use strict'; -import { nbformat } from '@jupyterlab/coreutils'; -import { Kernel } from '@jupyterlab/services'; +import type { nbformat } from '@jupyterlab/coreutils'; +import type { Kernel } from '@jupyterlab/services'; import { inject, injectable } from 'inversify'; import * as path from 'path'; import * as uuid from 'uuid/v4'; diff --git a/src/client/datascience/jupyter/liveshare/guestJupyterNotebook.ts b/src/client/datascience/jupyter/liveshare/guestJupyterNotebook.ts index 4950c265f750..b382df9b4f99 100644 --- a/src/client/datascience/jupyter/liveshare/guestJupyterNotebook.ts +++ b/src/client/datascience/jupyter/liveshare/guestJupyterNotebook.ts @@ -1,8 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. 'use strict'; -import { Kernel, KernelMessage } from '@jupyterlab/services'; -import { JSONObject } from '@phosphor/coreutils'; +import type { Kernel, KernelMessage } from '@jupyterlab/services'; +import type { JSONObject } from '@phosphor/coreutils'; import { Observable } from 'rxjs/Observable'; import { Event, EventEmitter, Uri } from 'vscode'; import { CancellationToken } from 'vscode-jsonrpc'; @@ -36,12 +36,12 @@ import { IExecuteObservableResponse, ILiveShareParticipant, IServerResponse } fr export class GuestJupyterNotebook extends LiveShareParticipantGuest(LiveShareParticipantDefault, LiveShare.JupyterNotebookSharedService) implements INotebook, ILiveShareParticipant { - private get jupyterLab(): undefined | typeof import('@jupyterlab/services') { + private get jupyterLab(): typeof import('@jupyterlab/services') { if (!this._jupyterLab) { // tslint:disable-next-line:no-require-imports this._jupyterLab = require('@jupyterlab/services') as typeof import('@jupyterlab/services'); // NOSONAR } - return this._jupyterLab; + return this._jupyterLab!; } public get identity(): Uri { @@ -299,7 +299,7 @@ export class GuestJupyterNotebook public requestCommInfo( _content: KernelMessage.ICommInfoRequestMsg['content'] ): Promise { - const shellMessage = KernelMessage.createMessage({ + const shellMessage = this.jupyterLab?.KernelMessage.createMessage({ msgType: 'comm_info_reply', channel: 'shell', content: { diff --git a/src/client/datascience/jupyter/liveshare/hostJupyterServer.ts b/src/client/datascience/jupyter/liveshare/hostJupyterServer.ts index 841243c13a00..4c0fd6cf49fc 100644 --- a/src/client/datascience/jupyter/liveshare/hostJupyterServer.ts +++ b/src/client/datascience/jupyter/liveshare/hostJupyterServer.ts @@ -10,7 +10,7 @@ import * as vscode from 'vscode'; import { CancellationToken } from 'vscode-jsonrpc'; import * as vsls from 'vsls/vscode'; -import { nbformat } from '@jupyterlab/coreutils'; +import type { nbformat } from '@jupyterlab/coreutils'; import { IApplicationShell, ILiveShareApi, IWorkspaceService } from '../../../common/application/types'; import { isTestExecution } from '../../../common/constants'; import { traceInfo } from '../../../common/logger'; diff --git a/src/client/datascience/liveshare/postOffice.ts b/src/client/datascience/liveshare/postOffice.ts index 08f98b8deb74..cf6f9e956083 100644 --- a/src/client/datascience/liveshare/postOffice.ts +++ b/src/client/datascience/liveshare/postOffice.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. 'use strict'; -import { JSONArray } from '@phosphor/coreutils'; +import type { JSONArray } from '@phosphor/coreutils'; import * as vscode from 'vscode'; import * as vsls from 'vsls/vscode'; diff --git a/src/client/datascience/raw-kernel/enchannel-zmq-backend-6/index.ts b/src/client/datascience/raw-kernel/enchannel-zmq-backend-6/index.ts index 0ae50893f0c5..58fc99d848e2 100644 --- a/src/client/datascience/raw-kernel/enchannel-zmq-backend-6/index.ts +++ b/src/client/datascience/raw-kernel/enchannel-zmq-backend-6/index.ts @@ -1,7 +1,7 @@ // This code was copied from https://github.com/nteract/enchannel-zmq-backend/blob/master/src/index.ts // and modified to work with zeromq-beta-6 -import { Channels, JupyterMessage } from '@nteract/messaging'; +import type { Channels, JupyterMessage } from '@nteract/messaging'; import * as wireProtocol from '@nteract/messaging/lib/wire-protocol'; import * as Events from 'events'; import * as rxjs from 'rxjs'; diff --git a/src/client/datascience/raw-kernel/enchannelJMPConnection.ts b/src/client/datascience/raw-kernel/enchannelJMPConnection.ts index b703e6dcb0ef..042822d09f91 100644 --- a/src/client/datascience/raw-kernel/enchannelJMPConnection.ts +++ b/src/client/datascience/raw-kernel/enchannelJMPConnection.ts @@ -1,5 +1,5 @@ -import { KernelMessage } from '@jupyterlab/services'; -import { Channels } from '@nteract/messaging'; +import type { KernelMessage } from '@jupyterlab/services'; +import type { Channels } from '@nteract/messaging'; import { injectable } from 'inversify'; import { IJMPConnection, IJMPConnectionInfo } from '../types'; diff --git a/src/client/datascience/raw-kernel/liveshare/guestRawNotebookProvider.ts b/src/client/datascience/raw-kernel/liveshare/guestRawNotebookProvider.ts index 6ce9d9bc5c2c..1c3114b3d61c 100644 --- a/src/client/datascience/raw-kernel/liveshare/guestRawNotebookProvider.ts +++ b/src/client/datascience/raw-kernel/liveshare/guestRawNotebookProvider.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. 'use strict'; -import { nbformat } from '@jupyterlab/coreutils'; +import type { nbformat } from '@jupyterlab/coreutils'; import { Uri } from 'vscode'; import { CancellationToken } from 'vscode-jsonrpc'; import * as vsls from 'vsls/vscode'; diff --git a/src/client/datascience/raw-kernel/liveshare/hostRawNotebookProvider.ts b/src/client/datascience/raw-kernel/liveshare/hostRawNotebookProvider.ts index ea2a79ef8fd7..0930fd31f7dd 100644 --- a/src/client/datascience/raw-kernel/liveshare/hostRawNotebookProvider.ts +++ b/src/client/datascience/raw-kernel/liveshare/hostRawNotebookProvider.ts @@ -7,7 +7,7 @@ import * as vscode from 'vscode'; import { CancellationToken } from 'vscode-jsonrpc'; import * as vsls from 'vsls/vscode'; -import { nbformat } from '@jupyterlab/coreutils'; +import type { nbformat } from '@jupyterlab/coreutils'; import { IApplicationShell, ILiveShareApi, IWorkspaceService } from '../../../common/application/types'; import { traceError, traceInfo } from '../../../common/logger'; import { IFileSystem } from '../../../common/platform/types'; diff --git a/src/client/datascience/raw-kernel/rawFuture.ts b/src/client/datascience/raw-kernel/rawFuture.ts index 0011f671616f..c36957e146f8 100644 --- a/src/client/datascience/raw-kernel/rawFuture.ts +++ b/src/client/datascience/raw-kernel/rawFuture.ts @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -import { Kernel, KernelMessage } from '@jupyterlab/services'; +import type { Kernel, KernelMessage } from '@jupyterlab/services'; import { createDeferred, Deferred } from '../../common/utils/async'; import { noop } from '../../common/utils/misc'; diff --git a/src/client/datascience/raw-kernel/rawKernel.ts b/src/client/datascience/raw-kernel/rawKernel.ts index 661b19db30c2..79b73577edfe 100644 --- a/src/client/datascience/raw-kernel/rawKernel.ts +++ b/src/client/datascience/raw-kernel/rawKernel.ts @@ -1,8 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -import { Kernel, KernelMessage, ServerConnection } from '@jupyterlab/services'; -import { JSONObject } from '@phosphor/coreutils'; -import { ISignal, Signal } from '@phosphor/signaling'; +import type { Kernel, KernelMessage, ServerConnection } from '@jupyterlab/services'; +import type { JSONObject } from '@phosphor/coreutils'; +import type { ISignal, Signal } from '@phosphor/signaling'; // tslint:disable-next-line: no-require-imports import cloneDeep = require('lodash/cloneDeep'); import * as uuid from 'uuid/v4'; @@ -94,7 +94,9 @@ export class RawKernel implements Kernel.IKernel { this._clientId = clientId; this._id = uuid(); this._status = 'unknown'; - this._statusChanged = new Signal(this); + // tslint:disable-next-line: no-require-imports + const signalling = require('@phosphor/signaling') as typeof import('@phosphor/signaling'); + this._statusChanged = new signalling.Signal(this); // Subscribe to messages coming in from our JMP channel this.jmpConnection = jmpConnection; @@ -438,7 +440,7 @@ export class RawKernel implements Kernel.IKernel { return false; } - /* + /* Messages are handled async so there is a possibility that the kernel might be disposed or restarted during handling. Throw an error here if our message that we are handling is no longer valid. diff --git a/src/client/datascience/raw-kernel/rawNotebookProvider.ts b/src/client/datascience/raw-kernel/rawNotebookProvider.ts index 1946736d2f34..d7b37d541427 100644 --- a/src/client/datascience/raw-kernel/rawNotebookProvider.ts +++ b/src/client/datascience/raw-kernel/rawNotebookProvider.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. 'use strict'; -import { nbformat } from '@jupyterlab/coreutils'; +import type { nbformat } from '@jupyterlab/coreutils'; import * as uuid from 'uuid/v4'; import { Event, EventEmitter, Uri } from 'vscode'; import { CancellationToken } from 'vscode-jsonrpc'; diff --git a/src/client/datascience/raw-kernel/rawNotebookProviderWrapper.ts b/src/client/datascience/raw-kernel/rawNotebookProviderWrapper.ts index 455d814f4998..07c4abf6d2f7 100644 --- a/src/client/datascience/raw-kernel/rawNotebookProviderWrapper.ts +++ b/src/client/datascience/raw-kernel/rawNotebookProviderWrapper.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. 'use strict'; -import { nbformat } from '@jupyterlab/coreutils'; +import type { nbformat } from '@jupyterlab/coreutils'; import { inject, injectable } from 'inversify'; import { Uri } from 'vscode'; import { CancellationToken } from 'vscode-jsonrpc'; diff --git a/src/client/datascience/raw-kernel/rawSession.ts b/src/client/datascience/raw-kernel/rawSession.ts index 48c5f272052f..2fa1ece20689 100644 --- a/src/client/datascience/raw-kernel/rawSession.ts +++ b/src/client/datascience/raw-kernel/rawSession.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -import { Kernel, KernelMessage, ServerConnection, Session } from '@jupyterlab/services'; -import { ISignal, Signal } from '@phosphor/signaling'; +import type { Kernel, KernelMessage, ServerConnection, Session } from '@jupyterlab/services'; +import type { ISignal, Signal } from '@phosphor/signaling'; import * as uuid from 'uuid/v4'; import { IKernelProcess } from '../kernel-launcher/types'; import { IJMPConnection } from '../types'; @@ -21,10 +21,13 @@ export class RawSession implements Session.ISession { private _id: string; private _clientID: string; private _kernel: RawKernel; - private _statusChanged = new Signal(this); + private readonly _statusChanged: Signal; // RawSession owns the lifetime of the kernel process and will dispose it constructor(connection: IJMPConnection, private kernelProcess: IKernelProcess) { + // tslint:disable-next-line: no-require-imports + const singalling = require('@phosphor/signaling') as typeof import('@phosphor/signaling'); + this._statusChanged = new singalling.Signal(this); // Unique ID for this session instance this._id = uuid(); diff --git a/src/client/datascience/types.ts b/src/client/datascience/types.ts index e9935396435b..2faee277a744 100644 --- a/src/client/datascience/types.ts +++ b/src/client/datascience/types.ts @@ -1,10 +1,10 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. 'use strict'; -import { nbformat } from '@jupyterlab/coreutils'; +import type { nbformat } from '@jupyterlab/coreutils'; import type { Session } from '@jupyterlab/services'; import type { Kernel, KernelMessage } from '@jupyterlab/services/lib/kernel'; -import { JSONObject } from '@phosphor/coreutils'; +import type { JSONObject } from '@phosphor/coreutils'; import { Observable } from 'rxjs/Observable'; import { CancellationToken, diff --git a/src/client/telemetry/index.ts b/src/client/telemetry/index.ts index 9863bf234966..a48ffbdce094 100644 --- a/src/client/telemetry/index.ts +++ b/src/client/telemetry/index.ts @@ -2,7 +2,7 @@ // Licensed under the MIT License. // tslint:disable:no-reference no-any import-name no-any function-name /// -import { JSONObject } from '@phosphor/coreutils'; +import type { JSONObject } from '@phosphor/coreutils'; import { basename as pathBasename, sep as pathSep } from 'path'; import * as stackTrace from 'stack-trace'; import TelemetryReporter from 'vscode-extension-telemetry';