-
Notifications
You must be signed in to change notification settings - Fork 0
/
workbench.ts
58 lines (50 loc) · 1.58 KB
/
workbench.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import {
create
} from "vs/workbench/workbench.web.main";
import { URI, UriComponents } from "vs/base/common/uri";
import { IWorkbenchConstructionOptions } from "vs/workbench/browser/web.api";
import { IWorkspace, IWorkspaceProvider } from "vs/workbench/services/host/browser/browserHostService";
declare const window: any;
(async function () {
// create workbench
let config: IWorkbenchConstructionOptions & {
folderUri?: UriComponents;
workspaceUri?: UriComponents;
domElementId?: string;
} = {};
if (window.product) {
config = window.product;
} else {
const result = await fetch("/product.json");
config = await result.json();
}
if (Array.isArray(config.additionalBuiltinExtensions)) {
const tempConfig = { ...config };
tempConfig.additionalBuiltinExtensions =
config.additionalBuiltinExtensions.map((ext) => URI.revive(ext));
config = tempConfig;
}
let workspace;
if (config.folderUri) {
workspace = { folderUri: URI.revive(config.folderUri) };
} else if (config.workspaceUri) {
workspace = { workspaceUri: URI.revive(config.workspaceUri) };
} else {
workspace = undefined;
}
if (workspace) {
const workspaceProvider: IWorkspaceProvider = {
workspace,
open: async (
workspace: IWorkspace,
options?: { reuse?: boolean; payload?: object }
) => true,
trusted: true,
};
config = { ...config, workspaceProvider };
}
const domElement = !!config.domElementId
&& document.getElementById(config.domElementId)
|| document.body;
create(domElement, config);
})();