@willbooster/web-tree-sitter 1.0.4 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/debug/web-tree-sitter.cjs +15 -14
- package/debug/web-tree-sitter.cjs.map +2 -2
- package/debug/web-tree-sitter.js +15 -14
- package/debug/web-tree-sitter.js.map +2 -2
- package/package.json +8 -1
- package/web-tree-sitter.cjs +15 -14
- package/web-tree-sitter.cjs.map +2 -2
- package/web-tree-sitter.d.cts +0 -7
- package/web-tree-sitter.d.cts.map +1 -1
- package/web-tree-sitter.d.ts +0 -7
- package/web-tree-sitter.d.ts.map +1 -1
- package/web-tree-sitter.js +15 -14
- package/web-tree-sitter.js.map +2 -2
- package/web-tree-sitter.web.js +15 -14
- package/web-tree-sitter.web.js.map +2 -2
package/web-tree-sitter.web.js
CHANGED
|
@@ -1364,7 +1364,7 @@ __name(unmarshalLanguageMetadata, "unmarshalLanguageMetadata");
|
|
|
1364
1364
|
|
|
1365
1365
|
// src/language.ts
|
|
1366
1366
|
var LANGUAGE_FUNCTION_REGEX = /^tree_sitter_\w+$/;
|
|
1367
|
-
var Language = class
|
|
1367
|
+
var Language = class {
|
|
1368
1368
|
static {
|
|
1369
1369
|
__name(this, "Language");
|
|
1370
1370
|
}
|
|
@@ -1583,18 +1583,7 @@ ${body2}`);
|
|
|
1583
1583
|
}
|
|
1584
1584
|
}
|
|
1585
1585
|
const mod = await C.loadWebAssemblyModule(binary2, { loadAsync: true });
|
|
1586
|
-
return
|
|
1587
|
-
}
|
|
1588
|
-
static loadFromWasmExports(mod, { sync }) {
|
|
1589
|
-
const symbolNames = Object.keys(mod);
|
|
1590
|
-
const functionName = symbolNames.find((key) => LANGUAGE_FUNCTION_REGEX.test(key) && !key.includes("external_scanner_"));
|
|
1591
|
-
if (!functionName) {
|
|
1592
|
-
console.log(`Couldn't find language function in Wasm file. Symbols:
|
|
1593
|
-
${JSON.stringify(symbolNames, null, 2)}`);
|
|
1594
|
-
throw new Error(`Language.${sync ? "loadSync" : "load"} failed: no language function found in Wasm file`);
|
|
1595
|
-
}
|
|
1596
|
-
const languageAddress = mod[functionName]();
|
|
1597
|
-
return new _Language(INTERNAL, languageAddress);
|
|
1586
|
+
return loadFromWasmExports(mod, { sync: false });
|
|
1598
1587
|
}
|
|
1599
1588
|
/**
|
|
1600
1589
|
* Load a language synchronously from a pre-compiled WebAssembly module.
|
|
@@ -1602,9 +1591,21 @@ ${JSON.stringify(symbolNames, null, 2)}`);
|
|
|
1602
1591
|
*/
|
|
1603
1592
|
static loadSync(wasmModule) {
|
|
1604
1593
|
const mod = C.loadWebAssemblyModule(wasmModule, { loadAsync: false });
|
|
1605
|
-
return
|
|
1594
|
+
return loadFromWasmExports(mod, { sync: true });
|
|
1606
1595
|
}
|
|
1607
1596
|
};
|
|
1597
|
+
function loadFromWasmExports(mod, { sync }) {
|
|
1598
|
+
const symbolNames = Object.keys(mod);
|
|
1599
|
+
const functionName = symbolNames.find((key) => LANGUAGE_FUNCTION_REGEX.test(key) && !key.includes("external_scanner_"));
|
|
1600
|
+
if (!functionName) {
|
|
1601
|
+
console.log(`Couldn't find language function in Wasm file. Symbols:
|
|
1602
|
+
${JSON.stringify(symbolNames, null, 2)}`);
|
|
1603
|
+
throw new Error(`Language.${sync ? "loadSync" : "load"} failed: no language function found in Wasm file`);
|
|
1604
|
+
}
|
|
1605
|
+
const languageAddress = mod[functionName]();
|
|
1606
|
+
return new Language(INTERNAL, languageAddress);
|
|
1607
|
+
}
|
|
1608
|
+
__name(loadFromWasmExports, "loadFromWasmExports");
|
|
1608
1609
|
|
|
1609
1610
|
// lib/web-tree-sitter.mjs
|
|
1610
1611
|
async function Module2(moduleArg = {}) {
|