Skip to content

Commit

Permalink
Back to business
Browse files Browse the repository at this point in the history
  • Loading branch information
goanpeca committed Aug 11, 2020
1 parent 782a42b commit ceb36b8
Show file tree
Hide file tree
Showing 83 changed files with 160 additions and 324 deletions.
4 changes: 2 additions & 2 deletions examples/console/src/index.ts
Expand Up @@ -69,14 +69,14 @@ function startApp(path: string, manager: ServiceManager.IManager) {

const rendermime = new RenderMimeRegistry({ initialFactories });

const editorFactory = editorServices.getFactoryService().newInlineEditor;
const editorFactory = editorServices.factoryService.newInlineEditor;
const contentFactory = new ConsolePanel.ContentFactory({ editorFactory });
const consolePanel = new ConsolePanel({
rendermime,
manager,
path,
contentFactory,
mimeTypeService: editorServices.getMimeTypeService()
mimeTypeService: editorServices.mimeTypeService
});
consolePanel.title.label = TITLE;

Expand Down
4 changes: 2 additions & 2 deletions examples/notebook/src/index.ts
Expand Up @@ -89,7 +89,7 @@ function createApp(manager: ServiceManager.IManager): void {
opener
});
const mFactory = new NotebookModelFactory({});
const editorFactory = editorServices.getFactoryService().newInlineEditor;
const editorFactory = editorServices.factoryService.newInlineEditor;
const contentFactory = new NotebookPanel.ContentFactory({ editorFactory });

