forked from 71/dance
-
Notifications
You must be signed in to change notification settings - Fork 0
/
extension.ts
50 lines (38 loc) · 1.16 KB
/
extension.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
import * as vscode from "vscode";
import * as api from "./api";
import { Extension } from "./state/extension";
import { extensionId, extensionName } from "./utils/constants";
/**
* Global state of the extension.
*/
export let extensionState: Extension | undefined;
let isActivated = false;
/**
* Function called by VS Code to activate the extension.
*/
export async function activate() {
isActivated = true;
const extensionData = vscode.extensions.getExtension(extensionId),
extensionPackageJSON = extensionData?.packageJSON;
if (extensionPackageJSON?.[`${extensionName}.disableArbitraryCodeExecution`]) {
api.disableRunFunction();
} else {
api.setRunGlobals({ vscode, ...api });
}
if (extensionPackageJSON?.[`${extensionName}.disableArbitraryCommandExecution`]) {
api.disableExecuteFunction();
}
const { commands } = await import("./commands/load-all");
if (!isActivated) {
return;
}
return { api, extension: (extensionState = new Extension(commands)) };
}
/**
* Function called by VS Code to deactivate the extension.
*/
export function deactivate() {
isActivated = false;
extensionState?.dispose();
}
export { api };