oh-my-opencode 0.1.7 → 0.1.8
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/README.ko.md +1 -1
- package/dist/index.js +3634 -277
- package/package.json +1 -1
- /package/{README.en.md → README.md} +0 -0
package/dist/index.js
CHANGED
|
@@ -1,16 +1,2905 @@
|
|
|
1
1
|
// @bun
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
2
4
|
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __toESM = (mod, isNodeMode, target) => {
|
|
8
|
+
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
9
|
+
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
10
|
+
for (let key of __getOwnPropNames(mod))
|
|
11
|
+
if (!__hasOwnProp.call(to, key))
|
|
12
|
+
__defProp(to, key, {
|
|
13
|
+
get: () => mod[key],
|
|
14
|
+
enumerable: true
|
|
15
|
+
});
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
3
19
|
var __export = (target, all) => {
|
|
4
|
-
for (var
|
|
5
|
-
__defProp(target,
|
|
6
|
-
get: all[
|
|
20
|
+
for (var name2 in all)
|
|
21
|
+
__defProp(target, name2, {
|
|
22
|
+
get: all[name2],
|
|
7
23
|
enumerable: true,
|
|
8
24
|
configurable: true,
|
|
9
|
-
set: (newValue) => all[
|
|
25
|
+
set: (newValue) => all[name2] = () => newValue
|
|
10
26
|
});
|
|
11
27
|
};
|
|
12
28
|
var __require = import.meta.require;
|
|
13
29
|
|
|
30
|
+
// node_modules/web-tree-sitter/tree-sitter.js
|
|
31
|
+
var require_tree_sitter = __commonJS((exports, module2) => {
|
|
32
|
+
var __dirname = "/home/runner/work/oh-my-opencode/oh-my-opencode/node_modules/web-tree-sitter";
|
|
33
|
+
var Module = typeof Module != "undefined" ? Module : {};
|
|
34
|
+
var ENVIRONMENT_IS_WEB = typeof window == "object";
|
|
35
|
+
var ENVIRONMENT_IS_WORKER = typeof importScripts == "function";
|
|
36
|
+
var ENVIRONMENT_IS_NODE = typeof process == "object" && typeof process.versions == "object" && typeof process.versions.node == "string";
|
|
37
|
+
if (ENVIRONMENT_IS_NODE) {}
|
|
38
|
+
var TreeSitter = function() {
|
|
39
|
+
var initPromise;
|
|
40
|
+
var document = typeof window == "object" ? {
|
|
41
|
+
currentScript: window.document.currentScript
|
|
42
|
+
} : null;
|
|
43
|
+
|
|
44
|
+
class Parser {
|
|
45
|
+
constructor() {
|
|
46
|
+
this.initialize();
|
|
47
|
+
}
|
|
48
|
+
initialize() {
|
|
49
|
+
throw new Error("cannot construct a Parser before calling `init()`");
|
|
50
|
+
}
|
|
51
|
+
static init(moduleOptions) {
|
|
52
|
+
if (initPromise)
|
|
53
|
+
return initPromise;
|
|
54
|
+
Module = Object.assign({}, Module, moduleOptions);
|
|
55
|
+
return initPromise = new Promise((resolveInitPromise) => {
|
|
56
|
+
var moduleOverrides = Object.assign({}, Module);
|
|
57
|
+
var arguments_ = [];
|
|
58
|
+
var thisProgram = "./this.program";
|
|
59
|
+
var quit_ = (status, toThrow) => {
|
|
60
|
+
throw toThrow;
|
|
61
|
+
};
|
|
62
|
+
var scriptDirectory = "";
|
|
63
|
+
function locateFile(path) {
|
|
64
|
+
if (Module["locateFile"]) {
|
|
65
|
+
return Module["locateFile"](path, scriptDirectory);
|
|
66
|
+
}
|
|
67
|
+
return scriptDirectory + path;
|
|
68
|
+
}
|
|
69
|
+
var readAsync, readBinary;
|
|
70
|
+
if (ENVIRONMENT_IS_NODE) {
|
|
71
|
+
var fs = __require("fs");
|
|
72
|
+
var nodePath = __require("path");
|
|
73
|
+
scriptDirectory = __dirname + "/";
|
|
74
|
+
readBinary = (filename) => {
|
|
75
|
+
filename = isFileURI(filename) ? new URL(filename) : nodePath.normalize(filename);
|
|
76
|
+
var ret = fs.readFileSync(filename);
|
|
77
|
+
return ret;
|
|
78
|
+
};
|
|
79
|
+
readAsync = (filename, binary2 = true) => {
|
|
80
|
+
filename = isFileURI(filename) ? new URL(filename) : nodePath.normalize(filename);
|
|
81
|
+
return new Promise((resolve, reject) => {
|
|
82
|
+
fs.readFile(filename, binary2 ? undefined : "utf8", (err2, data) => {
|
|
83
|
+
if (err2)
|
|
84
|
+
reject(err2);
|
|
85
|
+
else
|
|
86
|
+
resolve(binary2 ? data.buffer : data);
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
};
|
|
90
|
+
if (!Module["thisProgram"] && process.argv.length > 1) {
|
|
91
|
+
thisProgram = process.argv[1].replace(/\\/g, "/");
|
|
92
|
+
}
|
|
93
|
+
arguments_ = process.argv.slice(2);
|
|
94
|
+
if (typeof module2 != "undefined") {
|
|
95
|
+
module2["exports"] = Module;
|
|
96
|
+
}
|
|
97
|
+
quit_ = (status, toThrow) => {
|
|
98
|
+
process.exitCode = status;
|
|
99
|
+
throw toThrow;
|
|
100
|
+
};
|
|
101
|
+
} else if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) {
|
|
102
|
+
if (ENVIRONMENT_IS_WORKER) {
|
|
103
|
+
scriptDirectory = self.location.href;
|
|
104
|
+
} else if (typeof document != "undefined" && document.currentScript) {
|
|
105
|
+
scriptDirectory = document.currentScript.src;
|
|
106
|
+
}
|
|
107
|
+
if (scriptDirectory.startsWith("blob:")) {
|
|
108
|
+
scriptDirectory = "";
|
|
109
|
+
} else {
|
|
110
|
+
scriptDirectory = scriptDirectory.substr(0, scriptDirectory.replace(/[?#].*/, "").lastIndexOf("/") + 1);
|
|
111
|
+
}
|
|
112
|
+
{
|
|
113
|
+
if (ENVIRONMENT_IS_WORKER) {
|
|
114
|
+
readBinary = (url) => {
|
|
115
|
+
var xhr = new XMLHttpRequest;
|
|
116
|
+
xhr.open("GET", url, false);
|
|
117
|
+
xhr.responseType = "arraybuffer";
|
|
118
|
+
xhr.send(null);
|
|
119
|
+
return new Uint8Array(xhr.response);
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
readAsync = (url) => {
|
|
123
|
+
if (isFileURI(url)) {
|
|
124
|
+
return new Promise((reject, resolve) => {
|
|
125
|
+
var xhr = new XMLHttpRequest;
|
|
126
|
+
xhr.open("GET", url, true);
|
|
127
|
+
xhr.responseType = "arraybuffer";
|
|
128
|
+
xhr.onload = () => {
|
|
129
|
+
if (xhr.status == 200 || xhr.status == 0 && xhr.response) {
|
|
130
|
+
resolve(xhr.response);
|
|
131
|
+
}
|
|
132
|
+
reject(xhr.status);
|
|
133
|
+
};
|
|
134
|
+
xhr.onerror = reject;
|
|
135
|
+
xhr.send(null);
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
return fetch(url, {
|
|
139
|
+
credentials: "same-origin"
|
|
140
|
+
}).then((response) => {
|
|
141
|
+
if (response.ok) {
|
|
142
|
+
return response.arrayBuffer();
|
|
143
|
+
}
|
|
144
|
+
return Promise.reject(new Error(response.status + " : " + response.url));
|
|
145
|
+
});
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
} else {}
|
|
149
|
+
var out = Module["print"] || console.log.bind(console);
|
|
150
|
+
var err = Module["printErr"] || console.error.bind(console);
|
|
151
|
+
Object.assign(Module, moduleOverrides);
|
|
152
|
+
moduleOverrides = null;
|
|
153
|
+
if (Module["arguments"])
|
|
154
|
+
arguments_ = Module["arguments"];
|
|
155
|
+
if (Module["thisProgram"])
|
|
156
|
+
thisProgram = Module["thisProgram"];
|
|
157
|
+
if (Module["quit"])
|
|
158
|
+
quit_ = Module["quit"];
|
|
159
|
+
var dynamicLibraries = Module["dynamicLibraries"] || [];
|
|
160
|
+
var wasmBinary;
|
|
161
|
+
if (Module["wasmBinary"])
|
|
162
|
+
wasmBinary = Module["wasmBinary"];
|
|
163
|
+
var wasmMemory;
|
|
164
|
+
var ABORT = false;
|
|
165
|
+
var EXITSTATUS;
|
|
166
|
+
var HEAP8, HEAPU8, HEAP16, HEAPU16, HEAP32, HEAPU32, HEAPF32, HEAPF64;
|
|
167
|
+
var HEAP_DATA_VIEW;
|
|
168
|
+
function updateMemoryViews() {
|
|
169
|
+
var b = wasmMemory.buffer;
|
|
170
|
+
Module["HEAP_DATA_VIEW"] = HEAP_DATA_VIEW = new DataView(b);
|
|
171
|
+
Module["HEAP8"] = HEAP8 = new Int8Array(b);
|
|
172
|
+
Module["HEAP16"] = HEAP16 = new Int16Array(b);
|
|
173
|
+
Module["HEAPU8"] = HEAPU8 = new Uint8Array(b);
|
|
174
|
+
Module["HEAPU16"] = HEAPU16 = new Uint16Array(b);
|
|
175
|
+
Module["HEAP32"] = HEAP32 = new Int32Array(b);
|
|
176
|
+
Module["HEAPU32"] = HEAPU32 = new Uint32Array(b);
|
|
177
|
+
Module["HEAPF32"] = HEAPF32 = new Float32Array(b);
|
|
178
|
+
Module["HEAPF64"] = HEAPF64 = new Float64Array(b);
|
|
179
|
+
}
|
|
180
|
+
if (Module["wasmMemory"]) {
|
|
181
|
+
wasmMemory = Module["wasmMemory"];
|
|
182
|
+
} else {
|
|
183
|
+
var INITIAL_MEMORY = Module["INITIAL_MEMORY"] || 33554432;
|
|
184
|
+
wasmMemory = new WebAssembly.Memory({
|
|
185
|
+
initial: INITIAL_MEMORY / 65536,
|
|
186
|
+
maximum: 2147483648 / 65536
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
updateMemoryViews();
|
|
190
|
+
var __ATPRERUN__ = [];
|
|
191
|
+
var __ATINIT__ = [];
|
|
192
|
+
var __ATMAIN__ = [];
|
|
193
|
+
var __ATPOSTRUN__ = [];
|
|
194
|
+
var __RELOC_FUNCS__ = [];
|
|
195
|
+
var runtimeInitialized = false;
|
|
196
|
+
function preRun() {
|
|
197
|
+
if (Module["preRun"]) {
|
|
198
|
+
if (typeof Module["preRun"] == "function")
|
|
199
|
+
Module["preRun"] = [Module["preRun"]];
|
|
200
|
+
while (Module["preRun"].length) {
|
|
201
|
+
addOnPreRun(Module["preRun"].shift());
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
callRuntimeCallbacks(__ATPRERUN__);
|
|
205
|
+
}
|
|
206
|
+
function initRuntime() {
|
|
207
|
+
runtimeInitialized = true;
|
|
208
|
+
callRuntimeCallbacks(__RELOC_FUNCS__);
|
|
209
|
+
callRuntimeCallbacks(__ATINIT__);
|
|
210
|
+
}
|
|
211
|
+
function preMain() {
|
|
212
|
+
callRuntimeCallbacks(__ATMAIN__);
|
|
213
|
+
}
|
|
214
|
+
function postRun() {
|
|
215
|
+
if (Module["postRun"]) {
|
|
216
|
+
if (typeof Module["postRun"] == "function")
|
|
217
|
+
Module["postRun"] = [Module["postRun"]];
|
|
218
|
+
while (Module["postRun"].length) {
|
|
219
|
+
addOnPostRun(Module["postRun"].shift());
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
callRuntimeCallbacks(__ATPOSTRUN__);
|
|
223
|
+
}
|
|
224
|
+
function addOnPreRun(cb) {
|
|
225
|
+
__ATPRERUN__.unshift(cb);
|
|
226
|
+
}
|
|
227
|
+
function addOnInit(cb) {
|
|
228
|
+
__ATINIT__.unshift(cb);
|
|
229
|
+
}
|
|
230
|
+
function addOnPostRun(cb) {
|
|
231
|
+
__ATPOSTRUN__.unshift(cb);
|
|
232
|
+
}
|
|
233
|
+
var runDependencies = 0;
|
|
234
|
+
var runDependencyWatcher = null;
|
|
235
|
+
var dependenciesFulfilled = null;
|
|
236
|
+
function getUniqueRunDependency(id) {
|
|
237
|
+
return id;
|
|
238
|
+
}
|
|
239
|
+
function addRunDependency(id) {
|
|
240
|
+
runDependencies++;
|
|
241
|
+
Module["monitorRunDependencies"]?.(runDependencies);
|
|
242
|
+
}
|
|
243
|
+
function removeRunDependency(id) {
|
|
244
|
+
runDependencies--;
|
|
245
|
+
Module["monitorRunDependencies"]?.(runDependencies);
|
|
246
|
+
if (runDependencies == 0) {
|
|
247
|
+
if (runDependencyWatcher !== null) {
|
|
248
|
+
clearInterval(runDependencyWatcher);
|
|
249
|
+
runDependencyWatcher = null;
|
|
250
|
+
}
|
|
251
|
+
if (dependenciesFulfilled) {
|
|
252
|
+
var callback = dependenciesFulfilled;
|
|
253
|
+
dependenciesFulfilled = null;
|
|
254
|
+
callback();
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
function abort(what) {
|
|
259
|
+
Module["onAbort"]?.(what);
|
|
260
|
+
what = "Aborted(" + what + ")";
|
|
261
|
+
err(what);
|
|
262
|
+
ABORT = true;
|
|
263
|
+
EXITSTATUS = 1;
|
|
264
|
+
what += ". Build with -sASSERTIONS for more info.";
|
|
265
|
+
var e = new WebAssembly.RuntimeError(what);
|
|
266
|
+
throw e;
|
|
267
|
+
}
|
|
268
|
+
var dataURIPrefix = "data:application/octet-stream;base64,";
|
|
269
|
+
var isDataURI = (filename) => filename.startsWith(dataURIPrefix);
|
|
270
|
+
var isFileURI = (filename) => filename.startsWith("file://");
|
|
271
|
+
function findWasmBinary() {
|
|
272
|
+
var f = "tree-sitter.wasm";
|
|
273
|
+
if (!isDataURI(f)) {
|
|
274
|
+
return locateFile(f);
|
|
275
|
+
}
|
|
276
|
+
return f;
|
|
277
|
+
}
|
|
278
|
+
var wasmBinaryFile;
|
|
279
|
+
function getBinarySync(file) {
|
|
280
|
+
if (file == wasmBinaryFile && wasmBinary) {
|
|
281
|
+
return new Uint8Array(wasmBinary);
|
|
282
|
+
}
|
|
283
|
+
if (readBinary) {
|
|
284
|
+
return readBinary(file);
|
|
285
|
+
}
|
|
286
|
+
throw "both async and sync fetching of the wasm failed";
|
|
287
|
+
}
|
|
288
|
+
function getBinaryPromise(binaryFile) {
|
|
289
|
+
if (!wasmBinary) {
|
|
290
|
+
return readAsync(binaryFile).then((response) => new Uint8Array(response), () => getBinarySync(binaryFile));
|
|
291
|
+
}
|
|
292
|
+
return Promise.resolve().then(() => getBinarySync(binaryFile));
|
|
293
|
+
}
|
|
294
|
+
function instantiateArrayBuffer(binaryFile, imports, receiver) {
|
|
295
|
+
return getBinaryPromise(binaryFile).then((binary2) => WebAssembly.instantiate(binary2, imports)).then(receiver, (reason) => {
|
|
296
|
+
err(`failed to asynchronously prepare wasm: ${reason}`);
|
|
297
|
+
abort(reason);
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
function instantiateAsync(binary2, binaryFile, imports, callback) {
|
|
301
|
+
if (!binary2 && typeof WebAssembly.instantiateStreaming == "function" && !isDataURI(binaryFile) && !isFileURI(binaryFile) && !ENVIRONMENT_IS_NODE && typeof fetch == "function") {
|
|
302
|
+
return fetch(binaryFile, {
|
|
303
|
+
credentials: "same-origin"
|
|
304
|
+
}).then((response) => {
|
|
305
|
+
var result = WebAssembly.instantiateStreaming(response, imports);
|
|
306
|
+
return result.then(callback, function(reason) {
|
|
307
|
+
err(`wasm streaming compile failed: ${reason}`);
|
|
308
|
+
err("falling back to ArrayBuffer instantiation");
|
|
309
|
+
return instantiateArrayBuffer(binaryFile, imports, callback);
|
|
310
|
+
});
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
return instantiateArrayBuffer(binaryFile, imports, callback);
|
|
314
|
+
}
|
|
315
|
+
function getWasmImports() {
|
|
316
|
+
return {
|
|
317
|
+
env: wasmImports,
|
|
318
|
+
wasi_snapshot_preview1: wasmImports,
|
|
319
|
+
"GOT.mem": new Proxy(wasmImports, GOTHandler),
|
|
320
|
+
"GOT.func": new Proxy(wasmImports, GOTHandler)
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
function createWasm() {
|
|
324
|
+
var info2 = getWasmImports();
|
|
325
|
+
function receiveInstance(instance2, module3) {
|
|
326
|
+
wasmExports = instance2.exports;
|
|
327
|
+
wasmExports = relocateExports(wasmExports, 1024);
|
|
328
|
+
var metadata2 = getDylinkMetadata(module3);
|
|
329
|
+
if (metadata2.neededDynlibs) {
|
|
330
|
+
dynamicLibraries = metadata2.neededDynlibs.concat(dynamicLibraries);
|
|
331
|
+
}
|
|
332
|
+
mergeLibSymbols(wasmExports, "main");
|
|
333
|
+
LDSO.init();
|
|
334
|
+
loadDylibs();
|
|
335
|
+
addOnInit(wasmExports["__wasm_call_ctors"]);
|
|
336
|
+
__RELOC_FUNCS__.push(wasmExports["__wasm_apply_data_relocs"]);
|
|
337
|
+
removeRunDependency("wasm-instantiate");
|
|
338
|
+
return wasmExports;
|
|
339
|
+
}
|
|
340
|
+
addRunDependency("wasm-instantiate");
|
|
341
|
+
function receiveInstantiationResult(result) {
|
|
342
|
+
receiveInstance(result["instance"], result["module"]);
|
|
343
|
+
}
|
|
344
|
+
if (Module["instantiateWasm"]) {
|
|
345
|
+
try {
|
|
346
|
+
return Module["instantiateWasm"](info2, receiveInstance);
|
|
347
|
+
} catch (e) {
|
|
348
|
+
err(`Module.instantiateWasm callback failed with error: ${e}`);
|
|
349
|
+
return false;
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
if (!wasmBinaryFile)
|
|
353
|
+
wasmBinaryFile = findWasmBinary();
|
|
354
|
+
instantiateAsync(wasmBinary, wasmBinaryFile, info2, receiveInstantiationResult);
|
|
355
|
+
return {};
|
|
356
|
+
}
|
|
357
|
+
var ASM_CONSTS = {};
|
|
358
|
+
function ExitStatus(status) {
|
|
359
|
+
this.name = "ExitStatus";
|
|
360
|
+
this.message = `Program terminated with exit(${status})`;
|
|
361
|
+
this.status = status;
|
|
362
|
+
}
|
|
363
|
+
var GOT = {};
|
|
364
|
+
var currentModuleWeakSymbols = new Set([]);
|
|
365
|
+
var GOTHandler = {
|
|
366
|
+
get(obj, symName) {
|
|
367
|
+
var rtn = GOT[symName];
|
|
368
|
+
if (!rtn) {
|
|
369
|
+
rtn = GOT[symName] = new WebAssembly.Global({
|
|
370
|
+
value: "i32",
|
|
371
|
+
mutable: true
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
if (!currentModuleWeakSymbols.has(symName)) {
|
|
375
|
+
rtn.required = true;
|
|
376
|
+
}
|
|
377
|
+
return rtn;
|
|
378
|
+
}
|
|
379
|
+
};
|
|
380
|
+
var LE_HEAP_LOAD_F32 = (byteOffset) => HEAP_DATA_VIEW.getFloat32(byteOffset, true);
|
|
381
|
+
var LE_HEAP_LOAD_F64 = (byteOffset) => HEAP_DATA_VIEW.getFloat64(byteOffset, true);
|
|
382
|
+
var LE_HEAP_LOAD_I16 = (byteOffset) => HEAP_DATA_VIEW.getInt16(byteOffset, true);
|
|
383
|
+
var LE_HEAP_LOAD_I32 = (byteOffset) => HEAP_DATA_VIEW.getInt32(byteOffset, true);
|
|
384
|
+
var LE_HEAP_LOAD_U32 = (byteOffset) => HEAP_DATA_VIEW.getUint32(byteOffset, true);
|
|
385
|
+
var LE_HEAP_STORE_F32 = (byteOffset, value) => HEAP_DATA_VIEW.setFloat32(byteOffset, value, true);
|
|
386
|
+
var LE_HEAP_STORE_F64 = (byteOffset, value) => HEAP_DATA_VIEW.setFloat64(byteOffset, value, true);
|
|
387
|
+
var LE_HEAP_STORE_I16 = (byteOffset, value) => HEAP_DATA_VIEW.setInt16(byteOffset, value, true);
|
|
388
|
+
var LE_HEAP_STORE_I32 = (byteOffset, value) => HEAP_DATA_VIEW.setInt32(byteOffset, value, true);
|
|
389
|
+
var LE_HEAP_STORE_U32 = (byteOffset, value) => HEAP_DATA_VIEW.setUint32(byteOffset, value, true);
|
|
390
|
+
var callRuntimeCallbacks = (callbacks) => {
|
|
391
|
+
while (callbacks.length > 0) {
|
|
392
|
+
callbacks.shift()(Module);
|
|
393
|
+
}
|
|
394
|
+
};
|
|
395
|
+
var UTF8Decoder = typeof TextDecoder != "undefined" ? new TextDecoder : undefined;
|
|
396
|
+
var UTF8ArrayToString = (heapOrArray, idx, maxBytesToRead) => {
|
|
397
|
+
var endIdx = idx + maxBytesToRead;
|
|
398
|
+
var endPtr = idx;
|
|
399
|
+
while (heapOrArray[endPtr] && !(endPtr >= endIdx))
|
|
400
|
+
++endPtr;
|
|
401
|
+
if (endPtr - idx > 16 && heapOrArray.buffer && UTF8Decoder) {
|
|
402
|
+
return UTF8Decoder.decode(heapOrArray.subarray(idx, endPtr));
|
|
403
|
+
}
|
|
404
|
+
var str = "";
|
|
405
|
+
while (idx < endPtr) {
|
|
406
|
+
var u0 = heapOrArray[idx++];
|
|
407
|
+
if (!(u0 & 128)) {
|
|
408
|
+
str += String.fromCharCode(u0);
|
|
409
|
+
continue;
|
|
410
|
+
}
|
|
411
|
+
var u1 = heapOrArray[idx++] & 63;
|
|
412
|
+
if ((u0 & 224) == 192) {
|
|
413
|
+
str += String.fromCharCode((u0 & 31) << 6 | u1);
|
|
414
|
+
continue;
|
|
415
|
+
}
|
|
416
|
+
var u2 = heapOrArray[idx++] & 63;
|
|
417
|
+
if ((u0 & 240) == 224) {
|
|
418
|
+
u0 = (u0 & 15) << 12 | u1 << 6 | u2;
|
|
419
|
+
} else {
|
|
420
|
+
u0 = (u0 & 7) << 18 | u1 << 12 | u2 << 6 | heapOrArray[idx++] & 63;
|
|
421
|
+
}
|
|
422
|
+
if (u0 < 65536) {
|
|
423
|
+
str += String.fromCharCode(u0);
|
|
424
|
+
} else {
|
|
425
|
+
var ch = u0 - 65536;
|
|
426
|
+
str += String.fromCharCode(55296 | ch >> 10, 56320 | ch & 1023);
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
return str;
|
|
430
|
+
};
|
|
431
|
+
var getDylinkMetadata = (binary2) => {
|
|
432
|
+
var offset = 0;
|
|
433
|
+
var end = 0;
|
|
434
|
+
function getU8() {
|
|
435
|
+
return binary2[offset++];
|
|
436
|
+
}
|
|
437
|
+
function getLEB() {
|
|
438
|
+
var ret = 0;
|
|
439
|
+
var mul = 1;
|
|
440
|
+
while (true) {
|
|
441
|
+
var byte = binary2[offset++];
|
|
442
|
+
ret += (byte & 127) * mul;
|
|
443
|
+
mul *= 128;
|
|
444
|
+
if (!(byte & 128))
|
|
445
|
+
break;
|
|
446
|
+
}
|
|
447
|
+
return ret;
|
|
448
|
+
}
|
|
449
|
+
function getString() {
|
|
450
|
+
var len = getLEB();
|
|
451
|
+
offset += len;
|
|
452
|
+
return UTF8ArrayToString(binary2, offset - len, len);
|
|
453
|
+
}
|
|
454
|
+
function failIf(condition, message) {
|
|
455
|
+
if (condition)
|
|
456
|
+
throw new Error(message);
|
|
457
|
+
}
|
|
458
|
+
var name2 = "dylink.0";
|
|
459
|
+
if (binary2 instanceof WebAssembly.Module) {
|
|
460
|
+
var dylinkSection = WebAssembly.Module.customSections(binary2, name2);
|
|
461
|
+
if (dylinkSection.length === 0) {
|
|
462
|
+
name2 = "dylink";
|
|
463
|
+
dylinkSection = WebAssembly.Module.customSections(binary2, name2);
|
|
464
|
+
}
|
|
465
|
+
failIf(dylinkSection.length === 0, "need dylink section");
|
|
466
|
+
binary2 = new Uint8Array(dylinkSection[0]);
|
|
467
|
+
end = binary2.length;
|
|
468
|
+
} else {
|
|
469
|
+
var int32View = new Uint32Array(new Uint8Array(binary2.subarray(0, 24)).buffer);
|
|
470
|
+
var magicNumberFound = int32View[0] == 1836278016 || int32View[0] == 6386541;
|
|
471
|
+
failIf(!magicNumberFound, "need to see wasm magic number");
|
|
472
|
+
failIf(binary2[8] !== 0, "need the dylink section to be first");
|
|
473
|
+
offset = 9;
|
|
474
|
+
var section_size = getLEB();
|
|
475
|
+
end = offset + section_size;
|
|
476
|
+
name2 = getString();
|
|
477
|
+
}
|
|
478
|
+
var customSection = {
|
|
479
|
+
neededDynlibs: [],
|
|
480
|
+
tlsExports: new Set,
|
|
481
|
+
weakImports: new Set
|
|
482
|
+
};
|
|
483
|
+
if (name2 == "dylink") {
|
|
484
|
+
customSection.memorySize = getLEB();
|
|
485
|
+
customSection.memoryAlign = getLEB();
|
|
486
|
+
customSection.tableSize = getLEB();
|
|
487
|
+
customSection.tableAlign = getLEB();
|
|
488
|
+
var neededDynlibsCount = getLEB();
|
|
489
|
+
for (var i2 = 0;i2 < neededDynlibsCount; ++i2) {
|
|
490
|
+
var libname = getString();
|
|
491
|
+
customSection.neededDynlibs.push(libname);
|
|
492
|
+
}
|
|
493
|
+
} else {
|
|
494
|
+
failIf(name2 !== "dylink.0");
|
|
495
|
+
var WASM_DYLINK_MEM_INFO = 1;
|
|
496
|
+
var WASM_DYLINK_NEEDED = 2;
|
|
497
|
+
var WASM_DYLINK_EXPORT_INFO = 3;
|
|
498
|
+
var WASM_DYLINK_IMPORT_INFO = 4;
|
|
499
|
+
var WASM_SYMBOL_TLS = 256;
|
|
500
|
+
var WASM_SYMBOL_BINDING_MASK = 3;
|
|
501
|
+
var WASM_SYMBOL_BINDING_WEAK = 1;
|
|
502
|
+
while (offset < end) {
|
|
503
|
+
var subsectionType = getU8();
|
|
504
|
+
var subsectionSize = getLEB();
|
|
505
|
+
if (subsectionType === WASM_DYLINK_MEM_INFO) {
|
|
506
|
+
customSection.memorySize = getLEB();
|
|
507
|
+
customSection.memoryAlign = getLEB();
|
|
508
|
+
customSection.tableSize = getLEB();
|
|
509
|
+
customSection.tableAlign = getLEB();
|
|
510
|
+
} else if (subsectionType === WASM_DYLINK_NEEDED) {
|
|
511
|
+
var neededDynlibsCount = getLEB();
|
|
512
|
+
for (var i2 = 0;i2 < neededDynlibsCount; ++i2) {
|
|
513
|
+
libname = getString();
|
|
514
|
+
customSection.neededDynlibs.push(libname);
|
|
515
|
+
}
|
|
516
|
+
} else if (subsectionType === WASM_DYLINK_EXPORT_INFO) {
|
|
517
|
+
var count = getLEB();
|
|
518
|
+
while (count--) {
|
|
519
|
+
var symname = getString();
|
|
520
|
+
var flags2 = getLEB();
|
|
521
|
+
if (flags2 & WASM_SYMBOL_TLS) {
|
|
522
|
+
customSection.tlsExports.add(symname);
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
} else if (subsectionType === WASM_DYLINK_IMPORT_INFO) {
|
|
526
|
+
var count = getLEB();
|
|
527
|
+
while (count--) {
|
|
528
|
+
var modname = getString();
|
|
529
|
+
var symname = getString();
|
|
530
|
+
var flags2 = getLEB();
|
|
531
|
+
if ((flags2 & WASM_SYMBOL_BINDING_MASK) == WASM_SYMBOL_BINDING_WEAK) {
|
|
532
|
+
customSection.weakImports.add(symname);
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
} else {
|
|
536
|
+
offset += subsectionSize;
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
return customSection;
|
|
541
|
+
};
|
|
542
|
+
function getValue(ptr, type = "i8") {
|
|
543
|
+
if (type.endsWith("*"))
|
|
544
|
+
type = "*";
|
|
545
|
+
switch (type) {
|
|
546
|
+
case "i1":
|
|
547
|
+
return HEAP8[ptr];
|
|
548
|
+
case "i8":
|
|
549
|
+
return HEAP8[ptr];
|
|
550
|
+
case "i16":
|
|
551
|
+
return LE_HEAP_LOAD_I16((ptr >> 1) * 2);
|
|
552
|
+
case "i32":
|
|
553
|
+
return LE_HEAP_LOAD_I32((ptr >> 2) * 4);
|
|
554
|
+
case "i64":
|
|
555
|
+
abort("to do getValue(i64) use WASM_BIGINT");
|
|
556
|
+
case "float":
|
|
557
|
+
return LE_HEAP_LOAD_F32((ptr >> 2) * 4);
|
|
558
|
+
case "double":
|
|
559
|
+
return LE_HEAP_LOAD_F64((ptr >> 3) * 8);
|
|
560
|
+
case "*":
|
|
561
|
+
return LE_HEAP_LOAD_U32((ptr >> 2) * 4);
|
|
562
|
+
default:
|
|
563
|
+
abort(`invalid type for getValue: ${type}`);
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
var newDSO = (name2, handle2, syms) => {
|
|
567
|
+
var dso = {
|
|
568
|
+
refcount: Infinity,
|
|
569
|
+
name: name2,
|
|
570
|
+
exports: syms,
|
|
571
|
+
global: true
|
|
572
|
+
};
|
|
573
|
+
LDSO.loadedLibsByName[name2] = dso;
|
|
574
|
+
if (handle2 != null) {
|
|
575
|
+
LDSO.loadedLibsByHandle[handle2] = dso;
|
|
576
|
+
}
|
|
577
|
+
return dso;
|
|
578
|
+
};
|
|
579
|
+
var LDSO = {
|
|
580
|
+
loadedLibsByName: {},
|
|
581
|
+
loadedLibsByHandle: {},
|
|
582
|
+
init() {
|
|
583
|
+
newDSO("__main__", 0, wasmImports);
|
|
584
|
+
}
|
|
585
|
+
};
|
|
586
|
+
var ___heap_base = 78112;
|
|
587
|
+
var zeroMemory = (address, size) => {
|
|
588
|
+
HEAPU8.fill(0, address, address + size);
|
|
589
|
+
return address;
|
|
590
|
+
};
|
|
591
|
+
var alignMemory = (size, alignment) => Math.ceil(size / alignment) * alignment;
|
|
592
|
+
var getMemory = (size) => {
|
|
593
|
+
if (runtimeInitialized) {
|
|
594
|
+
return zeroMemory(_malloc(size), size);
|
|
595
|
+
}
|
|
596
|
+
var ret = ___heap_base;
|
|
597
|
+
var end = ret + alignMemory(size, 16);
|
|
598
|
+
___heap_base = end;
|
|
599
|
+
GOT["__heap_base"].value = end;
|
|
600
|
+
return ret;
|
|
601
|
+
};
|
|
602
|
+
var isInternalSym = (symName) => ["__cpp_exception", "__c_longjmp", "__wasm_apply_data_relocs", "__dso_handle", "__tls_size", "__tls_align", "__set_stack_limits", "_emscripten_tls_init", "__wasm_init_tls", "__wasm_call_ctors", "__start_em_asm", "__stop_em_asm", "__start_em_js", "__stop_em_js"].includes(symName) || symName.startsWith("__em_js__");
|
|
603
|
+
var uleb128Encode = (n, target) => {
|
|
604
|
+
if (n < 128) {
|
|
605
|
+
target.push(n);
|
|
606
|
+
} else {
|
|
607
|
+
target.push(n % 128 | 128, n >> 7);
|
|
608
|
+
}
|
|
609
|
+
};
|
|
610
|
+
var sigToWasmTypes = (sig) => {
|
|
611
|
+
var typeNames = {
|
|
612
|
+
i: "i32",
|
|
613
|
+
j: "i64",
|
|
614
|
+
f: "f32",
|
|
615
|
+
d: "f64",
|
|
616
|
+
e: "externref",
|
|
617
|
+
p: "i32"
|
|
618
|
+
};
|
|
619
|
+
var type = {
|
|
620
|
+
parameters: [],
|
|
621
|
+
results: sig[0] == "v" ? [] : [typeNames[sig[0]]]
|
|
622
|
+
};
|
|
623
|
+
for (var i2 = 1;i2 < sig.length; ++i2) {
|
|
624
|
+
type.parameters.push(typeNames[sig[i2]]);
|
|
625
|
+
}
|
|
626
|
+
return type;
|
|
627
|
+
};
|
|
628
|
+
var generateFuncType = (sig, target) => {
|
|
629
|
+
var sigRet = sig.slice(0, 1);
|
|
630
|
+
var sigParam = sig.slice(1);
|
|
631
|
+
var typeCodes = {
|
|
632
|
+
i: 127,
|
|
633
|
+
p: 127,
|
|
634
|
+
j: 126,
|
|
635
|
+
f: 125,
|
|
636
|
+
d: 124,
|
|
637
|
+
e: 111
|
|
638
|
+
};
|
|
639
|
+
target.push(96);
|
|
640
|
+
uleb128Encode(sigParam.length, target);
|
|
641
|
+
for (var i2 = 0;i2 < sigParam.length; ++i2) {
|
|
642
|
+
target.push(typeCodes[sigParam[i2]]);
|
|
643
|
+
}
|
|
644
|
+
if (sigRet == "v") {
|
|
645
|
+
target.push(0);
|
|
646
|
+
} else {
|
|
647
|
+
target.push(1, typeCodes[sigRet]);
|
|
648
|
+
}
|
|
649
|
+
};
|
|
650
|
+
var convertJsFunctionToWasm = (func2, sig) => {
|
|
651
|
+
if (typeof WebAssembly.Function == "function") {
|
|
652
|
+
return new WebAssembly.Function(sigToWasmTypes(sig), func2);
|
|
653
|
+
}
|
|
654
|
+
var typeSectionBody = [1];
|
|
655
|
+
generateFuncType(sig, typeSectionBody);
|
|
656
|
+
var bytes = [
|
|
657
|
+
0,
|
|
658
|
+
97,
|
|
659
|
+
115,
|
|
660
|
+
109,
|
|
661
|
+
1,
|
|
662
|
+
0,
|
|
663
|
+
0,
|
|
664
|
+
0,
|
|
665
|
+
1
|
|
666
|
+
];
|
|
667
|
+
uleb128Encode(typeSectionBody.length, bytes);
|
|
668
|
+
bytes.push(...typeSectionBody);
|
|
669
|
+
bytes.push(2, 7, 1, 1, 101, 1, 102, 0, 0, 7, 5, 1, 1, 102, 0, 0);
|
|
670
|
+
var module3 = new WebAssembly.Module(new Uint8Array(bytes));
|
|
671
|
+
var instance2 = new WebAssembly.Instance(module3, {
|
|
672
|
+
e: {
|
|
673
|
+
f: func2
|
|
674
|
+
}
|
|
675
|
+
});
|
|
676
|
+
var wrappedFunc = instance2.exports["f"];
|
|
677
|
+
return wrappedFunc;
|
|
678
|
+
};
|
|
679
|
+
var wasmTableMirror = [];
|
|
680
|
+
var wasmTable = new WebAssembly.Table({
|
|
681
|
+
initial: 28,
|
|
682
|
+
element: "anyfunc"
|
|
683
|
+
});
|
|
684
|
+
var getWasmTableEntry = (funcPtr) => {
|
|
685
|
+
var func2 = wasmTableMirror[funcPtr];
|
|
686
|
+
if (!func2) {
|
|
687
|
+
if (funcPtr >= wasmTableMirror.length)
|
|
688
|
+
wasmTableMirror.length = funcPtr + 1;
|
|
689
|
+
wasmTableMirror[funcPtr] = func2 = wasmTable.get(funcPtr);
|
|
690
|
+
}
|
|
691
|
+
return func2;
|
|
692
|
+
};
|
|
693
|
+
var updateTableMap = (offset, count) => {
|
|
694
|
+
if (functionsInTableMap) {
|
|
695
|
+
for (var i2 = offset;i2 < offset + count; i2++) {
|
|
696
|
+
var item = getWasmTableEntry(i2);
|
|
697
|
+
if (item) {
|
|
698
|
+
functionsInTableMap.set(item, i2);
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
};
|
|
703
|
+
var functionsInTableMap;
|
|
704
|
+
var getFunctionAddress = (func2) => {
|
|
705
|
+
if (!functionsInTableMap) {
|
|
706
|
+
functionsInTableMap = new WeakMap;
|
|
707
|
+
updateTableMap(0, wasmTable.length);
|
|
708
|
+
}
|
|
709
|
+
return functionsInTableMap.get(func2) || 0;
|
|
710
|
+
};
|
|
711
|
+
var freeTableIndexes = [];
|
|
712
|
+
var getEmptyTableSlot = () => {
|
|
713
|
+
if (freeTableIndexes.length) {
|
|
714
|
+
return freeTableIndexes.pop();
|
|
715
|
+
}
|
|
716
|
+
try {
|
|
717
|
+
wasmTable.grow(1);
|
|
718
|
+
} catch (err2) {
|
|
719
|
+
if (!(err2 instanceof RangeError)) {
|
|
720
|
+
throw err2;
|
|
721
|
+
}
|
|
722
|
+
throw "Unable to grow wasm table. Set ALLOW_TABLE_GROWTH.";
|
|
723
|
+
}
|
|
724
|
+
return wasmTable.length - 1;
|
|
725
|
+
};
|
|
726
|
+
var setWasmTableEntry = (idx, func2) => {
|
|
727
|
+
wasmTable.set(idx, func2);
|
|
728
|
+
wasmTableMirror[idx] = wasmTable.get(idx);
|
|
729
|
+
};
|
|
730
|
+
var addFunction = (func2, sig) => {
|
|
731
|
+
var rtn = getFunctionAddress(func2);
|
|
732
|
+
if (rtn) {
|
|
733
|
+
return rtn;
|
|
734
|
+
}
|
|
735
|
+
var ret = getEmptyTableSlot();
|
|
736
|
+
try {
|
|
737
|
+
setWasmTableEntry(ret, func2);
|
|
738
|
+
} catch (err2) {
|
|
739
|
+
if (!(err2 instanceof TypeError)) {
|
|
740
|
+
throw err2;
|
|
741
|
+
}
|
|
742
|
+
var wrapped = convertJsFunctionToWasm(func2, sig);
|
|
743
|
+
setWasmTableEntry(ret, wrapped);
|
|
744
|
+
}
|
|
745
|
+
functionsInTableMap.set(func2, ret);
|
|
746
|
+
return ret;
|
|
747
|
+
};
|
|
748
|
+
var updateGOT = (exports2, replace) => {
|
|
749
|
+
for (var symName in exports2) {
|
|
750
|
+
if (isInternalSym(symName)) {
|
|
751
|
+
continue;
|
|
752
|
+
}
|
|
753
|
+
var value = exports2[symName];
|
|
754
|
+
if (symName.startsWith("orig$")) {
|
|
755
|
+
symName = symName.split("$")[1];
|
|
756
|
+
replace = true;
|
|
757
|
+
}
|
|
758
|
+
GOT[symName] ||= new WebAssembly.Global({
|
|
759
|
+
value: "i32",
|
|
760
|
+
mutable: true
|
|
761
|
+
});
|
|
762
|
+
if (replace || GOT[symName].value == 0) {
|
|
763
|
+
if (typeof value == "function") {
|
|
764
|
+
GOT[symName].value = addFunction(value);
|
|
765
|
+
} else if (typeof value == "number") {
|
|
766
|
+
GOT[symName].value = value;
|
|
767
|
+
} else {
|
|
768
|
+
err(`unhandled export type for '${symName}': ${typeof value}`);
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
};
|
|
773
|
+
var relocateExports = (exports2, memoryBase2, replace) => {
|
|
774
|
+
var relocated = {};
|
|
775
|
+
for (var e in exports2) {
|
|
776
|
+
var value = exports2[e];
|
|
777
|
+
if (typeof value == "object") {
|
|
778
|
+
value = value.value;
|
|
779
|
+
}
|
|
780
|
+
if (typeof value == "number") {
|
|
781
|
+
value += memoryBase2;
|
|
782
|
+
}
|
|
783
|
+
relocated[e] = value;
|
|
784
|
+
}
|
|
785
|
+
updateGOT(relocated, replace);
|
|
786
|
+
return relocated;
|
|
787
|
+
};
|
|
788
|
+
var isSymbolDefined = (symName) => {
|
|
789
|
+
var existing = wasmImports[symName];
|
|
790
|
+
if (!existing || existing.stub) {
|
|
791
|
+
return false;
|
|
792
|
+
}
|
|
793
|
+
return true;
|
|
794
|
+
};
|
|
795
|
+
var dynCallLegacy = (sig, ptr, args2) => {
|
|
796
|
+
sig = sig.replace(/p/g, "i");
|
|
797
|
+
var f = Module["dynCall_" + sig];
|
|
798
|
+
return f(ptr, ...args2);
|
|
799
|
+
};
|
|
800
|
+
var dynCall = (sig, ptr, args2 = []) => {
|
|
801
|
+
if (sig.includes("j")) {
|
|
802
|
+
return dynCallLegacy(sig, ptr, args2);
|
|
803
|
+
}
|
|
804
|
+
var rtn = getWasmTableEntry(ptr)(...args2);
|
|
805
|
+
return rtn;
|
|
806
|
+
};
|
|
807
|
+
var stackSave = () => _emscripten_stack_get_current();
|
|
808
|
+
var stackRestore = (val) => __emscripten_stack_restore(val);
|
|
809
|
+
var createInvokeFunction = (sig) => (ptr, ...args2) => {
|
|
810
|
+
var sp = stackSave();
|
|
811
|
+
try {
|
|
812
|
+
return dynCall(sig, ptr, args2);
|
|
813
|
+
} catch (e) {
|
|
814
|
+
stackRestore(sp);
|
|
815
|
+
if (e !== e + 0)
|
|
816
|
+
throw e;
|
|
817
|
+
_setThrew(1, 0);
|
|
818
|
+
}
|
|
819
|
+
};
|
|
820
|
+
var resolveGlobalSymbol = (symName, direct = false) => {
|
|
821
|
+
var sym;
|
|
822
|
+
if (direct && "orig$" + symName in wasmImports) {
|
|
823
|
+
symName = "orig$" + symName;
|
|
824
|
+
}
|
|
825
|
+
if (isSymbolDefined(symName)) {
|
|
826
|
+
sym = wasmImports[symName];
|
|
827
|
+
} else if (symName.startsWith("invoke_")) {
|
|
828
|
+
sym = wasmImports[symName] = createInvokeFunction(symName.split("_")[1]);
|
|
829
|
+
}
|
|
830
|
+
return {
|
|
831
|
+
sym,
|
|
832
|
+
name: symName
|
|
833
|
+
};
|
|
834
|
+
};
|
|
835
|
+
var UTF8ToString = (ptr, maxBytesToRead) => ptr ? UTF8ArrayToString(HEAPU8, ptr, maxBytesToRead) : "";
|
|
836
|
+
var loadWebAssemblyModule = (binary, flags, libName, localScope, handle) => {
|
|
837
|
+
var metadata = getDylinkMetadata(binary);
|
|
838
|
+
currentModuleWeakSymbols = metadata.weakImports;
|
|
839
|
+
function loadModule() {
|
|
840
|
+
var firstLoad = !handle || !HEAP8[handle + 8];
|
|
841
|
+
if (firstLoad) {
|
|
842
|
+
var memAlign = Math.pow(2, metadata.memoryAlign);
|
|
843
|
+
var memoryBase = metadata.memorySize ? alignMemory(getMemory(metadata.memorySize + memAlign), memAlign) : 0;
|
|
844
|
+
var tableBase = metadata.tableSize ? wasmTable.length : 0;
|
|
845
|
+
if (handle) {
|
|
846
|
+
HEAP8[handle + 8] = 1;
|
|
847
|
+
LE_HEAP_STORE_U32((handle + 12 >> 2) * 4, memoryBase);
|
|
848
|
+
LE_HEAP_STORE_I32((handle + 16 >> 2) * 4, metadata.memorySize);
|
|
849
|
+
LE_HEAP_STORE_U32((handle + 20 >> 2) * 4, tableBase);
|
|
850
|
+
LE_HEAP_STORE_I32((handle + 24 >> 2) * 4, metadata.tableSize);
|
|
851
|
+
}
|
|
852
|
+
} else {
|
|
853
|
+
memoryBase = LE_HEAP_LOAD_U32((handle + 12 >> 2) * 4);
|
|
854
|
+
tableBase = LE_HEAP_LOAD_U32((handle + 20 >> 2) * 4);
|
|
855
|
+
}
|
|
856
|
+
var tableGrowthNeeded = tableBase + metadata.tableSize - wasmTable.length;
|
|
857
|
+
if (tableGrowthNeeded > 0) {
|
|
858
|
+
wasmTable.grow(tableGrowthNeeded);
|
|
859
|
+
}
|
|
860
|
+
var moduleExports;
|
|
861
|
+
function resolveSymbol(sym) {
|
|
862
|
+
var resolved = resolveGlobalSymbol(sym).sym;
|
|
863
|
+
if (!resolved && localScope) {
|
|
864
|
+
resolved = localScope[sym];
|
|
865
|
+
}
|
|
866
|
+
if (!resolved) {
|
|
867
|
+
resolved = moduleExports[sym];
|
|
868
|
+
}
|
|
869
|
+
return resolved;
|
|
870
|
+
}
|
|
871
|
+
var proxyHandler = {
|
|
872
|
+
get(stubs, prop) {
|
|
873
|
+
switch (prop) {
|
|
874
|
+
case "__memory_base":
|
|
875
|
+
return memoryBase;
|
|
876
|
+
case "__table_base":
|
|
877
|
+
return tableBase;
|
|
878
|
+
}
|
|
879
|
+
if (prop in wasmImports && !wasmImports[prop].stub) {
|
|
880
|
+
return wasmImports[prop];
|
|
881
|
+
}
|
|
882
|
+
if (!(prop in stubs)) {
|
|
883
|
+
var resolved;
|
|
884
|
+
stubs[prop] = (...args2) => {
|
|
885
|
+
resolved ||= resolveSymbol(prop);
|
|
886
|
+
return resolved(...args2);
|
|
887
|
+
};
|
|
888
|
+
}
|
|
889
|
+
return stubs[prop];
|
|
890
|
+
}
|
|
891
|
+
};
|
|
892
|
+
var proxy = new Proxy({}, proxyHandler);
|
|
893
|
+
var info = {
|
|
894
|
+
"GOT.mem": new Proxy({}, GOTHandler),
|
|
895
|
+
"GOT.func": new Proxy({}, GOTHandler),
|
|
896
|
+
env: proxy,
|
|
897
|
+
wasi_snapshot_preview1: proxy
|
|
898
|
+
};
|
|
899
|
+
function postInstantiation(module, instance) {
|
|
900
|
+
updateTableMap(tableBase, metadata.tableSize);
|
|
901
|
+
moduleExports = relocateExports(instance.exports, memoryBase);
|
|
902
|
+
if (!flags.allowUndefined) {
|
|
903
|
+
reportUndefinedSymbols();
|
|
904
|
+
}
|
|
905
|
+
function addEmAsm(addr, body) {
|
|
906
|
+
var args = [];
|
|
907
|
+
var arity = 0;
|
|
908
|
+
for (;arity < 16; arity++) {
|
|
909
|
+
if (body.indexOf("$" + arity) != -1) {
|
|
910
|
+
args.push("$" + arity);
|
|
911
|
+
} else {
|
|
912
|
+
break;
|
|
913
|
+
}
|
|
914
|
+
}
|
|
915
|
+
args = args.join(",");
|
|
916
|
+
var func = `(${args}) => { ${body} };`;
|
|
917
|
+
ASM_CONSTS[start] = eval(func);
|
|
918
|
+
}
|
|
919
|
+
if ("__start_em_asm" in moduleExports) {
|
|
920
|
+
var start = moduleExports["__start_em_asm"];
|
|
921
|
+
var stop = moduleExports["__stop_em_asm"];
|
|
922
|
+
while (start < stop) {
|
|
923
|
+
var jsString = UTF8ToString(start);
|
|
924
|
+
addEmAsm(start, jsString);
|
|
925
|
+
start = HEAPU8.indexOf(0, start) + 1;
|
|
926
|
+
}
|
|
927
|
+
}
|
|
928
|
+
function addEmJs(name, cSig, body) {
|
|
929
|
+
var jsArgs = [];
|
|
930
|
+
cSig = cSig.slice(1, -1);
|
|
931
|
+
if (cSig != "void") {
|
|
932
|
+
cSig = cSig.split(",");
|
|
933
|
+
for (var i in cSig) {
|
|
934
|
+
var jsArg = cSig[i].split(" ").pop();
|
|
935
|
+
jsArgs.push(jsArg.replace("*", ""));
|
|
936
|
+
}
|
|
937
|
+
}
|
|
938
|
+
var func = `(${jsArgs}) => ${body};`;
|
|
939
|
+
moduleExports[name] = eval(func);
|
|
940
|
+
}
|
|
941
|
+
for (var name in moduleExports) {
|
|
942
|
+
if (name.startsWith("__em_js__")) {
|
|
943
|
+
var start = moduleExports[name];
|
|
944
|
+
var jsString = UTF8ToString(start);
|
|
945
|
+
var parts = jsString.split("<::>");
|
|
946
|
+
addEmJs(name.replace("__em_js__", ""), parts[0], parts[1]);
|
|
947
|
+
delete moduleExports[name];
|
|
948
|
+
}
|
|
949
|
+
}
|
|
950
|
+
var applyRelocs = moduleExports["__wasm_apply_data_relocs"];
|
|
951
|
+
if (applyRelocs) {
|
|
952
|
+
if (runtimeInitialized) {
|
|
953
|
+
applyRelocs();
|
|
954
|
+
} else {
|
|
955
|
+
__RELOC_FUNCS__.push(applyRelocs);
|
|
956
|
+
}
|
|
957
|
+
}
|
|
958
|
+
var init = moduleExports["__wasm_call_ctors"];
|
|
959
|
+
if (init) {
|
|
960
|
+
if (runtimeInitialized) {
|
|
961
|
+
init();
|
|
962
|
+
} else {
|
|
963
|
+
__ATINIT__.push(init);
|
|
964
|
+
}
|
|
965
|
+
}
|
|
966
|
+
return moduleExports;
|
|
967
|
+
}
|
|
968
|
+
if (flags.loadAsync) {
|
|
969
|
+
if (binary instanceof WebAssembly.Module) {
|
|
970
|
+
var instance = new WebAssembly.Instance(binary, info);
|
|
971
|
+
return Promise.resolve(postInstantiation(binary, instance));
|
|
972
|
+
}
|
|
973
|
+
return WebAssembly.instantiate(binary, info).then((result) => postInstantiation(result.module, result.instance));
|
|
974
|
+
}
|
|
975
|
+
var module = binary instanceof WebAssembly.Module ? binary : new WebAssembly.Module(binary);
|
|
976
|
+
var instance = new WebAssembly.Instance(module, info);
|
|
977
|
+
return postInstantiation(module, instance);
|
|
978
|
+
}
|
|
979
|
+
if (flags.loadAsync) {
|
|
980
|
+
return metadata.neededDynlibs.reduce((chain, dynNeeded) => chain.then(() => loadDynamicLibrary(dynNeeded, flags, localScope)), Promise.resolve()).then(loadModule);
|
|
981
|
+
}
|
|
982
|
+
metadata.neededDynlibs.forEach((needed) => loadDynamicLibrary(needed, flags, localScope));
|
|
983
|
+
return loadModule();
|
|
984
|
+
};
|
|
985
|
+
var mergeLibSymbols = (exports2, libName2) => {
|
|
986
|
+
for (var [sym, exp] of Object.entries(exports2)) {
|
|
987
|
+
const setImport = (target) => {
|
|
988
|
+
if (!isSymbolDefined(target)) {
|
|
989
|
+
wasmImports[target] = exp;
|
|
990
|
+
}
|
|
991
|
+
};
|
|
992
|
+
setImport(sym);
|
|
993
|
+
const main_alias = "__main_argc_argv";
|
|
994
|
+
if (sym == "main") {
|
|
995
|
+
setImport(main_alias);
|
|
996
|
+
}
|
|
997
|
+
if (sym == main_alias) {
|
|
998
|
+
setImport("main");
|
|
999
|
+
}
|
|
1000
|
+
if (sym.startsWith("dynCall_") && !Module.hasOwnProperty(sym)) {
|
|
1001
|
+
Module[sym] = exp;
|
|
1002
|
+
}
|
|
1003
|
+
}
|
|
1004
|
+
};
|
|
1005
|
+
var asyncLoad = (url, onload, onerror, noRunDep) => {
|
|
1006
|
+
var dep = !noRunDep ? getUniqueRunDependency(`al ${url}`) : "";
|
|
1007
|
+
readAsync(url).then((arrayBuffer) => {
|
|
1008
|
+
onload(new Uint8Array(arrayBuffer));
|
|
1009
|
+
if (dep)
|
|
1010
|
+
removeRunDependency(dep);
|
|
1011
|
+
}, (err2) => {
|
|
1012
|
+
if (onerror) {
|
|
1013
|
+
onerror();
|
|
1014
|
+
} else {
|
|
1015
|
+
throw `Loading data file "${url}" failed.`;
|
|
1016
|
+
}
|
|
1017
|
+
});
|
|
1018
|
+
if (dep)
|
|
1019
|
+
addRunDependency(dep);
|
|
1020
|
+
};
|
|
1021
|
+
function loadDynamicLibrary(libName2, flags2 = {
|
|
1022
|
+
global: true,
|
|
1023
|
+
nodelete: true
|
|
1024
|
+
}, localScope2, handle2) {
|
|
1025
|
+
var dso = LDSO.loadedLibsByName[libName2];
|
|
1026
|
+
if (dso) {
|
|
1027
|
+
if (!flags2.global) {
|
|
1028
|
+
if (localScope2) {
|
|
1029
|
+
Object.assign(localScope2, dso.exports);
|
|
1030
|
+
}
|
|
1031
|
+
} else if (!dso.global) {
|
|
1032
|
+
dso.global = true;
|
|
1033
|
+
mergeLibSymbols(dso.exports, libName2);
|
|
1034
|
+
}
|
|
1035
|
+
if (flags2.nodelete && dso.refcount !== Infinity) {
|
|
1036
|
+
dso.refcount = Infinity;
|
|
1037
|
+
}
|
|
1038
|
+
dso.refcount++;
|
|
1039
|
+
if (handle2) {
|
|
1040
|
+
LDSO.loadedLibsByHandle[handle2] = dso;
|
|
1041
|
+
}
|
|
1042
|
+
return flags2.loadAsync ? Promise.resolve(true) : true;
|
|
1043
|
+
}
|
|
1044
|
+
dso = newDSO(libName2, handle2, "loading");
|
|
1045
|
+
dso.refcount = flags2.nodelete ? Infinity : 1;
|
|
1046
|
+
dso.global = flags2.global;
|
|
1047
|
+
function loadLibData() {
|
|
1048
|
+
if (handle2) {
|
|
1049
|
+
var data = LE_HEAP_LOAD_U32((handle2 + 28 >> 2) * 4);
|
|
1050
|
+
var dataSize = LE_HEAP_LOAD_U32((handle2 + 32 >> 2) * 4);
|
|
1051
|
+
if (data && dataSize) {
|
|
1052
|
+
var libData = HEAP8.slice(data, data + dataSize);
|
|
1053
|
+
return flags2.loadAsync ? Promise.resolve(libData) : libData;
|
|
1054
|
+
}
|
|
1055
|
+
}
|
|
1056
|
+
var libFile = locateFile(libName2);
|
|
1057
|
+
if (flags2.loadAsync) {
|
|
1058
|
+
return new Promise(function(resolve, reject) {
|
|
1059
|
+
asyncLoad(libFile, resolve, reject);
|
|
1060
|
+
});
|
|
1061
|
+
}
|
|
1062
|
+
if (!readBinary) {
|
|
1063
|
+
throw new Error(`${libFile}: file not found, and synchronous loading of external files is not available`);
|
|
1064
|
+
}
|
|
1065
|
+
return readBinary(libFile);
|
|
1066
|
+
}
|
|
1067
|
+
function getExports() {
|
|
1068
|
+
if (flags2.loadAsync) {
|
|
1069
|
+
return loadLibData().then((libData) => loadWebAssemblyModule(libData, flags2, libName2, localScope2, handle2));
|
|
1070
|
+
}
|
|
1071
|
+
return loadWebAssemblyModule(loadLibData(), flags2, libName2, localScope2, handle2);
|
|
1072
|
+
}
|
|
1073
|
+
function moduleLoaded(exports2) {
|
|
1074
|
+
if (dso.global) {
|
|
1075
|
+
mergeLibSymbols(exports2, libName2);
|
|
1076
|
+
} else if (localScope2) {
|
|
1077
|
+
Object.assign(localScope2, exports2);
|
|
1078
|
+
}
|
|
1079
|
+
dso.exports = exports2;
|
|
1080
|
+
}
|
|
1081
|
+
if (flags2.loadAsync) {
|
|
1082
|
+
return getExports().then((exports2) => {
|
|
1083
|
+
moduleLoaded(exports2);
|
|
1084
|
+
return true;
|
|
1085
|
+
});
|
|
1086
|
+
}
|
|
1087
|
+
moduleLoaded(getExports());
|
|
1088
|
+
return true;
|
|
1089
|
+
}
|
|
1090
|
+
var reportUndefinedSymbols = () => {
|
|
1091
|
+
for (var [symName, entry] of Object.entries(GOT)) {
|
|
1092
|
+
if (entry.value == 0) {
|
|
1093
|
+
var value = resolveGlobalSymbol(symName, true).sym;
|
|
1094
|
+
if (!value && !entry.required) {
|
|
1095
|
+
continue;
|
|
1096
|
+
}
|
|
1097
|
+
if (typeof value == "function") {
|
|
1098
|
+
entry.value = addFunction(value, value.sig);
|
|
1099
|
+
} else if (typeof value == "number") {
|
|
1100
|
+
entry.value = value;
|
|
1101
|
+
} else {
|
|
1102
|
+
throw new Error(`bad export type for '${symName}': ${typeof value}`);
|
|
1103
|
+
}
|
|
1104
|
+
}
|
|
1105
|
+
}
|
|
1106
|
+
};
|
|
1107
|
+
var loadDylibs = () => {
|
|
1108
|
+
if (!dynamicLibraries.length) {
|
|
1109
|
+
reportUndefinedSymbols();
|
|
1110
|
+
return;
|
|
1111
|
+
}
|
|
1112
|
+
addRunDependency("loadDylibs");
|
|
1113
|
+
dynamicLibraries.reduce((chain, lib) => chain.then(() => loadDynamicLibrary(lib, {
|
|
1114
|
+
loadAsync: true,
|
|
1115
|
+
global: true,
|
|
1116
|
+
nodelete: true,
|
|
1117
|
+
allowUndefined: true
|
|
1118
|
+
})), Promise.resolve()).then(() => {
|
|
1119
|
+
reportUndefinedSymbols();
|
|
1120
|
+
removeRunDependency("loadDylibs");
|
|
1121
|
+
});
|
|
1122
|
+
};
|
|
1123
|
+
var noExitRuntime = Module["noExitRuntime"] || true;
|
|
1124
|
+
function setValue(ptr, value, type = "i8") {
|
|
1125
|
+
if (type.endsWith("*"))
|
|
1126
|
+
type = "*";
|
|
1127
|
+
switch (type) {
|
|
1128
|
+
case "i1":
|
|
1129
|
+
HEAP8[ptr] = value;
|
|
1130
|
+
break;
|
|
1131
|
+
case "i8":
|
|
1132
|
+
HEAP8[ptr] = value;
|
|
1133
|
+
break;
|
|
1134
|
+
case "i16":
|
|
1135
|
+
LE_HEAP_STORE_I16((ptr >> 1) * 2, value);
|
|
1136
|
+
break;
|
|
1137
|
+
case "i32":
|
|
1138
|
+
LE_HEAP_STORE_I32((ptr >> 2) * 4, value);
|
|
1139
|
+
break;
|
|
1140
|
+
case "i64":
|
|
1141
|
+
abort("to do setValue(i64) use WASM_BIGINT");
|
|
1142
|
+
case "float":
|
|
1143
|
+
LE_HEAP_STORE_F32((ptr >> 2) * 4, value);
|
|
1144
|
+
break;
|
|
1145
|
+
case "double":
|
|
1146
|
+
LE_HEAP_STORE_F64((ptr >> 3) * 8, value);
|
|
1147
|
+
break;
|
|
1148
|
+
case "*":
|
|
1149
|
+
LE_HEAP_STORE_U32((ptr >> 2) * 4, value);
|
|
1150
|
+
break;
|
|
1151
|
+
default:
|
|
1152
|
+
abort(`invalid type for setValue: ${type}`);
|
|
1153
|
+
}
|
|
1154
|
+
}
|
|
1155
|
+
var ___memory_base = new WebAssembly.Global({
|
|
1156
|
+
value: "i32",
|
|
1157
|
+
mutable: false
|
|
1158
|
+
}, 1024);
|
|
1159
|
+
var ___stack_pointer = new WebAssembly.Global({
|
|
1160
|
+
value: "i32",
|
|
1161
|
+
mutable: true
|
|
1162
|
+
}, 78112);
|
|
1163
|
+
var ___table_base = new WebAssembly.Global({
|
|
1164
|
+
value: "i32",
|
|
1165
|
+
mutable: false
|
|
1166
|
+
}, 1);
|
|
1167
|
+
var __abort_js = () => {
|
|
1168
|
+
abort("");
|
|
1169
|
+
};
|
|
1170
|
+
__abort_js.sig = "v";
|
|
1171
|
+
var nowIsMonotonic = 1;
|
|
1172
|
+
var __emscripten_get_now_is_monotonic = () => nowIsMonotonic;
|
|
1173
|
+
__emscripten_get_now_is_monotonic.sig = "i";
|
|
1174
|
+
var __emscripten_memcpy_js = (dest, src, num) => HEAPU8.copyWithin(dest, src, src + num);
|
|
1175
|
+
__emscripten_memcpy_js.sig = "vppp";
|
|
1176
|
+
var _emscripten_date_now = () => Date.now();
|
|
1177
|
+
_emscripten_date_now.sig = "d";
|
|
1178
|
+
var _emscripten_get_now;
|
|
1179
|
+
_emscripten_get_now = () => performance.now();
|
|
1180
|
+
_emscripten_get_now.sig = "d";
|
|
1181
|
+
var getHeapMax = () => 2147483648;
|
|
1182
|
+
var growMemory = (size) => {
|
|
1183
|
+
var b = wasmMemory.buffer;
|
|
1184
|
+
var pages = (size - b.byteLength + 65535) / 65536;
|
|
1185
|
+
try {
|
|
1186
|
+
wasmMemory.grow(pages);
|
|
1187
|
+
updateMemoryViews();
|
|
1188
|
+
return 1;
|
|
1189
|
+
} catch (e) {}
|
|
1190
|
+
};
|
|
1191
|
+
var _emscripten_resize_heap = (requestedSize) => {
|
|
1192
|
+
var oldSize = HEAPU8.length;
|
|
1193
|
+
requestedSize >>>= 0;
|
|
1194
|
+
var maxHeapSize = getHeapMax();
|
|
1195
|
+
if (requestedSize > maxHeapSize) {
|
|
1196
|
+
return false;
|
|
1197
|
+
}
|
|
1198
|
+
var alignUp = (x, multiple) => x + (multiple - x % multiple) % multiple;
|
|
1199
|
+
for (var cutDown = 1;cutDown <= 4; cutDown *= 2) {
|
|
1200
|
+
var overGrownHeapSize = oldSize * (1 + 0.2 / cutDown);
|
|
1201
|
+
overGrownHeapSize = Math.min(overGrownHeapSize, requestedSize + 100663296);
|
|
1202
|
+
var newSize = Math.min(maxHeapSize, alignUp(Math.max(requestedSize, overGrownHeapSize), 65536));
|
|
1203
|
+
var replacement = growMemory(newSize);
|
|
1204
|
+
if (replacement) {
|
|
1205
|
+
return true;
|
|
1206
|
+
}
|
|
1207
|
+
}
|
|
1208
|
+
return false;
|
|
1209
|
+
};
|
|
1210
|
+
_emscripten_resize_heap.sig = "ip";
|
|
1211
|
+
var _fd_close = (fd) => 52;
|
|
1212
|
+
_fd_close.sig = "ii";
|
|
1213
|
+
var convertI32PairToI53Checked = (lo, hi) => hi + 2097152 >>> 0 < 4194305 - !!lo ? (lo >>> 0) + hi * 4294967296 : NaN;
|
|
1214
|
+
function _fd_seek(fd, offset_low, offset_high, whence, newOffset) {
|
|
1215
|
+
var offset = convertI32PairToI53Checked(offset_low, offset_high);
|
|
1216
|
+
return 70;
|
|
1217
|
+
}
|
|
1218
|
+
_fd_seek.sig = "iiiiip";
|
|
1219
|
+
var printCharBuffers = [null, [], []];
|
|
1220
|
+
var printChar = (stream, curr) => {
|
|
1221
|
+
var buffer = printCharBuffers[stream];
|
|
1222
|
+
if (curr === 0 || curr === 10) {
|
|
1223
|
+
(stream === 1 ? out : err)(UTF8ArrayToString(buffer, 0));
|
|
1224
|
+
buffer.length = 0;
|
|
1225
|
+
} else {
|
|
1226
|
+
buffer.push(curr);
|
|
1227
|
+
}
|
|
1228
|
+
};
|
|
1229
|
+
var _fd_write = (fd, iov, iovcnt, pnum) => {
|
|
1230
|
+
var num = 0;
|
|
1231
|
+
for (var i2 = 0;i2 < iovcnt; i2++) {
|
|
1232
|
+
var ptr = LE_HEAP_LOAD_U32((iov >> 2) * 4);
|
|
1233
|
+
var len = LE_HEAP_LOAD_U32((iov + 4 >> 2) * 4);
|
|
1234
|
+
iov += 8;
|
|
1235
|
+
for (var j = 0;j < len; j++) {
|
|
1236
|
+
printChar(fd, HEAPU8[ptr + j]);
|
|
1237
|
+
}
|
|
1238
|
+
num += len;
|
|
1239
|
+
}
|
|
1240
|
+
LE_HEAP_STORE_U32((pnum >> 2) * 4, num);
|
|
1241
|
+
return 0;
|
|
1242
|
+
};
|
|
1243
|
+
_fd_write.sig = "iippp";
|
|
1244
|
+
function _tree_sitter_log_callback(isLexMessage, messageAddress) {
|
|
1245
|
+
if (currentLogCallback) {
|
|
1246
|
+
const message = UTF8ToString(messageAddress);
|
|
1247
|
+
currentLogCallback(message, isLexMessage !== 0);
|
|
1248
|
+
}
|
|
1249
|
+
}
|
|
1250
|
+
function _tree_sitter_parse_callback(inputBufferAddress, index, row, column, lengthAddress) {
|
|
1251
|
+
const INPUT_BUFFER_SIZE = 10 * 1024;
|
|
1252
|
+
const string = currentParseCallback(index, {
|
|
1253
|
+
row,
|
|
1254
|
+
column
|
|
1255
|
+
});
|
|
1256
|
+
if (typeof string === "string") {
|
|
1257
|
+
setValue(lengthAddress, string.length, "i32");
|
|
1258
|
+
stringToUTF16(string, inputBufferAddress, INPUT_BUFFER_SIZE);
|
|
1259
|
+
} else {
|
|
1260
|
+
setValue(lengthAddress, 0, "i32");
|
|
1261
|
+
}
|
|
1262
|
+
}
|
|
1263
|
+
var runtimeKeepaliveCounter = 0;
|
|
1264
|
+
var keepRuntimeAlive = () => noExitRuntime || runtimeKeepaliveCounter > 0;
|
|
1265
|
+
var _proc_exit = (code) => {
|
|
1266
|
+
EXITSTATUS = code;
|
|
1267
|
+
if (!keepRuntimeAlive()) {
|
|
1268
|
+
Module["onExit"]?.(code);
|
|
1269
|
+
ABORT = true;
|
|
1270
|
+
}
|
|
1271
|
+
quit_(code, new ExitStatus(code));
|
|
1272
|
+
};
|
|
1273
|
+
_proc_exit.sig = "vi";
|
|
1274
|
+
var exitJS = (status, implicit) => {
|
|
1275
|
+
EXITSTATUS = status;
|
|
1276
|
+
_proc_exit(status);
|
|
1277
|
+
};
|
|
1278
|
+
var handleException = (e) => {
|
|
1279
|
+
if (e instanceof ExitStatus || e == "unwind") {
|
|
1280
|
+
return EXITSTATUS;
|
|
1281
|
+
}
|
|
1282
|
+
quit_(1, e);
|
|
1283
|
+
};
|
|
1284
|
+
var lengthBytesUTF8 = (str) => {
|
|
1285
|
+
var len = 0;
|
|
1286
|
+
for (var i2 = 0;i2 < str.length; ++i2) {
|
|
1287
|
+
var c = str.charCodeAt(i2);
|
|
1288
|
+
if (c <= 127) {
|
|
1289
|
+
len++;
|
|
1290
|
+
} else if (c <= 2047) {
|
|
1291
|
+
len += 2;
|
|
1292
|
+
} else if (c >= 55296 && c <= 57343) {
|
|
1293
|
+
len += 4;
|
|
1294
|
+
++i2;
|
|
1295
|
+
} else {
|
|
1296
|
+
len += 3;
|
|
1297
|
+
}
|
|
1298
|
+
}
|
|
1299
|
+
return len;
|
|
1300
|
+
};
|
|
1301
|
+
var stringToUTF8Array = (str, heap, outIdx, maxBytesToWrite) => {
|
|
1302
|
+
if (!(maxBytesToWrite > 0))
|
|
1303
|
+
return 0;
|
|
1304
|
+
var startIdx = outIdx;
|
|
1305
|
+
var endIdx = outIdx + maxBytesToWrite - 1;
|
|
1306
|
+
for (var i2 = 0;i2 < str.length; ++i2) {
|
|
1307
|
+
var u = str.charCodeAt(i2);
|
|
1308
|
+
if (u >= 55296 && u <= 57343) {
|
|
1309
|
+
var u1 = str.charCodeAt(++i2);
|
|
1310
|
+
u = 65536 + ((u & 1023) << 10) | u1 & 1023;
|
|
1311
|
+
}
|
|
1312
|
+
if (u <= 127) {
|
|
1313
|
+
if (outIdx >= endIdx)
|
|
1314
|
+
break;
|
|
1315
|
+
heap[outIdx++] = u;
|
|
1316
|
+
} else if (u <= 2047) {
|
|
1317
|
+
if (outIdx + 1 >= endIdx)
|
|
1318
|
+
break;
|
|
1319
|
+
heap[outIdx++] = 192 | u >> 6;
|
|
1320
|
+
heap[outIdx++] = 128 | u & 63;
|
|
1321
|
+
} else if (u <= 65535) {
|
|
1322
|
+
if (outIdx + 2 >= endIdx)
|
|
1323
|
+
break;
|
|
1324
|
+
heap[outIdx++] = 224 | u >> 12;
|
|
1325
|
+
heap[outIdx++] = 128 | u >> 6 & 63;
|
|
1326
|
+
heap[outIdx++] = 128 | u & 63;
|
|
1327
|
+
} else {
|
|
1328
|
+
if (outIdx + 3 >= endIdx)
|
|
1329
|
+
break;
|
|
1330
|
+
heap[outIdx++] = 240 | u >> 18;
|
|
1331
|
+
heap[outIdx++] = 128 | u >> 12 & 63;
|
|
1332
|
+
heap[outIdx++] = 128 | u >> 6 & 63;
|
|
1333
|
+
heap[outIdx++] = 128 | u & 63;
|
|
1334
|
+
}
|
|
1335
|
+
}
|
|
1336
|
+
heap[outIdx] = 0;
|
|
1337
|
+
return outIdx - startIdx;
|
|
1338
|
+
};
|
|
1339
|
+
var stringToUTF8 = (str, outPtr, maxBytesToWrite) => stringToUTF8Array(str, HEAPU8, outPtr, maxBytesToWrite);
|
|
1340
|
+
var stackAlloc = (sz) => __emscripten_stack_alloc(sz);
|
|
1341
|
+
var stringToUTF8OnStack = (str) => {
|
|
1342
|
+
var size = lengthBytesUTF8(str) + 1;
|
|
1343
|
+
var ret = stackAlloc(size);
|
|
1344
|
+
stringToUTF8(str, ret, size);
|
|
1345
|
+
return ret;
|
|
1346
|
+
};
|
|
1347
|
+
var stringToUTF16 = (str, outPtr, maxBytesToWrite) => {
|
|
1348
|
+
maxBytesToWrite ??= 2147483647;
|
|
1349
|
+
if (maxBytesToWrite < 2)
|
|
1350
|
+
return 0;
|
|
1351
|
+
maxBytesToWrite -= 2;
|
|
1352
|
+
var startPtr = outPtr;
|
|
1353
|
+
var numCharsToWrite = maxBytesToWrite < str.length * 2 ? maxBytesToWrite / 2 : str.length;
|
|
1354
|
+
for (var i2 = 0;i2 < numCharsToWrite; ++i2) {
|
|
1355
|
+
var codeUnit = str.charCodeAt(i2);
|
|
1356
|
+
LE_HEAP_STORE_I16((outPtr >> 1) * 2, codeUnit);
|
|
1357
|
+
outPtr += 2;
|
|
1358
|
+
}
|
|
1359
|
+
LE_HEAP_STORE_I16((outPtr >> 1) * 2, 0);
|
|
1360
|
+
return outPtr - startPtr;
|
|
1361
|
+
};
|
|
1362
|
+
var AsciiToString = (ptr) => {
|
|
1363
|
+
var str = "";
|
|
1364
|
+
while (true) {
|
|
1365
|
+
var ch = HEAPU8[ptr++];
|
|
1366
|
+
if (!ch)
|
|
1367
|
+
return str;
|
|
1368
|
+
str += String.fromCharCode(ch);
|
|
1369
|
+
}
|
|
1370
|
+
};
|
|
1371
|
+
var wasmImports = {
|
|
1372
|
+
__heap_base: ___heap_base,
|
|
1373
|
+
__indirect_function_table: wasmTable,
|
|
1374
|
+
__memory_base: ___memory_base,
|
|
1375
|
+
__stack_pointer: ___stack_pointer,
|
|
1376
|
+
__table_base: ___table_base,
|
|
1377
|
+
_abort_js: __abort_js,
|
|
1378
|
+
_emscripten_get_now_is_monotonic: __emscripten_get_now_is_monotonic,
|
|
1379
|
+
_emscripten_memcpy_js: __emscripten_memcpy_js,
|
|
1380
|
+
emscripten_get_now: _emscripten_get_now,
|
|
1381
|
+
emscripten_resize_heap: _emscripten_resize_heap,
|
|
1382
|
+
fd_close: _fd_close,
|
|
1383
|
+
fd_seek: _fd_seek,
|
|
1384
|
+
fd_write: _fd_write,
|
|
1385
|
+
memory: wasmMemory,
|
|
1386
|
+
tree_sitter_log_callback: _tree_sitter_log_callback,
|
|
1387
|
+
tree_sitter_parse_callback: _tree_sitter_parse_callback
|
|
1388
|
+
};
|
|
1389
|
+
var wasmExports = createWasm();
|
|
1390
|
+
var ___wasm_call_ctors = () => (___wasm_call_ctors = wasmExports["__wasm_call_ctors"])();
|
|
1391
|
+
var ___wasm_apply_data_relocs = () => (___wasm_apply_data_relocs = wasmExports["__wasm_apply_data_relocs"])();
|
|
1392
|
+
var _malloc = Module["_malloc"] = (a0) => (_malloc = Module["_malloc"] = wasmExports["malloc"])(a0);
|
|
1393
|
+
var _calloc = Module["_calloc"] = (a0, a1) => (_calloc = Module["_calloc"] = wasmExports["calloc"])(a0, a1);
|
|
1394
|
+
var _realloc = Module["_realloc"] = (a0, a1) => (_realloc = Module["_realloc"] = wasmExports["realloc"])(a0, a1);
|
|
1395
|
+
var _free = Module["_free"] = (a0) => (_free = Module["_free"] = wasmExports["free"])(a0);
|
|
1396
|
+
var _ts_language_symbol_count = Module["_ts_language_symbol_count"] = (a0) => (_ts_language_symbol_count = Module["_ts_language_symbol_count"] = wasmExports["ts_language_symbol_count"])(a0);
|
|
1397
|
+
var _ts_language_state_count = Module["_ts_language_state_count"] = (a0) => (_ts_language_state_count = Module["_ts_language_state_count"] = wasmExports["ts_language_state_count"])(a0);
|
|
1398
|
+
var _ts_language_version = Module["_ts_language_version"] = (a0) => (_ts_language_version = Module["_ts_language_version"] = wasmExports["ts_language_version"])(a0);
|
|
1399
|
+
var _ts_language_field_count = Module["_ts_language_field_count"] = (a0) => (_ts_language_field_count = Module["_ts_language_field_count"] = wasmExports["ts_language_field_count"])(a0);
|
|
1400
|
+
var _ts_language_next_state = Module["_ts_language_next_state"] = (a0, a1, a2) => (_ts_language_next_state = Module["_ts_language_next_state"] = wasmExports["ts_language_next_state"])(a0, a1, a2);
|
|
1401
|
+
var _ts_language_symbol_name = Module["_ts_language_symbol_name"] = (a0, a1) => (_ts_language_symbol_name = Module["_ts_language_symbol_name"] = wasmExports["ts_language_symbol_name"])(a0, a1);
|
|
1402
|
+
var _ts_language_symbol_for_name = Module["_ts_language_symbol_for_name"] = (a0, a1, a2, a3) => (_ts_language_symbol_for_name = Module["_ts_language_symbol_for_name"] = wasmExports["ts_language_symbol_for_name"])(a0, a1, a2, a3);
|
|
1403
|
+
var _strncmp = Module["_strncmp"] = (a0, a1, a2) => (_strncmp = Module["_strncmp"] = wasmExports["strncmp"])(a0, a1, a2);
|
|
1404
|
+
var _ts_language_symbol_type = Module["_ts_language_symbol_type"] = (a0, a1) => (_ts_language_symbol_type = Module["_ts_language_symbol_type"] = wasmExports["ts_language_symbol_type"])(a0, a1);
|
|
1405
|
+
var _ts_language_field_name_for_id = Module["_ts_language_field_name_for_id"] = (a0, a1) => (_ts_language_field_name_for_id = Module["_ts_language_field_name_for_id"] = wasmExports["ts_language_field_name_for_id"])(a0, a1);
|
|
1406
|
+
var _ts_lookahead_iterator_new = Module["_ts_lookahead_iterator_new"] = (a0, a1) => (_ts_lookahead_iterator_new = Module["_ts_lookahead_iterator_new"] = wasmExports["ts_lookahead_iterator_new"])(a0, a1);
|
|
1407
|
+
var _ts_lookahead_iterator_delete = Module["_ts_lookahead_iterator_delete"] = (a0) => (_ts_lookahead_iterator_delete = Module["_ts_lookahead_iterator_delete"] = wasmExports["ts_lookahead_iterator_delete"])(a0);
|
|
1408
|
+
var _ts_lookahead_iterator_reset_state = Module["_ts_lookahead_iterator_reset_state"] = (a0, a1) => (_ts_lookahead_iterator_reset_state = Module["_ts_lookahead_iterator_reset_state"] = wasmExports["ts_lookahead_iterator_reset_state"])(a0, a1);
|
|
1409
|
+
var _ts_lookahead_iterator_reset = Module["_ts_lookahead_iterator_reset"] = (a0, a1, a2) => (_ts_lookahead_iterator_reset = Module["_ts_lookahead_iterator_reset"] = wasmExports["ts_lookahead_iterator_reset"])(a0, a1, a2);
|
|
1410
|
+
var _ts_lookahead_iterator_next = Module["_ts_lookahead_iterator_next"] = (a0) => (_ts_lookahead_iterator_next = Module["_ts_lookahead_iterator_next"] = wasmExports["ts_lookahead_iterator_next"])(a0);
|
|
1411
|
+
var _ts_lookahead_iterator_current_symbol = Module["_ts_lookahead_iterator_current_symbol"] = (a0) => (_ts_lookahead_iterator_current_symbol = Module["_ts_lookahead_iterator_current_symbol"] = wasmExports["ts_lookahead_iterator_current_symbol"])(a0);
|
|
1412
|
+
var _memset = Module["_memset"] = (a0, a1, a2) => (_memset = Module["_memset"] = wasmExports["memset"])(a0, a1, a2);
|
|
1413
|
+
var _memcpy = Module["_memcpy"] = (a0, a1, a2) => (_memcpy = Module["_memcpy"] = wasmExports["memcpy"])(a0, a1, a2);
|
|
1414
|
+
var _ts_parser_delete = Module["_ts_parser_delete"] = (a0) => (_ts_parser_delete = Module["_ts_parser_delete"] = wasmExports["ts_parser_delete"])(a0);
|
|
1415
|
+
var _ts_parser_reset = Module["_ts_parser_reset"] = (a0) => (_ts_parser_reset = Module["_ts_parser_reset"] = wasmExports["ts_parser_reset"])(a0);
|
|
1416
|
+
var _ts_parser_set_language = Module["_ts_parser_set_language"] = (a0, a1) => (_ts_parser_set_language = Module["_ts_parser_set_language"] = wasmExports["ts_parser_set_language"])(a0, a1);
|
|
1417
|
+
var _ts_parser_timeout_micros = Module["_ts_parser_timeout_micros"] = (a0) => (_ts_parser_timeout_micros = Module["_ts_parser_timeout_micros"] = wasmExports["ts_parser_timeout_micros"])(a0);
|
|
1418
|
+
var _ts_parser_set_timeout_micros = Module["_ts_parser_set_timeout_micros"] = (a0, a1, a2) => (_ts_parser_set_timeout_micros = Module["_ts_parser_set_timeout_micros"] = wasmExports["ts_parser_set_timeout_micros"])(a0, a1, a2);
|
|
1419
|
+
var _ts_parser_set_included_ranges = Module["_ts_parser_set_included_ranges"] = (a0, a1, a2) => (_ts_parser_set_included_ranges = Module["_ts_parser_set_included_ranges"] = wasmExports["ts_parser_set_included_ranges"])(a0, a1, a2);
|
|
1420
|
+
var _memmove = Module["_memmove"] = (a0, a1, a2) => (_memmove = Module["_memmove"] = wasmExports["memmove"])(a0, a1, a2);
|
|
1421
|
+
var _memcmp = Module["_memcmp"] = (a0, a1, a2) => (_memcmp = Module["_memcmp"] = wasmExports["memcmp"])(a0, a1, a2);
|
|
1422
|
+
var _ts_query_new = Module["_ts_query_new"] = (a0, a1, a2, a3, a4) => (_ts_query_new = Module["_ts_query_new"] = wasmExports["ts_query_new"])(a0, a1, a2, a3, a4);
|
|
1423
|
+
var _ts_query_delete = Module["_ts_query_delete"] = (a0) => (_ts_query_delete = Module["_ts_query_delete"] = wasmExports["ts_query_delete"])(a0);
|
|
1424
|
+
var _iswspace = Module["_iswspace"] = (a0) => (_iswspace = Module["_iswspace"] = wasmExports["iswspace"])(a0);
|
|
1425
|
+
var _iswalnum = Module["_iswalnum"] = (a0) => (_iswalnum = Module["_iswalnum"] = wasmExports["iswalnum"])(a0);
|
|
1426
|
+
var _ts_query_pattern_count = Module["_ts_query_pattern_count"] = (a0) => (_ts_query_pattern_count = Module["_ts_query_pattern_count"] = wasmExports["ts_query_pattern_count"])(a0);
|
|
1427
|
+
var _ts_query_capture_count = Module["_ts_query_capture_count"] = (a0) => (_ts_query_capture_count = Module["_ts_query_capture_count"] = wasmExports["ts_query_capture_count"])(a0);
|
|
1428
|
+
var _ts_query_string_count = Module["_ts_query_string_count"] = (a0) => (_ts_query_string_count = Module["_ts_query_string_count"] = wasmExports["ts_query_string_count"])(a0);
|
|
1429
|
+
var _ts_query_capture_name_for_id = Module["_ts_query_capture_name_for_id"] = (a0, a1, a2) => (_ts_query_capture_name_for_id = Module["_ts_query_capture_name_for_id"] = wasmExports["ts_query_capture_name_for_id"])(a0, a1, a2);
|
|
1430
|
+
var _ts_query_string_value_for_id = Module["_ts_query_string_value_for_id"] = (a0, a1, a2) => (_ts_query_string_value_for_id = Module["_ts_query_string_value_for_id"] = wasmExports["ts_query_string_value_for_id"])(a0, a1, a2);
|
|
1431
|
+
var _ts_query_predicates_for_pattern = Module["_ts_query_predicates_for_pattern"] = (a0, a1, a2) => (_ts_query_predicates_for_pattern = Module["_ts_query_predicates_for_pattern"] = wasmExports["ts_query_predicates_for_pattern"])(a0, a1, a2);
|
|
1432
|
+
var _ts_query_disable_capture = Module["_ts_query_disable_capture"] = (a0, a1, a2) => (_ts_query_disable_capture = Module["_ts_query_disable_capture"] = wasmExports["ts_query_disable_capture"])(a0, a1, a2);
|
|
1433
|
+
var _ts_tree_copy = Module["_ts_tree_copy"] = (a0) => (_ts_tree_copy = Module["_ts_tree_copy"] = wasmExports["ts_tree_copy"])(a0);
|
|
1434
|
+
var _ts_tree_delete = Module["_ts_tree_delete"] = (a0) => (_ts_tree_delete = Module["_ts_tree_delete"] = wasmExports["ts_tree_delete"])(a0);
|
|
1435
|
+
var _ts_init = Module["_ts_init"] = () => (_ts_init = Module["_ts_init"] = wasmExports["ts_init"])();
|
|
1436
|
+
var _ts_parser_new_wasm = Module["_ts_parser_new_wasm"] = () => (_ts_parser_new_wasm = Module["_ts_parser_new_wasm"] = wasmExports["ts_parser_new_wasm"])();
|
|
1437
|
+
var _ts_parser_enable_logger_wasm = Module["_ts_parser_enable_logger_wasm"] = (a0, a1) => (_ts_parser_enable_logger_wasm = Module["_ts_parser_enable_logger_wasm"] = wasmExports["ts_parser_enable_logger_wasm"])(a0, a1);
|
|
1438
|
+
var _ts_parser_parse_wasm = Module["_ts_parser_parse_wasm"] = (a0, a1, a2, a3, a4) => (_ts_parser_parse_wasm = Module["_ts_parser_parse_wasm"] = wasmExports["ts_parser_parse_wasm"])(a0, a1, a2, a3, a4);
|
|
1439
|
+
var _ts_parser_included_ranges_wasm = Module["_ts_parser_included_ranges_wasm"] = (a0) => (_ts_parser_included_ranges_wasm = Module["_ts_parser_included_ranges_wasm"] = wasmExports["ts_parser_included_ranges_wasm"])(a0);
|
|
1440
|
+
var _ts_language_type_is_named_wasm = Module["_ts_language_type_is_named_wasm"] = (a0, a1) => (_ts_language_type_is_named_wasm = Module["_ts_language_type_is_named_wasm"] = wasmExports["ts_language_type_is_named_wasm"])(a0, a1);
|
|
1441
|
+
var _ts_language_type_is_visible_wasm = Module["_ts_language_type_is_visible_wasm"] = (a0, a1) => (_ts_language_type_is_visible_wasm = Module["_ts_language_type_is_visible_wasm"] = wasmExports["ts_language_type_is_visible_wasm"])(a0, a1);
|
|
1442
|
+
var _ts_tree_root_node_wasm = Module["_ts_tree_root_node_wasm"] = (a0) => (_ts_tree_root_node_wasm = Module["_ts_tree_root_node_wasm"] = wasmExports["ts_tree_root_node_wasm"])(a0);
|
|
1443
|
+
var _ts_tree_root_node_with_offset_wasm = Module["_ts_tree_root_node_with_offset_wasm"] = (a0) => (_ts_tree_root_node_with_offset_wasm = Module["_ts_tree_root_node_with_offset_wasm"] = wasmExports["ts_tree_root_node_with_offset_wasm"])(a0);
|
|
1444
|
+
var _ts_tree_edit_wasm = Module["_ts_tree_edit_wasm"] = (a0) => (_ts_tree_edit_wasm = Module["_ts_tree_edit_wasm"] = wasmExports["ts_tree_edit_wasm"])(a0);
|
|
1445
|
+
var _ts_tree_included_ranges_wasm = Module["_ts_tree_included_ranges_wasm"] = (a0) => (_ts_tree_included_ranges_wasm = Module["_ts_tree_included_ranges_wasm"] = wasmExports["ts_tree_included_ranges_wasm"])(a0);
|
|
1446
|
+
var _ts_tree_get_changed_ranges_wasm = Module["_ts_tree_get_changed_ranges_wasm"] = (a0, a1) => (_ts_tree_get_changed_ranges_wasm = Module["_ts_tree_get_changed_ranges_wasm"] = wasmExports["ts_tree_get_changed_ranges_wasm"])(a0, a1);
|
|
1447
|
+
var _ts_tree_cursor_new_wasm = Module["_ts_tree_cursor_new_wasm"] = (a0) => (_ts_tree_cursor_new_wasm = Module["_ts_tree_cursor_new_wasm"] = wasmExports["ts_tree_cursor_new_wasm"])(a0);
|
|
1448
|
+
var _ts_tree_cursor_delete_wasm = Module["_ts_tree_cursor_delete_wasm"] = (a0) => (_ts_tree_cursor_delete_wasm = Module["_ts_tree_cursor_delete_wasm"] = wasmExports["ts_tree_cursor_delete_wasm"])(a0);
|
|
1449
|
+
var _ts_tree_cursor_reset_wasm = Module["_ts_tree_cursor_reset_wasm"] = (a0) => (_ts_tree_cursor_reset_wasm = Module["_ts_tree_cursor_reset_wasm"] = wasmExports["ts_tree_cursor_reset_wasm"])(a0);
|
|
1450
|
+
var _ts_tree_cursor_reset_to_wasm = Module["_ts_tree_cursor_reset_to_wasm"] = (a0, a1) => (_ts_tree_cursor_reset_to_wasm = Module["_ts_tree_cursor_reset_to_wasm"] = wasmExports["ts_tree_cursor_reset_to_wasm"])(a0, a1);
|
|
1451
|
+
var _ts_tree_cursor_goto_first_child_wasm = Module["_ts_tree_cursor_goto_first_child_wasm"] = (a0) => (_ts_tree_cursor_goto_first_child_wasm = Module["_ts_tree_cursor_goto_first_child_wasm"] = wasmExports["ts_tree_cursor_goto_first_child_wasm"])(a0);
|
|
1452
|
+
var _ts_tree_cursor_goto_last_child_wasm = Module["_ts_tree_cursor_goto_last_child_wasm"] = (a0) => (_ts_tree_cursor_goto_last_child_wasm = Module["_ts_tree_cursor_goto_last_child_wasm"] = wasmExports["ts_tree_cursor_goto_last_child_wasm"])(a0);
|
|
1453
|
+
var _ts_tree_cursor_goto_first_child_for_index_wasm = Module["_ts_tree_cursor_goto_first_child_for_index_wasm"] = (a0) => (_ts_tree_cursor_goto_first_child_for_index_wasm = Module["_ts_tree_cursor_goto_first_child_for_index_wasm"] = wasmExports["ts_tree_cursor_goto_first_child_for_index_wasm"])(a0);
|
|
1454
|
+
var _ts_tree_cursor_goto_first_child_for_position_wasm = Module["_ts_tree_cursor_goto_first_child_for_position_wasm"] = (a0) => (_ts_tree_cursor_goto_first_child_for_position_wasm = Module["_ts_tree_cursor_goto_first_child_for_position_wasm"] = wasmExports["ts_tree_cursor_goto_first_child_for_position_wasm"])(a0);
|
|
1455
|
+
var _ts_tree_cursor_goto_next_sibling_wasm = Module["_ts_tree_cursor_goto_next_sibling_wasm"] = (a0) => (_ts_tree_cursor_goto_next_sibling_wasm = Module["_ts_tree_cursor_goto_next_sibling_wasm"] = wasmExports["ts_tree_cursor_goto_next_sibling_wasm"])(a0);
|
|
1456
|
+
var _ts_tree_cursor_goto_previous_sibling_wasm = Module["_ts_tree_cursor_goto_previous_sibling_wasm"] = (a0) => (_ts_tree_cursor_goto_previous_sibling_wasm = Module["_ts_tree_cursor_goto_previous_sibling_wasm"] = wasmExports["ts_tree_cursor_goto_previous_sibling_wasm"])(a0);
|
|
1457
|
+
var _ts_tree_cursor_goto_descendant_wasm = Module["_ts_tree_cursor_goto_descendant_wasm"] = (a0, a1) => (_ts_tree_cursor_goto_descendant_wasm = Module["_ts_tree_cursor_goto_descendant_wasm"] = wasmExports["ts_tree_cursor_goto_descendant_wasm"])(a0, a1);
|
|
1458
|
+
var _ts_tree_cursor_goto_parent_wasm = Module["_ts_tree_cursor_goto_parent_wasm"] = (a0) => (_ts_tree_cursor_goto_parent_wasm = Module["_ts_tree_cursor_goto_parent_wasm"] = wasmExports["ts_tree_cursor_goto_parent_wasm"])(a0);
|
|
1459
|
+
var _ts_tree_cursor_current_node_type_id_wasm = Module["_ts_tree_cursor_current_node_type_id_wasm"] = (a0) => (_ts_tree_cursor_current_node_type_id_wasm = Module["_ts_tree_cursor_current_node_type_id_wasm"] = wasmExports["ts_tree_cursor_current_node_type_id_wasm"])(a0);
|
|
1460
|
+
var _ts_tree_cursor_current_node_state_id_wasm = Module["_ts_tree_cursor_current_node_state_id_wasm"] = (a0) => (_ts_tree_cursor_current_node_state_id_wasm = Module["_ts_tree_cursor_current_node_state_id_wasm"] = wasmExports["ts_tree_cursor_current_node_state_id_wasm"])(a0);
|
|
1461
|
+
var _ts_tree_cursor_current_node_is_named_wasm = Module["_ts_tree_cursor_current_node_is_named_wasm"] = (a0) => (_ts_tree_cursor_current_node_is_named_wasm = Module["_ts_tree_cursor_current_node_is_named_wasm"] = wasmExports["ts_tree_cursor_current_node_is_named_wasm"])(a0);
|
|
1462
|
+
var _ts_tree_cursor_current_node_is_missing_wasm = Module["_ts_tree_cursor_current_node_is_missing_wasm"] = (a0) => (_ts_tree_cursor_current_node_is_missing_wasm = Module["_ts_tree_cursor_current_node_is_missing_wasm"] = wasmExports["ts_tree_cursor_current_node_is_missing_wasm"])(a0);
|
|
1463
|
+
var _ts_tree_cursor_current_node_id_wasm = Module["_ts_tree_cursor_current_node_id_wasm"] = (a0) => (_ts_tree_cursor_current_node_id_wasm = Module["_ts_tree_cursor_current_node_id_wasm"] = wasmExports["ts_tree_cursor_current_node_id_wasm"])(a0);
|
|
1464
|
+
var _ts_tree_cursor_start_position_wasm = Module["_ts_tree_cursor_start_position_wasm"] = (a0) => (_ts_tree_cursor_start_position_wasm = Module["_ts_tree_cursor_start_position_wasm"] = wasmExports["ts_tree_cursor_start_position_wasm"])(a0);
|
|
1465
|
+
var _ts_tree_cursor_end_position_wasm = Module["_ts_tree_cursor_end_position_wasm"] = (a0) => (_ts_tree_cursor_end_position_wasm = Module["_ts_tree_cursor_end_position_wasm"] = wasmExports["ts_tree_cursor_end_position_wasm"])(a0);
|
|
1466
|
+
var _ts_tree_cursor_start_index_wasm = Module["_ts_tree_cursor_start_index_wasm"] = (a0) => (_ts_tree_cursor_start_index_wasm = Module["_ts_tree_cursor_start_index_wasm"] = wasmExports["ts_tree_cursor_start_index_wasm"])(a0);
|
|
1467
|
+
var _ts_tree_cursor_end_index_wasm = Module["_ts_tree_cursor_end_index_wasm"] = (a0) => (_ts_tree_cursor_end_index_wasm = Module["_ts_tree_cursor_end_index_wasm"] = wasmExports["ts_tree_cursor_end_index_wasm"])(a0);
|
|
1468
|
+
var _ts_tree_cursor_current_field_id_wasm = Module["_ts_tree_cursor_current_field_id_wasm"] = (a0) => (_ts_tree_cursor_current_field_id_wasm = Module["_ts_tree_cursor_current_field_id_wasm"] = wasmExports["ts_tree_cursor_current_field_id_wasm"])(a0);
|
|
1469
|
+
var _ts_tree_cursor_current_depth_wasm = Module["_ts_tree_cursor_current_depth_wasm"] = (a0) => (_ts_tree_cursor_current_depth_wasm = Module["_ts_tree_cursor_current_depth_wasm"] = wasmExports["ts_tree_cursor_current_depth_wasm"])(a0);
|
|
1470
|
+
var _ts_tree_cursor_current_descendant_index_wasm = Module["_ts_tree_cursor_current_descendant_index_wasm"] = (a0) => (_ts_tree_cursor_current_descendant_index_wasm = Module["_ts_tree_cursor_current_descendant_index_wasm"] = wasmExports["ts_tree_cursor_current_descendant_index_wasm"])(a0);
|
|
1471
|
+
var _ts_tree_cursor_current_node_wasm = Module["_ts_tree_cursor_current_node_wasm"] = (a0) => (_ts_tree_cursor_current_node_wasm = Module["_ts_tree_cursor_current_node_wasm"] = wasmExports["ts_tree_cursor_current_node_wasm"])(a0);
|
|
1472
|
+
var _ts_node_symbol_wasm = Module["_ts_node_symbol_wasm"] = (a0) => (_ts_node_symbol_wasm = Module["_ts_node_symbol_wasm"] = wasmExports["ts_node_symbol_wasm"])(a0);
|
|
1473
|
+
var _ts_node_field_name_for_child_wasm = Module["_ts_node_field_name_for_child_wasm"] = (a0, a1) => (_ts_node_field_name_for_child_wasm = Module["_ts_node_field_name_for_child_wasm"] = wasmExports["ts_node_field_name_for_child_wasm"])(a0, a1);
|
|
1474
|
+
var _ts_node_children_by_field_id_wasm = Module["_ts_node_children_by_field_id_wasm"] = (a0, a1) => (_ts_node_children_by_field_id_wasm = Module["_ts_node_children_by_field_id_wasm"] = wasmExports["ts_node_children_by_field_id_wasm"])(a0, a1);
|
|
1475
|
+
var _ts_node_first_child_for_byte_wasm = Module["_ts_node_first_child_for_byte_wasm"] = (a0) => (_ts_node_first_child_for_byte_wasm = Module["_ts_node_first_child_for_byte_wasm"] = wasmExports["ts_node_first_child_for_byte_wasm"])(a0);
|
|
1476
|
+
var _ts_node_first_named_child_for_byte_wasm = Module["_ts_node_first_named_child_for_byte_wasm"] = (a0) => (_ts_node_first_named_child_for_byte_wasm = Module["_ts_node_first_named_child_for_byte_wasm"] = wasmExports["ts_node_first_named_child_for_byte_wasm"])(a0);
|
|
1477
|
+
var _ts_node_grammar_symbol_wasm = Module["_ts_node_grammar_symbol_wasm"] = (a0) => (_ts_node_grammar_symbol_wasm = Module["_ts_node_grammar_symbol_wasm"] = wasmExports["ts_node_grammar_symbol_wasm"])(a0);
|
|
1478
|
+
var _ts_node_child_count_wasm = Module["_ts_node_child_count_wasm"] = (a0) => (_ts_node_child_count_wasm = Module["_ts_node_child_count_wasm"] = wasmExports["ts_node_child_count_wasm"])(a0);
|
|
1479
|
+
var _ts_node_named_child_count_wasm = Module["_ts_node_named_child_count_wasm"] = (a0) => (_ts_node_named_child_count_wasm = Module["_ts_node_named_child_count_wasm"] = wasmExports["ts_node_named_child_count_wasm"])(a0);
|
|
1480
|
+
var _ts_node_child_wasm = Module["_ts_node_child_wasm"] = (a0, a1) => (_ts_node_child_wasm = Module["_ts_node_child_wasm"] = wasmExports["ts_node_child_wasm"])(a0, a1);
|
|
1481
|
+
var _ts_node_named_child_wasm = Module["_ts_node_named_child_wasm"] = (a0, a1) => (_ts_node_named_child_wasm = Module["_ts_node_named_child_wasm"] = wasmExports["ts_node_named_child_wasm"])(a0, a1);
|
|
1482
|
+
var _ts_node_child_by_field_id_wasm = Module["_ts_node_child_by_field_id_wasm"] = (a0, a1) => (_ts_node_child_by_field_id_wasm = Module["_ts_node_child_by_field_id_wasm"] = wasmExports["ts_node_child_by_field_id_wasm"])(a0, a1);
|
|
1483
|
+
var _ts_node_next_sibling_wasm = Module["_ts_node_next_sibling_wasm"] = (a0) => (_ts_node_next_sibling_wasm = Module["_ts_node_next_sibling_wasm"] = wasmExports["ts_node_next_sibling_wasm"])(a0);
|
|
1484
|
+
var _ts_node_prev_sibling_wasm = Module["_ts_node_prev_sibling_wasm"] = (a0) => (_ts_node_prev_sibling_wasm = Module["_ts_node_prev_sibling_wasm"] = wasmExports["ts_node_prev_sibling_wasm"])(a0);
|
|
1485
|
+
var _ts_node_next_named_sibling_wasm = Module["_ts_node_next_named_sibling_wasm"] = (a0) => (_ts_node_next_named_sibling_wasm = Module["_ts_node_next_named_sibling_wasm"] = wasmExports["ts_node_next_named_sibling_wasm"])(a0);
|
|
1486
|
+
var _ts_node_prev_named_sibling_wasm = Module["_ts_node_prev_named_sibling_wasm"] = (a0) => (_ts_node_prev_named_sibling_wasm = Module["_ts_node_prev_named_sibling_wasm"] = wasmExports["ts_node_prev_named_sibling_wasm"])(a0);
|
|
1487
|
+
var _ts_node_descendant_count_wasm = Module["_ts_node_descendant_count_wasm"] = (a0) => (_ts_node_descendant_count_wasm = Module["_ts_node_descendant_count_wasm"] = wasmExports["ts_node_descendant_count_wasm"])(a0);
|
|
1488
|
+
var _ts_node_parent_wasm = Module["_ts_node_parent_wasm"] = (a0) => (_ts_node_parent_wasm = Module["_ts_node_parent_wasm"] = wasmExports["ts_node_parent_wasm"])(a0);
|
|
1489
|
+
var _ts_node_descendant_for_index_wasm = Module["_ts_node_descendant_for_index_wasm"] = (a0) => (_ts_node_descendant_for_index_wasm = Module["_ts_node_descendant_for_index_wasm"] = wasmExports["ts_node_descendant_for_index_wasm"])(a0);
|
|
1490
|
+
var _ts_node_named_descendant_for_index_wasm = Module["_ts_node_named_descendant_for_index_wasm"] = (a0) => (_ts_node_named_descendant_for_index_wasm = Module["_ts_node_named_descendant_for_index_wasm"] = wasmExports["ts_node_named_descendant_for_index_wasm"])(a0);
|
|
1491
|
+
var _ts_node_descendant_for_position_wasm = Module["_ts_node_descendant_for_position_wasm"] = (a0) => (_ts_node_descendant_for_position_wasm = Module["_ts_node_descendant_for_position_wasm"] = wasmExports["ts_node_descendant_for_position_wasm"])(a0);
|
|
1492
|
+
var _ts_node_named_descendant_for_position_wasm = Module["_ts_node_named_descendant_for_position_wasm"] = (a0) => (_ts_node_named_descendant_for_position_wasm = Module["_ts_node_named_descendant_for_position_wasm"] = wasmExports["ts_node_named_descendant_for_position_wasm"])(a0);
|
|
1493
|
+
var _ts_node_start_point_wasm = Module["_ts_node_start_point_wasm"] = (a0) => (_ts_node_start_point_wasm = Module["_ts_node_start_point_wasm"] = wasmExports["ts_node_start_point_wasm"])(a0);
|
|
1494
|
+
var _ts_node_end_point_wasm = Module["_ts_node_end_point_wasm"] = (a0) => (_ts_node_end_point_wasm = Module["_ts_node_end_point_wasm"] = wasmExports["ts_node_end_point_wasm"])(a0);
|
|
1495
|
+
var _ts_node_start_index_wasm = Module["_ts_node_start_index_wasm"] = (a0) => (_ts_node_start_index_wasm = Module["_ts_node_start_index_wasm"] = wasmExports["ts_node_start_index_wasm"])(a0);
|
|
1496
|
+
var _ts_node_end_index_wasm = Module["_ts_node_end_index_wasm"] = (a0) => (_ts_node_end_index_wasm = Module["_ts_node_end_index_wasm"] = wasmExports["ts_node_end_index_wasm"])(a0);
|
|
1497
|
+
var _ts_node_to_string_wasm = Module["_ts_node_to_string_wasm"] = (a0) => (_ts_node_to_string_wasm = Module["_ts_node_to_string_wasm"] = wasmExports["ts_node_to_string_wasm"])(a0);
|
|
1498
|
+
var _ts_node_children_wasm = Module["_ts_node_children_wasm"] = (a0) => (_ts_node_children_wasm = Module["_ts_node_children_wasm"] = wasmExports["ts_node_children_wasm"])(a0);
|
|
1499
|
+
var _ts_node_named_children_wasm = Module["_ts_node_named_children_wasm"] = (a0) => (_ts_node_named_children_wasm = Module["_ts_node_named_children_wasm"] = wasmExports["ts_node_named_children_wasm"])(a0);
|
|
1500
|
+
var _ts_node_descendants_of_type_wasm = Module["_ts_node_descendants_of_type_wasm"] = (a0, a1, a2, a3, a4, a5, a6) => (_ts_node_descendants_of_type_wasm = Module["_ts_node_descendants_of_type_wasm"] = wasmExports["ts_node_descendants_of_type_wasm"])(a0, a1, a2, a3, a4, a5, a6);
|
|
1501
|
+
var _ts_node_is_named_wasm = Module["_ts_node_is_named_wasm"] = (a0) => (_ts_node_is_named_wasm = Module["_ts_node_is_named_wasm"] = wasmExports["ts_node_is_named_wasm"])(a0);
|
|
1502
|
+
var _ts_node_has_changes_wasm = Module["_ts_node_has_changes_wasm"] = (a0) => (_ts_node_has_changes_wasm = Module["_ts_node_has_changes_wasm"] = wasmExports["ts_node_has_changes_wasm"])(a0);
|
|
1503
|
+
var _ts_node_has_error_wasm = Module["_ts_node_has_error_wasm"] = (a0) => (_ts_node_has_error_wasm = Module["_ts_node_has_error_wasm"] = wasmExports["ts_node_has_error_wasm"])(a0);
|
|
1504
|
+
var _ts_node_is_error_wasm = Module["_ts_node_is_error_wasm"] = (a0) => (_ts_node_is_error_wasm = Module["_ts_node_is_error_wasm"] = wasmExports["ts_node_is_error_wasm"])(a0);
|
|
1505
|
+
var _ts_node_is_missing_wasm = Module["_ts_node_is_missing_wasm"] = (a0) => (_ts_node_is_missing_wasm = Module["_ts_node_is_missing_wasm"] = wasmExports["ts_node_is_missing_wasm"])(a0);
|
|
1506
|
+
var _ts_node_is_extra_wasm = Module["_ts_node_is_extra_wasm"] = (a0) => (_ts_node_is_extra_wasm = Module["_ts_node_is_extra_wasm"] = wasmExports["ts_node_is_extra_wasm"])(a0);
|
|
1507
|
+
var _ts_node_parse_state_wasm = Module["_ts_node_parse_state_wasm"] = (a0) => (_ts_node_parse_state_wasm = Module["_ts_node_parse_state_wasm"] = wasmExports["ts_node_parse_state_wasm"])(a0);
|
|
1508
|
+
var _ts_node_next_parse_state_wasm = Module["_ts_node_next_parse_state_wasm"] = (a0) => (_ts_node_next_parse_state_wasm = Module["_ts_node_next_parse_state_wasm"] = wasmExports["ts_node_next_parse_state_wasm"])(a0);
|
|
1509
|
+
var _ts_query_matches_wasm = Module["_ts_query_matches_wasm"] = (a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) => (_ts_query_matches_wasm = Module["_ts_query_matches_wasm"] = wasmExports["ts_query_matches_wasm"])(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10);
|
|
1510
|
+
var _ts_query_captures_wasm = Module["_ts_query_captures_wasm"] = (a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) => (_ts_query_captures_wasm = Module["_ts_query_captures_wasm"] = wasmExports["ts_query_captures_wasm"])(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10);
|
|
1511
|
+
var _iswalpha = Module["_iswalpha"] = (a0) => (_iswalpha = Module["_iswalpha"] = wasmExports["iswalpha"])(a0);
|
|
1512
|
+
var _iswblank = Module["_iswblank"] = (a0) => (_iswblank = Module["_iswblank"] = wasmExports["iswblank"])(a0);
|
|
1513
|
+
var _iswdigit = Module["_iswdigit"] = (a0) => (_iswdigit = Module["_iswdigit"] = wasmExports["iswdigit"])(a0);
|
|
1514
|
+
var _iswlower = Module["_iswlower"] = (a0) => (_iswlower = Module["_iswlower"] = wasmExports["iswlower"])(a0);
|
|
1515
|
+
var _iswupper = Module["_iswupper"] = (a0) => (_iswupper = Module["_iswupper"] = wasmExports["iswupper"])(a0);
|
|
1516
|
+
var _iswxdigit = Module["_iswxdigit"] = (a0) => (_iswxdigit = Module["_iswxdigit"] = wasmExports["iswxdigit"])(a0);
|
|
1517
|
+
var _memchr = Module["_memchr"] = (a0, a1, a2) => (_memchr = Module["_memchr"] = wasmExports["memchr"])(a0, a1, a2);
|
|
1518
|
+
var _strlen = Module["_strlen"] = (a0) => (_strlen = Module["_strlen"] = wasmExports["strlen"])(a0);
|
|
1519
|
+
var _strcmp = Module["_strcmp"] = (a0, a1) => (_strcmp = Module["_strcmp"] = wasmExports["strcmp"])(a0, a1);
|
|
1520
|
+
var _strncat = Module["_strncat"] = (a0, a1, a2) => (_strncat = Module["_strncat"] = wasmExports["strncat"])(a0, a1, a2);
|
|
1521
|
+
var _strncpy = Module["_strncpy"] = (a0, a1, a2) => (_strncpy = Module["_strncpy"] = wasmExports["strncpy"])(a0, a1, a2);
|
|
1522
|
+
var _towlower = Module["_towlower"] = (a0) => (_towlower = Module["_towlower"] = wasmExports["towlower"])(a0);
|
|
1523
|
+
var _towupper = Module["_towupper"] = (a0) => (_towupper = Module["_towupper"] = wasmExports["towupper"])(a0);
|
|
1524
|
+
var _setThrew = (a0, a1) => (_setThrew = wasmExports["setThrew"])(a0, a1);
|
|
1525
|
+
var __emscripten_stack_restore = (a0) => (__emscripten_stack_restore = wasmExports["_emscripten_stack_restore"])(a0);
|
|
1526
|
+
var __emscripten_stack_alloc = (a0) => (__emscripten_stack_alloc = wasmExports["_emscripten_stack_alloc"])(a0);
|
|
1527
|
+
var _emscripten_stack_get_current = () => (_emscripten_stack_get_current = wasmExports["emscripten_stack_get_current"])();
|
|
1528
|
+
var dynCall_jiji = Module["dynCall_jiji"] = (a0, a1, a2, a3, a4) => (dynCall_jiji = Module["dynCall_jiji"] = wasmExports["dynCall_jiji"])(a0, a1, a2, a3, a4);
|
|
1529
|
+
var _orig$ts_parser_timeout_micros = Module["_orig$ts_parser_timeout_micros"] = (a0) => (_orig$ts_parser_timeout_micros = Module["_orig$ts_parser_timeout_micros"] = wasmExports["orig$ts_parser_timeout_micros"])(a0);
|
|
1530
|
+
var _orig$ts_parser_set_timeout_micros = Module["_orig$ts_parser_set_timeout_micros"] = (a0, a1) => (_orig$ts_parser_set_timeout_micros = Module["_orig$ts_parser_set_timeout_micros"] = wasmExports["orig$ts_parser_set_timeout_micros"])(a0, a1);
|
|
1531
|
+
Module["AsciiToString"] = AsciiToString;
|
|
1532
|
+
Module["stringToUTF16"] = stringToUTF16;
|
|
1533
|
+
var calledRun;
|
|
1534
|
+
dependenciesFulfilled = function runCaller() {
|
|
1535
|
+
if (!calledRun)
|
|
1536
|
+
run();
|
|
1537
|
+
if (!calledRun)
|
|
1538
|
+
dependenciesFulfilled = runCaller;
|
|
1539
|
+
};
|
|
1540
|
+
function callMain(args2 = []) {
|
|
1541
|
+
var entryFunction = resolveGlobalSymbol("main").sym;
|
|
1542
|
+
if (!entryFunction)
|
|
1543
|
+
return;
|
|
1544
|
+
args2.unshift(thisProgram);
|
|
1545
|
+
var argc = args2.length;
|
|
1546
|
+
var argv = stackAlloc((argc + 1) * 4);
|
|
1547
|
+
var argv_ptr = argv;
|
|
1548
|
+
args2.forEach((arg) => {
|
|
1549
|
+
LE_HEAP_STORE_U32((argv_ptr >> 2) * 4, stringToUTF8OnStack(arg));
|
|
1550
|
+
argv_ptr += 4;
|
|
1551
|
+
});
|
|
1552
|
+
LE_HEAP_STORE_U32((argv_ptr >> 2) * 4, 0);
|
|
1553
|
+
try {
|
|
1554
|
+
var ret = entryFunction(argc, argv);
|
|
1555
|
+
exitJS(ret, true);
|
|
1556
|
+
return ret;
|
|
1557
|
+
} catch (e) {
|
|
1558
|
+
return handleException(e);
|
|
1559
|
+
}
|
|
1560
|
+
}
|
|
1561
|
+
function run(args2 = arguments_) {
|
|
1562
|
+
if (runDependencies > 0) {
|
|
1563
|
+
return;
|
|
1564
|
+
}
|
|
1565
|
+
preRun();
|
|
1566
|
+
if (runDependencies > 0) {
|
|
1567
|
+
return;
|
|
1568
|
+
}
|
|
1569
|
+
function doRun() {
|
|
1570
|
+
if (calledRun)
|
|
1571
|
+
return;
|
|
1572
|
+
calledRun = true;
|
|
1573
|
+
Module["calledRun"] = true;
|
|
1574
|
+
if (ABORT)
|
|
1575
|
+
return;
|
|
1576
|
+
initRuntime();
|
|
1577
|
+
preMain();
|
|
1578
|
+
Module["onRuntimeInitialized"]?.();
|
|
1579
|
+
if (shouldRunNow)
|
|
1580
|
+
callMain(args2);
|
|
1581
|
+
postRun();
|
|
1582
|
+
}
|
|
1583
|
+
if (Module["setStatus"]) {
|
|
1584
|
+
Module["setStatus"]("Running...");
|
|
1585
|
+
setTimeout(function() {
|
|
1586
|
+
setTimeout(function() {
|
|
1587
|
+
Module["setStatus"]("");
|
|
1588
|
+
}, 1);
|
|
1589
|
+
doRun();
|
|
1590
|
+
}, 1);
|
|
1591
|
+
} else {
|
|
1592
|
+
doRun();
|
|
1593
|
+
}
|
|
1594
|
+
}
|
|
1595
|
+
if (Module["preInit"]) {
|
|
1596
|
+
if (typeof Module["preInit"] == "function")
|
|
1597
|
+
Module["preInit"] = [Module["preInit"]];
|
|
1598
|
+
while (Module["preInit"].length > 0) {
|
|
1599
|
+
Module["preInit"].pop()();
|
|
1600
|
+
}
|
|
1601
|
+
}
|
|
1602
|
+
var shouldRunNow = true;
|
|
1603
|
+
if (Module["noInitialRun"])
|
|
1604
|
+
shouldRunNow = false;
|
|
1605
|
+
run();
|
|
1606
|
+
const C = Module;
|
|
1607
|
+
const INTERNAL = {};
|
|
1608
|
+
const SIZE_OF_INT = 4;
|
|
1609
|
+
const SIZE_OF_CURSOR = 4 * SIZE_OF_INT;
|
|
1610
|
+
const SIZE_OF_NODE = 5 * SIZE_OF_INT;
|
|
1611
|
+
const SIZE_OF_POINT = 2 * SIZE_OF_INT;
|
|
1612
|
+
const SIZE_OF_RANGE = 2 * SIZE_OF_INT + 2 * SIZE_OF_POINT;
|
|
1613
|
+
const ZERO_POINT = {
|
|
1614
|
+
row: 0,
|
|
1615
|
+
column: 0
|
|
1616
|
+
};
|
|
1617
|
+
const QUERY_WORD_REGEX = /[\w-.]*/g;
|
|
1618
|
+
const PREDICATE_STEP_TYPE_CAPTURE = 1;
|
|
1619
|
+
const PREDICATE_STEP_TYPE_STRING = 2;
|
|
1620
|
+
const LANGUAGE_FUNCTION_REGEX = /^_?tree_sitter_\w+/;
|
|
1621
|
+
let VERSION;
|
|
1622
|
+
let MIN_COMPATIBLE_VERSION;
|
|
1623
|
+
let TRANSFER_BUFFER;
|
|
1624
|
+
let currentParseCallback;
|
|
1625
|
+
let currentLogCallback;
|
|
1626
|
+
|
|
1627
|
+
class ParserImpl {
|
|
1628
|
+
static init() {
|
|
1629
|
+
TRANSFER_BUFFER = C._ts_init();
|
|
1630
|
+
VERSION = getValue(TRANSFER_BUFFER, "i32");
|
|
1631
|
+
MIN_COMPATIBLE_VERSION = getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
|
|
1632
|
+
}
|
|
1633
|
+
initialize() {
|
|
1634
|
+
C._ts_parser_new_wasm();
|
|
1635
|
+
this[0] = getValue(TRANSFER_BUFFER, "i32");
|
|
1636
|
+
this[1] = getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
|
|
1637
|
+
}
|
|
1638
|
+
delete() {
|
|
1639
|
+
C._ts_parser_delete(this[0]);
|
|
1640
|
+
C._free(this[1]);
|
|
1641
|
+
this[0] = 0;
|
|
1642
|
+
this[1] = 0;
|
|
1643
|
+
}
|
|
1644
|
+
setLanguage(language) {
|
|
1645
|
+
let address;
|
|
1646
|
+
if (!language) {
|
|
1647
|
+
address = 0;
|
|
1648
|
+
language = null;
|
|
1649
|
+
} else if (language.constructor === Language) {
|
|
1650
|
+
address = language[0];
|
|
1651
|
+
const version = C._ts_language_version(address);
|
|
1652
|
+
if (version < MIN_COMPATIBLE_VERSION || VERSION < version) {
|
|
1653
|
+
throw new Error(`Incompatible language version ${version}. ` + `Compatibility range ${MIN_COMPATIBLE_VERSION} through ${VERSION}.`);
|
|
1654
|
+
}
|
|
1655
|
+
} else {
|
|
1656
|
+
throw new Error("Argument must be a Language");
|
|
1657
|
+
}
|
|
1658
|
+
this.language = language;
|
|
1659
|
+
C._ts_parser_set_language(this[0], address);
|
|
1660
|
+
return this;
|
|
1661
|
+
}
|
|
1662
|
+
getLanguage() {
|
|
1663
|
+
return this.language;
|
|
1664
|
+
}
|
|
1665
|
+
parse(callback, oldTree, options) {
|
|
1666
|
+
if (typeof callback === "string") {
|
|
1667
|
+
currentParseCallback = (index, _) => callback.slice(index);
|
|
1668
|
+
} else if (typeof callback === "function") {
|
|
1669
|
+
currentParseCallback = callback;
|
|
1670
|
+
} else {
|
|
1671
|
+
throw new Error("Argument must be a string or a function");
|
|
1672
|
+
}
|
|
1673
|
+
if (this.logCallback) {
|
|
1674
|
+
currentLogCallback = this.logCallback;
|
|
1675
|
+
C._ts_parser_enable_logger_wasm(this[0], 1);
|
|
1676
|
+
} else {
|
|
1677
|
+
currentLogCallback = null;
|
|
1678
|
+
C._ts_parser_enable_logger_wasm(this[0], 0);
|
|
1679
|
+
}
|
|
1680
|
+
let rangeCount = 0;
|
|
1681
|
+
let rangeAddress = 0;
|
|
1682
|
+
if (options?.includedRanges) {
|
|
1683
|
+
rangeCount = options.includedRanges.length;
|
|
1684
|
+
rangeAddress = C._calloc(rangeCount, SIZE_OF_RANGE);
|
|
1685
|
+
let address = rangeAddress;
|
|
1686
|
+
for (let i2 = 0;i2 < rangeCount; i2++) {
|
|
1687
|
+
marshalRange(address, options.includedRanges[i2]);
|
|
1688
|
+
address += SIZE_OF_RANGE;
|
|
1689
|
+
}
|
|
1690
|
+
}
|
|
1691
|
+
const treeAddress = C._ts_parser_parse_wasm(this[0], this[1], oldTree ? oldTree[0] : 0, rangeAddress, rangeCount);
|
|
1692
|
+
if (!treeAddress) {
|
|
1693
|
+
currentParseCallback = null;
|
|
1694
|
+
currentLogCallback = null;
|
|
1695
|
+
throw new Error("Parsing failed");
|
|
1696
|
+
}
|
|
1697
|
+
const result = new Tree(INTERNAL, treeAddress, this.language, currentParseCallback);
|
|
1698
|
+
currentParseCallback = null;
|
|
1699
|
+
currentLogCallback = null;
|
|
1700
|
+
return result;
|
|
1701
|
+
}
|
|
1702
|
+
reset() {
|
|
1703
|
+
C._ts_parser_reset(this[0]);
|
|
1704
|
+
}
|
|
1705
|
+
getIncludedRanges() {
|
|
1706
|
+
C._ts_parser_included_ranges_wasm(this[0]);
|
|
1707
|
+
const count = getValue(TRANSFER_BUFFER, "i32");
|
|
1708
|
+
const buffer = getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
|
|
1709
|
+
const result = new Array(count);
|
|
1710
|
+
if (count > 0) {
|
|
1711
|
+
let address = buffer;
|
|
1712
|
+
for (let i2 = 0;i2 < count; i2++) {
|
|
1713
|
+
result[i2] = unmarshalRange(address);
|
|
1714
|
+
address += SIZE_OF_RANGE;
|
|
1715
|
+
}
|
|
1716
|
+
C._free(buffer);
|
|
1717
|
+
}
|
|
1718
|
+
return result;
|
|
1719
|
+
}
|
|
1720
|
+
getTimeoutMicros() {
|
|
1721
|
+
return C._ts_parser_timeout_micros(this[0]);
|
|
1722
|
+
}
|
|
1723
|
+
setTimeoutMicros(timeout) {
|
|
1724
|
+
C._ts_parser_set_timeout_micros(this[0], timeout);
|
|
1725
|
+
}
|
|
1726
|
+
setLogger(callback) {
|
|
1727
|
+
if (!callback) {
|
|
1728
|
+
callback = null;
|
|
1729
|
+
} else if (typeof callback !== "function") {
|
|
1730
|
+
throw new Error("Logger callback must be a function");
|
|
1731
|
+
}
|
|
1732
|
+
this.logCallback = callback;
|
|
1733
|
+
return this;
|
|
1734
|
+
}
|
|
1735
|
+
getLogger() {
|
|
1736
|
+
return this.logCallback;
|
|
1737
|
+
}
|
|
1738
|
+
}
|
|
1739
|
+
|
|
1740
|
+
class Tree {
|
|
1741
|
+
constructor(internal, address, language, textCallback) {
|
|
1742
|
+
assertInternal(internal);
|
|
1743
|
+
this[0] = address;
|
|
1744
|
+
this.language = language;
|
|
1745
|
+
this.textCallback = textCallback;
|
|
1746
|
+
}
|
|
1747
|
+
copy() {
|
|
1748
|
+
const address = C._ts_tree_copy(this[0]);
|
|
1749
|
+
return new Tree(INTERNAL, address, this.language, this.textCallback);
|
|
1750
|
+
}
|
|
1751
|
+
delete() {
|
|
1752
|
+
C._ts_tree_delete(this[0]);
|
|
1753
|
+
this[0] = 0;
|
|
1754
|
+
}
|
|
1755
|
+
edit(edit) {
|
|
1756
|
+
marshalEdit(edit);
|
|
1757
|
+
C._ts_tree_edit_wasm(this[0]);
|
|
1758
|
+
}
|
|
1759
|
+
get rootNode() {
|
|
1760
|
+
C._ts_tree_root_node_wasm(this[0]);
|
|
1761
|
+
return unmarshalNode(this);
|
|
1762
|
+
}
|
|
1763
|
+
rootNodeWithOffset(offsetBytes, offsetExtent) {
|
|
1764
|
+
const address = TRANSFER_BUFFER + SIZE_OF_NODE;
|
|
1765
|
+
setValue(address, offsetBytes, "i32");
|
|
1766
|
+
marshalPoint(address + SIZE_OF_INT, offsetExtent);
|
|
1767
|
+
C._ts_tree_root_node_with_offset_wasm(this[0]);
|
|
1768
|
+
return unmarshalNode(this);
|
|
1769
|
+
}
|
|
1770
|
+
getLanguage() {
|
|
1771
|
+
return this.language;
|
|
1772
|
+
}
|
|
1773
|
+
walk() {
|
|
1774
|
+
return this.rootNode.walk();
|
|
1775
|
+
}
|
|
1776
|
+
getChangedRanges(other) {
|
|
1777
|
+
if (other.constructor !== Tree) {
|
|
1778
|
+
throw new TypeError("Argument must be a Tree");
|
|
1779
|
+
}
|
|
1780
|
+
C._ts_tree_get_changed_ranges_wasm(this[0], other[0]);
|
|
1781
|
+
const count = getValue(TRANSFER_BUFFER, "i32");
|
|
1782
|
+
const buffer = getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
|
|
1783
|
+
const result = new Array(count);
|
|
1784
|
+
if (count > 0) {
|
|
1785
|
+
let address = buffer;
|
|
1786
|
+
for (let i2 = 0;i2 < count; i2++) {
|
|
1787
|
+
result[i2] = unmarshalRange(address);
|
|
1788
|
+
address += SIZE_OF_RANGE;
|
|
1789
|
+
}
|
|
1790
|
+
C._free(buffer);
|
|
1791
|
+
}
|
|
1792
|
+
return result;
|
|
1793
|
+
}
|
|
1794
|
+
getIncludedRanges() {
|
|
1795
|
+
C._ts_tree_included_ranges_wasm(this[0]);
|
|
1796
|
+
const count = getValue(TRANSFER_BUFFER, "i32");
|
|
1797
|
+
const buffer = getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
|
|
1798
|
+
const result = new Array(count);
|
|
1799
|
+
if (count > 0) {
|
|
1800
|
+
let address = buffer;
|
|
1801
|
+
for (let i2 = 0;i2 < count; i2++) {
|
|
1802
|
+
result[i2] = unmarshalRange(address);
|
|
1803
|
+
address += SIZE_OF_RANGE;
|
|
1804
|
+
}
|
|
1805
|
+
C._free(buffer);
|
|
1806
|
+
}
|
|
1807
|
+
return result;
|
|
1808
|
+
}
|
|
1809
|
+
}
|
|
1810
|
+
|
|
1811
|
+
class Node {
|
|
1812
|
+
constructor(internal, tree) {
|
|
1813
|
+
assertInternal(internal);
|
|
1814
|
+
this.tree = tree;
|
|
1815
|
+
}
|
|
1816
|
+
get typeId() {
|
|
1817
|
+
marshalNode(this);
|
|
1818
|
+
return C._ts_node_symbol_wasm(this.tree[0]);
|
|
1819
|
+
}
|
|
1820
|
+
get grammarId() {
|
|
1821
|
+
marshalNode(this);
|
|
1822
|
+
return C._ts_node_grammar_symbol_wasm(this.tree[0]);
|
|
1823
|
+
}
|
|
1824
|
+
get type() {
|
|
1825
|
+
return this.tree.language.types[this.typeId] || "ERROR";
|
|
1826
|
+
}
|
|
1827
|
+
get grammarType() {
|
|
1828
|
+
return this.tree.language.types[this.grammarId] || "ERROR";
|
|
1829
|
+
}
|
|
1830
|
+
get endPosition() {
|
|
1831
|
+
marshalNode(this);
|
|
1832
|
+
C._ts_node_end_point_wasm(this.tree[0]);
|
|
1833
|
+
return unmarshalPoint(TRANSFER_BUFFER);
|
|
1834
|
+
}
|
|
1835
|
+
get endIndex() {
|
|
1836
|
+
marshalNode(this);
|
|
1837
|
+
return C._ts_node_end_index_wasm(this.tree[0]);
|
|
1838
|
+
}
|
|
1839
|
+
get text() {
|
|
1840
|
+
return getText(this.tree, this.startIndex, this.endIndex);
|
|
1841
|
+
}
|
|
1842
|
+
get parseState() {
|
|
1843
|
+
marshalNode(this);
|
|
1844
|
+
return C._ts_node_parse_state_wasm(this.tree[0]);
|
|
1845
|
+
}
|
|
1846
|
+
get nextParseState() {
|
|
1847
|
+
marshalNode(this);
|
|
1848
|
+
return C._ts_node_next_parse_state_wasm(this.tree[0]);
|
|
1849
|
+
}
|
|
1850
|
+
get isNamed() {
|
|
1851
|
+
marshalNode(this);
|
|
1852
|
+
return C._ts_node_is_named_wasm(this.tree[0]) === 1;
|
|
1853
|
+
}
|
|
1854
|
+
get hasError() {
|
|
1855
|
+
marshalNode(this);
|
|
1856
|
+
return C._ts_node_has_error_wasm(this.tree[0]) === 1;
|
|
1857
|
+
}
|
|
1858
|
+
get hasChanges() {
|
|
1859
|
+
marshalNode(this);
|
|
1860
|
+
return C._ts_node_has_changes_wasm(this.tree[0]) === 1;
|
|
1861
|
+
}
|
|
1862
|
+
get isError() {
|
|
1863
|
+
marshalNode(this);
|
|
1864
|
+
return C._ts_node_is_error_wasm(this.tree[0]) === 1;
|
|
1865
|
+
}
|
|
1866
|
+
get isMissing() {
|
|
1867
|
+
marshalNode(this);
|
|
1868
|
+
return C._ts_node_is_missing_wasm(this.tree[0]) === 1;
|
|
1869
|
+
}
|
|
1870
|
+
get isExtra() {
|
|
1871
|
+
marshalNode(this);
|
|
1872
|
+
return C._ts_node_is_extra_wasm(this.tree[0]) === 1;
|
|
1873
|
+
}
|
|
1874
|
+
equals(other) {
|
|
1875
|
+
return this.id === other.id;
|
|
1876
|
+
}
|
|
1877
|
+
child(index) {
|
|
1878
|
+
marshalNode(this);
|
|
1879
|
+
C._ts_node_child_wasm(this.tree[0], index);
|
|
1880
|
+
return unmarshalNode(this.tree);
|
|
1881
|
+
}
|
|
1882
|
+
namedChild(index) {
|
|
1883
|
+
marshalNode(this);
|
|
1884
|
+
C._ts_node_named_child_wasm(this.tree[0], index);
|
|
1885
|
+
return unmarshalNode(this.tree);
|
|
1886
|
+
}
|
|
1887
|
+
childForFieldId(fieldId) {
|
|
1888
|
+
marshalNode(this);
|
|
1889
|
+
C._ts_node_child_by_field_id_wasm(this.tree[0], fieldId);
|
|
1890
|
+
return unmarshalNode(this.tree);
|
|
1891
|
+
}
|
|
1892
|
+
childForFieldName(fieldName) {
|
|
1893
|
+
const fieldId = this.tree.language.fields.indexOf(fieldName);
|
|
1894
|
+
if (fieldId !== -1)
|
|
1895
|
+
return this.childForFieldId(fieldId);
|
|
1896
|
+
return null;
|
|
1897
|
+
}
|
|
1898
|
+
fieldNameForChild(index) {
|
|
1899
|
+
marshalNode(this);
|
|
1900
|
+
const address = C._ts_node_field_name_for_child_wasm(this.tree[0], index);
|
|
1901
|
+
if (!address) {
|
|
1902
|
+
return null;
|
|
1903
|
+
}
|
|
1904
|
+
const result = AsciiToString(address);
|
|
1905
|
+
return result;
|
|
1906
|
+
}
|
|
1907
|
+
childrenForFieldName(fieldName) {
|
|
1908
|
+
const fieldId = this.tree.language.fields.indexOf(fieldName);
|
|
1909
|
+
if (fieldId !== -1 && fieldId !== 0)
|
|
1910
|
+
return this.childrenForFieldId(fieldId);
|
|
1911
|
+
return [];
|
|
1912
|
+
}
|
|
1913
|
+
childrenForFieldId(fieldId) {
|
|
1914
|
+
marshalNode(this);
|
|
1915
|
+
C._ts_node_children_by_field_id_wasm(this.tree[0], fieldId);
|
|
1916
|
+
const count = getValue(TRANSFER_BUFFER, "i32");
|
|
1917
|
+
const buffer = getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
|
|
1918
|
+
const result = new Array(count);
|
|
1919
|
+
if (count > 0) {
|
|
1920
|
+
let address = buffer;
|
|
1921
|
+
for (let i2 = 0;i2 < count; i2++) {
|
|
1922
|
+
result[i2] = unmarshalNode(this.tree, address);
|
|
1923
|
+
address += SIZE_OF_NODE;
|
|
1924
|
+
}
|
|
1925
|
+
C._free(buffer);
|
|
1926
|
+
}
|
|
1927
|
+
return result;
|
|
1928
|
+
}
|
|
1929
|
+
firstChildForIndex(index) {
|
|
1930
|
+
marshalNode(this);
|
|
1931
|
+
const address = TRANSFER_BUFFER + SIZE_OF_NODE;
|
|
1932
|
+
setValue(address, index, "i32");
|
|
1933
|
+
C._ts_node_first_child_for_byte_wasm(this.tree[0]);
|
|
1934
|
+
return unmarshalNode(this.tree);
|
|
1935
|
+
}
|
|
1936
|
+
firstNamedChildForIndex(index) {
|
|
1937
|
+
marshalNode(this);
|
|
1938
|
+
const address = TRANSFER_BUFFER + SIZE_OF_NODE;
|
|
1939
|
+
setValue(address, index, "i32");
|
|
1940
|
+
C._ts_node_first_named_child_for_byte_wasm(this.tree[0]);
|
|
1941
|
+
return unmarshalNode(this.tree);
|
|
1942
|
+
}
|
|
1943
|
+
get childCount() {
|
|
1944
|
+
marshalNode(this);
|
|
1945
|
+
return C._ts_node_child_count_wasm(this.tree[0]);
|
|
1946
|
+
}
|
|
1947
|
+
get namedChildCount() {
|
|
1948
|
+
marshalNode(this);
|
|
1949
|
+
return C._ts_node_named_child_count_wasm(this.tree[0]);
|
|
1950
|
+
}
|
|
1951
|
+
get firstChild() {
|
|
1952
|
+
return this.child(0);
|
|
1953
|
+
}
|
|
1954
|
+
get firstNamedChild() {
|
|
1955
|
+
return this.namedChild(0);
|
|
1956
|
+
}
|
|
1957
|
+
get lastChild() {
|
|
1958
|
+
return this.child(this.childCount - 1);
|
|
1959
|
+
}
|
|
1960
|
+
get lastNamedChild() {
|
|
1961
|
+
return this.namedChild(this.namedChildCount - 1);
|
|
1962
|
+
}
|
|
1963
|
+
get children() {
|
|
1964
|
+
if (!this._children) {
|
|
1965
|
+
marshalNode(this);
|
|
1966
|
+
C._ts_node_children_wasm(this.tree[0]);
|
|
1967
|
+
const count = getValue(TRANSFER_BUFFER, "i32");
|
|
1968
|
+
const buffer = getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
|
|
1969
|
+
this._children = new Array(count);
|
|
1970
|
+
if (count > 0) {
|
|
1971
|
+
let address = buffer;
|
|
1972
|
+
for (let i2 = 0;i2 < count; i2++) {
|
|
1973
|
+
this._children[i2] = unmarshalNode(this.tree, address);
|
|
1974
|
+
address += SIZE_OF_NODE;
|
|
1975
|
+
}
|
|
1976
|
+
C._free(buffer);
|
|
1977
|
+
}
|
|
1978
|
+
}
|
|
1979
|
+
return this._children;
|
|
1980
|
+
}
|
|
1981
|
+
get namedChildren() {
|
|
1982
|
+
if (!this._namedChildren) {
|
|
1983
|
+
marshalNode(this);
|
|
1984
|
+
C._ts_node_named_children_wasm(this.tree[0]);
|
|
1985
|
+
const count = getValue(TRANSFER_BUFFER, "i32");
|
|
1986
|
+
const buffer = getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
|
|
1987
|
+
this._namedChildren = new Array(count);
|
|
1988
|
+
if (count > 0) {
|
|
1989
|
+
let address = buffer;
|
|
1990
|
+
for (let i2 = 0;i2 < count; i2++) {
|
|
1991
|
+
this._namedChildren[i2] = unmarshalNode(this.tree, address);
|
|
1992
|
+
address += SIZE_OF_NODE;
|
|
1993
|
+
}
|
|
1994
|
+
C._free(buffer);
|
|
1995
|
+
}
|
|
1996
|
+
}
|
|
1997
|
+
return this._namedChildren;
|
|
1998
|
+
}
|
|
1999
|
+
descendantsOfType(types2, startPosition, endPosition) {
|
|
2000
|
+
if (!Array.isArray(types2))
|
|
2001
|
+
types2 = [types2];
|
|
2002
|
+
if (!startPosition)
|
|
2003
|
+
startPosition = ZERO_POINT;
|
|
2004
|
+
if (!endPosition)
|
|
2005
|
+
endPosition = ZERO_POINT;
|
|
2006
|
+
const symbols = [];
|
|
2007
|
+
const typesBySymbol = this.tree.language.types;
|
|
2008
|
+
for (let i2 = 0, n = typesBySymbol.length;i2 < n; i2++) {
|
|
2009
|
+
if (types2.includes(typesBySymbol[i2])) {
|
|
2010
|
+
symbols.push(i2);
|
|
2011
|
+
}
|
|
2012
|
+
}
|
|
2013
|
+
const symbolsAddress = C._malloc(SIZE_OF_INT * symbols.length);
|
|
2014
|
+
for (let i2 = 0, n = symbols.length;i2 < n; i2++) {
|
|
2015
|
+
setValue(symbolsAddress + i2 * SIZE_OF_INT, symbols[i2], "i32");
|
|
2016
|
+
}
|
|
2017
|
+
marshalNode(this);
|
|
2018
|
+
C._ts_node_descendants_of_type_wasm(this.tree[0], symbolsAddress, symbols.length, startPosition.row, startPosition.column, endPosition.row, endPosition.column);
|
|
2019
|
+
const descendantCount = getValue(TRANSFER_BUFFER, "i32");
|
|
2020
|
+
const descendantAddress = getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
|
|
2021
|
+
const result = new Array(descendantCount);
|
|
2022
|
+
if (descendantCount > 0) {
|
|
2023
|
+
let address = descendantAddress;
|
|
2024
|
+
for (let i2 = 0;i2 < descendantCount; i2++) {
|
|
2025
|
+
result[i2] = unmarshalNode(this.tree, address);
|
|
2026
|
+
address += SIZE_OF_NODE;
|
|
2027
|
+
}
|
|
2028
|
+
}
|
|
2029
|
+
C._free(descendantAddress);
|
|
2030
|
+
C._free(symbolsAddress);
|
|
2031
|
+
return result;
|
|
2032
|
+
}
|
|
2033
|
+
get nextSibling() {
|
|
2034
|
+
marshalNode(this);
|
|
2035
|
+
C._ts_node_next_sibling_wasm(this.tree[0]);
|
|
2036
|
+
return unmarshalNode(this.tree);
|
|
2037
|
+
}
|
|
2038
|
+
get previousSibling() {
|
|
2039
|
+
marshalNode(this);
|
|
2040
|
+
C._ts_node_prev_sibling_wasm(this.tree[0]);
|
|
2041
|
+
return unmarshalNode(this.tree);
|
|
2042
|
+
}
|
|
2043
|
+
get nextNamedSibling() {
|
|
2044
|
+
marshalNode(this);
|
|
2045
|
+
C._ts_node_next_named_sibling_wasm(this.tree[0]);
|
|
2046
|
+
return unmarshalNode(this.tree);
|
|
2047
|
+
}
|
|
2048
|
+
get previousNamedSibling() {
|
|
2049
|
+
marshalNode(this);
|
|
2050
|
+
C._ts_node_prev_named_sibling_wasm(this.tree[0]);
|
|
2051
|
+
return unmarshalNode(this.tree);
|
|
2052
|
+
}
|
|
2053
|
+
get descendantCount() {
|
|
2054
|
+
marshalNode(this);
|
|
2055
|
+
return C._ts_node_descendant_count_wasm(this.tree[0]);
|
|
2056
|
+
}
|
|
2057
|
+
get parent() {
|
|
2058
|
+
marshalNode(this);
|
|
2059
|
+
C._ts_node_parent_wasm(this.tree[0]);
|
|
2060
|
+
return unmarshalNode(this.tree);
|
|
2061
|
+
}
|
|
2062
|
+
descendantForIndex(start2, end = start2) {
|
|
2063
|
+
if (typeof start2 !== "number" || typeof end !== "number") {
|
|
2064
|
+
throw new Error("Arguments must be numbers");
|
|
2065
|
+
}
|
|
2066
|
+
marshalNode(this);
|
|
2067
|
+
const address = TRANSFER_BUFFER + SIZE_OF_NODE;
|
|
2068
|
+
setValue(address, start2, "i32");
|
|
2069
|
+
setValue(address + SIZE_OF_INT, end, "i32");
|
|
2070
|
+
C._ts_node_descendant_for_index_wasm(this.tree[0]);
|
|
2071
|
+
return unmarshalNode(this.tree);
|
|
2072
|
+
}
|
|
2073
|
+
namedDescendantForIndex(start2, end = start2) {
|
|
2074
|
+
if (typeof start2 !== "number" || typeof end !== "number") {
|
|
2075
|
+
throw new Error("Arguments must be numbers");
|
|
2076
|
+
}
|
|
2077
|
+
marshalNode(this);
|
|
2078
|
+
const address = TRANSFER_BUFFER + SIZE_OF_NODE;
|
|
2079
|
+
setValue(address, start2, "i32");
|
|
2080
|
+
setValue(address + SIZE_OF_INT, end, "i32");
|
|
2081
|
+
C._ts_node_named_descendant_for_index_wasm(this.tree[0]);
|
|
2082
|
+
return unmarshalNode(this.tree);
|
|
2083
|
+
}
|
|
2084
|
+
descendantForPosition(start2, end = start2) {
|
|
2085
|
+
if (!isPoint(start2) || !isPoint(end)) {
|
|
2086
|
+
throw new Error("Arguments must be {row, column} objects");
|
|
2087
|
+
}
|
|
2088
|
+
marshalNode(this);
|
|
2089
|
+
const address = TRANSFER_BUFFER + SIZE_OF_NODE;
|
|
2090
|
+
marshalPoint(address, start2);
|
|
2091
|
+
marshalPoint(address + SIZE_OF_POINT, end);
|
|
2092
|
+
C._ts_node_descendant_for_position_wasm(this.tree[0]);
|
|
2093
|
+
return unmarshalNode(this.tree);
|
|
2094
|
+
}
|
|
2095
|
+
namedDescendantForPosition(start2, end = start2) {
|
|
2096
|
+
if (!isPoint(start2) || !isPoint(end)) {
|
|
2097
|
+
throw new Error("Arguments must be {row, column} objects");
|
|
2098
|
+
}
|
|
2099
|
+
marshalNode(this);
|
|
2100
|
+
const address = TRANSFER_BUFFER + SIZE_OF_NODE;
|
|
2101
|
+
marshalPoint(address, start2);
|
|
2102
|
+
marshalPoint(address + SIZE_OF_POINT, end);
|
|
2103
|
+
C._ts_node_named_descendant_for_position_wasm(this.tree[0]);
|
|
2104
|
+
return unmarshalNode(this.tree);
|
|
2105
|
+
}
|
|
2106
|
+
walk() {
|
|
2107
|
+
marshalNode(this);
|
|
2108
|
+
C._ts_tree_cursor_new_wasm(this.tree[0]);
|
|
2109
|
+
return new TreeCursor(INTERNAL, this.tree);
|
|
2110
|
+
}
|
|
2111
|
+
toString() {
|
|
2112
|
+
marshalNode(this);
|
|
2113
|
+
const address = C._ts_node_to_string_wasm(this.tree[0]);
|
|
2114
|
+
const result = AsciiToString(address);
|
|
2115
|
+
C._free(address);
|
|
2116
|
+
return result;
|
|
2117
|
+
}
|
|
2118
|
+
}
|
|
2119
|
+
|
|
2120
|
+
class TreeCursor {
|
|
2121
|
+
constructor(internal, tree) {
|
|
2122
|
+
assertInternal(internal);
|
|
2123
|
+
this.tree = tree;
|
|
2124
|
+
unmarshalTreeCursor(this);
|
|
2125
|
+
}
|
|
2126
|
+
delete() {
|
|
2127
|
+
marshalTreeCursor(this);
|
|
2128
|
+
C._ts_tree_cursor_delete_wasm(this.tree[0]);
|
|
2129
|
+
this[0] = this[1] = this[2] = 0;
|
|
2130
|
+
}
|
|
2131
|
+
reset(node) {
|
|
2132
|
+
marshalNode(node);
|
|
2133
|
+
marshalTreeCursor(this, TRANSFER_BUFFER + SIZE_OF_NODE);
|
|
2134
|
+
C._ts_tree_cursor_reset_wasm(this.tree[0]);
|
|
2135
|
+
unmarshalTreeCursor(this);
|
|
2136
|
+
}
|
|
2137
|
+
resetTo(cursor) {
|
|
2138
|
+
marshalTreeCursor(this, TRANSFER_BUFFER);
|
|
2139
|
+
marshalTreeCursor(cursor, TRANSFER_BUFFER + SIZE_OF_CURSOR);
|
|
2140
|
+
C._ts_tree_cursor_reset_to_wasm(this.tree[0], cursor.tree[0]);
|
|
2141
|
+
unmarshalTreeCursor(this);
|
|
2142
|
+
}
|
|
2143
|
+
get nodeType() {
|
|
2144
|
+
return this.tree.language.types[this.nodeTypeId] || "ERROR";
|
|
2145
|
+
}
|
|
2146
|
+
get nodeTypeId() {
|
|
2147
|
+
marshalTreeCursor(this);
|
|
2148
|
+
return C._ts_tree_cursor_current_node_type_id_wasm(this.tree[0]);
|
|
2149
|
+
}
|
|
2150
|
+
get nodeStateId() {
|
|
2151
|
+
marshalTreeCursor(this);
|
|
2152
|
+
return C._ts_tree_cursor_current_node_state_id_wasm(this.tree[0]);
|
|
2153
|
+
}
|
|
2154
|
+
get nodeId() {
|
|
2155
|
+
marshalTreeCursor(this);
|
|
2156
|
+
return C._ts_tree_cursor_current_node_id_wasm(this.tree[0]);
|
|
2157
|
+
}
|
|
2158
|
+
get nodeIsNamed() {
|
|
2159
|
+
marshalTreeCursor(this);
|
|
2160
|
+
return C._ts_tree_cursor_current_node_is_named_wasm(this.tree[0]) === 1;
|
|
2161
|
+
}
|
|
2162
|
+
get nodeIsMissing() {
|
|
2163
|
+
marshalTreeCursor(this);
|
|
2164
|
+
return C._ts_tree_cursor_current_node_is_missing_wasm(this.tree[0]) === 1;
|
|
2165
|
+
}
|
|
2166
|
+
get nodeText() {
|
|
2167
|
+
marshalTreeCursor(this);
|
|
2168
|
+
const startIndex = C._ts_tree_cursor_start_index_wasm(this.tree[0]);
|
|
2169
|
+
const endIndex = C._ts_tree_cursor_end_index_wasm(this.tree[0]);
|
|
2170
|
+
return getText(this.tree, startIndex, endIndex);
|
|
2171
|
+
}
|
|
2172
|
+
get startPosition() {
|
|
2173
|
+
marshalTreeCursor(this);
|
|
2174
|
+
C._ts_tree_cursor_start_position_wasm(this.tree[0]);
|
|
2175
|
+
return unmarshalPoint(TRANSFER_BUFFER);
|
|
2176
|
+
}
|
|
2177
|
+
get endPosition() {
|
|
2178
|
+
marshalTreeCursor(this);
|
|
2179
|
+
C._ts_tree_cursor_end_position_wasm(this.tree[0]);
|
|
2180
|
+
return unmarshalPoint(TRANSFER_BUFFER);
|
|
2181
|
+
}
|
|
2182
|
+
get startIndex() {
|
|
2183
|
+
marshalTreeCursor(this);
|
|
2184
|
+
return C._ts_tree_cursor_start_index_wasm(this.tree[0]);
|
|
2185
|
+
}
|
|
2186
|
+
get endIndex() {
|
|
2187
|
+
marshalTreeCursor(this);
|
|
2188
|
+
return C._ts_tree_cursor_end_index_wasm(this.tree[0]);
|
|
2189
|
+
}
|
|
2190
|
+
get currentNode() {
|
|
2191
|
+
marshalTreeCursor(this);
|
|
2192
|
+
C._ts_tree_cursor_current_node_wasm(this.tree[0]);
|
|
2193
|
+
return unmarshalNode(this.tree);
|
|
2194
|
+
}
|
|
2195
|
+
get currentFieldId() {
|
|
2196
|
+
marshalTreeCursor(this);
|
|
2197
|
+
return C._ts_tree_cursor_current_field_id_wasm(this.tree[0]);
|
|
2198
|
+
}
|
|
2199
|
+
get currentFieldName() {
|
|
2200
|
+
return this.tree.language.fields[this.currentFieldId];
|
|
2201
|
+
}
|
|
2202
|
+
get currentDepth() {
|
|
2203
|
+
marshalTreeCursor(this);
|
|
2204
|
+
return C._ts_tree_cursor_current_depth_wasm(this.tree[0]);
|
|
2205
|
+
}
|
|
2206
|
+
get currentDescendantIndex() {
|
|
2207
|
+
marshalTreeCursor(this);
|
|
2208
|
+
return C._ts_tree_cursor_current_descendant_index_wasm(this.tree[0]);
|
|
2209
|
+
}
|
|
2210
|
+
gotoFirstChild() {
|
|
2211
|
+
marshalTreeCursor(this);
|
|
2212
|
+
const result = C._ts_tree_cursor_goto_first_child_wasm(this.tree[0]);
|
|
2213
|
+
unmarshalTreeCursor(this);
|
|
2214
|
+
return result === 1;
|
|
2215
|
+
}
|
|
2216
|
+
gotoLastChild() {
|
|
2217
|
+
marshalTreeCursor(this);
|
|
2218
|
+
const result = C._ts_tree_cursor_goto_last_child_wasm(this.tree[0]);
|
|
2219
|
+
unmarshalTreeCursor(this);
|
|
2220
|
+
return result === 1;
|
|
2221
|
+
}
|
|
2222
|
+
gotoFirstChildForIndex(goalIndex) {
|
|
2223
|
+
marshalTreeCursor(this);
|
|
2224
|
+
setValue(TRANSFER_BUFFER + SIZE_OF_CURSOR, goalIndex, "i32");
|
|
2225
|
+
const result = C._ts_tree_cursor_goto_first_child_for_index_wasm(this.tree[0]);
|
|
2226
|
+
unmarshalTreeCursor(this);
|
|
2227
|
+
return result === 1;
|
|
2228
|
+
}
|
|
2229
|
+
gotoFirstChildForPosition(goalPosition) {
|
|
2230
|
+
marshalTreeCursor(this);
|
|
2231
|
+
marshalPoint(TRANSFER_BUFFER + SIZE_OF_CURSOR, goalPosition);
|
|
2232
|
+
const result = C._ts_tree_cursor_goto_first_child_for_position_wasm(this.tree[0]);
|
|
2233
|
+
unmarshalTreeCursor(this);
|
|
2234
|
+
return result === 1;
|
|
2235
|
+
}
|
|
2236
|
+
gotoNextSibling() {
|
|
2237
|
+
marshalTreeCursor(this);
|
|
2238
|
+
const result = C._ts_tree_cursor_goto_next_sibling_wasm(this.tree[0]);
|
|
2239
|
+
unmarshalTreeCursor(this);
|
|
2240
|
+
return result === 1;
|
|
2241
|
+
}
|
|
2242
|
+
gotoPreviousSibling() {
|
|
2243
|
+
marshalTreeCursor(this);
|
|
2244
|
+
const result = C._ts_tree_cursor_goto_previous_sibling_wasm(this.tree[0]);
|
|
2245
|
+
unmarshalTreeCursor(this);
|
|
2246
|
+
return result === 1;
|
|
2247
|
+
}
|
|
2248
|
+
gotoDescendant(goalDescendantindex) {
|
|
2249
|
+
marshalTreeCursor(this);
|
|
2250
|
+
C._ts_tree_cursor_goto_descendant_wasm(this.tree[0], goalDescendantindex);
|
|
2251
|
+
unmarshalTreeCursor(this);
|
|
2252
|
+
}
|
|
2253
|
+
gotoParent() {
|
|
2254
|
+
marshalTreeCursor(this);
|
|
2255
|
+
const result = C._ts_tree_cursor_goto_parent_wasm(this.tree[0]);
|
|
2256
|
+
unmarshalTreeCursor(this);
|
|
2257
|
+
return result === 1;
|
|
2258
|
+
}
|
|
2259
|
+
}
|
|
2260
|
+
|
|
2261
|
+
class Language {
|
|
2262
|
+
constructor(internal, address) {
|
|
2263
|
+
assertInternal(internal);
|
|
2264
|
+
this[0] = address;
|
|
2265
|
+
this.types = new Array(C._ts_language_symbol_count(this[0]));
|
|
2266
|
+
for (let i2 = 0, n = this.types.length;i2 < n; i2++) {
|
|
2267
|
+
if (C._ts_language_symbol_type(this[0], i2) < 2) {
|
|
2268
|
+
this.types[i2] = UTF8ToString(C._ts_language_symbol_name(this[0], i2));
|
|
2269
|
+
}
|
|
2270
|
+
}
|
|
2271
|
+
this.fields = new Array(C._ts_language_field_count(this[0]) + 1);
|
|
2272
|
+
for (let i2 = 0, n = this.fields.length;i2 < n; i2++) {
|
|
2273
|
+
const fieldName = C._ts_language_field_name_for_id(this[0], i2);
|
|
2274
|
+
if (fieldName !== 0) {
|
|
2275
|
+
this.fields[i2] = UTF8ToString(fieldName);
|
|
2276
|
+
} else {
|
|
2277
|
+
this.fields[i2] = null;
|
|
2278
|
+
}
|
|
2279
|
+
}
|
|
2280
|
+
}
|
|
2281
|
+
get version() {
|
|
2282
|
+
return C._ts_language_version(this[0]);
|
|
2283
|
+
}
|
|
2284
|
+
get fieldCount() {
|
|
2285
|
+
return this.fields.length - 1;
|
|
2286
|
+
}
|
|
2287
|
+
get stateCount() {
|
|
2288
|
+
return C._ts_language_state_count(this[0]);
|
|
2289
|
+
}
|
|
2290
|
+
fieldIdForName(fieldName) {
|
|
2291
|
+
const result = this.fields.indexOf(fieldName);
|
|
2292
|
+
if (result !== -1) {
|
|
2293
|
+
return result;
|
|
2294
|
+
} else {
|
|
2295
|
+
return null;
|
|
2296
|
+
}
|
|
2297
|
+
}
|
|
2298
|
+
fieldNameForId(fieldId) {
|
|
2299
|
+
return this.fields[fieldId] || null;
|
|
2300
|
+
}
|
|
2301
|
+
idForNodeType(type, named) {
|
|
2302
|
+
const typeLength = lengthBytesUTF8(type);
|
|
2303
|
+
const typeAddress = C._malloc(typeLength + 1);
|
|
2304
|
+
stringToUTF8(type, typeAddress, typeLength + 1);
|
|
2305
|
+
const result = C._ts_language_symbol_for_name(this[0], typeAddress, typeLength, named);
|
|
2306
|
+
C._free(typeAddress);
|
|
2307
|
+
return result || null;
|
|
2308
|
+
}
|
|
2309
|
+
get nodeTypeCount() {
|
|
2310
|
+
return C._ts_language_symbol_count(this[0]);
|
|
2311
|
+
}
|
|
2312
|
+
nodeTypeForId(typeId) {
|
|
2313
|
+
const name2 = C._ts_language_symbol_name(this[0], typeId);
|
|
2314
|
+
return name2 ? UTF8ToString(name2) : null;
|
|
2315
|
+
}
|
|
2316
|
+
nodeTypeIsNamed(typeId) {
|
|
2317
|
+
return C._ts_language_type_is_named_wasm(this[0], typeId) ? true : false;
|
|
2318
|
+
}
|
|
2319
|
+
nodeTypeIsVisible(typeId) {
|
|
2320
|
+
return C._ts_language_type_is_visible_wasm(this[0], typeId) ? true : false;
|
|
2321
|
+
}
|
|
2322
|
+
nextState(stateId, typeId) {
|
|
2323
|
+
return C._ts_language_next_state(this[0], stateId, typeId);
|
|
2324
|
+
}
|
|
2325
|
+
lookaheadIterator(stateId) {
|
|
2326
|
+
const address = C._ts_lookahead_iterator_new(this[0], stateId);
|
|
2327
|
+
if (address)
|
|
2328
|
+
return new LookaheadIterable(INTERNAL, address, this);
|
|
2329
|
+
return null;
|
|
2330
|
+
}
|
|
2331
|
+
query(source) {
|
|
2332
|
+
const sourceLength = lengthBytesUTF8(source);
|
|
2333
|
+
const sourceAddress = C._malloc(sourceLength + 1);
|
|
2334
|
+
stringToUTF8(source, sourceAddress, sourceLength + 1);
|
|
2335
|
+
const address = C._ts_query_new(this[0], sourceAddress, sourceLength, TRANSFER_BUFFER, TRANSFER_BUFFER + SIZE_OF_INT);
|
|
2336
|
+
if (!address) {
|
|
2337
|
+
const errorId = getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
|
|
2338
|
+
const errorByte = getValue(TRANSFER_BUFFER, "i32");
|
|
2339
|
+
const errorIndex = UTF8ToString(sourceAddress, errorByte).length;
|
|
2340
|
+
const suffix = source.substr(errorIndex, 100).split(`
|
|
2341
|
+
`)[0];
|
|
2342
|
+
let word = suffix.match(QUERY_WORD_REGEX)[0];
|
|
2343
|
+
let error;
|
|
2344
|
+
switch (errorId) {
|
|
2345
|
+
case 2:
|
|
2346
|
+
error = new RangeError(`Bad node name '${word}'`);
|
|
2347
|
+
break;
|
|
2348
|
+
case 3:
|
|
2349
|
+
error = new RangeError(`Bad field name '${word}'`);
|
|
2350
|
+
break;
|
|
2351
|
+
case 4:
|
|
2352
|
+
error = new RangeError(`Bad capture name @${word}`);
|
|
2353
|
+
break;
|
|
2354
|
+
case 5:
|
|
2355
|
+
error = new TypeError(`Bad pattern structure at offset ${errorIndex}: '${suffix}'...`);
|
|
2356
|
+
word = "";
|
|
2357
|
+
break;
|
|
2358
|
+
default:
|
|
2359
|
+
error = new SyntaxError(`Bad syntax at offset ${errorIndex}: '${suffix}'...`);
|
|
2360
|
+
word = "";
|
|
2361
|
+
break;
|
|
2362
|
+
}
|
|
2363
|
+
error.index = errorIndex;
|
|
2364
|
+
error.length = word.length;
|
|
2365
|
+
C._free(sourceAddress);
|
|
2366
|
+
throw error;
|
|
2367
|
+
}
|
|
2368
|
+
const stringCount = C._ts_query_string_count(address);
|
|
2369
|
+
const captureCount = C._ts_query_capture_count(address);
|
|
2370
|
+
const patternCount = C._ts_query_pattern_count(address);
|
|
2371
|
+
const captureNames = new Array(captureCount);
|
|
2372
|
+
const stringValues = new Array(stringCount);
|
|
2373
|
+
for (let i2 = 0;i2 < captureCount; i2++) {
|
|
2374
|
+
const nameAddress = C._ts_query_capture_name_for_id(address, i2, TRANSFER_BUFFER);
|
|
2375
|
+
const nameLength = getValue(TRANSFER_BUFFER, "i32");
|
|
2376
|
+
captureNames[i2] = UTF8ToString(nameAddress, nameLength);
|
|
2377
|
+
}
|
|
2378
|
+
for (let i2 = 0;i2 < stringCount; i2++) {
|
|
2379
|
+
const valueAddress = C._ts_query_string_value_for_id(address, i2, TRANSFER_BUFFER);
|
|
2380
|
+
const nameLength = getValue(TRANSFER_BUFFER, "i32");
|
|
2381
|
+
stringValues[i2] = UTF8ToString(valueAddress, nameLength);
|
|
2382
|
+
}
|
|
2383
|
+
const setProperties = new Array(patternCount);
|
|
2384
|
+
const assertedProperties = new Array(patternCount);
|
|
2385
|
+
const refutedProperties = new Array(patternCount);
|
|
2386
|
+
const predicates = new Array(patternCount);
|
|
2387
|
+
const textPredicates = new Array(patternCount);
|
|
2388
|
+
for (let i2 = 0;i2 < patternCount; i2++) {
|
|
2389
|
+
const predicatesAddress = C._ts_query_predicates_for_pattern(address, i2, TRANSFER_BUFFER);
|
|
2390
|
+
const stepCount = getValue(TRANSFER_BUFFER, "i32");
|
|
2391
|
+
predicates[i2] = [];
|
|
2392
|
+
textPredicates[i2] = [];
|
|
2393
|
+
const steps = [];
|
|
2394
|
+
let stepAddress = predicatesAddress;
|
|
2395
|
+
for (let j = 0;j < stepCount; j++) {
|
|
2396
|
+
const stepType = getValue(stepAddress, "i32");
|
|
2397
|
+
stepAddress += SIZE_OF_INT;
|
|
2398
|
+
const stepValueId = getValue(stepAddress, "i32");
|
|
2399
|
+
stepAddress += SIZE_OF_INT;
|
|
2400
|
+
if (stepType === PREDICATE_STEP_TYPE_CAPTURE) {
|
|
2401
|
+
steps.push({
|
|
2402
|
+
type: "capture",
|
|
2403
|
+
name: captureNames[stepValueId]
|
|
2404
|
+
});
|
|
2405
|
+
} else if (stepType === PREDICATE_STEP_TYPE_STRING) {
|
|
2406
|
+
steps.push({
|
|
2407
|
+
type: "string",
|
|
2408
|
+
value: stringValues[stepValueId]
|
|
2409
|
+
});
|
|
2410
|
+
} else if (steps.length > 0) {
|
|
2411
|
+
if (steps[0].type !== "string") {
|
|
2412
|
+
throw new Error("Predicates must begin with a literal value");
|
|
2413
|
+
}
|
|
2414
|
+
const operator = steps[0].value;
|
|
2415
|
+
let isPositive = true;
|
|
2416
|
+
let matchAll = true;
|
|
2417
|
+
let captureName;
|
|
2418
|
+
switch (operator) {
|
|
2419
|
+
case "any-not-eq?":
|
|
2420
|
+
case "not-eq?":
|
|
2421
|
+
isPositive = false;
|
|
2422
|
+
case "any-eq?":
|
|
2423
|
+
case "eq?":
|
|
2424
|
+
if (steps.length !== 3) {
|
|
2425
|
+
throw new Error(`Wrong number of arguments to \`#${operator}\` predicate. Expected 2, got ${steps.length - 1}`);
|
|
2426
|
+
}
|
|
2427
|
+
if (steps[1].type !== "capture") {
|
|
2428
|
+
throw new Error(`First argument of \`#${operator}\` predicate must be a capture. Got "${steps[1].value}"`);
|
|
2429
|
+
}
|
|
2430
|
+
matchAll = !operator.startsWith("any-");
|
|
2431
|
+
if (steps[2].type === "capture") {
|
|
2432
|
+
const captureName1 = steps[1].name;
|
|
2433
|
+
const captureName2 = steps[2].name;
|
|
2434
|
+
textPredicates[i2].push((captures) => {
|
|
2435
|
+
const nodes1 = [];
|
|
2436
|
+
const nodes2 = [];
|
|
2437
|
+
for (const c of captures) {
|
|
2438
|
+
if (c.name === captureName1)
|
|
2439
|
+
nodes1.push(c.node);
|
|
2440
|
+
if (c.name === captureName2)
|
|
2441
|
+
nodes2.push(c.node);
|
|
2442
|
+
}
|
|
2443
|
+
const compare = (n1, n2, positive) => positive ? n1.text === n2.text : n1.text !== n2.text;
|
|
2444
|
+
return matchAll ? nodes1.every((n1) => nodes2.some((n2) => compare(n1, n2, isPositive))) : nodes1.some((n1) => nodes2.some((n2) => compare(n1, n2, isPositive)));
|
|
2445
|
+
});
|
|
2446
|
+
} else {
|
|
2447
|
+
captureName = steps[1].name;
|
|
2448
|
+
const stringValue = steps[2].value;
|
|
2449
|
+
const matches = (n) => n.text === stringValue;
|
|
2450
|
+
const doesNotMatch = (n) => n.text !== stringValue;
|
|
2451
|
+
textPredicates[i2].push((captures) => {
|
|
2452
|
+
const nodes = [];
|
|
2453
|
+
for (const c of captures) {
|
|
2454
|
+
if (c.name === captureName)
|
|
2455
|
+
nodes.push(c.node);
|
|
2456
|
+
}
|
|
2457
|
+
const test = isPositive ? matches : doesNotMatch;
|
|
2458
|
+
return matchAll ? nodes.every(test) : nodes.some(test);
|
|
2459
|
+
});
|
|
2460
|
+
}
|
|
2461
|
+
break;
|
|
2462
|
+
case "any-not-match?":
|
|
2463
|
+
case "not-match?":
|
|
2464
|
+
isPositive = false;
|
|
2465
|
+
case "any-match?":
|
|
2466
|
+
case "match?":
|
|
2467
|
+
if (steps.length !== 3) {
|
|
2468
|
+
throw new Error(`Wrong number of arguments to \`#${operator}\` predicate. Expected 2, got ${steps.length - 1}.`);
|
|
2469
|
+
}
|
|
2470
|
+
if (steps[1].type !== "capture") {
|
|
2471
|
+
throw new Error(`First argument of \`#${operator}\` predicate must be a capture. Got "${steps[1].value}".`);
|
|
2472
|
+
}
|
|
2473
|
+
if (steps[2].type !== "string") {
|
|
2474
|
+
throw new Error(`Second argument of \`#${operator}\` predicate must be a string. Got @${steps[2].value}.`);
|
|
2475
|
+
}
|
|
2476
|
+
captureName = steps[1].name;
|
|
2477
|
+
const regex = new RegExp(steps[2].value);
|
|
2478
|
+
matchAll = !operator.startsWith("any-");
|
|
2479
|
+
textPredicates[i2].push((captures) => {
|
|
2480
|
+
const nodes = [];
|
|
2481
|
+
for (const c of captures) {
|
|
2482
|
+
if (c.name === captureName)
|
|
2483
|
+
nodes.push(c.node.text);
|
|
2484
|
+
}
|
|
2485
|
+
const test = (text, positive) => positive ? regex.test(text) : !regex.test(text);
|
|
2486
|
+
if (nodes.length === 0)
|
|
2487
|
+
return !isPositive;
|
|
2488
|
+
return matchAll ? nodes.every((text) => test(text, isPositive)) : nodes.some((text) => test(text, isPositive));
|
|
2489
|
+
});
|
|
2490
|
+
break;
|
|
2491
|
+
case "set!":
|
|
2492
|
+
if (steps.length < 2 || steps.length > 3) {
|
|
2493
|
+
throw new Error(`Wrong number of arguments to \`#set!\` predicate. Expected 1 or 2. Got ${steps.length - 1}.`);
|
|
2494
|
+
}
|
|
2495
|
+
if (steps.some((s) => s.type !== "string")) {
|
|
2496
|
+
throw new Error(`Arguments to \`#set!\` predicate must be a strings.".`);
|
|
2497
|
+
}
|
|
2498
|
+
if (!setProperties[i2])
|
|
2499
|
+
setProperties[i2] = {};
|
|
2500
|
+
setProperties[i2][steps[1].value] = steps[2] ? steps[2].value : null;
|
|
2501
|
+
break;
|
|
2502
|
+
case "is?":
|
|
2503
|
+
case "is-not?":
|
|
2504
|
+
if (steps.length < 2 || steps.length > 3) {
|
|
2505
|
+
throw new Error(`Wrong number of arguments to \`#${operator}\` predicate. Expected 1 or 2. Got ${steps.length - 1}.`);
|
|
2506
|
+
}
|
|
2507
|
+
if (steps.some((s) => s.type !== "string")) {
|
|
2508
|
+
throw new Error(`Arguments to \`#${operator}\` predicate must be a strings.".`);
|
|
2509
|
+
}
|
|
2510
|
+
const properties = operator === "is?" ? assertedProperties : refutedProperties;
|
|
2511
|
+
if (!properties[i2])
|
|
2512
|
+
properties[i2] = {};
|
|
2513
|
+
properties[i2][steps[1].value] = steps[2] ? steps[2].value : null;
|
|
2514
|
+
break;
|
|
2515
|
+
case "not-any-of?":
|
|
2516
|
+
isPositive = false;
|
|
2517
|
+
case "any-of?":
|
|
2518
|
+
if (steps.length < 2) {
|
|
2519
|
+
throw new Error(`Wrong number of arguments to \`#${operator}\` predicate. Expected at least 1. Got ${steps.length - 1}.`);
|
|
2520
|
+
}
|
|
2521
|
+
if (steps[1].type !== "capture") {
|
|
2522
|
+
throw new Error(`First argument of \`#${operator}\` predicate must be a capture. Got "${steps[1].value}".`);
|
|
2523
|
+
}
|
|
2524
|
+
for (let i3 = 2;i3 < steps.length; i3++) {
|
|
2525
|
+
if (steps[i3].type !== "string") {
|
|
2526
|
+
throw new Error(`Arguments to \`#${operator}\` predicate must be a strings.".`);
|
|
2527
|
+
}
|
|
2528
|
+
}
|
|
2529
|
+
captureName = steps[1].name;
|
|
2530
|
+
const values = steps.slice(2).map((s) => s.value);
|
|
2531
|
+
textPredicates[i2].push((captures) => {
|
|
2532
|
+
const nodes = [];
|
|
2533
|
+
for (const c of captures) {
|
|
2534
|
+
if (c.name === captureName)
|
|
2535
|
+
nodes.push(c.node.text);
|
|
2536
|
+
}
|
|
2537
|
+
if (nodes.length === 0)
|
|
2538
|
+
return !isPositive;
|
|
2539
|
+
return nodes.every((text) => values.includes(text)) === isPositive;
|
|
2540
|
+
});
|
|
2541
|
+
break;
|
|
2542
|
+
default:
|
|
2543
|
+
predicates[i2].push({
|
|
2544
|
+
operator,
|
|
2545
|
+
operands: steps.slice(1)
|
|
2546
|
+
});
|
|
2547
|
+
}
|
|
2548
|
+
steps.length = 0;
|
|
2549
|
+
}
|
|
2550
|
+
}
|
|
2551
|
+
Object.freeze(setProperties[i2]);
|
|
2552
|
+
Object.freeze(assertedProperties[i2]);
|
|
2553
|
+
Object.freeze(refutedProperties[i2]);
|
|
2554
|
+
}
|
|
2555
|
+
C._free(sourceAddress);
|
|
2556
|
+
return new Query(INTERNAL, address, captureNames, textPredicates, predicates, Object.freeze(setProperties), Object.freeze(assertedProperties), Object.freeze(refutedProperties));
|
|
2557
|
+
}
|
|
2558
|
+
static load(input) {
|
|
2559
|
+
let bytes;
|
|
2560
|
+
if (input instanceof Uint8Array) {
|
|
2561
|
+
bytes = Promise.resolve(input);
|
|
2562
|
+
} else {
|
|
2563
|
+
const url = input;
|
|
2564
|
+
if (typeof process !== "undefined" && process.versions && process.versions.node) {
|
|
2565
|
+
const fs2 = __require("fs");
|
|
2566
|
+
bytes = Promise.resolve(fs2.readFileSync(url));
|
|
2567
|
+
} else {
|
|
2568
|
+
bytes = fetch(url).then((response) => response.arrayBuffer().then((buffer) => {
|
|
2569
|
+
if (response.ok) {
|
|
2570
|
+
return new Uint8Array(buffer);
|
|
2571
|
+
} else {
|
|
2572
|
+
const body2 = new TextDecoder("utf-8").decode(buffer);
|
|
2573
|
+
throw new Error(`Language.load failed with status ${response.status}.
|
|
2574
|
+
|
|
2575
|
+
${body2}`);
|
|
2576
|
+
}
|
|
2577
|
+
}));
|
|
2578
|
+
}
|
|
2579
|
+
}
|
|
2580
|
+
return bytes.then((bytes2) => loadWebAssemblyModule(bytes2, {
|
|
2581
|
+
loadAsync: true
|
|
2582
|
+
})).then((mod) => {
|
|
2583
|
+
const symbolNames = Object.keys(mod);
|
|
2584
|
+
const functionName = symbolNames.find((key) => LANGUAGE_FUNCTION_REGEX.test(key) && !key.includes("external_scanner_"));
|
|
2585
|
+
if (!functionName) {
|
|
2586
|
+
console.log(`Couldn't find language function in WASM file. Symbols:
|
|
2587
|
+
${JSON.stringify(symbolNames, null, 2)}`);
|
|
2588
|
+
}
|
|
2589
|
+
const languageAddress = mod[functionName]();
|
|
2590
|
+
return new Language(INTERNAL, languageAddress);
|
|
2591
|
+
});
|
|
2592
|
+
}
|
|
2593
|
+
}
|
|
2594
|
+
|
|
2595
|
+
class LookaheadIterable {
|
|
2596
|
+
constructor(internal, address, language) {
|
|
2597
|
+
assertInternal(internal);
|
|
2598
|
+
this[0] = address;
|
|
2599
|
+
this.language = language;
|
|
2600
|
+
}
|
|
2601
|
+
get currentTypeId() {
|
|
2602
|
+
return C._ts_lookahead_iterator_current_symbol(this[0]);
|
|
2603
|
+
}
|
|
2604
|
+
get currentType() {
|
|
2605
|
+
return this.language.types[this.currentTypeId] || "ERROR";
|
|
2606
|
+
}
|
|
2607
|
+
delete() {
|
|
2608
|
+
C._ts_lookahead_iterator_delete(this[0]);
|
|
2609
|
+
this[0] = 0;
|
|
2610
|
+
}
|
|
2611
|
+
resetState(stateId) {
|
|
2612
|
+
return C._ts_lookahead_iterator_reset_state(this[0], stateId);
|
|
2613
|
+
}
|
|
2614
|
+
reset(language, stateId) {
|
|
2615
|
+
if (C._ts_lookahead_iterator_reset(this[0], language[0], stateId)) {
|
|
2616
|
+
this.language = language;
|
|
2617
|
+
return true;
|
|
2618
|
+
}
|
|
2619
|
+
return false;
|
|
2620
|
+
}
|
|
2621
|
+
[Symbol.iterator]() {
|
|
2622
|
+
const self2 = this;
|
|
2623
|
+
return {
|
|
2624
|
+
next() {
|
|
2625
|
+
if (C._ts_lookahead_iterator_next(self2[0])) {
|
|
2626
|
+
return {
|
|
2627
|
+
done: false,
|
|
2628
|
+
value: self2.currentType
|
|
2629
|
+
};
|
|
2630
|
+
}
|
|
2631
|
+
return {
|
|
2632
|
+
done: true,
|
|
2633
|
+
value: ""
|
|
2634
|
+
};
|
|
2635
|
+
}
|
|
2636
|
+
};
|
|
2637
|
+
}
|
|
2638
|
+
}
|
|
2639
|
+
|
|
2640
|
+
class Query {
|
|
2641
|
+
constructor(internal, address, captureNames, textPredicates, predicates, setProperties, assertedProperties, refutedProperties) {
|
|
2642
|
+
assertInternal(internal);
|
|
2643
|
+
this[0] = address;
|
|
2644
|
+
this.captureNames = captureNames;
|
|
2645
|
+
this.textPredicates = textPredicates;
|
|
2646
|
+
this.predicates = predicates;
|
|
2647
|
+
this.setProperties = setProperties;
|
|
2648
|
+
this.assertedProperties = assertedProperties;
|
|
2649
|
+
this.refutedProperties = refutedProperties;
|
|
2650
|
+
this.exceededMatchLimit = false;
|
|
2651
|
+
}
|
|
2652
|
+
delete() {
|
|
2653
|
+
C._ts_query_delete(this[0]);
|
|
2654
|
+
this[0] = 0;
|
|
2655
|
+
}
|
|
2656
|
+
matches(node, { startPosition = ZERO_POINT, endPosition = ZERO_POINT, startIndex = 0, endIndex = 0, matchLimit = 4294967295, maxStartDepth = 4294967295, timeoutMicros = 0 } = {}) {
|
|
2657
|
+
if (typeof matchLimit !== "number") {
|
|
2658
|
+
throw new Error("Arguments must be numbers");
|
|
2659
|
+
}
|
|
2660
|
+
marshalNode(node);
|
|
2661
|
+
C._ts_query_matches_wasm(this[0], node.tree[0], startPosition.row, startPosition.column, endPosition.row, endPosition.column, startIndex, endIndex, matchLimit, maxStartDepth, timeoutMicros);
|
|
2662
|
+
const rawCount = getValue(TRANSFER_BUFFER, "i32");
|
|
2663
|
+
const startAddress = getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
|
|
2664
|
+
const didExceedMatchLimit = getValue(TRANSFER_BUFFER + 2 * SIZE_OF_INT, "i32");
|
|
2665
|
+
const result = new Array(rawCount);
|
|
2666
|
+
this.exceededMatchLimit = Boolean(didExceedMatchLimit);
|
|
2667
|
+
let filteredCount = 0;
|
|
2668
|
+
let address = startAddress;
|
|
2669
|
+
for (let i2 = 0;i2 < rawCount; i2++) {
|
|
2670
|
+
const pattern = getValue(address, "i32");
|
|
2671
|
+
address += SIZE_OF_INT;
|
|
2672
|
+
const captureCount = getValue(address, "i32");
|
|
2673
|
+
address += SIZE_OF_INT;
|
|
2674
|
+
const captures = new Array(captureCount);
|
|
2675
|
+
address = unmarshalCaptures(this, node.tree, address, captures);
|
|
2676
|
+
if (this.textPredicates[pattern].every((p) => p(captures))) {
|
|
2677
|
+
result[filteredCount] = {
|
|
2678
|
+
pattern,
|
|
2679
|
+
captures
|
|
2680
|
+
};
|
|
2681
|
+
const setProperties = this.setProperties[pattern];
|
|
2682
|
+
if (setProperties)
|
|
2683
|
+
result[filteredCount].setProperties = setProperties;
|
|
2684
|
+
const assertedProperties = this.assertedProperties[pattern];
|
|
2685
|
+
if (assertedProperties)
|
|
2686
|
+
result[filteredCount].assertedProperties = assertedProperties;
|
|
2687
|
+
const refutedProperties = this.refutedProperties[pattern];
|
|
2688
|
+
if (refutedProperties)
|
|
2689
|
+
result[filteredCount].refutedProperties = refutedProperties;
|
|
2690
|
+
filteredCount++;
|
|
2691
|
+
}
|
|
2692
|
+
}
|
|
2693
|
+
result.length = filteredCount;
|
|
2694
|
+
C._free(startAddress);
|
|
2695
|
+
return result;
|
|
2696
|
+
}
|
|
2697
|
+
captures(node, { startPosition = ZERO_POINT, endPosition = ZERO_POINT, startIndex = 0, endIndex = 0, matchLimit = 4294967295, maxStartDepth = 4294967295, timeoutMicros = 0 } = {}) {
|
|
2698
|
+
if (typeof matchLimit !== "number") {
|
|
2699
|
+
throw new Error("Arguments must be numbers");
|
|
2700
|
+
}
|
|
2701
|
+
marshalNode(node);
|
|
2702
|
+
C._ts_query_captures_wasm(this[0], node.tree[0], startPosition.row, startPosition.column, endPosition.row, endPosition.column, startIndex, endIndex, matchLimit, maxStartDepth, timeoutMicros);
|
|
2703
|
+
const count = getValue(TRANSFER_BUFFER, "i32");
|
|
2704
|
+
const startAddress = getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
|
|
2705
|
+
const didExceedMatchLimit = getValue(TRANSFER_BUFFER + 2 * SIZE_OF_INT, "i32");
|
|
2706
|
+
const result = [];
|
|
2707
|
+
this.exceededMatchLimit = Boolean(didExceedMatchLimit);
|
|
2708
|
+
const captures = [];
|
|
2709
|
+
let address = startAddress;
|
|
2710
|
+
for (let i2 = 0;i2 < count; i2++) {
|
|
2711
|
+
const pattern = getValue(address, "i32");
|
|
2712
|
+
address += SIZE_OF_INT;
|
|
2713
|
+
const captureCount = getValue(address, "i32");
|
|
2714
|
+
address += SIZE_OF_INT;
|
|
2715
|
+
const captureIndex = getValue(address, "i32");
|
|
2716
|
+
address += SIZE_OF_INT;
|
|
2717
|
+
captures.length = captureCount;
|
|
2718
|
+
address = unmarshalCaptures(this, node.tree, address, captures);
|
|
2719
|
+
if (this.textPredicates[pattern].every((p) => p(captures))) {
|
|
2720
|
+
const capture = captures[captureIndex];
|
|
2721
|
+
const setProperties = this.setProperties[pattern];
|
|
2722
|
+
if (setProperties)
|
|
2723
|
+
capture.setProperties = setProperties;
|
|
2724
|
+
const assertedProperties = this.assertedProperties[pattern];
|
|
2725
|
+
if (assertedProperties)
|
|
2726
|
+
capture.assertedProperties = assertedProperties;
|
|
2727
|
+
const refutedProperties = this.refutedProperties[pattern];
|
|
2728
|
+
if (refutedProperties)
|
|
2729
|
+
capture.refutedProperties = refutedProperties;
|
|
2730
|
+
result.push(capture);
|
|
2731
|
+
}
|
|
2732
|
+
}
|
|
2733
|
+
C._free(startAddress);
|
|
2734
|
+
return result;
|
|
2735
|
+
}
|
|
2736
|
+
predicatesForPattern(patternIndex) {
|
|
2737
|
+
return this.predicates[patternIndex];
|
|
2738
|
+
}
|
|
2739
|
+
disableCapture(captureName) {
|
|
2740
|
+
const captureNameLength = lengthBytesUTF8(captureName);
|
|
2741
|
+
const captureNameAddress = C._malloc(captureNameLength + 1);
|
|
2742
|
+
stringToUTF8(captureName, captureNameAddress, captureNameLength + 1);
|
|
2743
|
+
C._ts_query_disable_capture(this[0], captureNameAddress, captureNameLength);
|
|
2744
|
+
C._free(captureNameAddress);
|
|
2745
|
+
}
|
|
2746
|
+
didExceedMatchLimit() {
|
|
2747
|
+
return this.exceededMatchLimit;
|
|
2748
|
+
}
|
|
2749
|
+
}
|
|
2750
|
+
function getText(tree, startIndex, endIndex) {
|
|
2751
|
+
const length = endIndex - startIndex;
|
|
2752
|
+
let result = tree.textCallback(startIndex, null, endIndex);
|
|
2753
|
+
startIndex += result.length;
|
|
2754
|
+
while (startIndex < endIndex) {
|
|
2755
|
+
const string = tree.textCallback(startIndex, null, endIndex);
|
|
2756
|
+
if (string && string.length > 0) {
|
|
2757
|
+
startIndex += string.length;
|
|
2758
|
+
result += string;
|
|
2759
|
+
} else {
|
|
2760
|
+
break;
|
|
2761
|
+
}
|
|
2762
|
+
}
|
|
2763
|
+
if (startIndex > endIndex) {
|
|
2764
|
+
result = result.slice(0, length);
|
|
2765
|
+
}
|
|
2766
|
+
return result;
|
|
2767
|
+
}
|
|
2768
|
+
function unmarshalCaptures(query, tree, address, result) {
|
|
2769
|
+
for (let i2 = 0, n = result.length;i2 < n; i2++) {
|
|
2770
|
+
const captureIndex = getValue(address, "i32");
|
|
2771
|
+
address += SIZE_OF_INT;
|
|
2772
|
+
const node = unmarshalNode(tree, address);
|
|
2773
|
+
address += SIZE_OF_NODE;
|
|
2774
|
+
result[i2] = {
|
|
2775
|
+
name: query.captureNames[captureIndex],
|
|
2776
|
+
node
|
|
2777
|
+
};
|
|
2778
|
+
}
|
|
2779
|
+
return address;
|
|
2780
|
+
}
|
|
2781
|
+
function assertInternal(x) {
|
|
2782
|
+
if (x !== INTERNAL)
|
|
2783
|
+
throw new Error("Illegal constructor");
|
|
2784
|
+
}
|
|
2785
|
+
function isPoint(point) {
|
|
2786
|
+
return point && typeof point.row === "number" && typeof point.column === "number";
|
|
2787
|
+
}
|
|
2788
|
+
function marshalNode(node) {
|
|
2789
|
+
let address = TRANSFER_BUFFER;
|
|
2790
|
+
setValue(address, node.id, "i32");
|
|
2791
|
+
address += SIZE_OF_INT;
|
|
2792
|
+
setValue(address, node.startIndex, "i32");
|
|
2793
|
+
address += SIZE_OF_INT;
|
|
2794
|
+
setValue(address, node.startPosition.row, "i32");
|
|
2795
|
+
address += SIZE_OF_INT;
|
|
2796
|
+
setValue(address, node.startPosition.column, "i32");
|
|
2797
|
+
address += SIZE_OF_INT;
|
|
2798
|
+
setValue(address, node[0], "i32");
|
|
2799
|
+
}
|
|
2800
|
+
function unmarshalNode(tree, address = TRANSFER_BUFFER) {
|
|
2801
|
+
const id = getValue(address, "i32");
|
|
2802
|
+
address += SIZE_OF_INT;
|
|
2803
|
+
if (id === 0)
|
|
2804
|
+
return null;
|
|
2805
|
+
const index = getValue(address, "i32");
|
|
2806
|
+
address += SIZE_OF_INT;
|
|
2807
|
+
const row = getValue(address, "i32");
|
|
2808
|
+
address += SIZE_OF_INT;
|
|
2809
|
+
const column = getValue(address, "i32");
|
|
2810
|
+
address += SIZE_OF_INT;
|
|
2811
|
+
const other = getValue(address, "i32");
|
|
2812
|
+
const result = new Node(INTERNAL, tree);
|
|
2813
|
+
result.id = id;
|
|
2814
|
+
result.startIndex = index;
|
|
2815
|
+
result.startPosition = {
|
|
2816
|
+
row,
|
|
2817
|
+
column
|
|
2818
|
+
};
|
|
2819
|
+
result[0] = other;
|
|
2820
|
+
return result;
|
|
2821
|
+
}
|
|
2822
|
+
function marshalTreeCursor(cursor, address = TRANSFER_BUFFER) {
|
|
2823
|
+
setValue(address + 0 * SIZE_OF_INT, cursor[0], "i32");
|
|
2824
|
+
setValue(address + 1 * SIZE_OF_INT, cursor[1], "i32");
|
|
2825
|
+
setValue(address + 2 * SIZE_OF_INT, cursor[2], "i32");
|
|
2826
|
+
setValue(address + 3 * SIZE_OF_INT, cursor[3], "i32");
|
|
2827
|
+
}
|
|
2828
|
+
function unmarshalTreeCursor(cursor) {
|
|
2829
|
+
cursor[0] = getValue(TRANSFER_BUFFER + 0 * SIZE_OF_INT, "i32");
|
|
2830
|
+
cursor[1] = getValue(TRANSFER_BUFFER + 1 * SIZE_OF_INT, "i32");
|
|
2831
|
+
cursor[2] = getValue(TRANSFER_BUFFER + 2 * SIZE_OF_INT, "i32");
|
|
2832
|
+
cursor[3] = getValue(TRANSFER_BUFFER + 3 * SIZE_OF_INT, "i32");
|
|
2833
|
+
}
|
|
2834
|
+
function marshalPoint(address, point) {
|
|
2835
|
+
setValue(address, point.row, "i32");
|
|
2836
|
+
setValue(address + SIZE_OF_INT, point.column, "i32");
|
|
2837
|
+
}
|
|
2838
|
+
function unmarshalPoint(address) {
|
|
2839
|
+
const result = {
|
|
2840
|
+
row: getValue(address, "i32") >>> 0,
|
|
2841
|
+
column: getValue(address + SIZE_OF_INT, "i32") >>> 0
|
|
2842
|
+
};
|
|
2843
|
+
return result;
|
|
2844
|
+
}
|
|
2845
|
+
function marshalRange(address, range) {
|
|
2846
|
+
marshalPoint(address, range.startPosition);
|
|
2847
|
+
address += SIZE_OF_POINT;
|
|
2848
|
+
marshalPoint(address, range.endPosition);
|
|
2849
|
+
address += SIZE_OF_POINT;
|
|
2850
|
+
setValue(address, range.startIndex, "i32");
|
|
2851
|
+
address += SIZE_OF_INT;
|
|
2852
|
+
setValue(address, range.endIndex, "i32");
|
|
2853
|
+
address += SIZE_OF_INT;
|
|
2854
|
+
}
|
|
2855
|
+
function unmarshalRange(address) {
|
|
2856
|
+
const result = {};
|
|
2857
|
+
result.startPosition = unmarshalPoint(address);
|
|
2858
|
+
address += SIZE_OF_POINT;
|
|
2859
|
+
result.endPosition = unmarshalPoint(address);
|
|
2860
|
+
address += SIZE_OF_POINT;
|
|
2861
|
+
result.startIndex = getValue(address, "i32") >>> 0;
|
|
2862
|
+
address += SIZE_OF_INT;
|
|
2863
|
+
result.endIndex = getValue(address, "i32") >>> 0;
|
|
2864
|
+
return result;
|
|
2865
|
+
}
|
|
2866
|
+
function marshalEdit(edit) {
|
|
2867
|
+
let address = TRANSFER_BUFFER;
|
|
2868
|
+
marshalPoint(address, edit.startPosition);
|
|
2869
|
+
address += SIZE_OF_POINT;
|
|
2870
|
+
marshalPoint(address, edit.oldEndPosition);
|
|
2871
|
+
address += SIZE_OF_POINT;
|
|
2872
|
+
marshalPoint(address, edit.newEndPosition);
|
|
2873
|
+
address += SIZE_OF_POINT;
|
|
2874
|
+
setValue(address, edit.startIndex, "i32");
|
|
2875
|
+
address += SIZE_OF_INT;
|
|
2876
|
+
setValue(address, edit.oldEndIndex, "i32");
|
|
2877
|
+
address += SIZE_OF_INT;
|
|
2878
|
+
setValue(address, edit.newEndIndex, "i32");
|
|
2879
|
+
address += SIZE_OF_INT;
|
|
2880
|
+
}
|
|
2881
|
+
for (const name2 of Object.getOwnPropertyNames(ParserImpl.prototype)) {
|
|
2882
|
+
Object.defineProperty(Parser.prototype, name2, {
|
|
2883
|
+
value: ParserImpl.prototype[name2],
|
|
2884
|
+
enumerable: false,
|
|
2885
|
+
writable: false
|
|
2886
|
+
});
|
|
2887
|
+
}
|
|
2888
|
+
Parser.Language = Language;
|
|
2889
|
+
Module.onRuntimeInitialized = () => {
|
|
2890
|
+
ParserImpl.init();
|
|
2891
|
+
resolveInitPromise();
|
|
2892
|
+
};
|
|
2893
|
+
});
|
|
2894
|
+
}
|
|
2895
|
+
}
|
|
2896
|
+
return Parser;
|
|
2897
|
+
}();
|
|
2898
|
+
if (typeof exports === "object") {
|
|
2899
|
+
module2.exports = TreeSitter;
|
|
2900
|
+
}
|
|
2901
|
+
});
|
|
2902
|
+
|
|
14
2903
|
// src/agents/oracle.ts
|
|
15
2904
|
var oracleAgent = {
|
|
16
2905
|
description: "Expert AI advisor with advanced reasoning capabilities for high-quality technical guidance, code reviews, architectural advice, and strategic planning.",
|
|
@@ -587,16 +3476,16 @@ function mergeAgentConfig(base, override) {
|
|
|
587
3476
|
}
|
|
588
3477
|
function createBuiltinAgents(disabledAgents = [], agentOverrides = {}) {
|
|
589
3478
|
const result = {};
|
|
590
|
-
for (const [
|
|
591
|
-
const agentName =
|
|
3479
|
+
for (const [name2, config] of Object.entries(allBuiltinAgents)) {
|
|
3480
|
+
const agentName = name2;
|
|
592
3481
|
if (disabledAgents.includes(agentName)) {
|
|
593
3482
|
continue;
|
|
594
3483
|
}
|
|
595
3484
|
const override = agentOverrides[agentName];
|
|
596
3485
|
if (override) {
|
|
597
|
-
result[
|
|
3486
|
+
result[name2] = mergeAgentConfig(config, override);
|
|
598
3487
|
} else {
|
|
599
|
-
result[
|
|
3488
|
+
result[name2] = config;
|
|
600
3489
|
}
|
|
601
3490
|
}
|
|
602
3491
|
return result;
|
|
@@ -619,11 +3508,11 @@ function detectInterrupt(error) {
|
|
|
619
3508
|
return false;
|
|
620
3509
|
if (typeof error === "object") {
|
|
621
3510
|
const errObj = error;
|
|
622
|
-
const
|
|
3511
|
+
const name2 = errObj.name;
|
|
623
3512
|
const message = errObj.message?.toLowerCase() ?? "";
|
|
624
|
-
if (
|
|
3513
|
+
if (name2 === "MessageAbortedError" || name2 === "AbortError")
|
|
625
3514
|
return true;
|
|
626
|
-
if (
|
|
3515
|
+
if (name2 === "DOMException" && message.includes("abort"))
|
|
627
3516
|
return true;
|
|
628
3517
|
if (message.includes("aborted") || message.includes("cancelled") || message.includes("interrupted"))
|
|
629
3518
|
return true;
|
|
@@ -705,9 +3594,9 @@ function createTodoContinuationEnforcer(ctx) {
|
|
|
705
3594
|
}
|
|
706
3595
|
}
|
|
707
3596
|
if (event.type === "message.updated") {
|
|
708
|
-
const
|
|
709
|
-
const sessionID =
|
|
710
|
-
if (sessionID &&
|
|
3597
|
+
const info2 = props?.info;
|
|
3598
|
+
const sessionID = info2?.sessionID;
|
|
3599
|
+
if (sessionID && info2?.role === "user") {
|
|
711
3600
|
remindedSessions.delete(sessionID);
|
|
712
3601
|
}
|
|
713
3602
|
}
|
|
@@ -814,12 +3703,12 @@ function detectErrorType(error) {
|
|
|
814
3703
|
}
|
|
815
3704
|
return null;
|
|
816
3705
|
}
|
|
817
|
-
function extractToolUseIds(
|
|
818
|
-
return
|
|
3706
|
+
function extractToolUseIds(parts2) {
|
|
3707
|
+
return parts2.filter((p) => p.type === "tool_use" && !!p.id).map((p) => p.id);
|
|
819
3708
|
}
|
|
820
3709
|
async function recoverToolResultMissing(client, sessionID, failedAssistantMsg) {
|
|
821
|
-
const
|
|
822
|
-
const toolUseIds = extractToolUseIds(
|
|
3710
|
+
const parts2 = failedAssistantMsg.parts || [];
|
|
3711
|
+
const toolUseIds = extractToolUseIds(parts2);
|
|
823
3712
|
if (toolUseIds.length === 0) {
|
|
824
3713
|
return false;
|
|
825
3714
|
}
|
|
@@ -926,9 +3815,9 @@ async function fallbackRevertStrategy(client, sessionID, failedAssistantMsg, dir
|
|
|
926
3815
|
targetUserMsg = msgs.find((m) => m.info?.id === parentMsgID) ?? null;
|
|
927
3816
|
}
|
|
928
3817
|
if (!targetUserMsg) {
|
|
929
|
-
for (let
|
|
930
|
-
if (msgs[
|
|
931
|
-
targetUserMsg = msgs[
|
|
3818
|
+
for (let i2 = msgs.length - 1;i2 >= 0; i2--) {
|
|
3819
|
+
if (msgs[i2].info?.role === "user") {
|
|
3820
|
+
targetUserMsg = msgs[i2];
|
|
932
3821
|
break;
|
|
933
3822
|
}
|
|
934
3823
|
}
|
|
@@ -961,14 +3850,14 @@ function createSessionRecoveryHook(ctx) {
|
|
|
961
3850
|
const isRecoverableError = (error) => {
|
|
962
3851
|
return detectErrorType(error) !== null;
|
|
963
3852
|
};
|
|
964
|
-
const handleSessionRecovery = async (
|
|
965
|
-
if (!
|
|
3853
|
+
const handleSessionRecovery = async (info2) => {
|
|
3854
|
+
if (!info2 || info2.role !== "assistant" || !info2.error)
|
|
966
3855
|
return false;
|
|
967
|
-
const errorType = detectErrorType(
|
|
3856
|
+
const errorType = detectErrorType(info2.error);
|
|
968
3857
|
if (!errorType)
|
|
969
3858
|
return false;
|
|
970
|
-
const sessionID =
|
|
971
|
-
const assistantMsgID =
|
|
3859
|
+
const sessionID = info2.sessionID;
|
|
3860
|
+
const assistantMsgID = info2.id;
|
|
972
3861
|
if (!sessionID || !assistantMsgID)
|
|
973
3862
|
return false;
|
|
974
3863
|
if (processingErrors.has(assistantMsgID))
|
|
@@ -1034,6 +3923,115 @@ function createSessionRecoveryHook(ctx) {
|
|
|
1034
3923
|
};
|
|
1035
3924
|
}
|
|
1036
3925
|
// src/hooks/comment-checker/constants.ts
|
|
3926
|
+
var EXTENSION_TO_LANGUAGE = {
|
|
3927
|
+
py: "python",
|
|
3928
|
+
js: "javascript",
|
|
3929
|
+
jsx: "javascript",
|
|
3930
|
+
ts: "typescript",
|
|
3931
|
+
tsx: "tsx",
|
|
3932
|
+
go: "golang",
|
|
3933
|
+
java: "java",
|
|
3934
|
+
kt: "kotlin",
|
|
3935
|
+
scala: "scala",
|
|
3936
|
+
c: "c",
|
|
3937
|
+
h: "c",
|
|
3938
|
+
cpp: "cpp",
|
|
3939
|
+
cc: "cpp",
|
|
3940
|
+
cxx: "cpp",
|
|
3941
|
+
hpp: "cpp",
|
|
3942
|
+
rs: "rust",
|
|
3943
|
+
rb: "ruby",
|
|
3944
|
+
sh: "bash",
|
|
3945
|
+
bash: "bash",
|
|
3946
|
+
cs: "csharp",
|
|
3947
|
+
swift: "swift",
|
|
3948
|
+
ex: "elixir",
|
|
3949
|
+
exs: "elixir",
|
|
3950
|
+
lua: "lua",
|
|
3951
|
+
php: "php",
|
|
3952
|
+
ml: "ocaml",
|
|
3953
|
+
mli: "ocaml",
|
|
3954
|
+
sql: "sql",
|
|
3955
|
+
html: "html",
|
|
3956
|
+
htm: "html",
|
|
3957
|
+
css: "css",
|
|
3958
|
+
yaml: "yaml",
|
|
3959
|
+
yml: "yaml",
|
|
3960
|
+
toml: "toml",
|
|
3961
|
+
hcl: "hcl",
|
|
3962
|
+
tf: "hcl",
|
|
3963
|
+
dockerfile: "dockerfile",
|
|
3964
|
+
proto: "protobuf",
|
|
3965
|
+
svelte: "svelte",
|
|
3966
|
+
elm: "elm",
|
|
3967
|
+
groovy: "groovy",
|
|
3968
|
+
cue: "cue"
|
|
3969
|
+
};
|
|
3970
|
+
var QUERY_TEMPLATES = {
|
|
3971
|
+
python: "(comment) @comment",
|
|
3972
|
+
javascript: "(comment) @comment",
|
|
3973
|
+
typescript: "(comment) @comment",
|
|
3974
|
+
tsx: "(comment) @comment",
|
|
3975
|
+
golang: "(comment) @comment",
|
|
3976
|
+
rust: `
|
|
3977
|
+
(line_comment) @comment
|
|
3978
|
+
(block_comment) @comment
|
|
3979
|
+
`,
|
|
3980
|
+
kotlin: `
|
|
3981
|
+
(line_comment) @comment
|
|
3982
|
+
(multiline_comment) @comment
|
|
3983
|
+
`,
|
|
3984
|
+
java: `
|
|
3985
|
+
(line_comment) @comment
|
|
3986
|
+
(block_comment) @comment
|
|
3987
|
+
`,
|
|
3988
|
+
c: "(comment) @comment",
|
|
3989
|
+
cpp: "(comment) @comment",
|
|
3990
|
+
csharp: "(comment) @comment",
|
|
3991
|
+
ruby: "(comment) @comment",
|
|
3992
|
+
bash: "(comment) @comment",
|
|
3993
|
+
swift: "(comment) @comment",
|
|
3994
|
+
elixir: "(comment) @comment",
|
|
3995
|
+
lua: "(comment) @comment",
|
|
3996
|
+
php: "(comment) @comment",
|
|
3997
|
+
ocaml: "(comment) @comment",
|
|
3998
|
+
sql: "(comment) @comment",
|
|
3999
|
+
html: "(comment) @comment",
|
|
4000
|
+
css: "(comment) @comment",
|
|
4001
|
+
yaml: "(comment) @comment",
|
|
4002
|
+
toml: "(comment) @comment",
|
|
4003
|
+
hcl: "(comment) @comment",
|
|
4004
|
+
dockerfile: "(comment) @comment",
|
|
4005
|
+
protobuf: "(comment) @comment",
|
|
4006
|
+
svelte: "(comment) @comment",
|
|
4007
|
+
elm: "(comment) @comment",
|
|
4008
|
+
groovy: "(comment) @comment",
|
|
4009
|
+
cue: "(comment) @comment",
|
|
4010
|
+
scala: "(comment) @comment"
|
|
4011
|
+
};
|
|
4012
|
+
var DOCSTRING_QUERIES = {
|
|
4013
|
+
python: `
|
|
4014
|
+
(module . (expression_statement (string) @docstring))
|
|
4015
|
+
(class_definition body: (block . (expression_statement (string) @docstring)))
|
|
4016
|
+
(function_definition body: (block . (expression_statement (string) @docstring)))
|
|
4017
|
+
`,
|
|
4018
|
+
javascript: `
|
|
4019
|
+
(comment) @jsdoc
|
|
4020
|
+
(#match? @jsdoc "^/\\\\*\\\\*")
|
|
4021
|
+
`,
|
|
4022
|
+
typescript: `
|
|
4023
|
+
(comment) @jsdoc
|
|
4024
|
+
(#match? @jsdoc "^/\\\\*\\\\*")
|
|
4025
|
+
`,
|
|
4026
|
+
tsx: `
|
|
4027
|
+
(comment) @jsdoc
|
|
4028
|
+
(#match? @jsdoc "^/\\\\*\\\\*")
|
|
4029
|
+
`,
|
|
4030
|
+
java: `
|
|
4031
|
+
(comment) @javadoc
|
|
4032
|
+
(#match? @javadoc "^/\\\\*\\\\*")
|
|
4033
|
+
`
|
|
4034
|
+
};
|
|
1037
4035
|
var BDD_KEYWORDS = new Set([
|
|
1038
4036
|
"given",
|
|
1039
4037
|
"when",
|
|
@@ -1044,6 +4042,303 @@ var BDD_KEYWORDS = new Set([
|
|
|
1044
4042
|
"when & then",
|
|
1045
4043
|
"when&then"
|
|
1046
4044
|
]);
|
|
4045
|
+
var TYPE_CHECKER_PREFIXES = [
|
|
4046
|
+
"type:",
|
|
4047
|
+
"noqa",
|
|
4048
|
+
"pyright:",
|
|
4049
|
+
"ruff:",
|
|
4050
|
+
"mypy:",
|
|
4051
|
+
"pylint:",
|
|
4052
|
+
"flake8:",
|
|
4053
|
+
"pyre:",
|
|
4054
|
+
"pytype:",
|
|
4055
|
+
"eslint-disable",
|
|
4056
|
+
"eslint-enable",
|
|
4057
|
+
"eslint-ignore",
|
|
4058
|
+
"prettier-ignore",
|
|
4059
|
+
"ts-ignore",
|
|
4060
|
+
"ts-expect-error",
|
|
4061
|
+
"ts-nocheck",
|
|
4062
|
+
"clippy::",
|
|
4063
|
+
"allow(",
|
|
4064
|
+
"deny(",
|
|
4065
|
+
"warn(",
|
|
4066
|
+
"forbid(",
|
|
4067
|
+
"nolint",
|
|
4068
|
+
"go:generate",
|
|
4069
|
+
"go:build",
|
|
4070
|
+
"go:embed",
|
|
4071
|
+
"coverage:",
|
|
4072
|
+
"c8 ignore",
|
|
4073
|
+
"biome-ignore",
|
|
4074
|
+
"region",
|
|
4075
|
+
"endregion"
|
|
4076
|
+
];
|
|
4077
|
+
var HOOK_MESSAGE_HEADER = `COMMENT/DOCSTRING DETECTED - IMMEDIATE ACTION REQUIRED
|
|
4078
|
+
|
|
4079
|
+
Your recent changes contain comments or docstrings, which triggered this hook.
|
|
4080
|
+
You need to take immediate action. You must follow the conditions below.
|
|
4081
|
+
(Listed in priority order - you must always act according to this priority order)
|
|
4082
|
+
|
|
4083
|
+
CRITICAL WARNING: This hook message MUST NEVER be ignored, even if you receive it multiple times.
|
|
4084
|
+
You MUST provide corresponding explanation or action for EACH occurrence of this message.
|
|
4085
|
+
Ignoring this message or failing to respond appropriately is strictly prohibited.
|
|
4086
|
+
|
|
4087
|
+
PRIORITY-BASED ACTION GUIDELINES:
|
|
4088
|
+
|
|
4089
|
+
1. This is a comment/docstring that already existed before
|
|
4090
|
+
-> Explain to the user that this is an existing comment/docstring and proceed (justify it)
|
|
4091
|
+
|
|
4092
|
+
2. This is a newly written comment: but it's in given, when, then format
|
|
4093
|
+
-> Tell the user it's a BDD comment and proceed (justify it)
|
|
4094
|
+
-> Note: This applies to comments only, not docstrings
|
|
4095
|
+
|
|
4096
|
+
3. This is a newly written comment/docstring: but it's a necessary comment/docstring
|
|
4097
|
+
-> Tell the user why this comment/docstring is absolutely necessary and proceed (justify it)
|
|
4098
|
+
-> Examples of necessary comments: complex algorithms, security-related, performance optimization, regex, mathematical formulas
|
|
4099
|
+
-> Examples of necessary docstrings: public API documentation, complex module/class interfaces
|
|
4100
|
+
-> IMPORTANT: Most docstrings are unnecessary if the code is self-explanatory. Only keep truly essential ones.
|
|
4101
|
+
|
|
4102
|
+
4. This is a newly written comment/docstring: but it's an unnecessary comment/docstring
|
|
4103
|
+
-> Apologize to the user and remove the comment/docstring.
|
|
4104
|
+
-> Make the code itself clearer so it can be understood without comments/docstrings.
|
|
4105
|
+
-> For verbose docstrings: refactor code to be self-documenting instead of adding lengthy explanations.
|
|
4106
|
+
|
|
4107
|
+
MANDATORY REQUIREMENT: You must acknowledge this hook message and take one of the above actions.
|
|
4108
|
+
Review in the above priority order and take the corresponding action EVERY TIME this appears.
|
|
4109
|
+
|
|
4110
|
+
Detected comments/docstrings:
|
|
4111
|
+
`;
|
|
4112
|
+
function getLanguageByExtension(filePath) {
|
|
4113
|
+
const lastDot = filePath.lastIndexOf(".");
|
|
4114
|
+
if (lastDot === -1) {
|
|
4115
|
+
const baseName = filePath.split("/").pop()?.toLowerCase();
|
|
4116
|
+
if (baseName === "dockerfile")
|
|
4117
|
+
return "dockerfile";
|
|
4118
|
+
return null;
|
|
4119
|
+
}
|
|
4120
|
+
const ext = filePath.slice(lastDot + 1).toLowerCase();
|
|
4121
|
+
return EXTENSION_TO_LANGUAGE[ext] ?? null;
|
|
4122
|
+
}
|
|
4123
|
+
|
|
4124
|
+
// src/hooks/comment-checker/detector.ts
|
|
4125
|
+
function isSupportedFile(filePath) {
|
|
4126
|
+
return getLanguageByExtension(filePath) !== null;
|
|
4127
|
+
}
|
|
4128
|
+
function determineCommentType(text, nodeType) {
|
|
4129
|
+
const stripped = text.trim();
|
|
4130
|
+
if (nodeType === "line_comment") {
|
|
4131
|
+
return "line";
|
|
4132
|
+
}
|
|
4133
|
+
if (nodeType === "block_comment" || nodeType === "multiline_comment") {
|
|
4134
|
+
return "block";
|
|
4135
|
+
}
|
|
4136
|
+
if (stripped.startsWith('"""') || stripped.startsWith("'''")) {
|
|
4137
|
+
return "docstring";
|
|
4138
|
+
}
|
|
4139
|
+
if (stripped.startsWith("//") || stripped.startsWith("#")) {
|
|
4140
|
+
return "line";
|
|
4141
|
+
}
|
|
4142
|
+
if (stripped.startsWith("/*") || stripped.startsWith("<!--") || stripped.startsWith("--")) {
|
|
4143
|
+
return "block";
|
|
4144
|
+
}
|
|
4145
|
+
return "line";
|
|
4146
|
+
}
|
|
4147
|
+
async function detectComments(filePath, content, includeDocstrings = true) {
|
|
4148
|
+
const langName = getLanguageByExtension(filePath);
|
|
4149
|
+
if (!langName) {
|
|
4150
|
+
return [];
|
|
4151
|
+
}
|
|
4152
|
+
const queryPattern = QUERY_TEMPLATES[langName];
|
|
4153
|
+
if (!queryPattern) {
|
|
4154
|
+
return [];
|
|
4155
|
+
}
|
|
4156
|
+
try {
|
|
4157
|
+
const Parser2 = (await Promise.resolve().then(() => __toESM(require_tree_sitter(), 1))).default;
|
|
4158
|
+
await Parser2.init();
|
|
4159
|
+
const parser = new Parser2;
|
|
4160
|
+
let wasmPath;
|
|
4161
|
+
try {
|
|
4162
|
+
const wasmModule = await import(`tree-sitter-wasms/out/tree-sitter-${langName}.wasm`);
|
|
4163
|
+
wasmPath = wasmModule.default;
|
|
4164
|
+
} catch {
|
|
4165
|
+
const languageMap = {
|
|
4166
|
+
golang: "go",
|
|
4167
|
+
csharp: "c_sharp",
|
|
4168
|
+
cpp: "cpp"
|
|
4169
|
+
};
|
|
4170
|
+
const mappedLang = languageMap[langName] || langName;
|
|
4171
|
+
try {
|
|
4172
|
+
const wasmModule = await import(`tree-sitter-wasms/out/tree-sitter-${mappedLang}.wasm`);
|
|
4173
|
+
wasmPath = wasmModule.default;
|
|
4174
|
+
} catch {
|
|
4175
|
+
return [];
|
|
4176
|
+
}
|
|
4177
|
+
}
|
|
4178
|
+
const language = await Parser2.Language.load(wasmPath);
|
|
4179
|
+
parser.setLanguage(language);
|
|
4180
|
+
const tree = parser.parse(content);
|
|
4181
|
+
const comments = [];
|
|
4182
|
+
const query = language.query(queryPattern);
|
|
4183
|
+
const matches = query.matches(tree.rootNode);
|
|
4184
|
+
for (const match of matches) {
|
|
4185
|
+
for (const capture of match.captures) {
|
|
4186
|
+
const node = capture.node;
|
|
4187
|
+
const text = node.text;
|
|
4188
|
+
const lineNumber = node.startPosition.row + 1;
|
|
4189
|
+
const commentType = determineCommentType(text, node.type);
|
|
4190
|
+
const isDocstring = commentType === "docstring";
|
|
4191
|
+
if (isDocstring && !includeDocstrings) {
|
|
4192
|
+
continue;
|
|
4193
|
+
}
|
|
4194
|
+
comments.push({
|
|
4195
|
+
text,
|
|
4196
|
+
lineNumber,
|
|
4197
|
+
filePath,
|
|
4198
|
+
commentType,
|
|
4199
|
+
isDocstring
|
|
4200
|
+
});
|
|
4201
|
+
}
|
|
4202
|
+
}
|
|
4203
|
+
if (includeDocstrings) {
|
|
4204
|
+
const docQuery = DOCSTRING_QUERIES[langName];
|
|
4205
|
+
if (docQuery) {
|
|
4206
|
+
try {
|
|
4207
|
+
const docQueryObj = language.query(docQuery);
|
|
4208
|
+
const docMatches = docQueryObj.matches(tree.rootNode);
|
|
4209
|
+
for (const match of docMatches) {
|
|
4210
|
+
for (const capture of match.captures) {
|
|
4211
|
+
const node = capture.node;
|
|
4212
|
+
const text = node.text;
|
|
4213
|
+
const lineNumber = node.startPosition.row + 1;
|
|
4214
|
+
const alreadyAdded = comments.some((c) => c.lineNumber === lineNumber && c.text === text);
|
|
4215
|
+
if (!alreadyAdded) {
|
|
4216
|
+
comments.push({
|
|
4217
|
+
text,
|
|
4218
|
+
lineNumber,
|
|
4219
|
+
filePath,
|
|
4220
|
+
commentType: "docstring",
|
|
4221
|
+
isDocstring: true
|
|
4222
|
+
});
|
|
4223
|
+
}
|
|
4224
|
+
}
|
|
4225
|
+
}
|
|
4226
|
+
} catch {}
|
|
4227
|
+
}
|
|
4228
|
+
}
|
|
4229
|
+
comments.sort((a, b) => a.lineNumber - b.lineNumber);
|
|
4230
|
+
return comments;
|
|
4231
|
+
} catch {
|
|
4232
|
+
return [];
|
|
4233
|
+
}
|
|
4234
|
+
}
|
|
4235
|
+
|
|
4236
|
+
// src/hooks/comment-checker/filters/bdd.ts
|
|
4237
|
+
function stripCommentPrefix(text) {
|
|
4238
|
+
let stripped = text.trim().toLowerCase();
|
|
4239
|
+
const prefixes = ["#", "//", "--", "/*", "*/"];
|
|
4240
|
+
for (const prefix of prefixes) {
|
|
4241
|
+
if (stripped.startsWith(prefix)) {
|
|
4242
|
+
stripped = stripped.slice(prefix.length).trim();
|
|
4243
|
+
}
|
|
4244
|
+
}
|
|
4245
|
+
return stripped;
|
|
4246
|
+
}
|
|
4247
|
+
function filterBddComments(comment) {
|
|
4248
|
+
const normalized = stripCommentPrefix(comment.text);
|
|
4249
|
+
if (BDD_KEYWORDS.has(normalized)) {
|
|
4250
|
+
return { shouldSkip: true, reason: `BDD keyword: ${normalized}` };
|
|
4251
|
+
}
|
|
4252
|
+
return { shouldSkip: false };
|
|
4253
|
+
}
|
|
4254
|
+
|
|
4255
|
+
// src/hooks/comment-checker/filters/directive.ts
|
|
4256
|
+
function stripCommentPrefix2(text) {
|
|
4257
|
+
let stripped = text.trim().toLowerCase();
|
|
4258
|
+
const prefixes = ["#", "//", "/*", "--"];
|
|
4259
|
+
for (const prefix of prefixes) {
|
|
4260
|
+
if (stripped.startsWith(prefix)) {
|
|
4261
|
+
stripped = stripped.slice(prefix.length).trim();
|
|
4262
|
+
}
|
|
4263
|
+
}
|
|
4264
|
+
stripped = stripped.replace(/^@/, "");
|
|
4265
|
+
return stripped;
|
|
4266
|
+
}
|
|
4267
|
+
function filterDirectiveComments(comment) {
|
|
4268
|
+
const normalized = stripCommentPrefix2(comment.text);
|
|
4269
|
+
for (const prefix of TYPE_CHECKER_PREFIXES) {
|
|
4270
|
+
if (normalized.startsWith(prefix.toLowerCase())) {
|
|
4271
|
+
return { shouldSkip: true, reason: `Directive: ${prefix}` };
|
|
4272
|
+
}
|
|
4273
|
+
}
|
|
4274
|
+
return { shouldSkip: false };
|
|
4275
|
+
}
|
|
4276
|
+
|
|
4277
|
+
// src/hooks/comment-checker/filters/docstring.ts
|
|
4278
|
+
function filterDocstringComments(comment) {
|
|
4279
|
+
if (comment.isDocstring) {
|
|
4280
|
+
return { shouldSkip: true, reason: "Docstring" };
|
|
4281
|
+
}
|
|
4282
|
+
const trimmed = comment.text.trimStart();
|
|
4283
|
+
if (trimmed.startsWith("/**")) {
|
|
4284
|
+
return { shouldSkip: true, reason: "JSDoc/PHPDoc" };
|
|
4285
|
+
}
|
|
4286
|
+
return { shouldSkip: false };
|
|
4287
|
+
}
|
|
4288
|
+
|
|
4289
|
+
// src/hooks/comment-checker/filters/shebang.ts
|
|
4290
|
+
function filterShebangComments(comment) {
|
|
4291
|
+
const trimmed = comment.text.trimStart();
|
|
4292
|
+
if (trimmed.startsWith("#!")) {
|
|
4293
|
+
return { shouldSkip: true, reason: "Shebang" };
|
|
4294
|
+
}
|
|
4295
|
+
return { shouldSkip: false };
|
|
4296
|
+
}
|
|
4297
|
+
|
|
4298
|
+
// src/hooks/comment-checker/filters/index.ts
|
|
4299
|
+
var ALL_FILTERS = [
|
|
4300
|
+
filterShebangComments,
|
|
4301
|
+
filterBddComments,
|
|
4302
|
+
filterDirectiveComments,
|
|
4303
|
+
filterDocstringComments
|
|
4304
|
+
];
|
|
4305
|
+
function applyFilters(comments) {
|
|
4306
|
+
return comments.filter((comment) => {
|
|
4307
|
+
for (const filter of ALL_FILTERS) {
|
|
4308
|
+
const result = filter(comment);
|
|
4309
|
+
if (result.shouldSkip) {
|
|
4310
|
+
return false;
|
|
4311
|
+
}
|
|
4312
|
+
}
|
|
4313
|
+
return true;
|
|
4314
|
+
});
|
|
4315
|
+
}
|
|
4316
|
+
|
|
4317
|
+
// src/hooks/comment-checker/output/xml-builder.ts
|
|
4318
|
+
function escapeXml(text) {
|
|
4319
|
+
return text.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
4320
|
+
}
|
|
4321
|
+
function buildCommentsXml(fileCommentsList) {
|
|
4322
|
+
const lines = [];
|
|
4323
|
+
for (const fc of fileCommentsList) {
|
|
4324
|
+
lines.push(`<comments file="${escapeXml(fc.filePath)}">`);
|
|
4325
|
+
for (const comment of fc.comments) {
|
|
4326
|
+
lines.push(` <comment line-number="${comment.lineNumber}">${escapeXml(comment.text)}</comment>`);
|
|
4327
|
+
}
|
|
4328
|
+
lines.push(`</comments>`);
|
|
4329
|
+
}
|
|
4330
|
+
return lines.join(`
|
|
4331
|
+
`);
|
|
4332
|
+
}
|
|
4333
|
+
// src/hooks/comment-checker/output/formatter.ts
|
|
4334
|
+
function formatHookMessage(fileCommentsList) {
|
|
4335
|
+
if (fileCommentsList.length === 0) {
|
|
4336
|
+
return "";
|
|
4337
|
+
}
|
|
4338
|
+
const xml = buildCommentsXml(fileCommentsList);
|
|
4339
|
+
return `${HOOK_MESSAGE_HEADER}${xml}
|
|
4340
|
+
`;
|
|
4341
|
+
}
|
|
1047
4342
|
// src/hooks/comment-checker/index.ts
|
|
1048
4343
|
var pendingCalls = new Map;
|
|
1049
4344
|
var PENDING_CALL_TTL = 60000;
|
|
@@ -1056,6 +4351,65 @@ function cleanupOldPendingCalls() {
|
|
|
1056
4351
|
}
|
|
1057
4352
|
}
|
|
1058
4353
|
setInterval(cleanupOldPendingCalls, 1e4);
|
|
4354
|
+
function createCommentCheckerHooks() {
|
|
4355
|
+
return {
|
|
4356
|
+
"tool.execute.before": async (input, output) => {
|
|
4357
|
+
const toolLower = input.tool.toLowerCase();
|
|
4358
|
+
if (toolLower !== "write" && toolLower !== "edit" && toolLower !== "multiedit") {
|
|
4359
|
+
return;
|
|
4360
|
+
}
|
|
4361
|
+
const filePath = output.args.filePath ?? output.args.file_path;
|
|
4362
|
+
const content = output.args.content;
|
|
4363
|
+
if (!filePath) {
|
|
4364
|
+
return;
|
|
4365
|
+
}
|
|
4366
|
+
if (!isSupportedFile(filePath)) {
|
|
4367
|
+
return;
|
|
4368
|
+
}
|
|
4369
|
+
pendingCalls.set(input.callID, {
|
|
4370
|
+
filePath,
|
|
4371
|
+
content,
|
|
4372
|
+
tool: toolLower,
|
|
4373
|
+
sessionID: input.sessionID,
|
|
4374
|
+
timestamp: Date.now()
|
|
4375
|
+
});
|
|
4376
|
+
},
|
|
4377
|
+
"tool.execute.after": async (input, output) => {
|
|
4378
|
+
const pendingCall = pendingCalls.get(input.callID);
|
|
4379
|
+
if (!pendingCall) {
|
|
4380
|
+
return;
|
|
4381
|
+
}
|
|
4382
|
+
pendingCalls.delete(input.callID);
|
|
4383
|
+
if (output.output.toLowerCase().includes("error")) {
|
|
4384
|
+
return;
|
|
4385
|
+
}
|
|
4386
|
+
try {
|
|
4387
|
+
let content;
|
|
4388
|
+
if (pendingCall.content) {
|
|
4389
|
+
content = pendingCall.content;
|
|
4390
|
+
} else {
|
|
4391
|
+
const file = Bun.file(pendingCall.filePath);
|
|
4392
|
+
content = await file.text();
|
|
4393
|
+
}
|
|
4394
|
+
const rawComments = await detectComments(pendingCall.filePath, content);
|
|
4395
|
+
const filteredComments = applyFilters(rawComments);
|
|
4396
|
+
if (filteredComments.length === 0) {
|
|
4397
|
+
return;
|
|
4398
|
+
}
|
|
4399
|
+
const fileComments = [
|
|
4400
|
+
{
|
|
4401
|
+
filePath: pendingCall.filePath,
|
|
4402
|
+
comments: filteredComments
|
|
4403
|
+
}
|
|
4404
|
+
];
|
|
4405
|
+
const message = formatHookMessage(fileComments);
|
|
4406
|
+
output.output += `
|
|
4407
|
+
|
|
4408
|
+
${message}`;
|
|
4409
|
+
} catch {}
|
|
4410
|
+
}
|
|
4411
|
+
};
|
|
4412
|
+
}
|
|
1059
4413
|
// src/features/terminal/title.ts
|
|
1060
4414
|
var STATUS_ICONS = {
|
|
1061
4415
|
ready: "",
|
|
@@ -1074,11 +4428,11 @@ function truncate(str, maxLen) {
|
|
|
1074
4428
|
function formatTerminalTitle(ctx) {
|
|
1075
4429
|
const title = ctx.sessionTitle || DEFAULT_TITLE;
|
|
1076
4430
|
const truncatedTitle = truncate(title, MAX_TITLE_LENGTH);
|
|
1077
|
-
const
|
|
4431
|
+
const parts2 = ["[OpenCode]", truncatedTitle];
|
|
1078
4432
|
if (ctx.status) {
|
|
1079
|
-
|
|
4433
|
+
parts2.push(STATUS_ICONS[ctx.status]);
|
|
1080
4434
|
}
|
|
1081
|
-
return
|
|
4435
|
+
return parts2.join(" ");
|
|
1082
4436
|
}
|
|
1083
4437
|
function isTmuxEnvironment() {
|
|
1084
4438
|
return !!process.env.TMUX || process.env.TERM_PROGRAM === "tmux";
|
|
@@ -1475,7 +4829,7 @@ class LSPServerManager {
|
|
|
1475
4829
|
this.clients.delete(key);
|
|
1476
4830
|
}
|
|
1477
4831
|
const client = new LSPClient(root, server);
|
|
1478
|
-
const
|
|
4832
|
+
const initPromise2 = (async () => {
|
|
1479
4833
|
await client.start();
|
|
1480
4834
|
await client.initialize();
|
|
1481
4835
|
})();
|
|
@@ -1483,10 +4837,10 @@ class LSPServerManager {
|
|
|
1483
4837
|
client,
|
|
1484
4838
|
lastUsedAt: Date.now(),
|
|
1485
4839
|
refCount: 1,
|
|
1486
|
-
initPromise,
|
|
4840
|
+
initPromise: initPromise2,
|
|
1487
4841
|
isInitializing: true
|
|
1488
4842
|
});
|
|
1489
|
-
await
|
|
4843
|
+
await initPromise2;
|
|
1490
4844
|
const m = this.clients.get(key);
|
|
1491
4845
|
if (m) {
|
|
1492
4846
|
m.initPromise = undefined;
|
|
@@ -1499,7 +4853,7 @@ class LSPServerManager {
|
|
|
1499
4853
|
if (this.clients.has(key))
|
|
1500
4854
|
return;
|
|
1501
4855
|
const client = new LSPClient(root, server);
|
|
1502
|
-
const
|
|
4856
|
+
const initPromise2 = (async () => {
|
|
1503
4857
|
await client.start();
|
|
1504
4858
|
await client.initialize();
|
|
1505
4859
|
})();
|
|
@@ -1507,10 +4861,10 @@ class LSPServerManager {
|
|
|
1507
4861
|
client,
|
|
1508
4862
|
lastUsedAt: Date.now(),
|
|
1509
4863
|
refCount: 0,
|
|
1510
|
-
initPromise,
|
|
4864
|
+
initPromise: initPromise2,
|
|
1511
4865
|
isInitializing: true
|
|
1512
4866
|
});
|
|
1513
|
-
|
|
4867
|
+
initPromise2.then(() => {
|
|
1514
4868
|
const m = this.clients.get(key);
|
|
1515
4869
|
if (m) {
|
|
1516
4870
|
m.initPromise = undefined;
|
|
@@ -1601,9 +4955,9 @@ stderr: ${stderr}` : ""));
|
|
|
1601
4955
|
this.buffer = newBuf;
|
|
1602
4956
|
this.processBuffer();
|
|
1603
4957
|
}
|
|
1604
|
-
} catch (
|
|
4958
|
+
} catch (err2) {
|
|
1605
4959
|
this.processExited = true;
|
|
1606
|
-
this.rejectAllPending(`LSP stdout read error: ${
|
|
4960
|
+
this.rejectAllPending(`LSP stdout read error: ${err2}`);
|
|
1607
4961
|
}
|
|
1608
4962
|
};
|
|
1609
4963
|
read();
|
|
@@ -1637,12 +4991,12 @@ stderr: ${stderr}` : ""));
|
|
|
1637
4991
|
}
|
|
1638
4992
|
findSequence(haystack, needle) {
|
|
1639
4993
|
outer:
|
|
1640
|
-
for (let
|
|
4994
|
+
for (let i2 = 0;i2 <= haystack.length - needle.length; i2++) {
|
|
1641
4995
|
for (let j = 0;j < needle.length; j++) {
|
|
1642
|
-
if (haystack[
|
|
4996
|
+
if (haystack[i2 + j] !== needle[j])
|
|
1643
4997
|
continue outer;
|
|
1644
4998
|
}
|
|
1645
|
-
return
|
|
4999
|
+
return i2;
|
|
1646
5000
|
}
|
|
1647
5001
|
return -1;
|
|
1648
5002
|
}
|
|
@@ -1670,11 +5024,11 @@ stderr: ${stderr}` : ""));
|
|
|
1670
5024
|
if (!match)
|
|
1671
5025
|
break;
|
|
1672
5026
|
const len = parseInt(match[1], 10);
|
|
1673
|
-
const
|
|
1674
|
-
const end =
|
|
5027
|
+
const start2 = headerEnd + sepLen;
|
|
5028
|
+
const end = start2 + len;
|
|
1675
5029
|
if (this.buffer.length < end)
|
|
1676
5030
|
break;
|
|
1677
|
-
const content = decoder.decode(this.buffer.slice(
|
|
5031
|
+
const content = decoder.decode(this.buffer.slice(start2, end));
|
|
1678
5032
|
this.buffer = this.buffer.slice(end);
|
|
1679
5033
|
try {
|
|
1680
5034
|
const msg = JSON.parse(content);
|
|
@@ -2062,12 +5416,12 @@ function formatCodeActions(actions) {
|
|
|
2062
5416
|
if (!actions || actions.length === 0)
|
|
2063
5417
|
return "No code actions available";
|
|
2064
5418
|
const lines = [];
|
|
2065
|
-
for (let
|
|
2066
|
-
const action = actions[
|
|
5419
|
+
for (let i2 = 0;i2 < actions.length; i2++) {
|
|
5420
|
+
const action = actions[i2];
|
|
2067
5421
|
if ("command" in action && typeof action.command === "string" && !("kind" in action)) {
|
|
2068
|
-
lines.push(`${
|
|
5422
|
+
lines.push(`${i2 + 1}. [command] ${action.title}`);
|
|
2069
5423
|
} else {
|
|
2070
|
-
lines.push(`${
|
|
5424
|
+
lines.push(`${i2 + 1}. ${formatCodeAction(action)}`);
|
|
2071
5425
|
}
|
|
2072
5426
|
}
|
|
2073
5427
|
return lines.join(`
|
|
@@ -2103,8 +5457,8 @@ function applyTextEditsToFile(filePath, edits) {
|
|
|
2103
5457
|
writeFileSync(filePath, lines.join(`
|
|
2104
5458
|
`), "utf-8");
|
|
2105
5459
|
return { success: true, editCount: edits.length };
|
|
2106
|
-
} catch (
|
|
2107
|
-
return { success: false, editCount: 0, error:
|
|
5460
|
+
} catch (err2) {
|
|
5461
|
+
return { success: false, editCount: 0, error: err2 instanceof Error ? err2.message : String(err2) };
|
|
2108
5462
|
}
|
|
2109
5463
|
}
|
|
2110
5464
|
function applyWorkspaceEdit(edit) {
|
|
@@ -2133,9 +5487,9 @@ function applyWorkspaceEdit(edit) {
|
|
|
2133
5487
|
const filePath = change.uri.replace("file://", "");
|
|
2134
5488
|
writeFileSync(filePath, "", "utf-8");
|
|
2135
5489
|
result.filesModified.push(filePath);
|
|
2136
|
-
} catch (
|
|
5490
|
+
} catch (err2) {
|
|
2137
5491
|
result.success = false;
|
|
2138
|
-
result.errors.push(`Create ${change.uri}: ${
|
|
5492
|
+
result.errors.push(`Create ${change.uri}: ${err2}`);
|
|
2139
5493
|
}
|
|
2140
5494
|
} else if (change.kind === "rename") {
|
|
2141
5495
|
try {
|
|
@@ -2145,18 +5499,18 @@ function applyWorkspaceEdit(edit) {
|
|
|
2145
5499
|
writeFileSync(newPath, content, "utf-8");
|
|
2146
5500
|
__require("fs").unlinkSync(oldPath);
|
|
2147
5501
|
result.filesModified.push(newPath);
|
|
2148
|
-
} catch (
|
|
5502
|
+
} catch (err2) {
|
|
2149
5503
|
result.success = false;
|
|
2150
|
-
result.errors.push(`Rename ${change.oldUri}: ${
|
|
5504
|
+
result.errors.push(`Rename ${change.oldUri}: ${err2}`);
|
|
2151
5505
|
}
|
|
2152
5506
|
} else if (change.kind === "delete") {
|
|
2153
5507
|
try {
|
|
2154
5508
|
const filePath = change.uri.replace("file://", "");
|
|
2155
5509
|
__require("fs").unlinkSync(filePath);
|
|
2156
5510
|
result.filesModified.push(filePath);
|
|
2157
|
-
} catch (
|
|
5511
|
+
} catch (err2) {
|
|
2158
5512
|
result.success = false;
|
|
2159
|
-
result.errors.push(`Delete ${change.uri}: ${
|
|
5513
|
+
result.errors.push(`Delete ${change.uri}: ${err2}`);
|
|
2160
5514
|
}
|
|
2161
5515
|
}
|
|
2162
5516
|
} else {
|
|
@@ -2183,8 +5537,8 @@ function formatApplyResult(result) {
|
|
|
2183
5537
|
}
|
|
2184
5538
|
} else {
|
|
2185
5539
|
lines.push("Failed to apply some changes:");
|
|
2186
|
-
for (const
|
|
2187
|
-
lines.push(` Error: ${
|
|
5540
|
+
for (const err2 of result.errors) {
|
|
5541
|
+
lines.push(` Error: ${err2}`);
|
|
2188
5542
|
}
|
|
2189
5543
|
if (result.filesModified.length > 0) {
|
|
2190
5544
|
lines.push(`Successfully modified: ${result.filesModified.join(", ")}`);
|
|
@@ -2691,15 +6045,15 @@ __export(exports_core2, {
|
|
|
2691
6045
|
var NEVER = Object.freeze({
|
|
2692
6046
|
status: "aborted"
|
|
2693
6047
|
});
|
|
2694
|
-
function $constructor(
|
|
2695
|
-
function
|
|
6048
|
+
function $constructor(name2, initializer, params) {
|
|
6049
|
+
function init2(inst, def) {
|
|
2696
6050
|
var _a;
|
|
2697
6051
|
Object.defineProperty(inst, "_zod", {
|
|
2698
6052
|
value: inst._zod ?? {},
|
|
2699
6053
|
enumerable: false
|
|
2700
6054
|
});
|
|
2701
6055
|
(_a = inst._zod).traits ?? (_a.traits = new Set);
|
|
2702
|
-
inst._zod.traits.add(
|
|
6056
|
+
inst._zod.traits.add(name2);
|
|
2703
6057
|
initializer(inst, def);
|
|
2704
6058
|
for (const k in _.prototype) {
|
|
2705
6059
|
if (!(k in inst))
|
|
@@ -2712,26 +6066,26 @@ function $constructor(name, initializer, params) {
|
|
|
2712
6066
|
|
|
2713
6067
|
class Definition extends Parent {
|
|
2714
6068
|
}
|
|
2715
|
-
Object.defineProperty(Definition, "name", { value:
|
|
6069
|
+
Object.defineProperty(Definition, "name", { value: name2 });
|
|
2716
6070
|
function _(def) {
|
|
2717
6071
|
var _a;
|
|
2718
6072
|
const inst = params?.Parent ? new Definition : this;
|
|
2719
|
-
|
|
6073
|
+
init2(inst, def);
|
|
2720
6074
|
(_a = inst._zod).deferred ?? (_a.deferred = []);
|
|
2721
6075
|
for (const fn of inst._zod.deferred) {
|
|
2722
6076
|
fn();
|
|
2723
6077
|
}
|
|
2724
6078
|
return inst;
|
|
2725
6079
|
}
|
|
2726
|
-
Object.defineProperty(_, "init", { value:
|
|
6080
|
+
Object.defineProperty(_, "init", { value: init2 });
|
|
2727
6081
|
Object.defineProperty(_, Symbol.hasInstance, {
|
|
2728
6082
|
value: (inst) => {
|
|
2729
6083
|
if (params?.Parent && inst instanceof params.Parent)
|
|
2730
6084
|
return true;
|
|
2731
|
-
return inst?._zod?.traits?.has(
|
|
6085
|
+
return inst?._zod?.traits?.has(name2);
|
|
2732
6086
|
}
|
|
2733
6087
|
});
|
|
2734
|
-
Object.defineProperty(_, "name", { value:
|
|
6088
|
+
Object.defineProperty(_, "name", { value: name2 });
|
|
2735
6089
|
return _;
|
|
2736
6090
|
}
|
|
2737
6091
|
var $brand = Symbol("zod_brand");
|
|
@@ -2743,8 +6097,8 @@ class $ZodAsyncError extends Error {
|
|
|
2743
6097
|
}
|
|
2744
6098
|
|
|
2745
6099
|
class $ZodEncodeError extends Error {
|
|
2746
|
-
constructor(
|
|
2747
|
-
super(`Encountered unidirectional transform during encode: ${
|
|
6100
|
+
constructor(name2) {
|
|
6101
|
+
super(`Encountered unidirectional transform during encode: ${name2}`);
|
|
2748
6102
|
this.name = "ZodEncodeError";
|
|
2749
6103
|
}
|
|
2750
6104
|
}
|
|
@@ -2859,9 +6213,9 @@ function nullish(input) {
|
|
|
2859
6213
|
return input === null || input === undefined;
|
|
2860
6214
|
}
|
|
2861
6215
|
function cleanRegex(source) {
|
|
2862
|
-
const
|
|
6216
|
+
const start2 = source.startsWith("^") ? 1 : 0;
|
|
2863
6217
|
const end = source.endsWith("$") ? source.length - 1 : source.length;
|
|
2864
|
-
return source.slice(
|
|
6218
|
+
return source.slice(start2, end);
|
|
2865
6219
|
}
|
|
2866
6220
|
function floatSafeRemainder(val, step) {
|
|
2867
6221
|
const valDecCount = (val.toString().split(".")[1] || "").length;
|
|
@@ -2932,8 +6286,8 @@ function promiseAllObject(promisesObj) {
|
|
|
2932
6286
|
const promises = keys.map((key) => promisesObj[key]);
|
|
2933
6287
|
return Promise.all(promises).then((results) => {
|
|
2934
6288
|
const resolvedObj = {};
|
|
2935
|
-
for (let
|
|
2936
|
-
resolvedObj[keys[
|
|
6289
|
+
for (let i2 = 0;i2 < keys.length; i2++) {
|
|
6290
|
+
resolvedObj[keys[i2]] = results[i2];
|
|
2937
6291
|
}
|
|
2938
6292
|
return resolvedObj;
|
|
2939
6293
|
});
|
|
@@ -2941,7 +6295,7 @@ function promiseAllObject(promisesObj) {
|
|
|
2941
6295
|
function randomString(length = 10) {
|
|
2942
6296
|
const chars = "abcdefghijklmnopqrstuvwxyz";
|
|
2943
6297
|
let str = "";
|
|
2944
|
-
for (let
|
|
6298
|
+
for (let i2 = 0;i2 < length; i2++) {
|
|
2945
6299
|
str += chars[Math.floor(Math.random() * chars.length)];
|
|
2946
6300
|
}
|
|
2947
6301
|
return str;
|
|
@@ -3277,8 +6631,8 @@ function required(Class, schema, mask) {
|
|
|
3277
6631
|
function aborted(x, startIndex = 0) {
|
|
3278
6632
|
if (x.aborted === true)
|
|
3279
6633
|
return true;
|
|
3280
|
-
for (let
|
|
3281
|
-
if (x.issues[
|
|
6634
|
+
for (let i2 = startIndex;i2 < x.issues.length; i2++) {
|
|
6635
|
+
if (x.issues[i2]?.continue !== true) {
|
|
3282
6636
|
return true;
|
|
3283
6637
|
}
|
|
3284
6638
|
}
|
|
@@ -3324,8 +6678,8 @@ function getLengthableOrigin(input) {
|
|
|
3324
6678
|
return "string";
|
|
3325
6679
|
return "unknown";
|
|
3326
6680
|
}
|
|
3327
|
-
function issue(...
|
|
3328
|
-
const [iss, input, inst] =
|
|
6681
|
+
function issue(...args2) {
|
|
6682
|
+
const [iss, input, inst] = args2;
|
|
3329
6683
|
if (typeof iss === "string") {
|
|
3330
6684
|
return {
|
|
3331
6685
|
message: iss,
|
|
@@ -3344,15 +6698,15 @@ function cleanEnum(obj) {
|
|
|
3344
6698
|
function base64ToUint8Array(base64) {
|
|
3345
6699
|
const binaryString = atob(base64);
|
|
3346
6700
|
const bytes = new Uint8Array(binaryString.length);
|
|
3347
|
-
for (let
|
|
3348
|
-
bytes[
|
|
6701
|
+
for (let i2 = 0;i2 < binaryString.length; i2++) {
|
|
6702
|
+
bytes[i2] = binaryString.charCodeAt(i2);
|
|
3349
6703
|
}
|
|
3350
6704
|
return bytes;
|
|
3351
6705
|
}
|
|
3352
6706
|
function uint8ArrayToBase64(bytes) {
|
|
3353
6707
|
let binaryString = "";
|
|
3354
|
-
for (let
|
|
3355
|
-
binaryString += String.fromCharCode(bytes[
|
|
6708
|
+
for (let i2 = 0;i2 < bytes.length; i2++) {
|
|
6709
|
+
binaryString += String.fromCharCode(bytes[i2]);
|
|
3356
6710
|
}
|
|
3357
6711
|
return btoa(binaryString);
|
|
3358
6712
|
}
|
|
@@ -3370,8 +6724,8 @@ function hexToUint8Array(hex) {
|
|
|
3370
6724
|
throw new Error("Invalid hex string length");
|
|
3371
6725
|
}
|
|
3372
6726
|
const bytes = new Uint8Array(cleanHex.length / 2);
|
|
3373
|
-
for (let
|
|
3374
|
-
bytes[
|
|
6727
|
+
for (let i2 = 0;i2 < cleanHex.length; i2 += 2) {
|
|
6728
|
+
bytes[i2 / 2] = Number.parseInt(cleanHex.slice(i2, i2 + 2), 16);
|
|
3375
6729
|
}
|
|
3376
6730
|
return bytes;
|
|
3377
6731
|
}
|
|
@@ -3432,10 +6786,10 @@ function formatError(error, _mapper) {
|
|
|
3432
6786
|
fieldErrors._errors.push(mapper(issue2));
|
|
3433
6787
|
} else {
|
|
3434
6788
|
let curr = fieldErrors;
|
|
3435
|
-
let
|
|
3436
|
-
while (
|
|
3437
|
-
const el = issue2.path[
|
|
3438
|
-
const terminal =
|
|
6789
|
+
let i2 = 0;
|
|
6790
|
+
while (i2 < issue2.path.length) {
|
|
6791
|
+
const el = issue2.path[i2];
|
|
6792
|
+
const terminal = i2 === issue2.path.length - 1;
|
|
3439
6793
|
if (!terminal) {
|
|
3440
6794
|
curr[el] = curr[el] || { _errors: [] };
|
|
3441
6795
|
} else {
|
|
@@ -3443,7 +6797,7 @@ function formatError(error, _mapper) {
|
|
|
3443
6797
|
curr[el]._errors.push(mapper(issue2));
|
|
3444
6798
|
}
|
|
3445
6799
|
curr = curr[el];
|
|
3446
|
-
|
|
6800
|
+
i2++;
|
|
3447
6801
|
}
|
|
3448
6802
|
}
|
|
3449
6803
|
}
|
|
@@ -3472,10 +6826,10 @@ function treeifyError(error, _mapper) {
|
|
|
3472
6826
|
continue;
|
|
3473
6827
|
}
|
|
3474
6828
|
let curr = result;
|
|
3475
|
-
let
|
|
3476
|
-
while (
|
|
3477
|
-
const el = fullpath[
|
|
3478
|
-
const terminal =
|
|
6829
|
+
let i2 = 0;
|
|
6830
|
+
while (i2 < fullpath.length) {
|
|
6831
|
+
const el = fullpath[i2];
|
|
6832
|
+
const terminal = i2 === fullpath.length - 1;
|
|
3479
6833
|
if (typeof el === "string") {
|
|
3480
6834
|
curr.properties ?? (curr.properties = {});
|
|
3481
6835
|
(_a = curr.properties)[el] ?? (_a[el] = { errors: [] });
|
|
@@ -3488,7 +6842,7 @@ function treeifyError(error, _mapper) {
|
|
|
3488
6842
|
if (terminal) {
|
|
3489
6843
|
curr.errors.push(mapper(issue2));
|
|
3490
6844
|
}
|
|
3491
|
-
|
|
6845
|
+
i2++;
|
|
3492
6846
|
}
|
|
3493
6847
|
}
|
|
3494
6848
|
}
|
|
@@ -3712,20 +7066,20 @@ var domain = /^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/;
|
|
|
3712
7066
|
var e164 = /^\+(?:[0-9]){6,14}[0-9]$/;
|
|
3713
7067
|
var dateSource = `(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`;
|
|
3714
7068
|
var date = /* @__PURE__ */ new RegExp(`^${dateSource}$`);
|
|
3715
|
-
function timeSource(
|
|
7069
|
+
function timeSource(args2) {
|
|
3716
7070
|
const hhmm = `(?:[01]\\d|2[0-3]):[0-5]\\d`;
|
|
3717
|
-
const regex = typeof
|
|
7071
|
+
const regex = typeof args2.precision === "number" ? args2.precision === -1 ? `${hhmm}` : args2.precision === 0 ? `${hhmm}:[0-5]\\d` : `${hhmm}:[0-5]\\d\\.\\d{${args2.precision}}` : `${hhmm}(?::[0-5]\\d(?:\\.\\d+)?)?`;
|
|
3718
7072
|
return regex;
|
|
3719
7073
|
}
|
|
3720
|
-
function time(
|
|
3721
|
-
return new RegExp(`^${timeSource(
|
|
7074
|
+
function time(args2) {
|
|
7075
|
+
return new RegExp(`^${timeSource(args2)}$`);
|
|
3722
7076
|
}
|
|
3723
|
-
function datetime(
|
|
3724
|
-
const time2 = timeSource({ precision:
|
|
7077
|
+
function datetime(args2) {
|
|
7078
|
+
const time2 = timeSource({ precision: args2.precision });
|
|
3725
7079
|
const opts = ["Z"];
|
|
3726
|
-
if (
|
|
7080
|
+
if (args2.local)
|
|
3727
7081
|
opts.push("");
|
|
3728
|
-
if (
|
|
7082
|
+
if (args2.offset)
|
|
3729
7083
|
opts.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);
|
|
3730
7084
|
const timeRegex = `${time2}(?:${opts.join("|")})`;
|
|
3731
7085
|
return new RegExp(`^${dateSource}T(?:${timeRegex})$`);
|
|
@@ -4308,11 +7662,11 @@ var $ZodCheckOverwrite = /* @__PURE__ */ $constructor("$ZodCheckOverwrite", (ins
|
|
|
4308
7662
|
|
|
4309
7663
|
// node_modules/zod/v4/core/doc.js
|
|
4310
7664
|
class Doc {
|
|
4311
|
-
constructor(
|
|
7665
|
+
constructor(args2 = []) {
|
|
4312
7666
|
this.content = [];
|
|
4313
7667
|
this.indent = 0;
|
|
4314
7668
|
if (this)
|
|
4315
|
-
this.args =
|
|
7669
|
+
this.args = args2;
|
|
4316
7670
|
}
|
|
4317
7671
|
indented(fn) {
|
|
4318
7672
|
this.indent += 1;
|
|
@@ -4336,10 +7690,10 @@ class Doc {
|
|
|
4336
7690
|
}
|
|
4337
7691
|
compile() {
|
|
4338
7692
|
const F = Function;
|
|
4339
|
-
const
|
|
7693
|
+
const args2 = this?.args;
|
|
4340
7694
|
const content = this?.content ?? [``];
|
|
4341
7695
|
const lines = [...content.map((x) => ` ${x}`)];
|
|
4342
|
-
return new F(...
|
|
7696
|
+
return new F(...args2, lines.join(`
|
|
4343
7697
|
`));
|
|
4344
7698
|
}
|
|
4345
7699
|
}
|
|
@@ -4644,11 +7998,11 @@ var $ZodCIDRv6 = /* @__PURE__ */ $constructor("$ZodCIDRv6", (inst, def) => {
|
|
|
4644
7998
|
def.pattern ?? (def.pattern = cidrv6);
|
|
4645
7999
|
$ZodStringFormat.init(inst, def);
|
|
4646
8000
|
inst._zod.check = (payload) => {
|
|
4647
|
-
const
|
|
8001
|
+
const parts2 = payload.value.split("/");
|
|
4648
8002
|
try {
|
|
4649
|
-
if (
|
|
8003
|
+
if (parts2.length !== 2)
|
|
4650
8004
|
throw new Error;
|
|
4651
|
-
const [address, prefix] =
|
|
8005
|
+
const [address, prefix] = parts2;
|
|
4652
8006
|
if (!prefix)
|
|
4653
8007
|
throw new Error;
|
|
4654
8008
|
const prefixNum = Number(prefix);
|
|
@@ -4975,16 +8329,16 @@ var $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
|
|
|
4975
8329
|
}
|
|
4976
8330
|
payload.value = Array(input.length);
|
|
4977
8331
|
const proms = [];
|
|
4978
|
-
for (let
|
|
4979
|
-
const item = input[
|
|
8332
|
+
for (let i2 = 0;i2 < input.length; i2++) {
|
|
8333
|
+
const item = input[i2];
|
|
4980
8334
|
const result = def.element._zod.run({
|
|
4981
8335
|
value: item,
|
|
4982
8336
|
issues: []
|
|
4983
8337
|
}, ctx);
|
|
4984
8338
|
if (result instanceof Promise) {
|
|
4985
|
-
proms.push(result.then((result2) => handleArrayResult(result2, payload,
|
|
8339
|
+
proms.push(result.then((result2) => handleArrayResult(result2, payload, i2)));
|
|
4986
8340
|
} else {
|
|
4987
|
-
handleArrayResult(result, payload,
|
|
8341
|
+
handleArrayResult(result, payload, i2);
|
|
4988
8342
|
}
|
|
4989
8343
|
}
|
|
4990
8344
|
if (proms.length) {
|
|
@@ -5415,35 +8769,35 @@ var $ZodTuple = /* @__PURE__ */ $constructor("$ZodTuple", (inst, def) => {
|
|
|
5415
8769
|
return payload;
|
|
5416
8770
|
}
|
|
5417
8771
|
}
|
|
5418
|
-
let
|
|
8772
|
+
let i2 = -1;
|
|
5419
8773
|
for (const item of items) {
|
|
5420
|
-
|
|
5421
|
-
if (
|
|
5422
|
-
if (
|
|
8774
|
+
i2++;
|
|
8775
|
+
if (i2 >= input.length) {
|
|
8776
|
+
if (i2 >= optStart)
|
|
5423
8777
|
continue;
|
|
5424
8778
|
}
|
|
5425
8779
|
const result = item._zod.run({
|
|
5426
|
-
value: input[
|
|
8780
|
+
value: input[i2],
|
|
5427
8781
|
issues: []
|
|
5428
8782
|
}, ctx);
|
|
5429
8783
|
if (result instanceof Promise) {
|
|
5430
|
-
proms.push(result.then((result2) => handleTupleResult(result2, payload,
|
|
8784
|
+
proms.push(result.then((result2) => handleTupleResult(result2, payload, i2)));
|
|
5431
8785
|
} else {
|
|
5432
|
-
handleTupleResult(result, payload,
|
|
8786
|
+
handleTupleResult(result, payload, i2);
|
|
5433
8787
|
}
|
|
5434
8788
|
}
|
|
5435
8789
|
if (def.rest) {
|
|
5436
8790
|
const rest = input.slice(items.length);
|
|
5437
8791
|
for (const el of rest) {
|
|
5438
|
-
|
|
8792
|
+
i2++;
|
|
5439
8793
|
const result = def.rest._zod.run({
|
|
5440
8794
|
value: el,
|
|
5441
8795
|
issues: []
|
|
5442
8796
|
}, ctx);
|
|
5443
8797
|
if (result instanceof Promise) {
|
|
5444
|
-
proms.push(result.then((result2) => handleTupleResult(result2, payload,
|
|
8798
|
+
proms.push(result.then((result2) => handleTupleResult(result2, payload, i2)));
|
|
5445
8799
|
} else {
|
|
5446
|
-
handleTupleResult(result, payload,
|
|
8800
|
+
handleTupleResult(result, payload, i2);
|
|
5447
8801
|
}
|
|
5448
8802
|
}
|
|
5449
8803
|
}
|
|
@@ -6015,9 +9369,9 @@ var $ZodTemplateLiteral = /* @__PURE__ */ $constructor("$ZodTemplateLiteral", (i
|
|
|
6015
9369
|
const source = part._zod.pattern instanceof RegExp ? part._zod.pattern.source : part._zod.pattern;
|
|
6016
9370
|
if (!source)
|
|
6017
9371
|
throw new Error(`Invalid template literal part: ${part._zod.traits}`);
|
|
6018
|
-
const
|
|
9372
|
+
const start2 = source.startsWith("^") ? 1 : 0;
|
|
6019
9373
|
const end = source.endsWith("$") ? source.length - 1 : source.length;
|
|
6020
|
-
regexParts.push(source.slice(
|
|
9374
|
+
regexParts.push(source.slice(start2, end));
|
|
6021
9375
|
} else if (part === null || primitiveTypes.has(typeof part)) {
|
|
6022
9376
|
regexParts.push(escapeRegex(`${part}`));
|
|
6023
9377
|
} else {
|
|
@@ -6053,26 +9407,26 @@ var $ZodFunction = /* @__PURE__ */ $constructor("$ZodFunction", (inst, def) => {
|
|
|
6053
9407
|
$ZodType.init(inst, def);
|
|
6054
9408
|
inst._def = def;
|
|
6055
9409
|
inst._zod.def = def;
|
|
6056
|
-
inst.implement = (
|
|
6057
|
-
if (typeof
|
|
9410
|
+
inst.implement = (func2) => {
|
|
9411
|
+
if (typeof func2 !== "function") {
|
|
6058
9412
|
throw new Error("implement() must be called with a function");
|
|
6059
9413
|
}
|
|
6060
|
-
return function(...
|
|
6061
|
-
const parsedArgs = inst._def.input ? parse(inst._def.input,
|
|
6062
|
-
const result = Reflect.apply(
|
|
9414
|
+
return function(...args2) {
|
|
9415
|
+
const parsedArgs = inst._def.input ? parse(inst._def.input, args2) : args2;
|
|
9416
|
+
const result = Reflect.apply(func2, this, parsedArgs);
|
|
6063
9417
|
if (inst._def.output) {
|
|
6064
9418
|
return parse(inst._def.output, result);
|
|
6065
9419
|
}
|
|
6066
9420
|
return result;
|
|
6067
9421
|
};
|
|
6068
9422
|
};
|
|
6069
|
-
inst.implementAsync = (
|
|
6070
|
-
if (typeof
|
|
9423
|
+
inst.implementAsync = (func2) => {
|
|
9424
|
+
if (typeof func2 !== "function") {
|
|
6071
9425
|
throw new Error("implementAsync() must be called with a function");
|
|
6072
9426
|
}
|
|
6073
|
-
return async function(...
|
|
6074
|
-
const parsedArgs = inst._def.input ? await parseAsync(inst._def.input,
|
|
6075
|
-
const result = await Reflect.apply(
|
|
9427
|
+
return async function(...args2) {
|
|
9428
|
+
const parsedArgs = inst._def.input ? await parseAsync(inst._def.input, args2) : args2;
|
|
9429
|
+
const result = await Reflect.apply(func2, this, parsedArgs);
|
|
6076
9430
|
if (inst._def.output) {
|
|
6077
9431
|
return await parseAsync(inst._def.output, result);
|
|
6078
9432
|
}
|
|
@@ -6097,22 +9451,22 @@ var $ZodFunction = /* @__PURE__ */ $constructor("$ZodFunction", (inst, def) => {
|
|
|
6097
9451
|
}
|
|
6098
9452
|
return payload;
|
|
6099
9453
|
};
|
|
6100
|
-
inst.input = (...
|
|
9454
|
+
inst.input = (...args2) => {
|
|
6101
9455
|
const F = inst.constructor;
|
|
6102
|
-
if (Array.isArray(
|
|
9456
|
+
if (Array.isArray(args2[0])) {
|
|
6103
9457
|
return new F({
|
|
6104
9458
|
type: "function",
|
|
6105
9459
|
input: new $ZodTuple({
|
|
6106
9460
|
type: "tuple",
|
|
6107
|
-
items:
|
|
6108
|
-
rest:
|
|
9461
|
+
items: args2[0],
|
|
9462
|
+
rest: args2[1]
|
|
6109
9463
|
}),
|
|
6110
9464
|
output: inst._def.output
|
|
6111
9465
|
});
|
|
6112
9466
|
}
|
|
6113
9467
|
return new F({
|
|
6114
9468
|
type: "function",
|
|
6115
|
-
input:
|
|
9469
|
+
input: args2[0],
|
|
6116
9470
|
output: inst._def.output
|
|
6117
9471
|
});
|
|
6118
9472
|
};
|
|
@@ -12440,11 +15794,11 @@ function _catch(Class2, innerType, catchValue) {
|
|
|
12440
15794
|
catchValue: typeof catchValue === "function" ? catchValue : () => catchValue
|
|
12441
15795
|
});
|
|
12442
15796
|
}
|
|
12443
|
-
function _pipe(Class2, in_,
|
|
15797
|
+
function _pipe(Class2, in_, out2) {
|
|
12444
15798
|
return new Class2({
|
|
12445
15799
|
type: "pipe",
|
|
12446
15800
|
in: in_,
|
|
12447
|
-
out
|
|
15801
|
+
out: out2
|
|
12448
15802
|
});
|
|
12449
15803
|
}
|
|
12450
15804
|
function _readonly(Class2, innerType) {
|
|
@@ -12453,10 +15807,10 @@ function _readonly(Class2, innerType) {
|
|
|
12453
15807
|
innerType
|
|
12454
15808
|
});
|
|
12455
15809
|
}
|
|
12456
|
-
function _templateLiteral(Class2,
|
|
15810
|
+
function _templateLiteral(Class2, parts2, params) {
|
|
12457
15811
|
return new Class2({
|
|
12458
15812
|
type: "template_literal",
|
|
12459
|
-
parts,
|
|
15813
|
+
parts: parts2,
|
|
12460
15814
|
...normalizeParams(params)
|
|
12461
15815
|
});
|
|
12462
15816
|
}
|
|
@@ -12813,9 +16167,9 @@ class JSONSchemaGenerator {
|
|
|
12813
16167
|
}
|
|
12814
16168
|
case "union": {
|
|
12815
16169
|
const json = _json;
|
|
12816
|
-
const options = def.options.map((x,
|
|
16170
|
+
const options = def.options.map((x, i2) => this.process(x, {
|
|
12817
16171
|
...params,
|
|
12818
|
-
path: [...params.path, "anyOf",
|
|
16172
|
+
path: [...params.path, "anyOf", i2]
|
|
12819
16173
|
}));
|
|
12820
16174
|
json.anyOf = options;
|
|
12821
16175
|
break;
|
|
@@ -12843,9 +16197,9 @@ class JSONSchemaGenerator {
|
|
|
12843
16197
|
json.type = "array";
|
|
12844
16198
|
const prefixPath = this.target === "draft-2020-12" ? "prefixItems" : "items";
|
|
12845
16199
|
const restPath = this.target === "draft-2020-12" ? "items" : this.target === "openapi-3.0" ? "items" : "additionalItems";
|
|
12846
|
-
const prefixItems = def.items.map((x,
|
|
16200
|
+
const prefixItems = def.items.map((x, i2) => this.process(x, {
|
|
12847
16201
|
...params,
|
|
12848
|
-
path: [...params.path, prefixPath,
|
|
16202
|
+
path: [...params.path, prefixPath, i2]
|
|
12849
16203
|
}));
|
|
12850
16204
|
const rest = def.rest ? this.process(def.rest, {
|
|
12851
16205
|
...params,
|
|
@@ -13543,12 +16897,12 @@ var ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
|
|
|
13543
16897
|
},
|
|
13544
16898
|
configurable: true
|
|
13545
16899
|
});
|
|
13546
|
-
inst.meta = (...
|
|
13547
|
-
if (
|
|
16900
|
+
inst.meta = (...args2) => {
|
|
16901
|
+
if (args2.length === 0) {
|
|
13548
16902
|
return globalRegistry.get(inst);
|
|
13549
16903
|
}
|
|
13550
16904
|
const cl = inst.clone();
|
|
13551
|
-
globalRegistry.add(cl,
|
|
16905
|
+
globalRegistry.add(cl, args2[0]);
|
|
13552
16906
|
return cl;
|
|
13553
16907
|
};
|
|
13554
16908
|
inst.isOptional = () => inst.safeParse(undefined).success;
|
|
@@ -13562,18 +16916,18 @@ var _ZodString = /* @__PURE__ */ $constructor("_ZodString", (inst, def) => {
|
|
|
13562
16916
|
inst.format = bag.format ?? null;
|
|
13563
16917
|
inst.minLength = bag.minimum ?? null;
|
|
13564
16918
|
inst.maxLength = bag.maximum ?? null;
|
|
13565
|
-
inst.regex = (...
|
|
13566
|
-
inst.includes = (...
|
|
13567
|
-
inst.startsWith = (...
|
|
13568
|
-
inst.endsWith = (...
|
|
13569
|
-
inst.min = (...
|
|
13570
|
-
inst.max = (...
|
|
13571
|
-
inst.length = (...
|
|
13572
|
-
inst.nonempty = (...
|
|
16919
|
+
inst.regex = (...args2) => inst.check(_regex(...args2));
|
|
16920
|
+
inst.includes = (...args2) => inst.check(_includes(...args2));
|
|
16921
|
+
inst.startsWith = (...args2) => inst.check(_startsWith(...args2));
|
|
16922
|
+
inst.endsWith = (...args2) => inst.check(_endsWith(...args2));
|
|
16923
|
+
inst.min = (...args2) => inst.check(_minLength(...args2));
|
|
16924
|
+
inst.max = (...args2) => inst.check(_maxLength(...args2));
|
|
16925
|
+
inst.length = (...args2) => inst.check(_length(...args2));
|
|
16926
|
+
inst.nonempty = (...args2) => inst.check(_minLength(1, ...args2));
|
|
13573
16927
|
inst.lowercase = (params) => inst.check(_lowercase(params));
|
|
13574
16928
|
inst.uppercase = (params) => inst.check(_uppercase(params));
|
|
13575
16929
|
inst.trim = () => inst.check(_trim());
|
|
13576
|
-
inst.normalize = (...
|
|
16930
|
+
inst.normalize = (...args2) => inst.check(_normalize(...args2));
|
|
13577
16931
|
inst.toLowerCase = () => inst.check(_toLowerCase());
|
|
13578
16932
|
inst.toUpperCase = () => inst.check(_toUpperCase());
|
|
13579
16933
|
});
|
|
@@ -13970,8 +17324,8 @@ var ZodObject = /* @__PURE__ */ $constructor("ZodObject", (inst, def) => {
|
|
|
13970
17324
|
inst.merge = (other) => exports_util.merge(inst, other);
|
|
13971
17325
|
inst.pick = (mask) => exports_util.pick(inst, mask);
|
|
13972
17326
|
inst.omit = (mask) => exports_util.omit(inst, mask);
|
|
13973
|
-
inst.partial = (...
|
|
13974
|
-
inst.required = (...
|
|
17327
|
+
inst.partial = (...args2) => exports_util.partial(ZodOptional, inst, args2[0]);
|
|
17328
|
+
inst.required = (...args2) => exports_util.required(ZodNonOptional, inst, args2[0]);
|
|
13975
17329
|
});
|
|
13976
17330
|
function object(shape, params) {
|
|
13977
17331
|
const def = {
|
|
@@ -14101,10 +17455,10 @@ function map(keyType, valueType, params) {
|
|
|
14101
17455
|
var ZodSet = /* @__PURE__ */ $constructor("ZodSet", (inst, def) => {
|
|
14102
17456
|
$ZodSet.init(inst, def);
|
|
14103
17457
|
ZodType.init(inst, def);
|
|
14104
|
-
inst.min = (...
|
|
17458
|
+
inst.min = (...args2) => inst.check(_minSize(...args2));
|
|
14105
17459
|
inst.nonempty = (params) => inst.check(_minSize(1, params));
|
|
14106
|
-
inst.max = (...
|
|
14107
|
-
inst.size = (...
|
|
17460
|
+
inst.max = (...args2) => inst.check(_maxSize(...args2));
|
|
17461
|
+
inst.size = (...args2) => inst.check(_size(...args2));
|
|
14108
17462
|
});
|
|
14109
17463
|
function set(valueType, params) {
|
|
14110
17464
|
return new ZodSet({
|
|
@@ -14335,22 +17689,22 @@ var ZodPipe = /* @__PURE__ */ $constructor("ZodPipe", (inst, def) => {
|
|
|
14335
17689
|
inst.in = def.in;
|
|
14336
17690
|
inst.out = def.out;
|
|
14337
17691
|
});
|
|
14338
|
-
function pipe(in_,
|
|
17692
|
+
function pipe(in_, out2) {
|
|
14339
17693
|
return new ZodPipe({
|
|
14340
17694
|
type: "pipe",
|
|
14341
17695
|
in: in_,
|
|
14342
|
-
out
|
|
17696
|
+
out: out2
|
|
14343
17697
|
});
|
|
14344
17698
|
}
|
|
14345
17699
|
var ZodCodec = /* @__PURE__ */ $constructor("ZodCodec", (inst, def) => {
|
|
14346
17700
|
ZodPipe.init(inst, def);
|
|
14347
17701
|
$ZodCodec.init(inst, def);
|
|
14348
17702
|
});
|
|
14349
|
-
function codec(in_,
|
|
17703
|
+
function codec(in_, out2, params) {
|
|
14350
17704
|
return new ZodCodec({
|
|
14351
17705
|
type: "pipe",
|
|
14352
17706
|
in: in_,
|
|
14353
|
-
out,
|
|
17707
|
+
out: out2,
|
|
14354
17708
|
transform: params.decode,
|
|
14355
17709
|
reverseTransform: params.encode
|
|
14356
17710
|
});
|
|
@@ -14370,10 +17724,10 @@ var ZodTemplateLiteral = /* @__PURE__ */ $constructor("ZodTemplateLiteral", (ins
|
|
|
14370
17724
|
$ZodTemplateLiteral.init(inst, def);
|
|
14371
17725
|
ZodType.init(inst, def);
|
|
14372
17726
|
});
|
|
14373
|
-
function templateLiteral(
|
|
17727
|
+
function templateLiteral(parts2, params) {
|
|
14374
17728
|
return new ZodTemplateLiteral({
|
|
14375
17729
|
type: "template_literal",
|
|
14376
|
-
parts,
|
|
17730
|
+
parts: parts2,
|
|
14377
17731
|
...exports_util.normalizeParams(params)
|
|
14378
17732
|
});
|
|
14379
17733
|
}
|
|
@@ -14443,11 +17797,11 @@ function _instanceof(cls, params = {
|
|
|
14443
17797
|
inst._zod.bag.Class = cls;
|
|
14444
17798
|
return inst;
|
|
14445
17799
|
}
|
|
14446
|
-
var stringbool = (...
|
|
17800
|
+
var stringbool = (...args2) => _stringbool({
|
|
14447
17801
|
Codec: ZodCodec,
|
|
14448
17802
|
Boolean: ZodBoolean,
|
|
14449
17803
|
String: ZodString
|
|
14450
|
-
}, ...
|
|
17804
|
+
}, ...args2);
|
|
14451
17805
|
function json(params) {
|
|
14452
17806
|
const jsonSchema = lazy(() => {
|
|
14453
17807
|
return union([string2(params), number2(), boolean2(), _null3(), array(jsonSchema), record(string2(), jsonSchema)]);
|
|
@@ -14522,10 +17876,10 @@ var lsp_hover = tool({
|
|
|
14522
17876
|
line: tool.schema.number().min(1).describe("Line number (1-based)"),
|
|
14523
17877
|
character: tool.schema.number().min(0).describe("Character position (0-based)")
|
|
14524
17878
|
},
|
|
14525
|
-
execute: async (
|
|
17879
|
+
execute: async (args2, context) => {
|
|
14526
17880
|
try {
|
|
14527
|
-
const result = await withLspClient(
|
|
14528
|
-
return await client.hover(
|
|
17881
|
+
const result = await withLspClient(args2.filePath, async (client) => {
|
|
17882
|
+
return await client.hover(args2.filePath, args2.line, args2.character);
|
|
14529
17883
|
});
|
|
14530
17884
|
const output = formatHoverResult(result);
|
|
14531
17885
|
return output;
|
|
@@ -14542,10 +17896,10 @@ var lsp_goto_definition = tool({
|
|
|
14542
17896
|
line: tool.schema.number().min(1).describe("Line number (1-based)"),
|
|
14543
17897
|
character: tool.schema.number().min(0).describe("Character position (0-based)")
|
|
14544
17898
|
},
|
|
14545
|
-
execute: async (
|
|
17899
|
+
execute: async (args2, context) => {
|
|
14546
17900
|
try {
|
|
14547
|
-
const result = await withLspClient(
|
|
14548
|
-
return await client.definition(
|
|
17901
|
+
const result = await withLspClient(args2.filePath, async (client) => {
|
|
17902
|
+
return await client.definition(args2.filePath, args2.line, args2.character);
|
|
14549
17903
|
});
|
|
14550
17904
|
if (!result) {
|
|
14551
17905
|
const output2 = "No definition found";
|
|
@@ -14573,10 +17927,10 @@ var lsp_find_references = tool({
|
|
|
14573
17927
|
character: tool.schema.number().min(0).describe("Character position (0-based)"),
|
|
14574
17928
|
includeDeclaration: tool.schema.boolean().optional().describe("Include the declaration itself")
|
|
14575
17929
|
},
|
|
14576
|
-
execute: async (
|
|
17930
|
+
execute: async (args2, context) => {
|
|
14577
17931
|
try {
|
|
14578
|
-
const result = await withLspClient(
|
|
14579
|
-
return await client.references(
|
|
17932
|
+
const result = await withLspClient(args2.filePath, async (client) => {
|
|
17933
|
+
return await client.references(args2.filePath, args2.line, args2.character, args2.includeDeclaration ?? true);
|
|
14580
17934
|
});
|
|
14581
17935
|
if (!result || result.length === 0) {
|
|
14582
17936
|
const output2 = "No references found";
|
|
@@ -14596,10 +17950,10 @@ var lsp_document_symbols = tool({
|
|
|
14596
17950
|
args: {
|
|
14597
17951
|
filePath: tool.schema.string().describe("The absolute path to the file")
|
|
14598
17952
|
},
|
|
14599
|
-
execute: async (
|
|
17953
|
+
execute: async (args2, context) => {
|
|
14600
17954
|
try {
|
|
14601
|
-
const result = await withLspClient(
|
|
14602
|
-
return await client.documentSymbols(
|
|
17955
|
+
const result = await withLspClient(args2.filePath, async (client) => {
|
|
17956
|
+
return await client.documentSymbols(args2.filePath);
|
|
14603
17957
|
});
|
|
14604
17958
|
if (!result || result.length === 0) {
|
|
14605
17959
|
const output2 = "No symbols found";
|
|
@@ -14627,16 +17981,16 @@ var lsp_workspace_symbols = tool({
|
|
|
14627
17981
|
query: tool.schema.string().describe("The symbol name to search for (supports fuzzy matching)"),
|
|
14628
17982
|
limit: tool.schema.number().optional().describe("Maximum number of results to return")
|
|
14629
17983
|
},
|
|
14630
|
-
execute: async (
|
|
17984
|
+
execute: async (args2, context) => {
|
|
14631
17985
|
try {
|
|
14632
|
-
const result = await withLspClient(
|
|
14633
|
-
return await client.workspaceSymbols(
|
|
17986
|
+
const result = await withLspClient(args2.filePath, async (client) => {
|
|
17987
|
+
return await client.workspaceSymbols(args2.query);
|
|
14634
17988
|
});
|
|
14635
17989
|
if (!result || result.length === 0) {
|
|
14636
17990
|
const output2 = "No symbols found";
|
|
14637
17991
|
return output2;
|
|
14638
17992
|
}
|
|
14639
|
-
const limited =
|
|
17993
|
+
const limited = args2.limit ? result.slice(0, args2.limit) : result;
|
|
14640
17994
|
const output = limited.map(formatSymbolInfo).join(`
|
|
14641
17995
|
`);
|
|
14642
17996
|
return output;
|
|
@@ -14652,10 +18006,10 @@ var lsp_diagnostics = tool({
|
|
|
14652
18006
|
filePath: tool.schema.string().describe("The absolute path to the file"),
|
|
14653
18007
|
severity: tool.schema.enum(["error", "warning", "information", "hint", "all"]).optional().describe("Filter by severity level")
|
|
14654
18008
|
},
|
|
14655
|
-
execute: async (
|
|
18009
|
+
execute: async (args2, context) => {
|
|
14656
18010
|
try {
|
|
14657
|
-
const result = await withLspClient(
|
|
14658
|
-
return await client.diagnostics(
|
|
18011
|
+
const result = await withLspClient(args2.filePath, async (client) => {
|
|
18012
|
+
return await client.diagnostics(args2.filePath);
|
|
14659
18013
|
});
|
|
14660
18014
|
let diagnostics = [];
|
|
14661
18015
|
if (result) {
|
|
@@ -14665,7 +18019,7 @@ var lsp_diagnostics = tool({
|
|
|
14665
18019
|
diagnostics = result.items;
|
|
14666
18020
|
}
|
|
14667
18021
|
}
|
|
14668
|
-
diagnostics = filterDiagnosticsBySeverity(diagnostics,
|
|
18022
|
+
diagnostics = filterDiagnosticsBySeverity(diagnostics, args2.severity);
|
|
14669
18023
|
if (diagnostics.length === 0) {
|
|
14670
18024
|
const output2 = "No diagnostics found";
|
|
14671
18025
|
return output2;
|
|
@@ -14708,10 +18062,10 @@ var lsp_prepare_rename = tool({
|
|
|
14708
18062
|
line: tool.schema.number().min(1).describe("Line number (1-based)"),
|
|
14709
18063
|
character: tool.schema.number().min(0).describe("Character position (0-based)")
|
|
14710
18064
|
},
|
|
14711
|
-
execute: async (
|
|
18065
|
+
execute: async (args2, context) => {
|
|
14712
18066
|
try {
|
|
14713
|
-
const result = await withLspClient(
|
|
14714
|
-
return await client.prepareRename(
|
|
18067
|
+
const result = await withLspClient(args2.filePath, async (client) => {
|
|
18068
|
+
return await client.prepareRename(args2.filePath, args2.line, args2.character);
|
|
14715
18069
|
});
|
|
14716
18070
|
const output = formatPrepareRenameResult(result);
|
|
14717
18071
|
return output;
|
|
@@ -14729,10 +18083,10 @@ var lsp_rename = tool({
|
|
|
14729
18083
|
character: tool.schema.number().min(0).describe("Character position (0-based)"),
|
|
14730
18084
|
newName: tool.schema.string().describe("The new name for the symbol")
|
|
14731
18085
|
},
|
|
14732
|
-
execute: async (
|
|
18086
|
+
execute: async (args2, context) => {
|
|
14733
18087
|
try {
|
|
14734
|
-
const edit = await withLspClient(
|
|
14735
|
-
return await client.rename(
|
|
18088
|
+
const edit = await withLspClient(args2.filePath, async (client) => {
|
|
18089
|
+
return await client.rename(args2.filePath, args2.line, args2.character, args2.newName);
|
|
14736
18090
|
});
|
|
14737
18091
|
const result = applyWorkspaceEdit(edit);
|
|
14738
18092
|
const output = formatApplyResult(result);
|
|
@@ -14762,11 +18116,11 @@ var lsp_code_actions = tool({
|
|
|
14762
18116
|
"source.fixAll"
|
|
14763
18117
|
]).optional().describe("Filter by code action kind")
|
|
14764
18118
|
},
|
|
14765
|
-
execute: async (
|
|
18119
|
+
execute: async (args2, context) => {
|
|
14766
18120
|
try {
|
|
14767
|
-
const only =
|
|
14768
|
-
const result = await withLspClient(
|
|
14769
|
-
return await client.codeAction(
|
|
18121
|
+
const only = args2.kind ? [args2.kind] : undefined;
|
|
18122
|
+
const result = await withLspClient(args2.filePath, async (client) => {
|
|
18123
|
+
return await client.codeAction(args2.filePath, args2.startLine, args2.startCharacter, args2.endLine, args2.endCharacter, only);
|
|
14770
18124
|
});
|
|
14771
18125
|
const output = formatCodeActions(result);
|
|
14772
18126
|
return output;
|
|
@@ -14782,10 +18136,10 @@ var lsp_code_action_resolve = tool({
|
|
|
14782
18136
|
filePath: tool.schema.string().describe("The absolute path to a file in the workspace (used to find the LSP server)"),
|
|
14783
18137
|
codeAction: tool.schema.string().describe("The code action JSON object as returned by lsp_code_actions (stringified)")
|
|
14784
18138
|
},
|
|
14785
|
-
execute: async (
|
|
18139
|
+
execute: async (args2, context) => {
|
|
14786
18140
|
try {
|
|
14787
|
-
const codeAction = JSON.parse(
|
|
14788
|
-
const resolved = await withLspClient(
|
|
18141
|
+
const codeAction = JSON.parse(args2.codeAction);
|
|
18142
|
+
const resolved = await withLspClient(args2.filePath, async (client) => {
|
|
14789
18143
|
return await client.codeActionResolve(codeAction);
|
|
14790
18144
|
});
|
|
14791
18145
|
if (!resolved) {
|
|
@@ -14917,24 +18271,24 @@ var LANG_EXTENSIONS = {
|
|
|
14917
18271
|
// src/tools/ast-grep/cli.ts
|
|
14918
18272
|
var {spawn: spawn2 } = globalThis.Bun;
|
|
14919
18273
|
async function runSg(options) {
|
|
14920
|
-
const
|
|
18274
|
+
const args2 = ["run", "-p", options.pattern, "--lang", options.lang, "--json=compact"];
|
|
14921
18275
|
if (options.rewrite) {
|
|
14922
|
-
|
|
18276
|
+
args2.push("-r", options.rewrite);
|
|
14923
18277
|
if (options.updateAll) {
|
|
14924
|
-
|
|
18278
|
+
args2.push("--update-all");
|
|
14925
18279
|
}
|
|
14926
18280
|
}
|
|
14927
18281
|
if (options.context && options.context > 0) {
|
|
14928
|
-
|
|
18282
|
+
args2.push("-C", String(options.context));
|
|
14929
18283
|
}
|
|
14930
18284
|
if (options.globs) {
|
|
14931
18285
|
for (const glob of options.globs) {
|
|
14932
|
-
|
|
18286
|
+
args2.push("--globs", glob);
|
|
14933
18287
|
}
|
|
14934
18288
|
}
|
|
14935
18289
|
const paths = options.paths && options.paths.length > 0 ? options.paths : ["."];
|
|
14936
|
-
|
|
14937
|
-
const proc = spawn2([SG_CLI_PATH, ...
|
|
18290
|
+
args2.push(...paths);
|
|
18291
|
+
const proc = spawn2([SG_CLI_PATH, ...args2], {
|
|
14938
18292
|
stdout: "pipe",
|
|
14939
18293
|
stderr: "pipe"
|
|
14940
18294
|
});
|
|
@@ -14989,11 +18343,11 @@ function extractMetaVariablesFromPattern(pattern) {
|
|
|
14989
18343
|
function extractMetaVariables(node, pattern) {
|
|
14990
18344
|
const varNames = extractMetaVariablesFromPattern(pattern);
|
|
14991
18345
|
const result = [];
|
|
14992
|
-
for (const
|
|
14993
|
-
const match = node.getMatch(
|
|
18346
|
+
for (const name2 of varNames) {
|
|
18347
|
+
const match = node.getMatch(name2);
|
|
14994
18348
|
if (match) {
|
|
14995
18349
|
result.push({
|
|
14996
|
-
name,
|
|
18350
|
+
name: name2,
|
|
14997
18351
|
text: match.text(),
|
|
14998
18352
|
kind: String(match.kind())
|
|
14999
18353
|
});
|
|
@@ -15117,14 +18471,14 @@ var ast_grep_search = tool({
|
|
|
15117
18471
|
globs: tool.schema.array(tool.schema.string()).optional().describe("Include/exclude globs (prefix ! to exclude)"),
|
|
15118
18472
|
context: tool.schema.number().optional().describe("Context lines around match")
|
|
15119
18473
|
},
|
|
15120
|
-
execute: async (
|
|
18474
|
+
execute: async (args2, context) => {
|
|
15121
18475
|
try {
|
|
15122
18476
|
const matches = await runSg({
|
|
15123
|
-
pattern:
|
|
15124
|
-
lang:
|
|
15125
|
-
paths:
|
|
15126
|
-
globs:
|
|
15127
|
-
context:
|
|
18477
|
+
pattern: args2.pattern,
|
|
18478
|
+
lang: args2.lang,
|
|
18479
|
+
paths: args2.paths,
|
|
18480
|
+
globs: args2.globs,
|
|
18481
|
+
context: args2.context
|
|
15128
18482
|
});
|
|
15129
18483
|
const output = formatSearchResult(matches);
|
|
15130
18484
|
showOutputToUser(context, output);
|
|
@@ -15146,17 +18500,17 @@ var ast_grep_replace = tool({
|
|
|
15146
18500
|
globs: tool.schema.array(tool.schema.string()).optional().describe("Include/exclude globs"),
|
|
15147
18501
|
dryRun: tool.schema.boolean().optional().describe("Preview changes without applying (default: true)")
|
|
15148
18502
|
},
|
|
15149
|
-
execute: async (
|
|
18503
|
+
execute: async (args2, context) => {
|
|
15150
18504
|
try {
|
|
15151
18505
|
const matches = await runSg({
|
|
15152
|
-
pattern:
|
|
15153
|
-
rewrite:
|
|
15154
|
-
lang:
|
|
15155
|
-
paths:
|
|
15156
|
-
globs:
|
|
15157
|
-
updateAll:
|
|
18506
|
+
pattern: args2.pattern,
|
|
18507
|
+
rewrite: args2.rewrite,
|
|
18508
|
+
lang: args2.lang,
|
|
18509
|
+
paths: args2.paths,
|
|
18510
|
+
globs: args2.globs,
|
|
18511
|
+
updateAll: args2.dryRun === false
|
|
15158
18512
|
});
|
|
15159
|
-
const output = formatReplaceResult(matches,
|
|
18513
|
+
const output = formatReplaceResult(matches, args2.dryRun !== false);
|
|
15160
18514
|
showOutputToUser(context, output);
|
|
15161
18515
|
return output;
|
|
15162
18516
|
} catch (e) {
|
|
@@ -15191,17 +18545,17 @@ var ast_grep_analyze = tool({
|
|
|
15191
18545
|
pattern: tool.schema.string().optional().describe("Pattern to find (omit for root structure)"),
|
|
15192
18546
|
extractMetaVars: tool.schema.boolean().optional().describe("Extract meta-variable bindings (default: true)")
|
|
15193
18547
|
},
|
|
15194
|
-
execute: async (
|
|
18548
|
+
execute: async (args2, context) => {
|
|
15195
18549
|
try {
|
|
15196
|
-
if (!
|
|
15197
|
-
const
|
|
15198
|
-
const output2 = `Root kind: ${
|
|
15199
|
-
Children: ${
|
|
18550
|
+
if (!args2.pattern) {
|
|
18551
|
+
const info2 = getRootInfo(args2.code, args2.lang);
|
|
18552
|
+
const output2 = `Root kind: ${info2.kind}
|
|
18553
|
+
Children: ${info2.childCount}`;
|
|
15200
18554
|
showOutputToUser(context, output2);
|
|
15201
18555
|
return output2;
|
|
15202
18556
|
}
|
|
15203
|
-
const results = analyzeCode(
|
|
15204
|
-
const output = formatAnalyzeResult(results,
|
|
18557
|
+
const results = analyzeCode(args2.code, args2.lang, args2.pattern, args2.extractMetaVars !== false);
|
|
18558
|
+
const output = formatAnalyzeResult(results, args2.extractMetaVars !== false);
|
|
15205
18559
|
showOutputToUser(context, output);
|
|
15206
18560
|
return output;
|
|
15207
18561
|
} catch (e) {
|
|
@@ -15219,10 +18573,10 @@ var ast_grep_transform = tool({
|
|
|
15219
18573
|
pattern: tool.schema.string().describe("Pattern to match"),
|
|
15220
18574
|
rewrite: tool.schema.string().describe("Replacement (can use $VAR from pattern)")
|
|
15221
18575
|
},
|
|
15222
|
-
execute: async (
|
|
18576
|
+
execute: async (args2, context) => {
|
|
15223
18577
|
try {
|
|
15224
|
-
const { transformed, editCount } = transformCode(
|
|
15225
|
-
const output = formatTransformResult(
|
|
18578
|
+
const { transformed, editCount } = transformCode(args2.code, args2.lang, args2.pattern, args2.rewrite);
|
|
18579
|
+
const output = formatTransformResult(args2.code, transformed, editCount);
|
|
15226
18580
|
showOutputToUser(context, output);
|
|
15227
18581
|
return output;
|
|
15228
18582
|
} catch (e) {
|
|
@@ -15241,11 +18595,11 @@ import { existsSync as existsSync4 } from "fs";
|
|
|
15241
18595
|
import { join as join3, dirname as dirname2 } from "path";
|
|
15242
18596
|
import { spawnSync } from "child_process";
|
|
15243
18597
|
var cachedCli = null;
|
|
15244
|
-
function findExecutable(
|
|
18598
|
+
function findExecutable(name2) {
|
|
15245
18599
|
const isWindows = process.platform === "win32";
|
|
15246
18600
|
const cmd = isWindows ? "where" : "which";
|
|
15247
18601
|
try {
|
|
15248
|
-
const result = spawnSync(cmd, [
|
|
18602
|
+
const result = spawnSync(cmd, [name2], { encoding: "utf-8", timeout: 5000 });
|
|
15249
18603
|
if (result.status === 0 && result.stdout.trim()) {
|
|
15250
18604
|
return result.stdout.trim().split(`
|
|
15251
18605
|
`)[0];
|
|
@@ -15309,7 +18663,7 @@ var GREP_SAFETY_FLAGS = ["-n", "-H", "--color=never"];
|
|
|
15309
18663
|
|
|
15310
18664
|
// src/tools/safe-grep/cli.ts
|
|
15311
18665
|
function buildRgArgs(options) {
|
|
15312
|
-
const
|
|
18666
|
+
const args2 = [
|
|
15313
18667
|
...RG_SAFETY_FLAGS,
|
|
15314
18668
|
`--max-depth=${Math.min(options.maxDepth ?? DEFAULT_MAX_DEPTH, DEFAULT_MAX_DEPTH)}`,
|
|
15315
18669
|
`--max-filesize=${options.maxFilesize ?? DEFAULT_MAX_FILESIZE}`,
|
|
@@ -15317,60 +18671,60 @@ function buildRgArgs(options) {
|
|
|
15317
18671
|
`--max-columns=${Math.min(options.maxColumns ?? DEFAULT_MAX_COLUMNS, DEFAULT_MAX_COLUMNS)}`
|
|
15318
18672
|
];
|
|
15319
18673
|
if (options.context !== undefined && options.context > 0) {
|
|
15320
|
-
|
|
18674
|
+
args2.push(`-C${Math.min(options.context, 10)}`);
|
|
15321
18675
|
}
|
|
15322
18676
|
if (options.caseSensitive)
|
|
15323
|
-
|
|
18677
|
+
args2.push("--case-sensitive");
|
|
15324
18678
|
if (options.wholeWord)
|
|
15325
|
-
|
|
18679
|
+
args2.push("-w");
|
|
15326
18680
|
if (options.fixedStrings)
|
|
15327
|
-
|
|
18681
|
+
args2.push("-F");
|
|
15328
18682
|
if (options.multiline)
|
|
15329
|
-
|
|
18683
|
+
args2.push("-U");
|
|
15330
18684
|
if (options.hidden)
|
|
15331
|
-
|
|
18685
|
+
args2.push("--hidden");
|
|
15332
18686
|
if (options.noIgnore)
|
|
15333
|
-
|
|
18687
|
+
args2.push("--no-ignore");
|
|
15334
18688
|
if (options.fileType?.length) {
|
|
15335
18689
|
for (const type of options.fileType) {
|
|
15336
|
-
|
|
18690
|
+
args2.push(`--type=${type}`);
|
|
15337
18691
|
}
|
|
15338
18692
|
}
|
|
15339
18693
|
if (options.globs) {
|
|
15340
18694
|
for (const glob of options.globs) {
|
|
15341
|
-
|
|
18695
|
+
args2.push(`--glob=${glob}`);
|
|
15342
18696
|
}
|
|
15343
18697
|
}
|
|
15344
18698
|
if (options.excludeGlobs) {
|
|
15345
18699
|
for (const glob of options.excludeGlobs) {
|
|
15346
|
-
|
|
18700
|
+
args2.push(`--glob=!${glob}`);
|
|
15347
18701
|
}
|
|
15348
18702
|
}
|
|
15349
|
-
return
|
|
18703
|
+
return args2;
|
|
15350
18704
|
}
|
|
15351
18705
|
function buildGrepArgs(options) {
|
|
15352
|
-
const
|
|
18706
|
+
const args2 = [...GREP_SAFETY_FLAGS, "-r"];
|
|
15353
18707
|
if (options.context !== undefined && options.context > 0) {
|
|
15354
|
-
|
|
18708
|
+
args2.push(`-C${Math.min(options.context, 10)}`);
|
|
15355
18709
|
}
|
|
15356
18710
|
if (!options.caseSensitive)
|
|
15357
|
-
|
|
18711
|
+
args2.push("-i");
|
|
15358
18712
|
if (options.wholeWord)
|
|
15359
|
-
|
|
18713
|
+
args2.push("-w");
|
|
15360
18714
|
if (options.fixedStrings)
|
|
15361
|
-
|
|
18715
|
+
args2.push("-F");
|
|
15362
18716
|
if (options.globs?.length) {
|
|
15363
18717
|
for (const glob of options.globs) {
|
|
15364
|
-
|
|
18718
|
+
args2.push(`--include=${glob}`);
|
|
15365
18719
|
}
|
|
15366
18720
|
}
|
|
15367
18721
|
if (options.excludeGlobs?.length) {
|
|
15368
18722
|
for (const glob of options.excludeGlobs) {
|
|
15369
|
-
|
|
18723
|
+
args2.push(`--exclude=${glob}`);
|
|
15370
18724
|
}
|
|
15371
18725
|
}
|
|
15372
|
-
|
|
15373
|
-
return
|
|
18726
|
+
args2.push("--exclude-dir=.git", "--exclude-dir=node_modules");
|
|
18727
|
+
return args2;
|
|
15374
18728
|
}
|
|
15375
18729
|
function buildArgs(options, backend) {
|
|
15376
18730
|
return backend === "rg" ? buildRgArgs(options) : buildGrepArgs(options);
|
|
@@ -15397,16 +18751,16 @@ function parseOutput(output) {
|
|
|
15397
18751
|
}
|
|
15398
18752
|
async function runRg(options) {
|
|
15399
18753
|
const cli = resolveGrepCli();
|
|
15400
|
-
const
|
|
18754
|
+
const args2 = buildArgs(options, cli.backend);
|
|
15401
18755
|
const timeout = Math.min(options.timeout ?? DEFAULT_TIMEOUT_MS, DEFAULT_TIMEOUT_MS);
|
|
15402
18756
|
if (cli.backend === "rg") {
|
|
15403
|
-
|
|
18757
|
+
args2.push("--", options.pattern);
|
|
15404
18758
|
} else {
|
|
15405
|
-
|
|
18759
|
+
args2.push("-e", options.pattern);
|
|
15406
18760
|
}
|
|
15407
18761
|
const paths = options.paths?.length ? options.paths : ["."];
|
|
15408
|
-
|
|
15409
|
-
const proc = spawn3([cli.path, ...
|
|
18762
|
+
args2.push(...paths);
|
|
18763
|
+
const proc = spawn3([cli.path, ...args2], {
|
|
15410
18764
|
stdout: "pipe",
|
|
15411
18765
|
stderr: "pipe"
|
|
15412
18766
|
});
|
|
@@ -15490,12 +18844,12 @@ var safe_grep = tool({
|
|
|
15490
18844
|
include: tool.schema.string().optional().describe('File pattern to include in the search (e.g. "*.js", "*.{ts,tsx}")'),
|
|
15491
18845
|
path: tool.schema.string().optional().describe("The directory to search in. Defaults to the current working directory.")
|
|
15492
18846
|
},
|
|
15493
|
-
execute: async (
|
|
18847
|
+
execute: async (args2) => {
|
|
15494
18848
|
try {
|
|
15495
|
-
const globs =
|
|
15496
|
-
const paths =
|
|
18849
|
+
const globs = args2.include ? [args2.include] : undefined;
|
|
18850
|
+
const paths = args2.path ? [args2.path] : undefined;
|
|
15497
18851
|
const result = await runRg({
|
|
15498
|
-
pattern:
|
|
18852
|
+
pattern: args2.pattern,
|
|
15499
18853
|
paths,
|
|
15500
18854
|
globs,
|
|
15501
18855
|
context: 0
|
|
@@ -15549,9 +18903,9 @@ var allBuiltinMcps = {
|
|
|
15549
18903
|
};
|
|
15550
18904
|
function createBuiltinMcps(disabledMcps = []) {
|
|
15551
18905
|
const mcps = {};
|
|
15552
|
-
for (const [
|
|
15553
|
-
if (!disabledMcps.includes(
|
|
15554
|
-
mcps[
|
|
18906
|
+
for (const [name2, config3] of Object.entries(allBuiltinMcps)) {
|
|
18907
|
+
if (!disabledMcps.includes(name2)) {
|
|
18908
|
+
mcps[name2] = config3;
|
|
15555
18909
|
}
|
|
15556
18910
|
}
|
|
15557
18911
|
return mcps;
|
|
@@ -15597,7 +18951,7 @@ var OhMyOpenCodeConfigSchema = exports_external.object({
|
|
|
15597
18951
|
agents: AgentOverridesSchema.optional()
|
|
15598
18952
|
});
|
|
15599
18953
|
// src/index.ts
|
|
15600
|
-
import * as
|
|
18954
|
+
import * as fs2 from "fs";
|
|
15601
18955
|
import * as path from "path";
|
|
15602
18956
|
function loadPluginConfig(directory) {
|
|
15603
18957
|
const configPaths = [
|
|
@@ -15606,8 +18960,8 @@ function loadPluginConfig(directory) {
|
|
|
15606
18960
|
];
|
|
15607
18961
|
for (const configPath of configPaths) {
|
|
15608
18962
|
try {
|
|
15609
|
-
if (
|
|
15610
|
-
const content =
|
|
18963
|
+
if (fs2.existsSync(configPath)) {
|
|
18964
|
+
const content = fs2.readFileSync(configPath, "utf-8");
|
|
15611
18965
|
const rawConfig = JSON.parse(content);
|
|
15612
18966
|
const result = OhMyOpenCodeConfigSchema.safeParse(rawConfig);
|
|
15613
18967
|
if (!result.success) {
|
|
@@ -15627,6 +18981,7 @@ var OhMyOpenCodePlugin = async (ctx) => {
|
|
|
15627
18981
|
const todoContinuationEnforcer = createTodoContinuationEnforcer(ctx);
|
|
15628
18982
|
const contextWindowMonitor = createContextWindowMonitorHook(ctx);
|
|
15629
18983
|
const sessionRecovery = createSessionRecoveryHook(ctx);
|
|
18984
|
+
const commentChecker = createCommentCheckerHooks();
|
|
15630
18985
|
updateTerminalTitle({ sessionId: "main" });
|
|
15631
18986
|
const pluginConfig = loadPluginConfig(ctx.directory);
|
|
15632
18987
|
let mainSessionID;
|
|
@@ -15726,7 +19081,8 @@ var OhMyOpenCodePlugin = async (ctx) => {
|
|
|
15726
19081
|
}
|
|
15727
19082
|
}
|
|
15728
19083
|
},
|
|
15729
|
-
"tool.execute.before": async (input,
|
|
19084
|
+
"tool.execute.before": async (input, output) => {
|
|
19085
|
+
await commentChecker["tool.execute.before"](input, output);
|
|
15730
19086
|
if (input.sessionID === mainSessionID) {
|
|
15731
19087
|
updateTerminalTitle({
|
|
15732
19088
|
sessionId: input.sessionID,
|
|
@@ -15739,6 +19095,7 @@ var OhMyOpenCodePlugin = async (ctx) => {
|
|
|
15739
19095
|
},
|
|
15740
19096
|
"tool.execute.after": async (input, output) => {
|
|
15741
19097
|
await contextWindowMonitor["tool.execute.after"](input, output);
|
|
19098
|
+
await commentChecker["tool.execute.after"](input, output);
|
|
15742
19099
|
if (input.sessionID === mainSessionID) {
|
|
15743
19100
|
updateTerminalTitle({
|
|
15744
19101
|
sessionId: input.sessionID,
|