MCPcopy Create free account
hub / github.com/coder/ghostty-web / load

Method load

lib/ghostty.ts:63–97  ·  view source on GitHub ↗
(wasmPath?: string)

Source from the content-addressed store, hash-verified

61 }
62
63 static async load(wasmPath?: string): Promise<Ghostty> {
64 // If explicit path provided, use it
65 if (wasmPath) {
66 return Ghostty.loadFromPath(wasmPath);
67 }
68
69 // Resolve path relative to this module
70 const moduleUrl = new URL('../ghostty-vt.wasm', import.meta.url);
71
72 // Build paths to try, prioritizing file system paths for Node/Bun
73 const defaultPaths: string[] = [];
74
75 // For Node/Bun: try absolute file path first (strip file:// protocol)
76 if (moduleUrl.protocol === 'file:') {
77 let filePath = moduleUrl.pathname;
78 // Remove leading slash on Windows paths (e.g., /C:/ -> C:/)
79 if (filePath.match(/^\/[A-Za-z]:\//)) {
80 filePath = filePath.slice(1);
81 }
82 defaultPaths.push(filePath);
83 }
84
85 // Also try other common paths
86 defaultPaths.push(moduleUrl.href, './ghostty-vt.wasm', '/ghostty-vt.wasm');
87
88 let lastError: Error | null = null;
89 for (const path of defaultPaths) {
90 try {
91 return await Ghostty.loadFromPath(path);
92 } catch (e) {
93 lastError = e instanceof Error ? e : new Error(String(e));
94 }
95 }
96 throw lastError || new Error('Failed to load Ghostty WASM');
97 }
98
99 private static async loadFromPath(path: string): Promise<Ghostty> {
100 let wasmBytes: ArrayBuffer | undefined;

Callers 4

initFunction · 0.80
createIsolatedTerminalFunction · 0.80
withTerminalsFunction · 0.80

Calls 1

loadFromPathMethod · 0.80

Tested by

no test coverage detected