2019-01-18 21:46:40 +00:00
|
|
|
import "./fill/require";
|
2019-01-22 18:27:59 +00:00
|
|
|
import * as paths from "./fill/paths";
|
2019-01-18 21:46:40 +00:00
|
|
|
import "./fill/storageDatabase";
|
|
|
|
import "./fill/windowsService";
|
2019-01-22 18:27:59 +00:00
|
|
|
import "./fill/environmentService";
|
2019-01-28 17:14:06 +00:00
|
|
|
import "./fill/vscodeTextmate";
|
2019-01-19 00:04:24 +00:00
|
|
|
import "./fill/dom";
|
|
|
|
import "./vscode.scss";
|
2019-01-18 21:46:40 +00:00
|
|
|
|
|
|
|
import { Client as IDEClient, IURI, IURIFactory } from "@coder/ide";
|
|
|
|
|
|
|
|
import { registerContextMenuListener } from "vs/base/parts/contextmenu/electron-main/contextmenu";
|
|
|
|
import { LogLevel } from "vs/platform/log/common/log";
|
|
|
|
// import { RawContextKey, IContextKeyService } from "vs/platform/contextkey/common/contextkey";
|
|
|
|
import { URI } from "vs/base/common/uri";
|
|
|
|
|
|
|
|
export class Client extends IDEClient {
|
|
|
|
|
2019-01-30 19:27:21 +00:00
|
|
|
private readonly windowId = parseInt(new Date().toISOString().replace(/[-:.TZ]/g, ""), 10);
|
2019-01-19 00:04:24 +00:00
|
|
|
|
2019-01-30 19:13:04 +00:00
|
|
|
protected initialize(): Promise<void> {
|
|
|
|
registerContextMenuListener();
|
2019-01-18 21:46:40 +00:00
|
|
|
|
2019-01-30 19:13:04 +00:00
|
|
|
const pathSets = this.sharedProcessData.then((data) => {
|
2019-01-22 18:27:59 +00:00
|
|
|
paths._paths.socketPath = data.socketPath;
|
2019-01-28 17:14:06 +00:00
|
|
|
process.env.VSCODE_LOGS = data.logPath;
|
2019-01-22 18:27:59 +00:00
|
|
|
});
|
2019-01-30 19:13:04 +00:00
|
|
|
|
|
|
|
return this.task("Start workbench", 1000, async (data) => {
|
2019-01-22 18:27:59 +00:00
|
|
|
paths._paths.appData = data.dataDirectory;
|
|
|
|
paths._paths.defaultUserData = data.dataDirectory;
|
2019-01-28 17:14:06 +00:00
|
|
|
process.env.SHELL = data.shell;
|
2019-01-18 21:46:40 +00:00
|
|
|
|
|
|
|
const { startup } = require("./startup");
|
|
|
|
await startup({
|
|
|
|
machineId: "1",
|
|
|
|
windowId: this.windowId,
|
|
|
|
logLevel: LogLevel.Info,
|
|
|
|
mainPid: 1,
|
2019-01-22 18:27:59 +00:00
|
|
|
appRoot: data.dataDirectory,
|
|
|
|
execPath: data.tmpDirectory,
|
2019-01-18 21:46:40 +00:00
|
|
|
userEnv: {},
|
2019-01-22 18:27:59 +00:00
|
|
|
nodeCachedDataDir: data.tmpDirectory,
|
2019-01-18 21:46:40 +00:00
|
|
|
perfEntries: [],
|
|
|
|
_: [],
|
2019-01-28 17:14:06 +00:00
|
|
|
folderUri: URI.file(data.workingDirectory),
|
2019-01-18 21:46:40 +00:00
|
|
|
});
|
|
|
|
|
2019-01-19 00:04:24 +00:00
|
|
|
// TODO: Set notification service for retrying.
|
|
|
|
// this.retry.setNotificationService({
|
|
|
|
// prompt: (severity, message, buttons, onCancel) => {
|
|
|
|
// const handle = getNotificationService().prompt(severity, message, buttons, onCancel);
|
|
|
|
// return {
|
|
|
|
// close: () => handle.close(),
|
|
|
|
// updateMessage: (message) => handle.updateMessage(message),
|
|
|
|
// updateButtons: (buttons) => handle.updateActions({
|
|
|
|
// primary: buttons.map((button) => ({
|
|
|
|
// id: undefined,
|
|
|
|
// label: button.label,
|
|
|
|
// tooltip: undefined,
|
|
|
|
// class: undefined,
|
|
|
|
// enabled: true,
|
|
|
|
// checked: false,
|
|
|
|
// radio: false,
|
|
|
|
// dispose: () => undefined,
|
|
|
|
// run: () => {
|
|
|
|
// button.run();
|
|
|
|
// return Promise.resolve();
|
|
|
|
// },
|
|
|
|
// })),
|
|
|
|
// }),
|
|
|
|
// };
|
|
|
|
// }
|
|
|
|
// });
|
|
|
|
|
2019-01-18 21:46:40 +00:00
|
|
|
// TODO: Set up clipboard context.
|
|
|
|
// const workbench = workbenchShell.workbench;
|
|
|
|
// const contextKeys = workbench.workbenchParams.serviceCollection.get(IContextKeyService) as IContextKeyService;
|
|
|
|
// const clipboardContextKey = new RawContextKey("nativeClipboard", this.clipboard.isSupported);
|
|
|
|
// const bounded = clipboardContextKey.bindTo(contextKeys);
|
|
|
|
// this.clipboard.onPermissionChange((enabled) => {
|
|
|
|
// bounded.set(enabled);
|
|
|
|
// });
|
|
|
|
this.clipboard.initialize();
|
2019-01-30 19:13:04 +00:00
|
|
|
}, this.initData, pathSets);
|
2019-01-18 21:46:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
protected createUriFactory(): IURIFactory {
|
|
|
|
return {
|
|
|
|
// TODO: not sure why this is an error.
|
|
|
|
// tslint:disable-next-line no-any
|
|
|
|
create: <URI>(uri: IURI): URI => URI.from(uri) as any,
|
|
|
|
file: (path: string): IURI => URI.file(path),
|
|
|
|
parse: (raw: string): IURI => URI.parse(raw),
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
export const client = new Client();
|