From 63d1079afe6b59b43a4f1e03b28fe3a51f262902 Mon Sep 17 00:00:00 2001 From: Duc Trung Le Date: Fri, 17 Feb 2023 17:06:26 +0100 Subject: [PATCH] Update import --- src/notebookrenderer/index.ts | 12 ++++-------- src/notebookrenderer/token.ts | 7 ++----- src/notebookrenderer/widgetManager.ts | 14 +++++--------- src/notebookrenderer/yCommProvider.ts | 9 ++++----- src/widget.tsx | 11 ++++------- tsconfig.json | 2 +- 6 files changed, 20 insertions(+), 35 deletions(-) diff --git a/src/notebookrenderer/index.ts b/src/notebookrenderer/index.ts index cf982388..44720e19 100644 --- a/src/notebookrenderer/index.ts +++ b/src/notebookrenderer/index.ts @@ -1,18 +1,14 @@ import { - createRendermimePlugin, JupyterFrontEnd, JupyterFrontEndPlugin } from '@jupyterlab/application'; -import { ISessionContext, WidgetTracker } from '@jupyterlab/apputils'; +import { ISessionContext } from '@jupyterlab/apputils'; import { IChangedArgs } from '@jupyterlab/coreutils'; -import { MimeDocument } from '@jupyterlab/docregistry'; import { INotebookTracker } from '@jupyterlab/notebook'; import { IRenderMimeRegistry } from '@jupyterlab/rendermime'; import { IRenderMime } from '@jupyterlab/rendermime-interfaces'; -import { IKernelConnection } from '@jupyterlab/services/lib/kernel/kernel'; +import { Kernel } from '@jupyterlab/services'; -import { IAnnotationModel } from '../types'; -import { IAnnotation } from './../token'; import { NotebookRendererModel } from './model'; import { IJupyterCadWidgetManager } from './token'; import { NotebookRenderer } from './view'; @@ -64,8 +60,8 @@ export const ypyWidgetManager: JupyterFrontEndPlugin = const onKernelChanged = ( _: ISessionContext, changedArgs: IChangedArgs< - IKernelConnection | null, - IKernelConnection | null, + Kernel.IKernelConnection | null, + Kernel.IKernelConnection | null, 'kernel' > ) => { diff --git a/src/notebookrenderer/token.ts b/src/notebookrenderer/token.ts index 757d0341..853c2b96 100644 --- a/src/notebookrenderer/token.ts +++ b/src/notebookrenderer/token.ts @@ -1,7 +1,4 @@ -import { - IComm, - IKernelConnection -} from '@jupyterlab/services/lib/kernel/kernel'; +import { Kernel } from '@jupyterlab/services'; import { Token } from '@lumino/coreutils'; import { IJupyterCadModel } from '../types'; @@ -10,7 +7,7 @@ export interface IJupyterCadWidgetModelRegistry { } export interface IJupyterCadWidgetManager { - registerKernel(kernel: IKernelConnection): void; + registerKernel(kernel: Kernel.IKernelConnection): void; getWidgetModel( kernelId: string, commId: string diff --git a/src/notebookrenderer/widgetManager.ts b/src/notebookrenderer/widgetManager.ts index 13d76b2c..f86749bd 100644 --- a/src/notebookrenderer/widgetManager.ts +++ b/src/notebookrenderer/widgetManager.ts @@ -1,10 +1,6 @@ import { URLExt } from '@jupyterlab/coreutils'; import { ServerConnection, ServiceManager, User } from '@jupyterlab/services'; -import { - IComm, - IKernelConnection -} from '@jupyterlab/services/lib/kernel/kernel'; -import { ICommOpenMsg } from '@jupyterlab/services/lib/kernel/messages'; +import { Kernel, KernelMessage } from '@jupyterlab/services'; import { JupyterCadModel } from '../model'; import { IJupyterCadWidgetModelRegistry, @@ -20,7 +16,7 @@ export class JupyterCadWidgetManager implements IJupyterCadWidgetManager { constructor(options: { manager: ServiceManager.IManager }) { this._manager = options.manager; } - registerKernel(kernel: IKernelConnection): void { + registerKernel(kernel: Kernel.IKernelConnection): void { const wm = new WidgetModelRegistry({ kernel, manager: this._manager }); this._registry.set(kernel.id, wm); } @@ -44,7 +40,7 @@ export class JupyterCadWidgetManager implements IJupyterCadWidgetManager { export class WidgetModelRegistry implements IJupyterCadWidgetModelRegistry { constructor(options: { - kernel: IKernelConnection; + kernel: Kernel.IKernelConnection; manager: ServiceManager.IManager; }) { const { kernel, manager } = options; @@ -60,8 +56,8 @@ export class WidgetModelRegistry implements IJupyterCadWidgetModelRegistry { * Handle when a comm is opened. */ private _handle_comm_open = async ( - comm: IComm, - msg: ICommOpenMsg + comm: Kernel.IComm, + msg: KernelMessage.ICommOpenMsg ): Promise => { const { path, format, contentType } = msg.content.data as { path?: string; diff --git a/src/notebookrenderer/yCommProvider.ts b/src/notebookrenderer/yCommProvider.ts index 3bfad60e..7b6ec171 100644 --- a/src/notebookrenderer/yCommProvider.ts +++ b/src/notebookrenderer/yCommProvider.ts @@ -1,5 +1,4 @@ -import { IComm } from '@jupyterlab/services/lib/kernel/kernel'; -import { ICommMsgMsg } from '@jupyterlab/services/lib/kernel/messages'; +import { Kernel, KernelMessage } from '@jupyterlab/services'; import * as decoding from 'lib0/decoding'; import * as encoding from 'lib0/encoding'; import * as syncProtocol from 'y-protocols/sync'; @@ -11,7 +10,7 @@ export enum YMessageType { AWARENESS = 1 } export class YCommProvider implements IDisposable { - constructor(options: { comm: IComm; ydoc: Y.Doc }) { + constructor(options: { comm: Kernel.IComm; ydoc: Y.Doc }) { this._comm = options.comm; this._ydoc = options.ydoc; this._ydoc.on('update', this._updateHandler); @@ -42,7 +41,7 @@ export class YCommProvider implements IDisposable { this._comm.close(); this._isDisposed = true; } - private _onMsg = (msg: ICommMsgMsg<'iopub' | 'shell'>) => { + private _onMsg = (msg: KernelMessage.ICommMsgMsg<'iopub' | 'shell'>) => { if (msg.buffers) { const buffer = msg.buffers[0] as ArrayBuffer; const encoder = Private.readMessage(this, new Uint8Array(buffer), true); @@ -75,7 +74,7 @@ export class YCommProvider implements IDisposable { this._comm.send({}, undefined, [bufferArray.buffer]); } - private _comm: IComm; + private _comm: Kernel.IComm; private _ydoc: Y.Doc; private _synced: boolean; private _isDisposed = false; diff --git a/src/widget.tsx b/src/widget.tsx index eacfc0ab..28d0ca24 100644 --- a/src/widget.tsx +++ b/src/widget.tsx @@ -1,20 +1,17 @@ -import * as React from 'react'; - import { ReactWidget } from '@jupyterlab/apputils'; -import { ObservableMap, IObservableMap } from '@jupyterlab/observables'; -import { DocumentRegistry, DocumentWidget } from '@jupyterlab/docregistry'; - +import { DocumentWidget } from '@jupyterlab/docregistry'; +import { IObservableMap, ObservableMap } from '@jupyterlab/observables'; +import { JSONValue } from '@lumino/coreutils'; import { ISignal, Signal } from '@lumino/signaling'; +import * as React from 'react'; import { MainView } from './mainview'; -import { JupyterCadModel } from './model'; import { AxeHelper, ExplodedView, IJupyterCadModel, IJupyterCadWidget } from './types'; -import { JSONValue } from '@lumino/coreutils'; export class JupyterCadWidget extends DocumentWidget diff --git a/tsconfig.json b/tsconfig.json index 93f02d84..906f750b 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -10,7 +10,7 @@ "moduleResolution": "node", "noEmitOnError": true, "noImplicitAny": false, - "noUnusedLocals": false, + "noUnusedLocals": true, "preserveWatchOutput": true, "resolveJsonModule": true, "outDir": "lib",