2019-02-27 01:01:14 +07:00
|
|
|
import { IdeClient } from "@coder/ide";
|
2019-02-27 01:12:42 +07:00
|
|
|
import { client as ideClientInstance } from "@coder/ide/src/fill/client";
|
2019-02-27 22:03:44 +07:00
|
|
|
import Severity from "vs/base/common/severity";
|
|
|
|
import { INotificationService } from "vs/platform/notification/common/notification";
|
2019-02-28 04:36:39 +07:00
|
|
|
import { IStatusbarService, StatusbarAlignment } from "vs/platform/statusbar/common/statusbar";
|
2019-01-23 01:27:59 +07:00
|
|
|
import * as paths from "./fill/paths";
|
2019-01-19 07:04:24 +07:00
|
|
|
import "./vscode.scss";
|
2019-02-28 04:36:39 +07:00
|
|
|
import { MenuId, MenuRegistry } from "vs/platform/actions/common/actions";
|
|
|
|
import { CommandsRegistry } from "vs/platform/commands/common/commands";
|
2019-02-27 01:01:14 +07:00
|
|
|
// NOTE: shouldn't import anything from VS Code here or anything that will
|
|
|
|
// depend on a synchronous fill like `os`.
|
2019-01-31 04:40:01 +07:00
|
|
|
|
2019-02-27 01:01:14 +07:00
|
|
|
class VSClient extends IdeClient {
|
2019-01-31 02:13:04 +07:00
|
|
|
protected initialize(): Promise<void> {
|
2019-02-07 05:55:29 +07:00
|
|
|
return this.task("Start workbench", 1000, async (data, sharedData) => {
|
|
|
|
paths._paths.initialize(data, sharedData);
|
2019-01-29 00:14:06 +07:00
|
|
|
process.env.SHELL = data.shell;
|
2019-02-27 01:01:14 +07:00
|
|
|
// At this point everything should be filled, including `os`. `os` also
|
|
|
|
// relies on `initData` but it listens first so it initialize before this
|
|
|
|
// callback, meaning we are safe to include everything from VS Code now.
|
|
|
|
const { workbench } = require("./workbench") as typeof import("./workbench");
|
|
|
|
await workbench.initialize();
|
2019-02-27 01:12:42 +07:00
|
|
|
|
2019-02-27 22:03:44 +07:00
|
|
|
// tslint:disable-next-line:no-any
|
|
|
|
const getService = <T>(id: any): T => workbench.serviceCollection.get<T>(id) as T;
|
2019-02-27 01:12:42 +07:00
|
|
|
window.ide = {
|
|
|
|
client: ideClientInstance,
|
|
|
|
workbench: {
|
2019-02-28 04:36:39 +07:00
|
|
|
commandRegistry: CommandsRegistry,
|
|
|
|
// tslint:disable-next-line:no-any
|
|
|
|
menuRegistry: MenuRegistry as any,
|
|
|
|
// tslint:disable-next-line:no-any
|
|
|
|
statusbarService: getService<IStatusbarService>(IStatusbarService) as any,
|
2019-02-27 22:03:44 +07:00
|
|
|
notificationService: getService<INotificationService>(INotificationService),
|
2019-02-27 01:12:42 +07:00
|
|
|
},
|
2019-02-28 04:36:39 +07:00
|
|
|
|
|
|
|
// @ts-ignore
|
|
|
|
// tslint:disable-next-line:no-any
|
|
|
|
MenuId: MenuId as any,
|
|
|
|
// tslint:disable-next-line:no-any
|
|
|
|
Severity: Severity as any,
|
|
|
|
// @ts-ignore
|
|
|
|
// tslint:disable-next-line:no-any
|
|
|
|
StatusbarAlignment: StatusbarAlignment as any,
|
2019-02-27 01:12:42 +07:00
|
|
|
};
|
|
|
|
|
|
|
|
const event = new CustomEvent("ide-ready");
|
|
|
|
// tslint:disable-next-line:no-any
|
|
|
|
(<any>event).ide = window.ide;
|
|
|
|
window.dispatchEvent(event);
|
2019-02-07 05:55:29 +07:00
|
|
|
}, this.initData, this.sharedProcessData);
|
2019-01-19 04:46:40 +07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-27 01:01:14 +07:00
|
|
|
export const client = new VSClient();
|