Archived
1
0
This repository has been archived on 2024-09-09. You can view files and clone it, but cannot push or open issues or pull requests.
code-server/packages/vscode/src/client.ts

44 lines
1.7 KiB
TypeScript
Raw Normal View History

import { IdeClient } from "@coder/ide";
2019-02-26 19:12:42 +01:00
import { client as ideClientInstance } from "@coder/ide/src/fill/client";
2019-02-27 16:03:44 +01:00
import Severity from "vs/base/common/severity";
import { INotificationService } from "vs/platform/notification/common/notification";
import { IStatusbarService } from "vs/platform/statusbar/common/statusbar";
import * as paths from "./fill/paths";
2019-01-19 01:04:24 +01:00
import "./vscode.scss";
// NOTE: shouldn't import anything from VS Code here or anything that will
// depend on a synchronous fill like `os`.
2019-01-30 22:40:01 +01:00
class VSClient extends IdeClient {
protected initialize(): Promise<void> {
return this.task("Start workbench", 1000, async (data, sharedData) => {
paths._paths.initialize(data, sharedData);
process.env.SHELL = data.shell;
// 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 19:12:42 +01:00
2019-02-27 16:03:44 +01:00
// tslint:disable-next-line:no-any
const getService = <T>(id: any): T => workbench.serviceCollection.get<T>(id) as T;
enum StatusbarAlignment { LEFT, RIGHT }
2019-02-26 19:12:42 +01:00
window.ide = {
client: ideClientInstance,
workbench: {
2019-02-27 16:03:44 +01:00
statusbarService: getService<IStatusbarService>(IStatusbarService),
notificationService: getService<INotificationService>(INotificationService),
2019-02-26 19:12:42 +01:00
},
2019-02-27 16:03:44 +01:00
Severity: Severity,
StatusbarAlignment: StatusbarAlignment,
2019-02-26 19:12:42 +01:00
};
const event = new CustomEvent("ide-ready");
// tslint:disable-next-line:no-any
(<any>event).ide = window.ide;
window.dispatchEvent(event);
}, this.initData, this.sharedProcessData);
}
}
export const client = new VSClient();