Skip to content

Commit

Permalink
Merge pull request #6334 from vidartf/interfaces
Browse files Browse the repository at this point in the history
Token refactor/cleanup
  • Loading branch information
blink1073 committed May 23, 2019
2 parents 3732d02 + 8e030e0 commit 7391a88
Show file tree
Hide file tree
Showing 73 changed files with 1,770 additions and 1,095 deletions.
4 changes: 2 additions & 2 deletions packages/application/src/shell.ts
Expand Up @@ -61,15 +61,15 @@ const ACTIVITY_CLASS = 'jp-Activity';

/* tslint:disable */
/**
* The layout restorer token.
* The JupyterLab application shell token.
*/
export const ILabShell = new Token<ILabShell>(
'@jupyterlab/application:ILabShell'
);
/* tslint:enable */

/**
* The JupyterLab application shell.
* The JupyterLab application shell interface.
*/
export interface ILabShell extends LabShell {}

Expand Down
1 change: 1 addition & 0 deletions packages/apputils/src/index.ts
Expand Up @@ -21,6 +21,7 @@ export * from './spinner';
export * from './splash';
export * from './styling';
export * from './thememanager';
export * from './tokens';
export * from './toolbar';
export * from './vdom';
export * from './windowresolver';
62 changes: 4 additions & 58 deletions packages/apputils/src/thememanager.ts
Expand Up @@ -5,8 +5,6 @@ import { IChangedArgs, ISettingRegistry, URLExt } from '@jupyterlab/coreutils';

import { each } from '@phosphor/algorithm';

import { Token } from '@phosphor/coreutils';

import { DisposableDelegate, IDisposable } from '@phosphor/disposable';

import { Widget } from '@phosphor/widgets';
Expand All @@ -17,19 +15,7 @@ import { Dialog, showDialog } from './dialog';

import { ISplashScreen } from './splash';

/* tslint:disable */
/**
* The theme manager token.
*/
export const IThemeManager = new Token<IThemeManager>(
'@jupyterlab/apputils:IThemeManager'
);
/* tslint:enable */

/**
* An interface for a theme manager.
*/
export interface IThemeManager extends ThemeManager {}
import { IThemeManager } from './tokens';

