2019-02-26 18:01:14 +00:00
|
|
|
import { IdeClient } from "@coder/ide";
|
2019-02-26 18:12:42 +00:00
|
|
|
import { client as ideClientInstance } from "@coder/ide/src/fill/client";
|
2019-01-22 18:27:59 +00:00
|
|
|
import * as paths from "./fill/paths";
|
2019-01-19 00:04:24 +00:00
|
|
|
import "./vscode.scss";
|
2019-02-26 18:01:14 +00:00
|
|
|
// NOTE: shouldn't import anything from VS Code here or anything that will
|
|
|
|
// depend on a synchronous fill like `os`.
|
2019-01-30 21:40:01 +00:00
|
|
|
|
2019-02-26 18:01:14 +00:00
|
|
|
class VSClient extends IdeClient {
|
2019-01-30 19:13:04 +00:00
|
|
|
protected initialize(): Promise<void> {
|
2019-02-06 22:55:29 +00:00
|
|
|
return this.task("Start workbench", 1000, async (data, sharedData) => {
|
|
|
|
paths._paths.initialize(data, sharedData);
|
2019-01-28 17:14:06 +00:00
|
|
|
process.env.SHELL = data.shell;
|
2019-02-26 18:01:14 +00: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-26 18:12:42 +00:00
|
|
|
|
|
|
|
window.ide = {
|
|
|
|
client: ideClientInstance,
|
|
|
|
workbench: {
|
|
|
|
// tslint:disable-next-line:no-any
|
|
|
|
getService: <T>(id: any): T => workbench.serviceCollection.get<T>(id) as T,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
const event = new CustomEvent("ide-ready");
|
|
|
|
// tslint:disable-next-line:no-any
|
|
|
|
(<any>event).ide = window.ide;
|
|
|
|
window.dispatchEvent(event);
|
2019-02-06 22:55:29 +00:00
|
|
|
}, this.initData, this.sharedProcessData);
|
2019-01-18 21:46:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-26 18:01:14 +00:00
|
|
|
export const client = new VSClient();
|