MCPcopy Create free account
hub / github.com/Zoo-Code-Org/Zoo-Code / importVscode

Function importVscode

packages/cloud/src/importVscode.ts:13–44  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

11 * Returns undefined if not running in a VSCode extension context.
12 */
13export async function importVscode(): Promise<typeof import("vscode") | undefined> {
14 if (vscodeModule) {
15 return vscodeModule
16 }
17
18 try {
19 if (typeof require !== "undefined") {
20 try {
21 // eslint-disable-next-line @typescript-eslint/no-require-imports
22 vscodeModule = require("vscode")
23
24 if (vscodeModule) {
25 console.log("VS Code module loaded from require")
26 return vscodeModule
27 }
28 } catch (error) {
29 console.error(`Error loading VS Code module: ${error instanceof Error ? error.message : String(error)}`)
30 // Fall through to dynamic import.
31 }
32 }
33
34 vscodeModule = await import("vscode")
35 console.log("VS Code module loaded from dynamic import")
36 return vscodeModule
37 } catch (error) {
38 console.warn(
39 `VS Code module not available in this environment: ${error instanceof Error ? error.message : String(error)}`,
40 )
41
42 return undefined
43 }
44}

Callers 4

loginMethod · 0.85
handleCallbackMethod · 0.85
logoutMethod · 0.85
shareTaskMethod · 0.85

Calls 4

logMethod · 0.65
errorMethod · 0.65
warnMethod · 0.65
StringInterface · 0.50

Tested by

no test coverage detected