/**
* The number of milliseconds between theme loading attempts.
Expand All @@ -44,7 +30,7 @@ const REQUEST_THRESHOLD = 20;
/**
* A class that provides theme management.
*/
export class ThemeManager {
export class ThemeManager implements IThemeManager {
/**
* Construct a new theme manager.
*/
Expand Down Expand Up @@ -119,7 +105,7 @@ export class ThemeManager {
*
* @returns A disposable that can be used to unregister the theme.
*/
register(theme: ThemeManager.ITheme): IDisposable {
register(theme: IThemeManager.ITheme): IDisposable {
const { name } = theme;
const themes = this._themes;

Expand Down Expand Up @@ -297,13 +283,10 @@ export class ThemeManager {
private _requests: { [theme: string]: number } = {};
private _settings: ISettingRegistry.ISettings;
private _splash: ISplashScreen | null;
private _themes: { [key: string]: ThemeManager.ITheme } = {};
private _themes: { [key: string]: IThemeManager.ITheme } = {};
private _themeChanged = new Signal<this, IChangedArgs<string>>(this);
}

/**
* A namespace for `ThemeManager` statics.
*/
export namespace ThemeManager {
/**
* The options used to create a theme manager.
Expand Down Expand Up @@ -334,43 +317,6 @@ export namespace ThemeManager {
*/
url: string;
}

/**
* An interface for a theme.
*/
export interface ITheme {
/**
* The display name of the theme.
*/
name: string;

/**
* Whether the theme is light or dark. Downstream authors
* of extensions can use this information to customize their
* UI depending upon the current theme.
*/
isLight: boolean;

/**
* Whether the theme includes styling for the scrollbar.
* If set to false, this theme will leave the native scrollbar untouched.
*/
themeScrollbars?: boolean;

/**
* Load the theme.
*
* @returns A promise that resolves when the theme has loaded.
*/
load(): Promise<void>;

/**
* Unload the theme.
*
* @returns A promise that resolves when the theme has unloaded.
*/
unload(): Promise<void>;
}
}

/**
Expand Down
113 changes: 113 additions & 0 deletions packages/apputils/src/tokens.ts
@@ -0,0 +1,113 @@
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.

import { IChangedArgs } from '@jupyterlab/coreutils';

import { Token } from '@phosphor/coreutils';

import { IDisposable } from '@phosphor/disposable';

import { ISignal } from '@phosphor/signaling';

/* tslint:disable */
/**
* The theme manager token.
*/
export const IThemeManager = new Token<IThemeManager>(
'@jupyterlab/apputils:IThemeManager'
);
/* tslint:enable */

/**
* An interface for a theme manager.
*/
export interface IThemeManager {
/**
* Get the name of the current theme.
*/
readonly theme: string | null;

/**
* The names of the registered themes.
*/
readonly themes: ReadonlyArray<string>;

/**
* A signal fired when the application theme changes.
*/
readonly themeChanged: ISignal<this, IChangedArgs<string>>;

/**
* Load a theme CSS file by path.
*
* @param path - The path of the file to load.
*/
loadCSS(path: string): Promise<void>;

/**
* Register a theme with the theme manager.
*
* @param theme - The theme to register.
*
* @returns A disposable that can be used to unregister the theme.
*/
register(theme: IThemeManager.ITheme): IDisposable;

/**
* Set the current theme.
*/
setTheme(name: string): Promise<void>;

/**
* Test whether a given theme is light.
*/
isLight(name: string): boolean;

/**
* Test whether a given theme styles scrollbars,
* and if the user has scrollbar styling enabled.
*/
themeScrollbars(name: string): boolean;
}

/**
* A namespace for the `IThemeManager` sub-types.
*/
export namespace IThemeManager {
/**
* An interface for a theme.
*/
export interface ITheme {
/**
* The display name of the theme.
*/
name: string;

/**
* Whether the theme is light or dark. Downstream authors
* of extensions can use this information to customize their
* UI depending upon the current theme.
*/
isLight: boolean;

/**
* Whether the theme includes styling for the scrollbar.
* If set to false, this theme will leave the native scrollbar untouched.
*/
themeScrollbars?: boolean;

/**
* Load the theme.
*
* @returns A promise that resolves when the theme has loaded.
*/
load(): Promise<void>;

/**
* Unload the theme.
*
* @returns A promise that resolves when the theme has unloaded.
*/
unload(): Promise<void>;
}
}
10 changes: 5 additions & 5 deletions packages/cells/src/widget.ts
Expand Up @@ -25,7 +25,7 @@ import {
import {
IRenderMime,
MimeModel,
RenderMimeRegistry
IRenderMimeRegistry
} from '@jupyterlab/rendermime';

import { KernelMessage } from '@jupyterlab/services';
Expand Down Expand Up @@ -974,7 +974,7 @@ export class CodeCell extends Cell {
this.toggleClass(NO_OUTPUTS_CLASS, force);
}

private _rendermime: RenderMimeRegistry = null;
private _rendermime: IRenderMimeRegistry = null;
private _outputHidden = false;
private _outputsScrolled: boolean;
private _outputWrapper: Widget = null;
Expand All @@ -1000,7 +1000,7 @@ export namespace CodeCell {
/**
* The mime renderer for the cell widget.
*/
rendermime: RenderMimeRegistry;
rendermime: IRenderMimeRegistry;
}

/**
Expand Down Expand Up @@ -1189,7 +1189,7 @@ export class MarkdownCell extends Cell {

private _monitor: ActivityMonitor<any, any> = null;
private _renderer: IRenderMime.IRenderer = null;
private _rendermime: RenderMimeRegistry;
private _rendermime: IRenderMimeRegistry;
private _rendered = true;
private _prevText = '';
private _ready = new PromiseDelegate<void>();
Expand All @@ -1211,7 +1211,7 @@ export namespace MarkdownCell {
/**
* The mime renderer for the cell widget.
*/
rendermime: RenderMimeRegistry;
rendermime: IRenderMimeRegistry;
}
}

Expand Down
31 changes: 1 addition & 30 deletions packages/codeeditor/src/index.ts
@@ -1,40 +1,11 @@
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.

import { Token } from '@phosphor/coreutils';

import { IEditorFactoryService } from './factory';

import { IEditorMimeTypeService } from './mimetype';

import '../style/index.css';

export * from './editor';
export * from './jsoneditor';
export * from './widget';
export * from './factory';
export * from './mimetype';

/* tslint:disable */
/**
* Code editor services token.
*/
export const IEditorServices = new Token<IEditorServices>(
'@jupyterlab/codeeditor:IEditorServices'
);
/* tslint:enable */

/**
* Code editor services.
*/
export interface IEditorServices {
/**
* The code editor factory.
*/
readonly factoryService: IEditorFactoryService;

/**
* The editor mime type service.
*/
readonly mimeTypeService: IEditorMimeTypeService;
}
export * from './tokens';
32 changes: 32 additions & 0 deletions packages/codeeditor/src/tokens.ts
@@ -0,0 +1,32 @@
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.

import { Token } from '@phosphor/coreutils';

import { IEditorFactoryService } from './factory';

import { IEditorMimeTypeService } from './mimetype';

/* tslint:disable */
/**
* Code editor services token.
*/
export const IEditorServices = new Token<IEditorServices>(
'@jupyterlab/codeeditor:IEditorServices'
);
/* tslint:enable */

/**
* Code editor services.
*/
export interface IEditorServices {
/**
* The code editor factory.
*/
readonly factoryService: IEditorFactoryService;

/**
* The editor mime type service.
*/
readonly mimeTypeService: IEditorMimeTypeService;
}
2 changes: 1 addition & 1 deletion packages/codemirror-extension/src/index.ts
Expand Up @@ -11,7 +11,7 @@ import {
JupyterFrontEndPlugin
} from '@jupyterlab/application';

import { IMainMenu, IEditMenu } from '@jupyterlab/mainmenu';
import { IEditMenu, IMainMenu } from '@jupyterlab/mainmenu';

import { IEditorServices } from '@jupyterlab/codeeditor';

Expand Down

0 comments on commit 7391a88

Please sign in to comment.