MCPcopy Index your code
hub / github.com/CodeGraphContext/CodeGraphContext / load

Method load

website/public/wasm/web-tree-sitter.js:1482–1516  ·  view source on GitHub ↗

* Load a language from a WebAssembly module. * The module can be provided as a path to a file or as a buffer.

(input)

Source from the content-addressed store, hash-verified

1480 * The module can be provided as a path to a file or as a buffer.
1481 */
1482 static async load(input) {
1483 let binary2;
1484 if (input instanceof Uint8Array) {
1485 binary2 = input;
1486 } else if (globalThis.process?.versions.node) {
1487 const fs2 = await import("fs/promises");
1488 binary2 = await fs2.readFile(input);
1489 } else {
1490 const response = await fetch(input);
1491 if (!response.ok) {
1492 const body2 = await response.text();
1493 throw new Error(`Language.load failed with status ${response.status}.
1494
1495${body2}`);
1496 }
1497 const retryResp = response.clone();
1498 try {
1499 binary2 = await WebAssembly.compileStreaming(response);
1500 } catch (reason) {
1501 console.error("wasm streaming compile failed:", reason);
1502 console.error("falling back to ArrayBuffer instantiation");
1503 binary2 = new Uint8Array(await retryResp.arrayBuffer());
1504 }
1505 }
1506 const mod = await C.loadWebAssemblyModule(binary2, { loadAsync: true });
1507 const symbolNames = Object.keys(mod);
1508 const functionName = symbolNames.find((key) => LANGUAGE_FUNCTION_REGEX.test(key) && !key.includes("external_scanner_"));
1509 if (!functionName) {
1510 console.log(`Couldn't find language function in Wasm file. Symbols:
1511${JSON.stringify(symbolNames, null, 2)}`);
1512 throw new Error("Language.load failed: no language function found in Wasm file");
1513 }
1514 const languageAddress = mod[functionName]();
1515 return new _Language(INTERNAL, languageAddress);
1516 }
1517};
1518
1519// lib/web-tree-sitter.mjs

Callers 8

_load_disabled_toolsMethod · 0.45
import_from_bundleMethod · 0.45
_validate_bundleMethod · 0.45
_import_schemaMethod · 0.45
_load_credentialsFunction · 0.45
convert_mcp_json_to_yamlFunction · 0.45
_configure_ideFunction · 0.45
getLanguageForFileFunction · 0.45

Calls 5

errorMethod · 0.80
loadWebAssemblyModuleMethod · 0.80
keysMethod · 0.80
logMethod · 0.80
textMethod · 0.45

Tested by

no test coverage detected