const wFactory = new NotebookWidgetFactory({
Expand All @@ -101,7 +101,7 @@ function createApp(manager: ServiceManager.IManager): void {
canStartKernel: true,
rendermime,
contentFactory,
mimeTypeService: editorServices.getMimeTypeService()
mimeTypeService: editorServices.mimeTypeService
});
docRegistry.addModelFactory(mFactory);
docRegistry.addWidgetFactory(wFactory);
Expand Down
4 changes: 1 addition & 3 deletions packages/application-extension/tsconfig.json
Expand Up @@ -4,9 +4,7 @@
"outDir": "lib",
"rootDir": "src"
},
"include": [
"src/*"
],
"include": ["src/*"],
"references": [
{
"path": "../application"
Expand Down
4 changes: 1 addition & 3 deletions packages/application/tsconfig.json
Expand Up @@ -4,9 +4,7 @@
"outDir": "lib",
"rootDir": "src"
},
"include": [
"src/*"
],
"include": ["src/*"],
"references": [
{
"path": "../apputils"
Expand Down
5 changes: 1 addition & 4 deletions packages/application/tsconfig.test.json
@@ -1,9 +1,6 @@
{
"extends": "../../tsconfigbase.test",
"include": [
"src/*",
"test/*"
],
"include": ["src/*", "test/*"],
"references": [
{
"path": "../apputils"
Expand Down
21 changes: 6 additions & 15 deletions packages/apputils-extension/src/palette.ts
Expand Up @@ -10,11 +10,7 @@ import { CommandPalette } from '@lumino/widgets';

import { ILayoutRestorer, JupyterFrontEnd } from '@jupyterlab/application';
import { ICommandPalette, IPaletteItem } from '@jupyterlab/apputils';
import {
nullTranslator,
ITranslator,
TranslationBundle
} from '@jupyterlab/translation';
import { ITranslator } from '@jupyterlab/translation';
import { CommandPaletteSvg, paletteIcon } from '@jupyterlab/ui-components';

/**
Expand All @@ -32,12 +28,11 @@ export class Palette implements ICommandPalette {
/**
* Create a palette instance.
*/
constructor(palette: CommandPalette, translator?: ITranslator) {
this.translator = translator || nullTranslator;
this._trans = this.translator.load('jupyterlab');
constructor(palette: CommandPalette, translator: ITranslator) {
const trans = translator.load('jupyterlab');
this._palette = palette;
this._palette.title.label = '';
this._palette.title.caption = this._trans.__('Command Palette');
this._palette.title.caption = trans.__('Command Palette');
}

/**
Expand Down Expand Up @@ -71,8 +66,6 @@ export class Palette implements ICommandPalette {
});
}

protected translator: ITranslator;
private _trans: TranslationBundle;
private _palette: CommandPalette;
}

Expand Down Expand Up @@ -129,7 +122,7 @@ export namespace Palette {
export function restore(
app: JupyterFrontEnd,
restorer: ILayoutRestorer,
translator?: ITranslator
translator: ITranslator
): void {
const palette = Private.createPalette(app, translator);

Expand All @@ -154,11 +147,9 @@ namespace Private {
*/
export function createPalette(
app: JupyterFrontEnd,
translator?: ITranslator
translator: ITranslator
): CommandPalette {
if (!palette) {
translator = translator || nullTranslator;

// use a renderer tweaked to use inline svg icons
palette = new CommandPalette({
commands: app.commands,
Expand Down
3 changes: 1 addition & 2 deletions packages/apputils-extension/src/workspacesplugin.ts
Expand Up @@ -208,9 +208,8 @@ namespace Private {
workspaces: WorkspaceManager,
router: IRouter | null,
state: IStateDB,
translator?: ITranslator
translator: ITranslator
) {
translator = translator || nullTranslator;
const trans = translator.load('jupyterlab');
super({
name: trans.__('Workspace loader'),
Expand Down
4 changes: 1 addition & 3 deletions packages/apputils-extension/tsconfig.json
Expand Up @@ -4,9 +4,7 @@
"outDir": "lib",
"rootDir": "src"
},
"include": [
"src/*"
],
"include": ["src/*"],
"references": [
{
"path": "../application"
Expand Down
9 changes: 6 additions & 3 deletions packages/apputils/src/sessioncontext.tsx
Expand Up @@ -278,6 +278,7 @@ export namespace ISessionContext {
}

export type KernelDisplayStatus = string;
// FIXES: Use a map to map {[status: KernelDisplayStatus]: string}
// export type KernelDisplayStatus =
// | Kernel.Status
// | Kernel.ConnectionStatus
Expand Down Expand Up @@ -538,6 +539,8 @@ export class SessionContext implements ISessionContext {
* the user.
*/
get kernelDisplayStatus(): string {
// FIXME:
// get kernelDisplayStatus(): ISessionContext.KernelDisplayStatus {
const kernel = this.session?.kernel;

if (this._isTerminating) {
Expand Down Expand Up @@ -1305,7 +1308,7 @@ namespace Private {
/**
* Create a new kernel selector widget.
*/
constructor(sessionContext: ISessionContext, translator?: ITranslator) {
constructor(sessionContext: ISessionContext, translator: ITranslator) {
super({ node: createSelectorNode(sessionContext, translator) });
}

Expand All @@ -1323,7 +1326,7 @@ namespace Private {
*/
function createSelectorNode(
sessionContext: ISessionContext,
translator?: ITranslator
translator: ITranslator
) {
translator = translator || nullTranslator;
const trans = translator.load('jupyterlab');
Expand Down Expand Up @@ -1414,7 +1417,7 @@ namespace Private {
export function populateKernelSelect(
node: HTMLSelectElement,
options: SessionContext.IKernelSearch,
translator?: ITranslator
translator: ITranslator
): void {
translator = translator || nullTranslator;
const trans = translator.load('jupyterlab');
Expand Down
2 changes: 1 addition & 1 deletion packages/apputils/src/tokens.ts
Expand Up @@ -114,7 +114,7 @@ export namespace IThemeManager {
/**
* The display name of the theme.
*/
displayName: string;
displayName?: string;

/**
* Whether the theme includes styling for the scrollbar.
Expand Down
1 change: 1 addition & 0 deletions packages/apputils/test/sessioncontext.spec.ts
Expand Up @@ -440,6 +440,7 @@ describe('@jupyterlab/apputils', () => {
});

it('should handle an error during kernel change', async () => {
// FIXME: Test failing
await sessionContext.initialize();
await sessionContext.session?.kernel?.info;
let status = 'idle';
Expand Down
4 changes: 1 addition & 3 deletions packages/apputils/tsconfig.json
Expand Up @@ -4,9 +4,7 @@
"outDir": "lib",
"rootDir": "src"
},
"include": [
"src/*"
],
"include": ["src/*"],
"references": [
{
"path": "../coreutils"
Expand Down
5 changes: 1 addition & 4 deletions packages/apputils/tsconfig.test.json
@@ -1,9 +1,6 @@
{
"extends": "../../tsconfigbase.test",
"include": [
"src/*",
"test/*"
],
"include": ["src/*", "test/*"],
"references": [
{
"path": "../coreutils"
Expand Down
4 changes: 1 addition & 3 deletions packages/celltags/tsconfig.json
Expand Up @@ -4,9 +4,7 @@
"outDir": "lib",
"rootDir": "src"
},
"include": [
"src/*"
],
"include": ["src/*"],
"references": [
{
"path": "../application"
Expand Down
6 changes: 2 additions & 4 deletions packages/codeeditor/src/tokens.ts
@@ -1,8 +1,6 @@
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.

import { ITranslator } from '@jupyterlab/translation';

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

import { IEditorFactoryService } from './factory';
Expand All @@ -25,10 +23,10 @@ export interface IEditorServices {
/**
* The code editor factory.
*/
getFactoryService(translator?: ITranslator): IEditorFactoryService;
readonly factoryService: IEditorFactoryService;

/**
* The editor mime type service.
*/
getMimeTypeService(translator?: ITranslator): IEditorMimeTypeService;
readonly mimeTypeService: IEditorMimeTypeService;
}
4 changes: 1 addition & 3 deletions packages/codeeditor/tsconfig.json
Expand Up @@ -4,9 +4,7 @@
"outDir": "lib",
"rootDir": "src"
},
"include": [
"src/*"
],
"include": ["src/*"],
"references": [
{
"path": "../coreutils"
Expand Down
5 changes: 1 addition & 4 deletions packages/codeeditor/tsconfig.test.json
@@ -1,9 +1,6 @@
{
"extends": "../../tsconfigbase.test",
"include": [
"src/*",
"test/*"
],
"include": ["src/*", "test/*"],
"references": [
{
"path": "../coreutils"
Expand Down
20 changes: 14 additions & 6 deletions packages/codemirror/src/index.ts
Expand Up @@ -3,8 +3,6 @@

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

import { ITranslator } from '@jupyterlab/translation';

import { CodeMirrorEditorFactory } from './factory';

import { CodeMirrorMimeTypeService } from './mimetype';
Expand All @@ -19,8 +17,18 @@ export * from './syntaxstatus';
* The default editor services.
*/
export const editorServices: IEditorServices = {
getFactoryService: (translator?: ITranslator) =>
new CodeMirrorEditorFactory({}, translator),
getMimeTypeService: (translator?: ITranslator) =>
new CodeMirrorMimeTypeService(translator)
factoryService: new CodeMirrorEditorFactory(),
mimeTypeService: new CodeMirrorMimeTypeService()
};

/**
* FIXME: Maybe an option to be able to pass a translator to the factories?
*
export function getEditorServices(translator: ITranslator): IEditorServices {
return {
factoryService: new CodeMirrorEditorFactory({}, translator),
mimeTypeService: new CodeMirrorMimeTypeService()
};
}
*/
7 changes: 0 additions & 7 deletions packages/codemirror/src/mimetype.ts
Expand Up @@ -7,8 +7,6 @@ import { PathExt } from '@jupyterlab/coreutils';

import * as nbformat from '@jupyterlab/nbformat';

import { ITranslator, nullTranslator } from '@jupyterlab/translation';

import { Mode } from './mode';

/**
Expand All @@ -21,9 +19,6 @@ export class CodeMirrorMimeTypeService implements IEditorMimeTypeService {
* #### Notes
* If a mime type cannot be found returns the defaul mime type `text/plain`, never `null`.
*/
constructor(translator?: ITranslator) {
this.translator = translator || nullTranslator;
}
getMimeTypeByLanguage(info: nbformat.ILanguageInfoMetadata): string {
const ext = info.file_extension || '';
return Mode.findBest(
Expand Down Expand Up @@ -51,6 +46,4 @@ export class CodeMirrorMimeTypeService implements IEditorMimeTypeService {
const mode = Mode.findByFileName(path) || Mode.findBest('');
return mode.mime;
}

protected translator: ITranslator;
}
14 changes: 5 additions & 9 deletions packages/console-extension/src/index.ts
Expand Up @@ -128,15 +128,10 @@ const tracker: JupyterFrontEndPlugin<IConsoleTracker> = {
const factory: JupyterFrontEndPlugin<ConsolePanel.IContentFactory> = {
id: '@jupyterlab/console-extension:factory',
provides: ConsolePanel.IContentFactory,
requires: [IEditorServices, ITranslator],
requires: [IEditorServices],
autoStart: true,
activate: (
app: JupyterFrontEnd,
editorServices: IEditorServices,
translator: ITranslator
) => {
const editorFactory = editorServices.getFactoryService(translator)
.newInlineEditor;
activate: (app: JupyterFrontEnd, editorServices: IEditorServices) => {
const editorFactory = editorServices.factoryService.newInlineEditor;
return new ConsolePanel.ContentFactory({ editorFactory });
}
};
Expand Down Expand Up @@ -264,12 +259,13 @@ async function activateConsole(
* Create a console for a given path.
*/
async function createConsole(options: ICreateOptions): Promise<ConsolePanel> {
console.log('async function createConsole(', translator);
await manager.ready;

const panel = new ConsolePanel({
manager,
contentFactory,
mimeTypeService: editorServices.getMimeTypeService(translator),
mimeTypeService: editorServices.mimeTypeService,
rendermime,
translator,
setBusy: (status && (() => status.setBusy())) ?? undefined,
Expand Down
4 changes: 1 addition & 3 deletions packages/console-extension/tsconfig.json
Expand Up @@ -4,9 +4,7 @@
"outDir": "lib",
"rootDir": "src"
},
"include": [
"src/*"
],
"include": ["src/*"],
"references": [
{
"path": "../application"
Expand Down

0 comments on commit ceb36b8

Please sign in to comment.