usfm-grammar-web 3.0.0-alpha.1
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/LICENSE +7 -0
- package/README.md +61 -0
- package/dist/cjs/index.cjs +2518 -0
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/esm/index.mjs +2513 -0
- package/dist/esm/index.mjs.map +1 -0
- package/package.json +46 -0
- package/tree-sitter-usfm.wasm +0 -0
- package/tree-sitter.wasm +0 -0
|
@@ -0,0 +1,2513 @@
|
|
|
1
|
+
|
|
2
|
+
function $parcel$interopDefault(a) {
|
|
3
|
+
return a && a.__esModule ? a.default : a;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
var $parcel$global = globalThis;
|
|
7
|
+
|
|
8
|
+
var $parcel$modules = {};
|
|
9
|
+
var $parcel$inits = {};
|
|
10
|
+
|
|
11
|
+
var parcelRequire = $parcel$global["parcelRequire9afa"];
|
|
12
|
+
|
|
13
|
+
if (parcelRequire == null) {
|
|
14
|
+
parcelRequire = function(id) {
|
|
15
|
+
if (id in $parcel$modules) {
|
|
16
|
+
return $parcel$modules[id].exports;
|
|
17
|
+
}
|
|
18
|
+
if (id in $parcel$inits) {
|
|
19
|
+
var init = $parcel$inits[id];
|
|
20
|
+
delete $parcel$inits[id];
|
|
21
|
+
var module = {id: id, exports: {}};
|
|
22
|
+
$parcel$modules[id] = module;
|
|
23
|
+
init.call(module.exports, module, module.exports);
|
|
24
|
+
return module.exports;
|
|
25
|
+
}
|
|
26
|
+
var err = new Error("Cannot find module '" + id + "'");
|
|
27
|
+
err.code = 'MODULE_NOT_FOUND';
|
|
28
|
+
throw err;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
parcelRequire.register = function register(id, init) {
|
|
32
|
+
$parcel$inits[id] = init;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
$parcel$global["parcelRequire9afa"] = parcelRequire;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
var parcelRegister = parcelRequire.register;
|
|
39
|
+
parcelRegister("dc2P8", function(module, exports) {
|
|
40
|
+
|
|
41
|
+
var $jGIDp = parcelRequire("jGIDp");
|
|
42
|
+
var __dirname = "src/web-tree-sitter";
|
|
43
|
+
var Module = void 0 !== Module ? Module : {};
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
var TreeSitter = function() {
|
|
48
|
+
var initPromise, document = "object" == typeof window ? {
|
|
49
|
+
currentScript: window.document.currentScript
|
|
50
|
+
} : null;
|
|
51
|
+
class Parser {
|
|
52
|
+
constructor(){
|
|
53
|
+
this.initialize();
|
|
54
|
+
}
|
|
55
|
+
initialize() {
|
|
56
|
+
throw new Error("cannot construct a Parser before calling `init()`");
|
|
57
|
+
}
|
|
58
|
+
static init(moduleOptions) {
|
|
59
|
+
return initPromise || (Module = Object.assign({}, Module, moduleOptions), initPromise = new Promise((resolveInitPromise)=>{
|
|
60
|
+
var moduleOverrides = Object.assign({}, Module), arguments_ = [], thisProgram = "./this.program", quit_ = (e, t)=>{
|
|
61
|
+
throw t;
|
|
62
|
+
}, ENVIRONMENT_IS_WEB = "object" == typeof window, ENVIRONMENT_IS_WORKER = "function" == typeof importScripts, ENVIRONMENT_IS_NODE = "object" == typeof $jGIDp && "object" == typeof $jGIDp.versions && "string" == typeof $jGIDp.versions.node, scriptDirectory = "", read_, readAsync, readBinary;
|
|
63
|
+
function locateFile(e) {
|
|
64
|
+
return Module.locateFile ? Module.locateFile(e, scriptDirectory) : scriptDirectory + e;
|
|
65
|
+
}
|
|
66
|
+
if (ENVIRONMENT_IS_NODE) {
|
|
67
|
+
var fs = (parcelRequire("jGIDp")), nodePath = (parcelRequire("jGIDp"));
|
|
68
|
+
scriptDirectory = ENVIRONMENT_IS_WORKER ? nodePath.dirname(scriptDirectory) + "/" : __dirname + "/", read_ = (e, t)=>(e = isFileURI(e) ? new URL(e) : nodePath.normalize(e), fs.readFileSync(e, t ? void 0 : "utf8")), readBinary = (e)=>{
|
|
69
|
+
var t = read_(e, !0);
|
|
70
|
+
return t.buffer || (t = new Uint8Array(t)), t;
|
|
71
|
+
}, readAsync = (e, t, _, s = !0)=>{
|
|
72
|
+
e = isFileURI(e) ? new URL(e) : nodePath.normalize(e), fs.readFile(e, s ? void 0 : "utf8", (e, r)=>{
|
|
73
|
+
e ? _(e) : t(s ? r.buffer : r);
|
|
74
|
+
});
|
|
75
|
+
}, !Module.thisProgram && $jGIDp.argv.length > 1 && (thisProgram = $jGIDp.argv[1].replace(/\\/g, "/")), arguments_ = $jGIDp.argv.slice(2), module.exports = Module, quit_ = (e, t)=>{
|
|
76
|
+
throw $jGIDp.exitCode = e, t;
|
|
77
|
+
};
|
|
78
|
+
} else (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) && (ENVIRONMENT_IS_WORKER ? scriptDirectory = self.location.href : void 0 !== document && document.currentScript && (scriptDirectory = document.currentScript.src), scriptDirectory = scriptDirectory.startsWith("blob:") ? "" : scriptDirectory.substr(0, scriptDirectory.replace(/[?#].*/, "").lastIndexOf("/") + 1), read_ = (e)=>{
|
|
79
|
+
var t = new XMLHttpRequest;
|
|
80
|
+
return t.open("GET", e, !1), t.send(null), t.responseText;
|
|
81
|
+
}, ENVIRONMENT_IS_WORKER && (readBinary = (e)=>{
|
|
82
|
+
var t = new XMLHttpRequest;
|
|
83
|
+
return t.open("GET", e, !1), t.responseType = "arraybuffer", t.send(null), new Uint8Array(t.response);
|
|
84
|
+
}), readAsync = (e, t, _)=>{
|
|
85
|
+
var s = new XMLHttpRequest;
|
|
86
|
+
s.open("GET", e, !0), s.responseType = "arraybuffer", s.onload = ()=>{
|
|
87
|
+
200 == s.status || 0 == s.status && s.response ? t(s.response) : _();
|
|
88
|
+
}, s.onerror = _, s.send(null);
|
|
89
|
+
});
|
|
90
|
+
var out = Module.print || console.log.bind(console), err = Module.printErr || console.error.bind(console);
|
|
91
|
+
Object.assign(Module, moduleOverrides), moduleOverrides = null, Module.arguments && (arguments_ = Module.arguments), Module.thisProgram && (thisProgram = Module.thisProgram), Module.quit && (quit_ = Module.quit);
|
|
92
|
+
var dynamicLibraries = Module.dynamicLibraries || [], wasmBinary, wasmMemory;
|
|
93
|
+
Module.wasmBinary && (wasmBinary = Module.wasmBinary), "object" != typeof WebAssembly && abort("no native wasm support detected");
|
|
94
|
+
var ABORT = !1, EXITSTATUS, HEAP8, HEAPU8, HEAP16, HEAPU16, HEAP32, HEAPU32, HEAPF32, HEAPF64;
|
|
95
|
+
function updateMemoryViews() {
|
|
96
|
+
var e = wasmMemory.buffer;
|
|
97
|
+
Module.HEAP8 = HEAP8 = new Int8Array(e), Module.HEAP16 = HEAP16 = new Int16Array(e), Module.HEAPU8 = HEAPU8 = new Uint8Array(e), Module.HEAPU16 = HEAPU16 = new Uint16Array(e), Module.HEAP32 = HEAP32 = new Int32Array(e), Module.HEAPU32 = HEAPU32 = new Uint32Array(e), Module.HEAPF32 = HEAPF32 = new Float32Array(e), Module.HEAPF64 = HEAPF64 = new Float64Array(e);
|
|
98
|
+
}
|
|
99
|
+
var INITIAL_MEMORY = Module.INITIAL_MEMORY || 33554432;
|
|
100
|
+
wasmMemory = Module.wasmMemory ? Module.wasmMemory : new WebAssembly.Memory({
|
|
101
|
+
initial: INITIAL_MEMORY / 65536,
|
|
102
|
+
maximum: 32768
|
|
103
|
+
}), updateMemoryViews(), INITIAL_MEMORY = wasmMemory.buffer.byteLength;
|
|
104
|
+
var __ATPRERUN__ = [], __ATINIT__ = [], __ATMAIN__ = [], __ATPOSTRUN__ = [], __RELOC_FUNCS__ = [], runtimeInitialized = !1;
|
|
105
|
+
function preRun() {
|
|
106
|
+
if (Module.preRun) for("function" == typeof Module.preRun && (Module.preRun = [
|
|
107
|
+
Module.preRun
|
|
108
|
+
]); Module.preRun.length;)addOnPreRun(Module.preRun.shift());
|
|
109
|
+
callRuntimeCallbacks(__ATPRERUN__);
|
|
110
|
+
}
|
|
111
|
+
function initRuntime() {
|
|
112
|
+
runtimeInitialized = !0, callRuntimeCallbacks(__RELOC_FUNCS__), callRuntimeCallbacks(__ATINIT__);
|
|
113
|
+
}
|
|
114
|
+
function preMain() {
|
|
115
|
+
callRuntimeCallbacks(__ATMAIN__);
|
|
116
|
+
}
|
|
117
|
+
function postRun() {
|
|
118
|
+
if (Module.postRun) for("function" == typeof Module.postRun && (Module.postRun = [
|
|
119
|
+
Module.postRun
|
|
120
|
+
]); Module.postRun.length;)addOnPostRun(Module.postRun.shift());
|
|
121
|
+
callRuntimeCallbacks(__ATPOSTRUN__);
|
|
122
|
+
}
|
|
123
|
+
function addOnPreRun(e) {
|
|
124
|
+
__ATPRERUN__.unshift(e);
|
|
125
|
+
}
|
|
126
|
+
function addOnInit(e) {
|
|
127
|
+
__ATINIT__.unshift(e);
|
|
128
|
+
}
|
|
129
|
+
function addOnPostRun(e) {
|
|
130
|
+
__ATPOSTRUN__.unshift(e);
|
|
131
|
+
}
|
|
132
|
+
var runDependencies = 0, runDependencyWatcher = null, dependenciesFulfilled = null;
|
|
133
|
+
function getUniqueRunDependency(e) {
|
|
134
|
+
return e;
|
|
135
|
+
}
|
|
136
|
+
function addRunDependency(e) {
|
|
137
|
+
runDependencies++, Module.monitorRunDependencies?.(runDependencies);
|
|
138
|
+
}
|
|
139
|
+
function removeRunDependency(e) {
|
|
140
|
+
if (runDependencies--, Module.monitorRunDependencies?.(runDependencies), 0 == runDependencies && (null !== runDependencyWatcher && (clearInterval(runDependencyWatcher), runDependencyWatcher = null), dependenciesFulfilled)) {
|
|
141
|
+
var t = dependenciesFulfilled;
|
|
142
|
+
dependenciesFulfilled = null, t();
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
function abort(e) {
|
|
146
|
+
throw Module.onAbort?.(e), err(e = "Aborted(" + e + ")"), ABORT = !0, EXITSTATUS = 1, e += ". Build with -sASSERTIONS for more info.", new WebAssembly.RuntimeError(e);
|
|
147
|
+
}
|
|
148
|
+
var dataURIPrefix = "data:application/octet-stream;base64,", isDataURI = (e)=>e.startsWith(dataURIPrefix), isFileURI = (e)=>e.startsWith("file://"), wasmBinaryFile;
|
|
149
|
+
function getBinarySync(e) {
|
|
150
|
+
if (e == wasmBinaryFile && wasmBinary) return new Uint8Array(wasmBinary);
|
|
151
|
+
if (readBinary) return readBinary(e);
|
|
152
|
+
throw "both async and sync fetching of the wasm failed";
|
|
153
|
+
}
|
|
154
|
+
function getBinaryPromise(e) {
|
|
155
|
+
if (!wasmBinary && (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER)) {
|
|
156
|
+
if ("function" == typeof fetch && !isFileURI(e)) return fetch(e, {
|
|
157
|
+
credentials: "same-origin"
|
|
158
|
+
}).then((t)=>{
|
|
159
|
+
if (!t.ok) throw `failed to load wasm binary file at '${e}'`;
|
|
160
|
+
return t.arrayBuffer();
|
|
161
|
+
}).catch(()=>getBinarySync(e));
|
|
162
|
+
if (readAsync) return new Promise((t, _)=>{
|
|
163
|
+
readAsync(e, (e)=>t(new Uint8Array(e)), _);
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
return Promise.resolve().then(()=>getBinarySync(e));
|
|
167
|
+
}
|
|
168
|
+
function instantiateArrayBuffer(e, t, _) {
|
|
169
|
+
return getBinaryPromise(e).then((e)=>WebAssembly.instantiate(e, t)).then(_, (e)=>{
|
|
170
|
+
err(`failed to asynchronously prepare wasm: ${e}`), abort(e);
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
function instantiateAsync(e, t, _, s) {
|
|
174
|
+
return e || "function" != typeof WebAssembly.instantiateStreaming || isDataURI(t) || isFileURI(t) || ENVIRONMENT_IS_NODE || "function" != typeof fetch ? instantiateArrayBuffer(t, _, s) : fetch(t, {
|
|
175
|
+
credentials: "same-origin"
|
|
176
|
+
}).then((e)=>WebAssembly.instantiateStreaming(e, _).then(s, function(e) {
|
|
177
|
+
return err(`wasm streaming compile failed: ${e}`), err("falling back to ArrayBuffer instantiation"), instantiateArrayBuffer(t, _, s);
|
|
178
|
+
}));
|
|
179
|
+
}
|
|
180
|
+
function createWasm() {
|
|
181
|
+
var e = {
|
|
182
|
+
env: wasmImports,
|
|
183
|
+
wasi_snapshot_preview1: wasmImports,
|
|
184
|
+
"GOT.mem": new Proxy(wasmImports, GOTHandler),
|
|
185
|
+
"GOT.func": new Proxy(wasmImports, GOTHandler)
|
|
186
|
+
};
|
|
187
|
+
function t(e, t) {
|
|
188
|
+
wasmExports = e.exports, wasmExports = relocateExports(wasmExports, 1024);
|
|
189
|
+
var _ = getDylinkMetadata(t);
|
|
190
|
+
return _.neededDynlibs && (dynamicLibraries = _.neededDynlibs.concat(dynamicLibraries)), mergeLibSymbols(wasmExports, "main"), LDSO.init(), loadDylibs(), addOnInit(wasmExports.__wasm_call_ctors), __RELOC_FUNCS__.push(wasmExports.__wasm_apply_data_relocs), removeRunDependency("wasm-instantiate"), wasmExports;
|
|
191
|
+
}
|
|
192
|
+
if (addRunDependency("wasm-instantiate"), Module.instantiateWasm) try {
|
|
193
|
+
return Module.instantiateWasm(e, t);
|
|
194
|
+
} catch (e) {
|
|
195
|
+
return err(`Module.instantiateWasm callback failed with error: ${e}`), !1;
|
|
196
|
+
}
|
|
197
|
+
return instantiateAsync(wasmBinary, wasmBinaryFile, e, function(e) {
|
|
198
|
+
t(e.instance, e.module);
|
|
199
|
+
}), {};
|
|
200
|
+
}
|
|
201
|
+
wasmBinaryFile = "tree-sitter.wasm", isDataURI(wasmBinaryFile) || (wasmBinaryFile = locateFile(wasmBinaryFile));
|
|
202
|
+
var ASM_CONSTS = {};
|
|
203
|
+
function ExitStatus(e) {
|
|
204
|
+
this.name = "ExitStatus", this.message = `Program terminated with exit(${e})`, this.status = e;
|
|
205
|
+
}
|
|
206
|
+
var GOT = {}, currentModuleWeakSymbols = new Set([]), GOTHandler = {
|
|
207
|
+
get (e, t) {
|
|
208
|
+
var _ = GOT[t];
|
|
209
|
+
return _ || (_ = GOT[t] = new WebAssembly.Global({
|
|
210
|
+
value: "i32",
|
|
211
|
+
mutable: !0
|
|
212
|
+
})), currentModuleWeakSymbols.has(t) || (_.required = !0), _;
|
|
213
|
+
}
|
|
214
|
+
}, callRuntimeCallbacks = (e)=>{
|
|
215
|
+
for(; e.length > 0;)e.shift()(Module);
|
|
216
|
+
}, UTF8Decoder = "undefined" != typeof TextDecoder ? new TextDecoder("utf8") : void 0, UTF8ArrayToString = (e, t, _)=>{
|
|
217
|
+
for(var s = t + _, r = t; e[r] && !(r >= s);)++r;
|
|
218
|
+
if (r - t > 16 && e.buffer && UTF8Decoder) return UTF8Decoder.decode(e.subarray(t, r));
|
|
219
|
+
for(var a = ""; t < r;){
|
|
220
|
+
var o = e[t++];
|
|
221
|
+
if (128 & o) {
|
|
222
|
+
var n = 63 & e[t++];
|
|
223
|
+
if (192 != (224 & o)) {
|
|
224
|
+
var l = 63 & e[t++];
|
|
225
|
+
if ((o = 224 == (240 & o) ? (15 & o) << 12 | n << 6 | l : (7 & o) << 18 | n << 12 | l << 6 | 63 & e[t++]) < 65536) a += String.fromCharCode(o);
|
|
226
|
+
else {
|
|
227
|
+
var d = o - 65536;
|
|
228
|
+
a += String.fromCharCode(55296 | d >> 10, 56320 | 1023 & d);
|
|
229
|
+
}
|
|
230
|
+
} else a += String.fromCharCode((31 & o) << 6 | n);
|
|
231
|
+
} else a += String.fromCharCode(o);
|
|
232
|
+
}
|
|
233
|
+
return a;
|
|
234
|
+
}, getDylinkMetadata = (e)=>{
|
|
235
|
+
var t = 0, _ = 0;
|
|
236
|
+
function s() {
|
|
237
|
+
for(var _ = 0, s = 1;;){
|
|
238
|
+
var r = e[t++];
|
|
239
|
+
if (_ += (127 & r) * s, s *= 128, !(128 & r)) break;
|
|
240
|
+
}
|
|
241
|
+
return _;
|
|
242
|
+
}
|
|
243
|
+
function r() {
|
|
244
|
+
var _ = s();
|
|
245
|
+
return UTF8ArrayToString(e, (t += _) - _, _);
|
|
246
|
+
}
|
|
247
|
+
function a(e, t) {
|
|
248
|
+
if (e) throw new Error(t);
|
|
249
|
+
}
|
|
250
|
+
var o = "dylink.0";
|
|
251
|
+
if (e instanceof WebAssembly.Module) {
|
|
252
|
+
var n = WebAssembly.Module.customSections(e, o);
|
|
253
|
+
0 === n.length && (o = "dylink", n = WebAssembly.Module.customSections(e, o)), a(0 === n.length, "need dylink section"), _ = (e = new Uint8Array(n[0])).length;
|
|
254
|
+
} else {
|
|
255
|
+
a(!(1836278016 == new Uint32Array(new Uint8Array(e.subarray(0, 24)).buffer)[0]), "need to see wasm magic number"), a(0 !== e[8], "need the dylink section to be first"), t = 9;
|
|
256
|
+
var l = s();
|
|
257
|
+
_ = t + l, o = r();
|
|
258
|
+
}
|
|
259
|
+
var d = {
|
|
260
|
+
neededDynlibs: [],
|
|
261
|
+
tlsExports: new Set,
|
|
262
|
+
weakImports: new Set
|
|
263
|
+
};
|
|
264
|
+
if ("dylink" == o) {
|
|
265
|
+
d.memorySize = s(), d.memoryAlign = s(), d.tableSize = s(), d.tableAlign = s();
|
|
266
|
+
for(var u = s(), m = 0; m < u; ++m){
|
|
267
|
+
var c = r();
|
|
268
|
+
d.neededDynlibs.push(c);
|
|
269
|
+
}
|
|
270
|
+
} else {
|
|
271
|
+
a("dylink.0" !== o);
|
|
272
|
+
for(; t < _;){
|
|
273
|
+
var w = e[t++], p = s();
|
|
274
|
+
if (1 === w) d.memorySize = s(), d.memoryAlign = s(), d.tableSize = s(), d.tableAlign = s();
|
|
275
|
+
else if (2 === w) for(u = s(), m = 0; m < u; ++m)c = r(), d.neededDynlibs.push(c);
|
|
276
|
+
else if (3 === w) for(var h = s(); h--;){
|
|
277
|
+
var g = r();
|
|
278
|
+
256 & s() && d.tlsExports.add(g);
|
|
279
|
+
}
|
|
280
|
+
else if (4 === w) for(h = s(); h--;){
|
|
281
|
+
r(), g = r();
|
|
282
|
+
1 == (3 & s()) && d.weakImports.add(g);
|
|
283
|
+
}
|
|
284
|
+
else t += p;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
return d;
|
|
288
|
+
};
|
|
289
|
+
function getValue(e, t = "i8") {
|
|
290
|
+
switch(t.endsWith("*") && (t = "*"), t){
|
|
291
|
+
case "i1":
|
|
292
|
+
case "i8":
|
|
293
|
+
return HEAP8[e];
|
|
294
|
+
case "i16":
|
|
295
|
+
return HEAP16[e >> 1];
|
|
296
|
+
case "i32":
|
|
297
|
+
return HEAP32[e >> 2];
|
|
298
|
+
case "i64":
|
|
299
|
+
abort("to do getValue(i64) use WASM_BIGINT");
|
|
300
|
+
case "float":
|
|
301
|
+
return HEAPF32[e >> 2];
|
|
302
|
+
case "double":
|
|
303
|
+
return HEAPF64[e >> 3];
|
|
304
|
+
case "*":
|
|
305
|
+
return HEAPU32[e >> 2];
|
|
306
|
+
default:
|
|
307
|
+
abort(`invalid type for getValue: ${t}`);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
var newDSO = (e, t, _)=>{
|
|
311
|
+
var s = {
|
|
312
|
+
refcount: 1 / 0,
|
|
313
|
+
name: e,
|
|
314
|
+
exports: _,
|
|
315
|
+
global: !0
|
|
316
|
+
};
|
|
317
|
+
return LDSO.loadedLibsByName[e] = s, null != t && (LDSO.loadedLibsByHandle[t] = s), s;
|
|
318
|
+
}, LDSO = {
|
|
319
|
+
loadedLibsByName: {},
|
|
320
|
+
loadedLibsByHandle: {},
|
|
321
|
+
init () {
|
|
322
|
+
newDSO("__main__", 0, wasmImports);
|
|
323
|
+
}
|
|
324
|
+
}, ___heap_base = 78096, zeroMemory = (e, t)=>(HEAPU8.fill(0, e, e + t), e), alignMemory = (e, t)=>Math.ceil(e / t) * t, getMemory = (e)=>{
|
|
325
|
+
if (runtimeInitialized) return zeroMemory(_malloc(e), e);
|
|
326
|
+
var t = ___heap_base, _ = t + alignMemory(e, 16);
|
|
327
|
+
return ___heap_base = _, GOT.__heap_base.value = _, t;
|
|
328
|
+
}, isInternalSym = (e)=>[
|
|
329
|
+
"__cpp_exception",
|
|
330
|
+
"__c_longjmp",
|
|
331
|
+
"__wasm_apply_data_relocs",
|
|
332
|
+
"__dso_handle",
|
|
333
|
+
"__tls_size",
|
|
334
|
+
"__tls_align",
|
|
335
|
+
"__set_stack_limits",
|
|
336
|
+
"_emscripten_tls_init",
|
|
337
|
+
"__wasm_init_tls",
|
|
338
|
+
"__wasm_call_ctors",
|
|
339
|
+
"__start_em_asm",
|
|
340
|
+
"__stop_em_asm",
|
|
341
|
+
"__start_em_js",
|
|
342
|
+
"__stop_em_js"
|
|
343
|
+
].includes(e) || e.startsWith("__em_js__"), uleb128Encode = (e, t)=>{
|
|
344
|
+
e < 128 ? t.push(e) : t.push(e % 128 | 128, e >> 7);
|
|
345
|
+
}, sigToWasmTypes = (e)=>{
|
|
346
|
+
for(var t = {
|
|
347
|
+
i: "i32",
|
|
348
|
+
j: "i64",
|
|
349
|
+
f: "f32",
|
|
350
|
+
d: "f64",
|
|
351
|
+
e: "externref",
|
|
352
|
+
p: "i32"
|
|
353
|
+
}, _ = {
|
|
354
|
+
parameters: [],
|
|
355
|
+
results: "v" == e[0] ? [] : [
|
|
356
|
+
t[e[0]]
|
|
357
|
+
]
|
|
358
|
+
}, s = 1; s < e.length; ++s)_.parameters.push(t[e[s]]);
|
|
359
|
+
return _;
|
|
360
|
+
}, generateFuncType = (e, t)=>{
|
|
361
|
+
var _ = e.slice(0, 1), s = e.slice(1), r = {
|
|
362
|
+
i: 127,
|
|
363
|
+
p: 127,
|
|
364
|
+
j: 126,
|
|
365
|
+
f: 125,
|
|
366
|
+
d: 124,
|
|
367
|
+
e: 111
|
|
368
|
+
};
|
|
369
|
+
t.push(96), uleb128Encode(s.length, t);
|
|
370
|
+
for(var a = 0; a < s.length; ++a)t.push(r[s[a]]);
|
|
371
|
+
"v" == _ ? t.push(0) : t.push(1, r[_]);
|
|
372
|
+
}, convertJsFunctionToWasm = (e, t)=>{
|
|
373
|
+
if ("function" == typeof WebAssembly.Function) return new WebAssembly.Function(sigToWasmTypes(t), e);
|
|
374
|
+
var _ = [
|
|
375
|
+
1
|
|
376
|
+
];
|
|
377
|
+
generateFuncType(t, _);
|
|
378
|
+
var s = [
|
|
379
|
+
0,
|
|
380
|
+
97,
|
|
381
|
+
115,
|
|
382
|
+
109,
|
|
383
|
+
1,
|
|
384
|
+
0,
|
|
385
|
+
0,
|
|
386
|
+
0,
|
|
387
|
+
1
|
|
388
|
+
];
|
|
389
|
+
uleb128Encode(_.length, s), s.push(..._), s.push(2, 7, 1, 1, 101, 1, 102, 0, 0, 7, 5, 1, 1, 102, 0, 0);
|
|
390
|
+
var r = new WebAssembly.Module(new Uint8Array(s));
|
|
391
|
+
return new WebAssembly.Instance(r, {
|
|
392
|
+
e: {
|
|
393
|
+
f: e
|
|
394
|
+
}
|
|
395
|
+
}).exports.f;
|
|
396
|
+
}, wasmTableMirror = [], wasmTable = new WebAssembly.Table({
|
|
397
|
+
initial: 27,
|
|
398
|
+
element: "anyfunc"
|
|
399
|
+
}), getWasmTableEntry = (e)=>{
|
|
400
|
+
var t = wasmTableMirror[e];
|
|
401
|
+
return t || (e >= wasmTableMirror.length && (wasmTableMirror.length = e + 1), wasmTableMirror[e] = t = wasmTable.get(e)), t;
|
|
402
|
+
}, updateTableMap = (e, t)=>{
|
|
403
|
+
if (functionsInTableMap) for(var _ = e; _ < e + t; _++){
|
|
404
|
+
var s = getWasmTableEntry(_);
|
|
405
|
+
s && functionsInTableMap.set(s, _);
|
|
406
|
+
}
|
|
407
|
+
}, functionsInTableMap, getFunctionAddress = (e)=>(functionsInTableMap || (functionsInTableMap = new WeakMap, updateTableMap(0, wasmTable.length)), functionsInTableMap.get(e) || 0), freeTableIndexes = [], getEmptyTableSlot = ()=>{
|
|
408
|
+
if (freeTableIndexes.length) return freeTableIndexes.pop();
|
|
409
|
+
try {
|
|
410
|
+
wasmTable.grow(1);
|
|
411
|
+
} catch (e) {
|
|
412
|
+
if (!(e instanceof RangeError)) throw e;
|
|
413
|
+
throw "Unable to grow wasm table. Set ALLOW_TABLE_GROWTH.";
|
|
414
|
+
}
|
|
415
|
+
return wasmTable.length - 1;
|
|
416
|
+
}, setWasmTableEntry = (e, t)=>{
|
|
417
|
+
wasmTable.set(e, t), wasmTableMirror[e] = wasmTable.get(e);
|
|
418
|
+
}, addFunction = (e, t)=>{
|
|
419
|
+
var _ = getFunctionAddress(e);
|
|
420
|
+
if (_) return _;
|
|
421
|
+
var s = getEmptyTableSlot();
|
|
422
|
+
try {
|
|
423
|
+
setWasmTableEntry(s, e);
|
|
424
|
+
} catch (_) {
|
|
425
|
+
if (!(_ instanceof TypeError)) throw _;
|
|
426
|
+
var r = convertJsFunctionToWasm(e, t);
|
|
427
|
+
setWasmTableEntry(s, r);
|
|
428
|
+
}
|
|
429
|
+
return functionsInTableMap.set(e, s), s;
|
|
430
|
+
}, updateGOT = (e, t)=>{
|
|
431
|
+
for(var _ in e)if (!isInternalSym(_)) {
|
|
432
|
+
var s = e[_];
|
|
433
|
+
_.startsWith("orig$") && (_ = _.split("$")[1], t = !0), GOT[_] ||= new WebAssembly.Global({
|
|
434
|
+
value: "i32",
|
|
435
|
+
mutable: !0
|
|
436
|
+
}), (t || 0 == GOT[_].value) && ("function" == typeof s ? GOT[_].value = addFunction(s) : "number" == typeof s ? GOT[_].value = s : err(`unhandled export type for '${_}': ${typeof s}`));
|
|
437
|
+
}
|
|
438
|
+
}, relocateExports = (e, t, _)=>{
|
|
439
|
+
var s = {};
|
|
440
|
+
for(var r in e){
|
|
441
|
+
var a = e[r];
|
|
442
|
+
"object" == typeof a && (a = a.value), "number" == typeof a && (a += t), s[r] = a;
|
|
443
|
+
}
|
|
444
|
+
return updateGOT(s, _), s;
|
|
445
|
+
}, isSymbolDefined = (e)=>{
|
|
446
|
+
var t = wasmImports[e];
|
|
447
|
+
return !(!t || t.stub);
|
|
448
|
+
}, dynCallLegacy = (e, t, _)=>(0, Module["dynCall_" + e])(t, ..._), dynCall = (e, t, _ = [])=>e.includes("j") ? dynCallLegacy(e, t, _) : getWasmTableEntry(t)(..._), createInvokeFunction = (e)=>function() {
|
|
449
|
+
var t = stackSave();
|
|
450
|
+
try {
|
|
451
|
+
return dynCall(e, arguments[0], Array.prototype.slice.call(arguments, 1));
|
|
452
|
+
} catch (e) {
|
|
453
|
+
if (stackRestore(t), e !== e + 0) throw e;
|
|
454
|
+
_setThrew(1, 0);
|
|
455
|
+
}
|
|
456
|
+
}, resolveGlobalSymbol = (e, t = !1)=>{
|
|
457
|
+
var _;
|
|
458
|
+
return t && "orig$" + e in wasmImports && (e = "orig$" + e), isSymbolDefined(e) ? _ = wasmImports[e] : e.startsWith("invoke_") && (_ = wasmImports[e] = createInvokeFunction(e.split("_")[1])), {
|
|
459
|
+
sym: _,
|
|
460
|
+
name: e
|
|
461
|
+
};
|
|
462
|
+
}, UTF8ToString = (e, t)=>e ? UTF8ArrayToString(HEAPU8, e, t) : "", loadWebAssemblyModule = (binary, flags, libName, localScope, handle)=>{
|
|
463
|
+
var metadata = getDylinkMetadata(binary);
|
|
464
|
+
function loadModule() {
|
|
465
|
+
var firstLoad = !handle || !HEAP8[handle + 8];
|
|
466
|
+
if (firstLoad) {
|
|
467
|
+
var memAlign = Math.pow(2, metadata.memoryAlign), memoryBase = metadata.memorySize ? alignMemory(getMemory(metadata.memorySize + memAlign), memAlign) : 0, tableBase = metadata.tableSize ? wasmTable.length : 0;
|
|
468
|
+
handle && (HEAP8[handle + 8] = 1, HEAPU32[handle + 12 >> 2] = memoryBase, HEAP32[handle + 16 >> 2] = metadata.memorySize, HEAPU32[handle + 20 >> 2] = tableBase, HEAP32[handle + 24 >> 2] = metadata.tableSize);
|
|
469
|
+
} else memoryBase = HEAPU32[handle + 12 >> 2], tableBase = HEAPU32[handle + 20 >> 2];
|
|
470
|
+
var tableGrowthNeeded = tableBase + metadata.tableSize - wasmTable.length, moduleExports;
|
|
471
|
+
function resolveSymbol(e) {
|
|
472
|
+
var t = resolveGlobalSymbol(e).sym;
|
|
473
|
+
return !t && localScope && (t = localScope[e]), t || (t = moduleExports[e]), t;
|
|
474
|
+
}
|
|
475
|
+
tableGrowthNeeded > 0 && wasmTable.grow(tableGrowthNeeded);
|
|
476
|
+
var proxyHandler = {
|
|
477
|
+
get (e, t) {
|
|
478
|
+
switch(t){
|
|
479
|
+
case "__memory_base":
|
|
480
|
+
return memoryBase;
|
|
481
|
+
case "__table_base":
|
|
482
|
+
return tableBase;
|
|
483
|
+
}
|
|
484
|
+
if (t in wasmImports && !wasmImports[t].stub) return wasmImports[t];
|
|
485
|
+
var _;
|
|
486
|
+
t in e || (e[t] = (...e)=>(_ ||= resolveSymbol(t), _(...e)));
|
|
487
|
+
return e[t];
|
|
488
|
+
}
|
|
489
|
+
}, proxy = new Proxy({}, proxyHandler), info = {
|
|
490
|
+
"GOT.mem": new Proxy({}, GOTHandler),
|
|
491
|
+
"GOT.func": new Proxy({}, GOTHandler),
|
|
492
|
+
env: proxy,
|
|
493
|
+
wasi_snapshot_preview1: proxy
|
|
494
|
+
};
|
|
495
|
+
function postInstantiation(module1, instance) {
|
|
496
|
+
function addEmAsm(addr, body) {
|
|
497
|
+
for(var args = [], arity = 0; arity < 16 && -1 != body.indexOf("$" + arity); arity++)args.push("$" + arity);
|
|
498
|
+
args = args.join(",");
|
|
499
|
+
var func = `(${args}) => { ${body} };`;
|
|
500
|
+
ASM_CONSTS[start] = eval(func);
|
|
501
|
+
}
|
|
502
|
+
if (updateTableMap(tableBase, metadata.tableSize), moduleExports = relocateExports(instance.exports, memoryBase), flags.allowUndefined || reportUndefinedSymbols(), "__start_em_asm" in moduleExports) for(var start = moduleExports.__start_em_asm, stop = moduleExports.__stop_em_asm; start < stop;){
|
|
503
|
+
var jsString = UTF8ToString(start);
|
|
504
|
+
addEmAsm(start, jsString), start = HEAPU8.indexOf(0, start) + 1;
|
|
505
|
+
}
|
|
506
|
+
function addEmJs(name, cSig, body) {
|
|
507
|
+
var jsArgs = [];
|
|
508
|
+
if (cSig = cSig.slice(1, -1), "void" != cSig) for(var i in cSig = cSig.split(","), cSig){
|
|
509
|
+
var jsArg = cSig[i].split(" ").pop();
|
|
510
|
+
jsArgs.push(jsArg.replace("*", ""));
|
|
511
|
+
}
|
|
512
|
+
var func = `(${jsArgs}) => ${body};`;
|
|
513
|
+
moduleExports[name] = eval(func);
|
|
514
|
+
}
|
|
515
|
+
for(var name in moduleExports)if (name.startsWith("__em_js__")) {
|
|
516
|
+
var start = moduleExports[name], jsString = UTF8ToString(start), parts = jsString.split("<::>");
|
|
517
|
+
addEmJs(name.replace("__em_js__", ""), parts[0], parts[1]), delete moduleExports[name];
|
|
518
|
+
}
|
|
519
|
+
var applyRelocs = moduleExports.__wasm_apply_data_relocs;
|
|
520
|
+
applyRelocs && (runtimeInitialized ? applyRelocs() : __RELOC_FUNCS__.push(applyRelocs));
|
|
521
|
+
var init = moduleExports.__wasm_call_ctors;
|
|
522
|
+
return init && (runtimeInitialized ? init() : __ATINIT__.push(init)), moduleExports;
|
|
523
|
+
}
|
|
524
|
+
if (flags.loadAsync) {
|
|
525
|
+
if (binary instanceof WebAssembly.Module) {
|
|
526
|
+
var instance = new WebAssembly.Instance(binary, info);
|
|
527
|
+
return Promise.resolve(postInstantiation(binary, instance));
|
|
528
|
+
}
|
|
529
|
+
return WebAssembly.instantiate(binary, info).then((e)=>postInstantiation(e.module, e.instance));
|
|
530
|
+
}
|
|
531
|
+
var module1 = binary instanceof WebAssembly.Module ? binary : new WebAssembly.Module(binary), instance = new WebAssembly.Instance(module1, info);
|
|
532
|
+
return postInstantiation(module1, instance);
|
|
533
|
+
}
|
|
534
|
+
return currentModuleWeakSymbols = metadata.weakImports, flags.loadAsync ? metadata.neededDynlibs.reduce((e, t)=>e.then(()=>loadDynamicLibrary(t, flags)), Promise.resolve()).then(loadModule) : (metadata.neededDynlibs.forEach((e)=>loadDynamicLibrary(e, flags, localScope)), loadModule());
|
|
535
|
+
}, mergeLibSymbols = (e, t)=>{
|
|
536
|
+
for (var [_, s] of Object.entries(e)){
|
|
537
|
+
const e = (e)=>{
|
|
538
|
+
isSymbolDefined(e) || (wasmImports[e] = s);
|
|
539
|
+
};
|
|
540
|
+
e(_);
|
|
541
|
+
const t = "__main_argc_argv";
|
|
542
|
+
"main" == _ && e(t), _ == t && e("main"), _.startsWith("dynCall_") && !Module.hasOwnProperty(_) && (Module[_] = s);
|
|
543
|
+
}
|
|
544
|
+
}, asyncLoad = (e, t, _, s)=>{
|
|
545
|
+
var r = s ? "" : getUniqueRunDependency(`al ${e}`);
|
|
546
|
+
readAsync(e, (e)=>{
|
|
547
|
+
t(new Uint8Array(e)), r && removeRunDependency(r);
|
|
548
|
+
}, (t)=>{
|
|
549
|
+
if (!_) throw `Loading data file "${e}" failed.`;
|
|
550
|
+
_();
|
|
551
|
+
}), r && addRunDependency(r);
|
|
552
|
+
};
|
|
553
|
+
function loadDynamicLibrary(e, t = {
|
|
554
|
+
global: !0,
|
|
555
|
+
nodelete: !0
|
|
556
|
+
}, _, s) {
|
|
557
|
+
var r = LDSO.loadedLibsByName[e];
|
|
558
|
+
if (r) return t.global ? r.global || (r.global = !0, mergeLibSymbols(r.exports, e)) : _ && Object.assign(_, r.exports), t.nodelete && r.refcount !== 1 / 0 && (r.refcount = 1 / 0), r.refcount++, s && (LDSO.loadedLibsByHandle[s] = r), !t.loadAsync || Promise.resolve(!0);
|
|
559
|
+
function a() {
|
|
560
|
+
if (s) {
|
|
561
|
+
var _ = HEAPU32[s + 28 >> 2], r = HEAPU32[s + 32 >> 2];
|
|
562
|
+
if (_ && r) {
|
|
563
|
+
var a = HEAP8.slice(_, _ + r);
|
|
564
|
+
return t.loadAsync ? Promise.resolve(a) : a;
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
var o = locateFile(e);
|
|
568
|
+
if (t.loadAsync) return new Promise(function(e, t) {
|
|
569
|
+
asyncLoad(o, e, t);
|
|
570
|
+
});
|
|
571
|
+
if (!readBinary) throw new Error(`${o}: file not found, and synchronous loading of external files is not available`);
|
|
572
|
+
return readBinary(o);
|
|
573
|
+
}
|
|
574
|
+
function o() {
|
|
575
|
+
return t.loadAsync ? a().then((r)=>loadWebAssemblyModule(r, t, e, _, s)) : loadWebAssemblyModule(a(), t, e, _, s);
|
|
576
|
+
}
|
|
577
|
+
function n(t) {
|
|
578
|
+
r.global ? mergeLibSymbols(t, e) : _ && Object.assign(_, t), r.exports = t;
|
|
579
|
+
}
|
|
580
|
+
return (r = newDSO(e, s, "loading")).refcount = t.nodelete ? 1 / 0 : 1, r.global = t.global, t.loadAsync ? o().then((e)=>(n(e), !0)) : (n(o()), !0);
|
|
581
|
+
}
|
|
582
|
+
var reportUndefinedSymbols = ()=>{
|
|
583
|
+
for (var [e, t] of Object.entries(GOT))if (0 == t.value) {
|
|
584
|
+
var _ = resolveGlobalSymbol(e, !0).sym;
|
|
585
|
+
if (!_ && !t.required) continue;
|
|
586
|
+
if ("function" == typeof _) t.value = addFunction(_, _.sig);
|
|
587
|
+
else {
|
|
588
|
+
if ("number" != typeof _) throw new Error(`bad export type for '${e}': ${typeof _}`);
|
|
589
|
+
t.value = _;
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
}, loadDylibs = ()=>{
|
|
593
|
+
dynamicLibraries.length ? (addRunDependency("loadDylibs"), dynamicLibraries.reduce((e, t)=>e.then(()=>loadDynamicLibrary(t, {
|
|
594
|
+
loadAsync: !0,
|
|
595
|
+
global: !0,
|
|
596
|
+
nodelete: !0,
|
|
597
|
+
allowUndefined: !0
|
|
598
|
+
})), Promise.resolve()).then(()=>{
|
|
599
|
+
reportUndefinedSymbols(), removeRunDependency("loadDylibs");
|
|
600
|
+
})) : reportUndefinedSymbols();
|
|
601
|
+
}, noExitRuntime = Module.noExitRuntime || !0;
|
|
602
|
+
function setValue(e, t, _ = "i8") {
|
|
603
|
+
switch(_.endsWith("*") && (_ = "*"), _){
|
|
604
|
+
case "i1":
|
|
605
|
+
case "i8":
|
|
606
|
+
HEAP8[e] = t;
|
|
607
|
+
break;
|
|
608
|
+
case "i16":
|
|
609
|
+
HEAP16[e >> 1] = t;
|
|
610
|
+
break;
|
|
611
|
+
case "i32":
|
|
612
|
+
HEAP32[e >> 2] = t;
|
|
613
|
+
break;
|
|
614
|
+
case "i64":
|
|
615
|
+
abort("to do setValue(i64) use WASM_BIGINT");
|
|
616
|
+
case "float":
|
|
617
|
+
HEAPF32[e >> 2] = t;
|
|
618
|
+
break;
|
|
619
|
+
case "double":
|
|
620
|
+
HEAPF64[e >> 3] = t;
|
|
621
|
+
break;
|
|
622
|
+
case "*":
|
|
623
|
+
HEAPU32[e >> 2] = t;
|
|
624
|
+
break;
|
|
625
|
+
default:
|
|
626
|
+
abort(`invalid type for setValue: ${_}`);
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
var ___memory_base = new WebAssembly.Global({
|
|
630
|
+
value: "i32",
|
|
631
|
+
mutable: !1
|
|
632
|
+
}, 1024), ___stack_pointer = new WebAssembly.Global({
|
|
633
|
+
value: "i32",
|
|
634
|
+
mutable: !0
|
|
635
|
+
}, 78096), ___table_base = new WebAssembly.Global({
|
|
636
|
+
value: "i32",
|
|
637
|
+
mutable: !1
|
|
638
|
+
}, 1), nowIsMonotonic = 1, __emscripten_get_now_is_monotonic = ()=>nowIsMonotonic;
|
|
639
|
+
__emscripten_get_now_is_monotonic.sig = "i";
|
|
640
|
+
var _abort = ()=>{
|
|
641
|
+
abort("");
|
|
642
|
+
};
|
|
643
|
+
_abort.sig = "v";
|
|
644
|
+
var _emscripten_date_now = ()=>Date.now(), _emscripten_get_now;
|
|
645
|
+
_emscripten_date_now.sig = "d", _emscripten_get_now = ()=>performance.now(), _emscripten_get_now.sig = "d";
|
|
646
|
+
var _emscripten_memcpy_js = (e, t, _)=>HEAPU8.copyWithin(e, t, t + _);
|
|
647
|
+
_emscripten_memcpy_js.sig = "vppp";
|
|
648
|
+
var getHeapMax = ()=>2147483648, growMemory = (e)=>{
|
|
649
|
+
var t = (e - wasmMemory.buffer.byteLength + 65535) / 65536;
|
|
650
|
+
try {
|
|
651
|
+
return wasmMemory.grow(t), updateMemoryViews(), 1;
|
|
652
|
+
} catch (e) {}
|
|
653
|
+
}, _emscripten_resize_heap = (e)=>{
|
|
654
|
+
var t = HEAPU8.length;
|
|
655
|
+
e >>>= 0;
|
|
656
|
+
var _ = getHeapMax();
|
|
657
|
+
if (e > _) return !1;
|
|
658
|
+
for(var s, r, a = 1; a <= 4; a *= 2){
|
|
659
|
+
var o = t * (1 + .2 / a);
|
|
660
|
+
o = Math.min(o, e + 100663296);
|
|
661
|
+
var n = Math.min(_, (s = Math.max(e, o)) + ((r = 65536) - s % r) % r);
|
|
662
|
+
if (growMemory(n)) return !0;
|
|
663
|
+
}
|
|
664
|
+
return !1;
|
|
665
|
+
};
|
|
666
|
+
_emscripten_resize_heap.sig = "ip";
|
|
667
|
+
var _fd_close = (e)=>52;
|
|
668
|
+
_fd_close.sig = "ii";
|
|
669
|
+
var convertI32PairToI53Checked = (e, t)=>t + 2097152 >>> 0 < 4194305 - !!e ? (e >>> 0) + 4294967296 * t : NaN;
|
|
670
|
+
function _fd_seek(e, t, _, s, r) {
|
|
671
|
+
convertI32PairToI53Checked(t, _);
|
|
672
|
+
return 70;
|
|
673
|
+
}
|
|
674
|
+
_fd_seek.sig = "iiiiip";
|
|
675
|
+
var printCharBuffers = [
|
|
676
|
+
null,
|
|
677
|
+
[],
|
|
678
|
+
[]
|
|
679
|
+
], printChar = (e, t)=>{
|
|
680
|
+
var _ = printCharBuffers[e];
|
|
681
|
+
0 === t || 10 === t ? ((1 === e ? out : err)(UTF8ArrayToString(_, 0)), _.length = 0) : _.push(t);
|
|
682
|
+
}, SYSCALLS = {
|
|
683
|
+
varargs: void 0,
|
|
684
|
+
get () {
|
|
685
|
+
var e = HEAP32[+SYSCALLS.varargs >> 2];
|
|
686
|
+
return SYSCALLS.varargs += 4, e;
|
|
687
|
+
},
|
|
688
|
+
getp: ()=>SYSCALLS.get(),
|
|
689
|
+
getStr: (e)=>UTF8ToString(e)
|
|
690
|
+
}, _fd_write = (e, t, _, s)=>{
|
|
691
|
+
for(var r = 0, a = 0; a < _; a++){
|
|
692
|
+
var o = HEAPU32[t >> 2], n = HEAPU32[t + 4 >> 2];
|
|
693
|
+
t += 8;
|
|
694
|
+
for(var l = 0; l < n; l++)printChar(e, HEAPU8[o + l]);
|
|
695
|
+
r += n;
|
|
696
|
+
}
|
|
697
|
+
return HEAPU32[s >> 2] = r, 0;
|
|
698
|
+
};
|
|
699
|
+
function _tree_sitter_log_callback(e, t) {
|
|
700
|
+
if (currentLogCallback) {
|
|
701
|
+
const _ = UTF8ToString(t);
|
|
702
|
+
currentLogCallback(_, 0 !== e);
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
function _tree_sitter_parse_callback(e, t, _, s, r) {
|
|
706
|
+
const a = currentParseCallback(t, {
|
|
707
|
+
row: _,
|
|
708
|
+
column: s
|
|
709
|
+
});
|
|
710
|
+
"string" == typeof a ? (setValue(r, a.length, "i32"), stringToUTF16(a, e, 10240)) : setValue(r, 0, "i32");
|
|
711
|
+
}
|
|
712
|
+
_fd_write.sig = "iippp";
|
|
713
|
+
var runtimeKeepaliveCounter = 0, keepRuntimeAlive = ()=>noExitRuntime || runtimeKeepaliveCounter > 0, _proc_exit = (e)=>{
|
|
714
|
+
EXITSTATUS = e, keepRuntimeAlive() || (Module.onExit?.(e), ABORT = !0), quit_(e, new ExitStatus(e));
|
|
715
|
+
};
|
|
716
|
+
_proc_exit.sig = "vi";
|
|
717
|
+
var exitJS = (e, t)=>{
|
|
718
|
+
EXITSTATUS = e, _proc_exit(e);
|
|
719
|
+
}, handleException = (e)=>{
|
|
720
|
+
if (e instanceof ExitStatus || "unwind" == e) return EXITSTATUS;
|
|
721
|
+
quit_(1, e);
|
|
722
|
+
}, lengthBytesUTF8 = (e)=>{
|
|
723
|
+
for(var t = 0, _ = 0; _ < e.length; ++_){
|
|
724
|
+
var s = e.charCodeAt(_);
|
|
725
|
+
s <= 127 ? t++ : s <= 2047 ? t += 2 : s >= 55296 && s <= 57343 ? (t += 4, ++_) : t += 3;
|
|
726
|
+
}
|
|
727
|
+
return t;
|
|
728
|
+
}, stringToUTF8Array = (e, t, _, s)=>{
|
|
729
|
+
if (!(s > 0)) return 0;
|
|
730
|
+
for(var r = _, a = _ + s - 1, o = 0; o < e.length; ++o){
|
|
731
|
+
var n = e.charCodeAt(o);
|
|
732
|
+
if (n >= 55296 && n <= 57343) n = 65536 + ((1023 & n) << 10) | 1023 & e.charCodeAt(++o);
|
|
733
|
+
if (n <= 127) {
|
|
734
|
+
if (_ >= a) break;
|
|
735
|
+
t[_++] = n;
|
|
736
|
+
} else if (n <= 2047) {
|
|
737
|
+
if (_ + 1 >= a) break;
|
|
738
|
+
t[_++] = 192 | n >> 6, t[_++] = 128 | 63 & n;
|
|
739
|
+
} else if (n <= 65535) {
|
|
740
|
+
if (_ + 2 >= a) break;
|
|
741
|
+
t[_++] = 224 | n >> 12, t[_++] = 128 | n >> 6 & 63, t[_++] = 128 | 63 & n;
|
|
742
|
+
} else {
|
|
743
|
+
if (_ + 3 >= a) break;
|
|
744
|
+
t[_++] = 240 | n >> 18, t[_++] = 128 | n >> 12 & 63, t[_++] = 128 | n >> 6 & 63, t[_++] = 128 | 63 & n;
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
return t[_] = 0, _ - r;
|
|
748
|
+
}, stringToUTF8 = (e, t, _)=>stringToUTF8Array(e, HEAPU8, t, _), stringToUTF8OnStack = (e)=>{
|
|
749
|
+
var t = lengthBytesUTF8(e) + 1, _ = stackAlloc(t);
|
|
750
|
+
return stringToUTF8(e, _, t), _;
|
|
751
|
+
}, stringToUTF16 = (e, t, _)=>{
|
|
752
|
+
if (_ ??= 2147483647, _ < 2) return 0;
|
|
753
|
+
for(var s = t, r = (_ -= 2) < 2 * e.length ? _ / 2 : e.length, a = 0; a < r; ++a){
|
|
754
|
+
var o = e.charCodeAt(a);
|
|
755
|
+
HEAP16[t >> 1] = o, t += 2;
|
|
756
|
+
}
|
|
757
|
+
return HEAP16[t >> 1] = 0, t - s;
|
|
758
|
+
}, AsciiToString = (e)=>{
|
|
759
|
+
for(var t = "";;){
|
|
760
|
+
var _ = HEAPU8[e++];
|
|
761
|
+
if (!_) return t;
|
|
762
|
+
t += String.fromCharCode(_);
|
|
763
|
+
}
|
|
764
|
+
}, wasmImports = {
|
|
765
|
+
__heap_base: ___heap_base,
|
|
766
|
+
__indirect_function_table: wasmTable,
|
|
767
|
+
__memory_base: ___memory_base,
|
|
768
|
+
__stack_pointer: ___stack_pointer,
|
|
769
|
+
__table_base: ___table_base,
|
|
770
|
+
_emscripten_get_now_is_monotonic: __emscripten_get_now_is_monotonic,
|
|
771
|
+
abort: _abort,
|
|
772
|
+
emscripten_get_now: _emscripten_get_now,
|
|
773
|
+
emscripten_memcpy_js: _emscripten_memcpy_js,
|
|
774
|
+
emscripten_resize_heap: _emscripten_resize_heap,
|
|
775
|
+
fd_close: _fd_close,
|
|
776
|
+
fd_seek: _fd_seek,
|
|
777
|
+
fd_write: _fd_write,
|
|
778
|
+
memory: wasmMemory,
|
|
779
|
+
tree_sitter_log_callback: _tree_sitter_log_callback,
|
|
780
|
+
tree_sitter_parse_callback: _tree_sitter_parse_callback
|
|
781
|
+
}, wasmExports = createWasm(), ___wasm_call_ctors = ()=>(___wasm_call_ctors = wasmExports.__wasm_call_ctors)(), ___wasm_apply_data_relocs = ()=>(___wasm_apply_data_relocs = wasmExports.__wasm_apply_data_relocs)(), _malloc = Module._malloc = (e)=>(_malloc = Module._malloc = wasmExports.malloc)(e), _calloc = Module._calloc = (e, t)=>(_calloc = Module._calloc = wasmExports.calloc)(e, t), _realloc = Module._realloc = (e, t)=>(_realloc = Module._realloc = wasmExports.realloc)(e, t), _free = Module._free = (e)=>(_free = Module._free = wasmExports.free)(e), _ts_language_symbol_count = Module._ts_language_symbol_count = (e)=>(_ts_language_symbol_count = Module._ts_language_symbol_count = wasmExports.ts_language_symbol_count)(e), _ts_language_state_count = Module._ts_language_state_count = (e)=>(_ts_language_state_count = Module._ts_language_state_count = wasmExports.ts_language_state_count)(e), _ts_language_version = Module._ts_language_version = (e)=>(_ts_language_version = Module._ts_language_version = wasmExports.ts_language_version)(e), _ts_language_field_count = Module._ts_language_field_count = (e)=>(_ts_language_field_count = Module._ts_language_field_count = wasmExports.ts_language_field_count)(e), _ts_language_next_state = Module._ts_language_next_state = (e, t, _)=>(_ts_language_next_state = Module._ts_language_next_state = wasmExports.ts_language_next_state)(e, t, _), _ts_language_symbol_name = Module._ts_language_symbol_name = (e, t)=>(_ts_language_symbol_name = Module._ts_language_symbol_name = wasmExports.ts_language_symbol_name)(e, t), _ts_language_symbol_for_name = Module._ts_language_symbol_for_name = (e, t, _, s)=>(_ts_language_symbol_for_name = Module._ts_language_symbol_for_name = wasmExports.ts_language_symbol_for_name)(e, t, _, s), _strncmp = Module._strncmp = (e, t, _)=>(_strncmp = Module._strncmp = wasmExports.strncmp)(e, t, _), _ts_language_symbol_type = Module._ts_language_symbol_type = (e, t)=>(_ts_language_symbol_type = Module._ts_language_symbol_type = wasmExports.ts_language_symbol_type)(e, t), _ts_language_field_name_for_id = Module._ts_language_field_name_for_id = (e, t)=>(_ts_language_field_name_for_id = Module._ts_language_field_name_for_id = wasmExports.ts_language_field_name_for_id)(e, t), _ts_lookahead_iterator_new = Module._ts_lookahead_iterator_new = (e, t)=>(_ts_lookahead_iterator_new = Module._ts_lookahead_iterator_new = wasmExports.ts_lookahead_iterator_new)(e, t), _ts_lookahead_iterator_delete = Module._ts_lookahead_iterator_delete = (e)=>(_ts_lookahead_iterator_delete = Module._ts_lookahead_iterator_delete = wasmExports.ts_lookahead_iterator_delete)(e), _ts_lookahead_iterator_reset_state = Module._ts_lookahead_iterator_reset_state = (e, t)=>(_ts_lookahead_iterator_reset_state = Module._ts_lookahead_iterator_reset_state = wasmExports.ts_lookahead_iterator_reset_state)(e, t), _ts_lookahead_iterator_reset = Module._ts_lookahead_iterator_reset = (e, t, _)=>(_ts_lookahead_iterator_reset = Module._ts_lookahead_iterator_reset = wasmExports.ts_lookahead_iterator_reset)(e, t, _), _ts_lookahead_iterator_next = Module._ts_lookahead_iterator_next = (e)=>(_ts_lookahead_iterator_next = Module._ts_lookahead_iterator_next = wasmExports.ts_lookahead_iterator_next)(e), _ts_lookahead_iterator_current_symbol = Module._ts_lookahead_iterator_current_symbol = (e)=>(_ts_lookahead_iterator_current_symbol = Module._ts_lookahead_iterator_current_symbol = wasmExports.ts_lookahead_iterator_current_symbol)(e), _memset = Module._memset = (e, t, _)=>(_memset = Module._memset = wasmExports.memset)(e, t, _), _memcpy = Module._memcpy = (e, t, _)=>(_memcpy = Module._memcpy = wasmExports.memcpy)(e, t, _), _ts_parser_delete = Module._ts_parser_delete = (e)=>(_ts_parser_delete = Module._ts_parser_delete = wasmExports.ts_parser_delete)(e), _ts_parser_reset = Module._ts_parser_reset = (e)=>(_ts_parser_reset = Module._ts_parser_reset = wasmExports.ts_parser_reset)(e), _ts_parser_set_language = Module._ts_parser_set_language = (e, t)=>(_ts_parser_set_language = Module._ts_parser_set_language = wasmExports.ts_parser_set_language)(e, t), _ts_parser_timeout_micros = Module._ts_parser_timeout_micros = (e)=>(_ts_parser_timeout_micros = Module._ts_parser_timeout_micros = wasmExports.ts_parser_timeout_micros)(e), _ts_parser_set_timeout_micros = Module._ts_parser_set_timeout_micros = (e, t, _)=>(_ts_parser_set_timeout_micros = Module._ts_parser_set_timeout_micros = wasmExports.ts_parser_set_timeout_micros)(e, t, _), _ts_parser_set_included_ranges = Module._ts_parser_set_included_ranges = (e, t, _)=>(_ts_parser_set_included_ranges = Module._ts_parser_set_included_ranges = wasmExports.ts_parser_set_included_ranges)(e, t, _), _memmove = Module._memmove = (e, t, _)=>(_memmove = Module._memmove = wasmExports.memmove)(e, t, _), _memcmp = Module._memcmp = (e, t, _)=>(_memcmp = Module._memcmp = wasmExports.memcmp)(e, t, _), _ts_query_new = Module._ts_query_new = (e, t, _, s, r)=>(_ts_query_new = Module._ts_query_new = wasmExports.ts_query_new)(e, t, _, s, r), _ts_query_delete = Module._ts_query_delete = (e)=>(_ts_query_delete = Module._ts_query_delete = wasmExports.ts_query_delete)(e), _iswspace = Module._iswspace = (e)=>(_iswspace = Module._iswspace = wasmExports.iswspace)(e), _iswalnum = Module._iswalnum = (e)=>(_iswalnum = Module._iswalnum = wasmExports.iswalnum)(e), _ts_query_pattern_count = Module._ts_query_pattern_count = (e)=>(_ts_query_pattern_count = Module._ts_query_pattern_count = wasmExports.ts_query_pattern_count)(e), _ts_query_capture_count = Module._ts_query_capture_count = (e)=>(_ts_query_capture_count = Module._ts_query_capture_count = wasmExports.ts_query_capture_count)(e), _ts_query_string_count = Module._ts_query_string_count = (e)=>(_ts_query_string_count = Module._ts_query_string_count = wasmExports.ts_query_string_count)(e), _ts_query_capture_name_for_id = Module._ts_query_capture_name_for_id = (e, t, _)=>(_ts_query_capture_name_for_id = Module._ts_query_capture_name_for_id = wasmExports.ts_query_capture_name_for_id)(e, t, _), _ts_query_string_value_for_id = Module._ts_query_string_value_for_id = (e, t, _)=>(_ts_query_string_value_for_id = Module._ts_query_string_value_for_id = wasmExports.ts_query_string_value_for_id)(e, t, _), _ts_query_predicates_for_pattern = Module._ts_query_predicates_for_pattern = (e, t, _)=>(_ts_query_predicates_for_pattern = Module._ts_query_predicates_for_pattern = wasmExports.ts_query_predicates_for_pattern)(e, t, _), _ts_query_disable_capture = Module._ts_query_disable_capture = (e, t, _)=>(_ts_query_disable_capture = Module._ts_query_disable_capture = wasmExports.ts_query_disable_capture)(e, t, _), _ts_tree_copy = Module._ts_tree_copy = (e)=>(_ts_tree_copy = Module._ts_tree_copy = wasmExports.ts_tree_copy)(e), _ts_tree_delete = Module._ts_tree_delete = (e)=>(_ts_tree_delete = Module._ts_tree_delete = wasmExports.ts_tree_delete)(e), _ts_init = Module._ts_init = ()=>(_ts_init = Module._ts_init = wasmExports.ts_init)(), _ts_parser_new_wasm = Module._ts_parser_new_wasm = ()=>(_ts_parser_new_wasm = Module._ts_parser_new_wasm = wasmExports.ts_parser_new_wasm)(), _ts_parser_enable_logger_wasm = Module._ts_parser_enable_logger_wasm = (e, t)=>(_ts_parser_enable_logger_wasm = Module._ts_parser_enable_logger_wasm = wasmExports.ts_parser_enable_logger_wasm)(e, t), _ts_parser_parse_wasm = Module._ts_parser_parse_wasm = (e, t, _, s, r)=>(_ts_parser_parse_wasm = Module._ts_parser_parse_wasm = wasmExports.ts_parser_parse_wasm)(e, t, _, s, r), _ts_parser_included_ranges_wasm = Module._ts_parser_included_ranges_wasm = (e)=>(_ts_parser_included_ranges_wasm = Module._ts_parser_included_ranges_wasm = wasmExports.ts_parser_included_ranges_wasm)(e), _ts_language_type_is_named_wasm = Module._ts_language_type_is_named_wasm = (e, t)=>(_ts_language_type_is_named_wasm = Module._ts_language_type_is_named_wasm = wasmExports.ts_language_type_is_named_wasm)(e, t), _ts_language_type_is_visible_wasm = Module._ts_language_type_is_visible_wasm = (e, t)=>(_ts_language_type_is_visible_wasm = Module._ts_language_type_is_visible_wasm = wasmExports.ts_language_type_is_visible_wasm)(e, t), _ts_tree_root_node_wasm = Module._ts_tree_root_node_wasm = (e)=>(_ts_tree_root_node_wasm = Module._ts_tree_root_node_wasm = wasmExports.ts_tree_root_node_wasm)(e), _ts_tree_root_node_with_offset_wasm = Module._ts_tree_root_node_with_offset_wasm = (e)=>(_ts_tree_root_node_with_offset_wasm = Module._ts_tree_root_node_with_offset_wasm = wasmExports.ts_tree_root_node_with_offset_wasm)(e), _ts_tree_edit_wasm = Module._ts_tree_edit_wasm = (e)=>(_ts_tree_edit_wasm = Module._ts_tree_edit_wasm = wasmExports.ts_tree_edit_wasm)(e), _ts_tree_included_ranges_wasm = Module._ts_tree_included_ranges_wasm = (e)=>(_ts_tree_included_ranges_wasm = Module._ts_tree_included_ranges_wasm = wasmExports.ts_tree_included_ranges_wasm)(e), _ts_tree_get_changed_ranges_wasm = Module._ts_tree_get_changed_ranges_wasm = (e, t)=>(_ts_tree_get_changed_ranges_wasm = Module._ts_tree_get_changed_ranges_wasm = wasmExports.ts_tree_get_changed_ranges_wasm)(e, t), _ts_tree_cursor_new_wasm = Module._ts_tree_cursor_new_wasm = (e)=>(_ts_tree_cursor_new_wasm = Module._ts_tree_cursor_new_wasm = wasmExports.ts_tree_cursor_new_wasm)(e), _ts_tree_cursor_delete_wasm = Module._ts_tree_cursor_delete_wasm = (e)=>(_ts_tree_cursor_delete_wasm = Module._ts_tree_cursor_delete_wasm = wasmExports.ts_tree_cursor_delete_wasm)(e), _ts_tree_cursor_reset_wasm = Module._ts_tree_cursor_reset_wasm = (e)=>(_ts_tree_cursor_reset_wasm = Module._ts_tree_cursor_reset_wasm = wasmExports.ts_tree_cursor_reset_wasm)(e), _ts_tree_cursor_reset_to_wasm = Module._ts_tree_cursor_reset_to_wasm = (e, t)=>(_ts_tree_cursor_reset_to_wasm = Module._ts_tree_cursor_reset_to_wasm = wasmExports.ts_tree_cursor_reset_to_wasm)(e, t), _ts_tree_cursor_goto_first_child_wasm = Module._ts_tree_cursor_goto_first_child_wasm = (e)=>(_ts_tree_cursor_goto_first_child_wasm = Module._ts_tree_cursor_goto_first_child_wasm = wasmExports.ts_tree_cursor_goto_first_child_wasm)(e), _ts_tree_cursor_goto_last_child_wasm = Module._ts_tree_cursor_goto_last_child_wasm = (e)=>(_ts_tree_cursor_goto_last_child_wasm = Module._ts_tree_cursor_goto_last_child_wasm = wasmExports.ts_tree_cursor_goto_last_child_wasm)(e), _ts_tree_cursor_goto_first_child_for_index_wasm = Module._ts_tree_cursor_goto_first_child_for_index_wasm = (e)=>(_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)(e), _ts_tree_cursor_goto_first_child_for_position_wasm = Module._ts_tree_cursor_goto_first_child_for_position_wasm = (e)=>(_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)(e), _ts_tree_cursor_goto_next_sibling_wasm = Module._ts_tree_cursor_goto_next_sibling_wasm = (e)=>(_ts_tree_cursor_goto_next_sibling_wasm = Module._ts_tree_cursor_goto_next_sibling_wasm = wasmExports.ts_tree_cursor_goto_next_sibling_wasm)(e), _ts_tree_cursor_goto_previous_sibling_wasm = Module._ts_tree_cursor_goto_previous_sibling_wasm = (e)=>(_ts_tree_cursor_goto_previous_sibling_wasm = Module._ts_tree_cursor_goto_previous_sibling_wasm = wasmExports.ts_tree_cursor_goto_previous_sibling_wasm)(e), _ts_tree_cursor_goto_descendant_wasm = Module._ts_tree_cursor_goto_descendant_wasm = (e, t)=>(_ts_tree_cursor_goto_descendant_wasm = Module._ts_tree_cursor_goto_descendant_wasm = wasmExports.ts_tree_cursor_goto_descendant_wasm)(e, t), _ts_tree_cursor_goto_parent_wasm = Module._ts_tree_cursor_goto_parent_wasm = (e)=>(_ts_tree_cursor_goto_parent_wasm = Module._ts_tree_cursor_goto_parent_wasm = wasmExports.ts_tree_cursor_goto_parent_wasm)(e), _ts_tree_cursor_current_node_type_id_wasm = Module._ts_tree_cursor_current_node_type_id_wasm = (e)=>(_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)(e), _ts_tree_cursor_current_node_state_id_wasm = Module._ts_tree_cursor_current_node_state_id_wasm = (e)=>(_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)(e), _ts_tree_cursor_current_node_is_named_wasm = Module._ts_tree_cursor_current_node_is_named_wasm = (e)=>(_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)(e), _ts_tree_cursor_current_node_is_missing_wasm = Module._ts_tree_cursor_current_node_is_missing_wasm = (e)=>(_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)(e), _ts_tree_cursor_current_node_id_wasm = Module._ts_tree_cursor_current_node_id_wasm = (e)=>(_ts_tree_cursor_current_node_id_wasm = Module._ts_tree_cursor_current_node_id_wasm = wasmExports.ts_tree_cursor_current_node_id_wasm)(e), _ts_tree_cursor_start_position_wasm = Module._ts_tree_cursor_start_position_wasm = (e)=>(_ts_tree_cursor_start_position_wasm = Module._ts_tree_cursor_start_position_wasm = wasmExports.ts_tree_cursor_start_position_wasm)(e), _ts_tree_cursor_end_position_wasm = Module._ts_tree_cursor_end_position_wasm = (e)=>(_ts_tree_cursor_end_position_wasm = Module._ts_tree_cursor_end_position_wasm = wasmExports.ts_tree_cursor_end_position_wasm)(e), _ts_tree_cursor_start_index_wasm = Module._ts_tree_cursor_start_index_wasm = (e)=>(_ts_tree_cursor_start_index_wasm = Module._ts_tree_cursor_start_index_wasm = wasmExports.ts_tree_cursor_start_index_wasm)(e), _ts_tree_cursor_end_index_wasm = Module._ts_tree_cursor_end_index_wasm = (e)=>(_ts_tree_cursor_end_index_wasm = Module._ts_tree_cursor_end_index_wasm = wasmExports.ts_tree_cursor_end_index_wasm)(e), _ts_tree_cursor_current_field_id_wasm = Module._ts_tree_cursor_current_field_id_wasm = (e)=>(_ts_tree_cursor_current_field_id_wasm = Module._ts_tree_cursor_current_field_id_wasm = wasmExports.ts_tree_cursor_current_field_id_wasm)(e), _ts_tree_cursor_current_depth_wasm = Module._ts_tree_cursor_current_depth_wasm = (e)=>(_ts_tree_cursor_current_depth_wasm = Module._ts_tree_cursor_current_depth_wasm = wasmExports.ts_tree_cursor_current_depth_wasm)(e), _ts_tree_cursor_current_descendant_index_wasm = Module._ts_tree_cursor_current_descendant_index_wasm = (e)=>(_ts_tree_cursor_current_descendant_index_wasm = Module._ts_tree_cursor_current_descendant_index_wasm = wasmExports.ts_tree_cursor_current_descendant_index_wasm)(e), _ts_tree_cursor_current_node_wasm = Module._ts_tree_cursor_current_node_wasm = (e)=>(_ts_tree_cursor_current_node_wasm = Module._ts_tree_cursor_current_node_wasm = wasmExports.ts_tree_cursor_current_node_wasm)(e), _ts_node_symbol_wasm = Module._ts_node_symbol_wasm = (e)=>(_ts_node_symbol_wasm = Module._ts_node_symbol_wasm = wasmExports.ts_node_symbol_wasm)(e), _ts_node_field_name_for_child_wasm = Module._ts_node_field_name_for_child_wasm = (e, t)=>(_ts_node_field_name_for_child_wasm = Module._ts_node_field_name_for_child_wasm = wasmExports.ts_node_field_name_for_child_wasm)(e, t), _ts_node_children_by_field_id_wasm = Module._ts_node_children_by_field_id_wasm = (e, t)=>(_ts_node_children_by_field_id_wasm = Module._ts_node_children_by_field_id_wasm = wasmExports.ts_node_children_by_field_id_wasm)(e, t), _ts_node_first_child_for_byte_wasm = Module._ts_node_first_child_for_byte_wasm = (e)=>(_ts_node_first_child_for_byte_wasm = Module._ts_node_first_child_for_byte_wasm = wasmExports.ts_node_first_child_for_byte_wasm)(e), _ts_node_first_named_child_for_byte_wasm = Module._ts_node_first_named_child_for_byte_wasm = (e)=>(_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)(e), _ts_node_grammar_symbol_wasm = Module._ts_node_grammar_symbol_wasm = (e)=>(_ts_node_grammar_symbol_wasm = Module._ts_node_grammar_symbol_wasm = wasmExports.ts_node_grammar_symbol_wasm)(e), _ts_node_child_count_wasm = Module._ts_node_child_count_wasm = (e)=>(_ts_node_child_count_wasm = Module._ts_node_child_count_wasm = wasmExports.ts_node_child_count_wasm)(e), _ts_node_named_child_count_wasm = Module._ts_node_named_child_count_wasm = (e)=>(_ts_node_named_child_count_wasm = Module._ts_node_named_child_count_wasm = wasmExports.ts_node_named_child_count_wasm)(e), _ts_node_child_wasm = Module._ts_node_child_wasm = (e, t)=>(_ts_node_child_wasm = Module._ts_node_child_wasm = wasmExports.ts_node_child_wasm)(e, t), _ts_node_named_child_wasm = Module._ts_node_named_child_wasm = (e, t)=>(_ts_node_named_child_wasm = Module._ts_node_named_child_wasm = wasmExports.ts_node_named_child_wasm)(e, t), _ts_node_child_by_field_id_wasm = Module._ts_node_child_by_field_id_wasm = (e, t)=>(_ts_node_child_by_field_id_wasm = Module._ts_node_child_by_field_id_wasm = wasmExports.ts_node_child_by_field_id_wasm)(e, t), _ts_node_next_sibling_wasm = Module._ts_node_next_sibling_wasm = (e)=>(_ts_node_next_sibling_wasm = Module._ts_node_next_sibling_wasm = wasmExports.ts_node_next_sibling_wasm)(e), _ts_node_prev_sibling_wasm = Module._ts_node_prev_sibling_wasm = (e)=>(_ts_node_prev_sibling_wasm = Module._ts_node_prev_sibling_wasm = wasmExports.ts_node_prev_sibling_wasm)(e), _ts_node_next_named_sibling_wasm = Module._ts_node_next_named_sibling_wasm = (e)=>(_ts_node_next_named_sibling_wasm = Module._ts_node_next_named_sibling_wasm = wasmExports.ts_node_next_named_sibling_wasm)(e), _ts_node_prev_named_sibling_wasm = Module._ts_node_prev_named_sibling_wasm = (e)=>(_ts_node_prev_named_sibling_wasm = Module._ts_node_prev_named_sibling_wasm = wasmExports.ts_node_prev_named_sibling_wasm)(e), _ts_node_descendant_count_wasm = Module._ts_node_descendant_count_wasm = (e)=>(_ts_node_descendant_count_wasm = Module._ts_node_descendant_count_wasm = wasmExports.ts_node_descendant_count_wasm)(e), _ts_node_parent_wasm = Module._ts_node_parent_wasm = (e)=>(_ts_node_parent_wasm = Module._ts_node_parent_wasm = wasmExports.ts_node_parent_wasm)(e), _ts_node_descendant_for_index_wasm = Module._ts_node_descendant_for_index_wasm = (e)=>(_ts_node_descendant_for_index_wasm = Module._ts_node_descendant_for_index_wasm = wasmExports.ts_node_descendant_for_index_wasm)(e), _ts_node_named_descendant_for_index_wasm = Module._ts_node_named_descendant_for_index_wasm = (e)=>(_ts_node_named_descendant_for_index_wasm = Module._ts_node_named_descendant_for_index_wasm = wasmExports.ts_node_named_descendant_for_index_wasm)(e), _ts_node_descendant_for_position_wasm = Module._ts_node_descendant_for_position_wasm = (e)=>(_ts_node_descendant_for_position_wasm = Module._ts_node_descendant_for_position_wasm = wasmExports.ts_node_descendant_for_position_wasm)(e), _ts_node_named_descendant_for_position_wasm = Module._ts_node_named_descendant_for_position_wasm = (e)=>(_ts_node_named_descendant_for_position_wasm = Module._ts_node_named_descendant_for_position_wasm = wasmExports.ts_node_named_descendant_for_position_wasm)(e), _ts_node_start_point_wasm = Module._ts_node_start_point_wasm = (e)=>(_ts_node_start_point_wasm = Module._ts_node_start_point_wasm = wasmExports.ts_node_start_point_wasm)(e), _ts_node_end_point_wasm = Module._ts_node_end_point_wasm = (e)=>(_ts_node_end_point_wasm = Module._ts_node_end_point_wasm = wasmExports.ts_node_end_point_wasm)(e), _ts_node_start_index_wasm = Module._ts_node_start_index_wasm = (e)=>(_ts_node_start_index_wasm = Module._ts_node_start_index_wasm = wasmExports.ts_node_start_index_wasm)(e), _ts_node_end_index_wasm = Module._ts_node_end_index_wasm = (e)=>(_ts_node_end_index_wasm = Module._ts_node_end_index_wasm = wasmExports.ts_node_end_index_wasm)(e), _ts_node_to_string_wasm = Module._ts_node_to_string_wasm = (e)=>(_ts_node_to_string_wasm = Module._ts_node_to_string_wasm = wasmExports.ts_node_to_string_wasm)(e), _ts_node_children_wasm = Module._ts_node_children_wasm = (e)=>(_ts_node_children_wasm = Module._ts_node_children_wasm = wasmExports.ts_node_children_wasm)(e), _ts_node_named_children_wasm = Module._ts_node_named_children_wasm = (e)=>(_ts_node_named_children_wasm = Module._ts_node_named_children_wasm = wasmExports.ts_node_named_children_wasm)(e), _ts_node_descendants_of_type_wasm = Module._ts_node_descendants_of_type_wasm = (e, t, _, s, r, a, o)=>(_ts_node_descendants_of_type_wasm = Module._ts_node_descendants_of_type_wasm = wasmExports.ts_node_descendants_of_type_wasm)(e, t, _, s, r, a, o), _ts_node_is_named_wasm = Module._ts_node_is_named_wasm = (e)=>(_ts_node_is_named_wasm = Module._ts_node_is_named_wasm = wasmExports.ts_node_is_named_wasm)(e), _ts_node_has_changes_wasm = Module._ts_node_has_changes_wasm = (e)=>(_ts_node_has_changes_wasm = Module._ts_node_has_changes_wasm = wasmExports.ts_node_has_changes_wasm)(e), _ts_node_has_error_wasm = Module._ts_node_has_error_wasm = (e)=>(_ts_node_has_error_wasm = Module._ts_node_has_error_wasm = wasmExports.ts_node_has_error_wasm)(e), _ts_node_is_error_wasm = Module._ts_node_is_error_wasm = (e)=>(_ts_node_is_error_wasm = Module._ts_node_is_error_wasm = wasmExports.ts_node_is_error_wasm)(e), _ts_node_is_missing_wasm = Module._ts_node_is_missing_wasm = (e)=>(_ts_node_is_missing_wasm = Module._ts_node_is_missing_wasm = wasmExports.ts_node_is_missing_wasm)(e), _ts_node_is_extra_wasm = Module._ts_node_is_extra_wasm = (e)=>(_ts_node_is_extra_wasm = Module._ts_node_is_extra_wasm = wasmExports.ts_node_is_extra_wasm)(e), _ts_node_parse_state_wasm = Module._ts_node_parse_state_wasm = (e)=>(_ts_node_parse_state_wasm = Module._ts_node_parse_state_wasm = wasmExports.ts_node_parse_state_wasm)(e), _ts_node_next_parse_state_wasm = Module._ts_node_next_parse_state_wasm = (e)=>(_ts_node_next_parse_state_wasm = Module._ts_node_next_parse_state_wasm = wasmExports.ts_node_next_parse_state_wasm)(e), _ts_query_matches_wasm = Module._ts_query_matches_wasm = (e, t, _, s, r, a, o, n, l, d)=>(_ts_query_matches_wasm = Module._ts_query_matches_wasm = wasmExports.ts_query_matches_wasm)(e, t, _, s, r, a, o, n, l, d), _ts_query_captures_wasm = Module._ts_query_captures_wasm = (e, t, _, s, r, a, o, n, l, d)=>(_ts_query_captures_wasm = Module._ts_query_captures_wasm = wasmExports.ts_query_captures_wasm)(e, t, _, s, r, a, o, n, l, d), _iswalpha = Module._iswalpha = (e)=>(_iswalpha = Module._iswalpha = wasmExports.iswalpha)(e), _iswblank = Module._iswblank = (e)=>(_iswblank = Module._iswblank = wasmExports.iswblank)(e), _iswdigit = Module._iswdigit = (e)=>(_iswdigit = Module._iswdigit = wasmExports.iswdigit)(e), _iswlower = Module._iswlower = (e)=>(_iswlower = Module._iswlower = wasmExports.iswlower)(e), _iswupper = Module._iswupper = (e)=>(_iswupper = Module._iswupper = wasmExports.iswupper)(e), _iswxdigit = Module._iswxdigit = (e)=>(_iswxdigit = Module._iswxdigit = wasmExports.iswxdigit)(e), _memchr = Module._memchr = (e, t, _)=>(_memchr = Module._memchr = wasmExports.memchr)(e, t, _), _strlen = Module._strlen = (e)=>(_strlen = Module._strlen = wasmExports.strlen)(e), _strcmp = Module._strcmp = (e, t)=>(_strcmp = Module._strcmp = wasmExports.strcmp)(e, t), _strncat = Module._strncat = (e, t, _)=>(_strncat = Module._strncat = wasmExports.strncat)(e, t, _), _strncpy = Module._strncpy = (e, t, _)=>(_strncpy = Module._strncpy = wasmExports.strncpy)(e, t, _), _towlower = Module._towlower = (e)=>(_towlower = Module._towlower = wasmExports.towlower)(e), _towupper = Module._towupper = (e)=>(_towupper = Module._towupper = wasmExports.towupper)(e), _setThrew = (e, t)=>(_setThrew = wasmExports.setThrew)(e, t), stackSave = ()=>(stackSave = wasmExports.stackSave)(), stackRestore = (e)=>(stackRestore = wasmExports.stackRestore)(e), stackAlloc = (e)=>(stackAlloc = wasmExports.stackAlloc)(e), dynCall_jiji = Module.dynCall_jiji = (e, t, _, s, r)=>(dynCall_jiji = Module.dynCall_jiji = wasmExports.dynCall_jiji)(e, t, _, s, r), _orig$ts_parser_timeout_micros = Module._orig$ts_parser_timeout_micros = (e)=>(_orig$ts_parser_timeout_micros = Module._orig$ts_parser_timeout_micros = wasmExports.orig$ts_parser_timeout_micros)(e), _orig$ts_parser_set_timeout_micros = Module._orig$ts_parser_set_timeout_micros = (e, t)=>(_orig$ts_parser_set_timeout_micros = Module._orig$ts_parser_set_timeout_micros = wasmExports.orig$ts_parser_set_timeout_micros)(e, t), calledRun;
|
|
782
|
+
function callMain(e = []) {
|
|
783
|
+
var t = resolveGlobalSymbol("main").sym;
|
|
784
|
+
if (t) {
|
|
785
|
+
e.unshift(thisProgram);
|
|
786
|
+
var _ = e.length, s = stackAlloc(4 * (_ + 1)), r = s;
|
|
787
|
+
e.forEach((e)=>{
|
|
788
|
+
HEAPU32[r >> 2] = stringToUTF8OnStack(e), r += 4;
|
|
789
|
+
}), HEAPU32[r >> 2] = 0;
|
|
790
|
+
try {
|
|
791
|
+
var a = t(_, s);
|
|
792
|
+
return exitJS(a, !0), a;
|
|
793
|
+
} catch (e) {
|
|
794
|
+
return handleException(e);
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
function run(e = arguments_) {
|
|
799
|
+
function t() {
|
|
800
|
+
calledRun || (calledRun = !0, Module.calledRun = !0, ABORT || (initRuntime(), preMain(), Module.onRuntimeInitialized && Module.onRuntimeInitialized(), shouldRunNow && callMain(e), postRun()));
|
|
801
|
+
}
|
|
802
|
+
runDependencies > 0 || (preRun(), runDependencies > 0 || (Module.setStatus ? (Module.setStatus("Running..."), setTimeout(function() {
|
|
803
|
+
setTimeout(function() {
|
|
804
|
+
Module.setStatus("");
|
|
805
|
+
}, 1), t();
|
|
806
|
+
}, 1)) : t()));
|
|
807
|
+
}
|
|
808
|
+
if (Module.AsciiToString = AsciiToString, Module.stringToUTF16 = stringToUTF16, dependenciesFulfilled = function e() {
|
|
809
|
+
calledRun || run(), calledRun || (dependenciesFulfilled = e);
|
|
810
|
+
}, Module.preInit) for("function" == typeof Module.preInit && (Module.preInit = [
|
|
811
|
+
Module.preInit
|
|
812
|
+
]); Module.preInit.length > 0;)Module.preInit.pop()();
|
|
813
|
+
var shouldRunNow = !0;
|
|
814
|
+
Module.noInitialRun && (shouldRunNow = !1), run();
|
|
815
|
+
const C = Module, INTERNAL = {}, SIZE_OF_INT = 4, SIZE_OF_CURSOR = 4 * SIZE_OF_INT, SIZE_OF_NODE = 5 * SIZE_OF_INT, SIZE_OF_POINT = 2 * SIZE_OF_INT, SIZE_OF_RANGE = 2 * SIZE_OF_INT + 2 * SIZE_OF_POINT, ZERO_POINT = {
|
|
816
|
+
row: 0,
|
|
817
|
+
column: 0
|
|
818
|
+
}, QUERY_WORD_REGEX = /[\w-.]*/g, PREDICATE_STEP_TYPE_CAPTURE = 1, PREDICATE_STEP_TYPE_STRING = 2, LANGUAGE_FUNCTION_REGEX = /^_?tree_sitter_\w+/;
|
|
819
|
+
let VERSION, MIN_COMPATIBLE_VERSION, TRANSFER_BUFFER, currentParseCallback, currentLogCallback;
|
|
820
|
+
class ParserImpl {
|
|
821
|
+
static init() {
|
|
822
|
+
TRANSFER_BUFFER = C._ts_init(), VERSION = getValue(TRANSFER_BUFFER, "i32"), MIN_COMPATIBLE_VERSION = getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
|
|
823
|
+
}
|
|
824
|
+
initialize() {
|
|
825
|
+
C._ts_parser_new_wasm(), this[0] = getValue(TRANSFER_BUFFER, "i32"), this[1] = getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
|
|
826
|
+
}
|
|
827
|
+
delete() {
|
|
828
|
+
C._ts_parser_delete(this[0]), C._free(this[1]), this[0] = 0, this[1] = 0;
|
|
829
|
+
}
|
|
830
|
+
setLanguage(e) {
|
|
831
|
+
let t;
|
|
832
|
+
if (e) {
|
|
833
|
+
if (e.constructor !== Language) throw new Error("Argument must be a Language");
|
|
834
|
+
{
|
|
835
|
+
t = e[0];
|
|
836
|
+
const _ = C._ts_language_version(t);
|
|
837
|
+
if (_ < MIN_COMPATIBLE_VERSION || VERSION < _) throw new Error(`Incompatible language version ${_}. Compatibility range ${MIN_COMPATIBLE_VERSION} through ${VERSION}.`);
|
|
838
|
+
}
|
|
839
|
+
} else t = 0, e = null;
|
|
840
|
+
return this.language = e, C._ts_parser_set_language(this[0], t), this;
|
|
841
|
+
}
|
|
842
|
+
getLanguage() {
|
|
843
|
+
return this.language;
|
|
844
|
+
}
|
|
845
|
+
parse(e, t, _) {
|
|
846
|
+
if ("string" == typeof e) currentParseCallback = (t, _)=>e.slice(t);
|
|
847
|
+
else {
|
|
848
|
+
if ("function" != typeof e) throw new Error("Argument must be a string or a function");
|
|
849
|
+
currentParseCallback = e;
|
|
850
|
+
}
|
|
851
|
+
this.logCallback ? (currentLogCallback = this.logCallback, C._ts_parser_enable_logger_wasm(this[0], 1)) : (currentLogCallback = null, C._ts_parser_enable_logger_wasm(this[0], 0));
|
|
852
|
+
let s = 0, r = 0;
|
|
853
|
+
if (_?.includedRanges) {
|
|
854
|
+
s = _.includedRanges.length, r = C._calloc(s, SIZE_OF_RANGE);
|
|
855
|
+
let e = r;
|
|
856
|
+
for(let t = 0; t < s; t++)marshalRange(e, _.includedRanges[t]), e += SIZE_OF_RANGE;
|
|
857
|
+
}
|
|
858
|
+
const a = C._ts_parser_parse_wasm(this[0], this[1], t ? t[0] : 0, r, s);
|
|
859
|
+
if (!a) throw currentParseCallback = null, currentLogCallback = null, new Error("Parsing failed");
|
|
860
|
+
const o = new Tree(INTERNAL, a, this.language, currentParseCallback);
|
|
861
|
+
return currentParseCallback = null, currentLogCallback = null, o;
|
|
862
|
+
}
|
|
863
|
+
reset() {
|
|
864
|
+
C._ts_parser_reset(this[0]);
|
|
865
|
+
}
|
|
866
|
+
getIncludedRanges() {
|
|
867
|
+
C._ts_parser_included_ranges_wasm(this[0]);
|
|
868
|
+
const e = getValue(TRANSFER_BUFFER, "i32"), t = getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32"), _ = new Array(e);
|
|
869
|
+
if (e > 0) {
|
|
870
|
+
let s = t;
|
|
871
|
+
for(let t = 0; t < e; t++)_[t] = unmarshalRange(s), s += SIZE_OF_RANGE;
|
|
872
|
+
C._free(t);
|
|
873
|
+
}
|
|
874
|
+
return _;
|
|
875
|
+
}
|
|
876
|
+
getTimeoutMicros() {
|
|
877
|
+
return C._ts_parser_timeout_micros(this[0]);
|
|
878
|
+
}
|
|
879
|
+
setTimeoutMicros(e) {
|
|
880
|
+
C._ts_parser_set_timeout_micros(this[0], e);
|
|
881
|
+
}
|
|
882
|
+
setLogger(e) {
|
|
883
|
+
if (e) {
|
|
884
|
+
if ("function" != typeof e) throw new Error("Logger callback must be a function");
|
|
885
|
+
} else e = null;
|
|
886
|
+
return this.logCallback = e, this;
|
|
887
|
+
}
|
|
888
|
+
getLogger() {
|
|
889
|
+
return this.logCallback;
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
class Tree {
|
|
893
|
+
constructor(e, t, _, s){
|
|
894
|
+
assertInternal(e), this[0] = t, this.language = _, this.textCallback = s;
|
|
895
|
+
}
|
|
896
|
+
copy() {
|
|
897
|
+
const e = C._ts_tree_copy(this[0]);
|
|
898
|
+
return new Tree(INTERNAL, e, this.language, this.textCallback);
|
|
899
|
+
}
|
|
900
|
+
delete() {
|
|
901
|
+
C._ts_tree_delete(this[0]), this[0] = 0;
|
|
902
|
+
}
|
|
903
|
+
edit(e) {
|
|
904
|
+
marshalEdit(e), C._ts_tree_edit_wasm(this[0]);
|
|
905
|
+
}
|
|
906
|
+
get rootNode() {
|
|
907
|
+
return C._ts_tree_root_node_wasm(this[0]), unmarshalNode(this);
|
|
908
|
+
}
|
|
909
|
+
rootNodeWithOffset(e, t) {
|
|
910
|
+
const _ = TRANSFER_BUFFER + SIZE_OF_NODE;
|
|
911
|
+
return setValue(_, e, "i32"), marshalPoint(_ + SIZE_OF_INT, t), C._ts_tree_root_node_with_offset_wasm(this[0]), unmarshalNode(this);
|
|
912
|
+
}
|
|
913
|
+
getLanguage() {
|
|
914
|
+
return this.language;
|
|
915
|
+
}
|
|
916
|
+
walk() {
|
|
917
|
+
return this.rootNode.walk();
|
|
918
|
+
}
|
|
919
|
+
getChangedRanges(e) {
|
|
920
|
+
if (e.constructor !== Tree) throw new TypeError("Argument must be a Tree");
|
|
921
|
+
C._ts_tree_get_changed_ranges_wasm(this[0], e[0]);
|
|
922
|
+
const t = getValue(TRANSFER_BUFFER, "i32"), _ = getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32"), s = new Array(t);
|
|
923
|
+
if (t > 0) {
|
|
924
|
+
let e = _;
|
|
925
|
+
for(let _ = 0; _ < t; _++)s[_] = unmarshalRange(e), e += SIZE_OF_RANGE;
|
|
926
|
+
C._free(_);
|
|
927
|
+
}
|
|
928
|
+
return s;
|
|
929
|
+
}
|
|
930
|
+
getIncludedRanges() {
|
|
931
|
+
C._ts_tree_included_ranges_wasm(this[0]);
|
|
932
|
+
const e = getValue(TRANSFER_BUFFER, "i32"), t = getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32"), _ = new Array(e);
|
|
933
|
+
if (e > 0) {
|
|
934
|
+
let s = t;
|
|
935
|
+
for(let t = 0; t < e; t++)_[t] = unmarshalRange(s), s += SIZE_OF_RANGE;
|
|
936
|
+
C._free(t);
|
|
937
|
+
}
|
|
938
|
+
return _;
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
class Node {
|
|
942
|
+
constructor(e, t){
|
|
943
|
+
assertInternal(e), this.tree = t;
|
|
944
|
+
}
|
|
945
|
+
get typeId() {
|
|
946
|
+
return marshalNode(this), C._ts_node_symbol_wasm(this.tree[0]);
|
|
947
|
+
}
|
|
948
|
+
get grammarId() {
|
|
949
|
+
return marshalNode(this), C._ts_node_grammar_symbol_wasm(this.tree[0]);
|
|
950
|
+
}
|
|
951
|
+
get type() {
|
|
952
|
+
return this.tree.language.types[this.typeId] || "ERROR";
|
|
953
|
+
}
|
|
954
|
+
get grammarType() {
|
|
955
|
+
return this.tree.language.types[this.grammarId] || "ERROR";
|
|
956
|
+
}
|
|
957
|
+
get endPosition() {
|
|
958
|
+
return marshalNode(this), C._ts_node_end_point_wasm(this.tree[0]), unmarshalPoint(TRANSFER_BUFFER);
|
|
959
|
+
}
|
|
960
|
+
get endIndex() {
|
|
961
|
+
return marshalNode(this), C._ts_node_end_index_wasm(this.tree[0]);
|
|
962
|
+
}
|
|
963
|
+
get text() {
|
|
964
|
+
return getText(this.tree, this.startIndex, this.endIndex);
|
|
965
|
+
}
|
|
966
|
+
get parseState() {
|
|
967
|
+
return marshalNode(this), C._ts_node_parse_state_wasm(this.tree[0]);
|
|
968
|
+
}
|
|
969
|
+
get nextParseState() {
|
|
970
|
+
return marshalNode(this), C._ts_node_next_parse_state_wasm(this.tree[0]);
|
|
971
|
+
}
|
|
972
|
+
get isNamed() {
|
|
973
|
+
return marshalNode(this), 1 === C._ts_node_is_named_wasm(this.tree[0]);
|
|
974
|
+
}
|
|
975
|
+
get hasError() {
|
|
976
|
+
return marshalNode(this), 1 === C._ts_node_has_error_wasm(this.tree[0]);
|
|
977
|
+
}
|
|
978
|
+
get hasChanges() {
|
|
979
|
+
return marshalNode(this), 1 === C._ts_node_has_changes_wasm(this.tree[0]);
|
|
980
|
+
}
|
|
981
|
+
get isError() {
|
|
982
|
+
return marshalNode(this), 1 === C._ts_node_is_error_wasm(this.tree[0]);
|
|
983
|
+
}
|
|
984
|
+
get isMissing() {
|
|
985
|
+
return marshalNode(this), 1 === C._ts_node_is_missing_wasm(this.tree[0]);
|
|
986
|
+
}
|
|
987
|
+
get isExtra() {
|
|
988
|
+
return marshalNode(this), 1 === C._ts_node_is_extra_wasm(this.tree[0]);
|
|
989
|
+
}
|
|
990
|
+
equals(e) {
|
|
991
|
+
return this.id === e.id;
|
|
992
|
+
}
|
|
993
|
+
child(e) {
|
|
994
|
+
return marshalNode(this), C._ts_node_child_wasm(this.tree[0], e), unmarshalNode(this.tree);
|
|
995
|
+
}
|
|
996
|
+
namedChild(e) {
|
|
997
|
+
return marshalNode(this), C._ts_node_named_child_wasm(this.tree[0], e), unmarshalNode(this.tree);
|
|
998
|
+
}
|
|
999
|
+
childForFieldId(e) {
|
|
1000
|
+
return marshalNode(this), C._ts_node_child_by_field_id_wasm(this.tree[0], e), unmarshalNode(this.tree);
|
|
1001
|
+
}
|
|
1002
|
+
childForFieldName(e) {
|
|
1003
|
+
const t = this.tree.language.fields.indexOf(e);
|
|
1004
|
+
return -1 !== t ? this.childForFieldId(t) : null;
|
|
1005
|
+
}
|
|
1006
|
+
fieldNameForChild(e) {
|
|
1007
|
+
marshalNode(this);
|
|
1008
|
+
const t = C._ts_node_field_name_for_child_wasm(this.tree[0], e);
|
|
1009
|
+
if (!t) return null;
|
|
1010
|
+
return AsciiToString(t);
|
|
1011
|
+
}
|
|
1012
|
+
childrenForFieldName(e) {
|
|
1013
|
+
const t = this.tree.language.fields.indexOf(e);
|
|
1014
|
+
return -1 !== t && 0 !== t ? this.childrenForFieldId(t) : [];
|
|
1015
|
+
}
|
|
1016
|
+
childrenForFieldId(e) {
|
|
1017
|
+
marshalNode(this), C._ts_node_children_by_field_id_wasm(this.tree[0], e);
|
|
1018
|
+
const t = getValue(TRANSFER_BUFFER, "i32"), _ = getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32"), s = new Array(t);
|
|
1019
|
+
if (t > 0) {
|
|
1020
|
+
let e = _;
|
|
1021
|
+
for(let _ = 0; _ < t; _++)s[_] = unmarshalNode(this.tree, e), e += SIZE_OF_NODE;
|
|
1022
|
+
C._free(_);
|
|
1023
|
+
}
|
|
1024
|
+
return s;
|
|
1025
|
+
}
|
|
1026
|
+
firstChildForIndex(e) {
|
|
1027
|
+
marshalNode(this);
|
|
1028
|
+
return setValue(TRANSFER_BUFFER + SIZE_OF_NODE, e, "i32"), C._ts_node_first_child_for_byte_wasm(this.tree[0]), unmarshalNode(this.tree);
|
|
1029
|
+
}
|
|
1030
|
+
firstNamedChildForIndex(e) {
|
|
1031
|
+
marshalNode(this);
|
|
1032
|
+
return setValue(TRANSFER_BUFFER + SIZE_OF_NODE, e, "i32"), C._ts_node_first_named_child_for_byte_wasm(this.tree[0]), unmarshalNode(this.tree);
|
|
1033
|
+
}
|
|
1034
|
+
get childCount() {
|
|
1035
|
+
return marshalNode(this), C._ts_node_child_count_wasm(this.tree[0]);
|
|
1036
|
+
}
|
|
1037
|
+
get namedChildCount() {
|
|
1038
|
+
return marshalNode(this), C._ts_node_named_child_count_wasm(this.tree[0]);
|
|
1039
|
+
}
|
|
1040
|
+
get firstChild() {
|
|
1041
|
+
return this.child(0);
|
|
1042
|
+
}
|
|
1043
|
+
get firstNamedChild() {
|
|
1044
|
+
return this.namedChild(0);
|
|
1045
|
+
}
|
|
1046
|
+
get lastChild() {
|
|
1047
|
+
return this.child(this.childCount - 1);
|
|
1048
|
+
}
|
|
1049
|
+
get lastNamedChild() {
|
|
1050
|
+
return this.namedChild(this.namedChildCount - 1);
|
|
1051
|
+
}
|
|
1052
|
+
get children() {
|
|
1053
|
+
if (!this._children) {
|
|
1054
|
+
marshalNode(this), C._ts_node_children_wasm(this.tree[0]);
|
|
1055
|
+
const e = getValue(TRANSFER_BUFFER, "i32"), t = getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
|
|
1056
|
+
if (this._children = new Array(e), e > 0) {
|
|
1057
|
+
let _ = t;
|
|
1058
|
+
for(let t = 0; t < e; t++)this._children[t] = unmarshalNode(this.tree, _), _ += SIZE_OF_NODE;
|
|
1059
|
+
C._free(t);
|
|
1060
|
+
}
|
|
1061
|
+
}
|
|
1062
|
+
return this._children;
|
|
1063
|
+
}
|
|
1064
|
+
get namedChildren() {
|
|
1065
|
+
if (!this._namedChildren) {
|
|
1066
|
+
marshalNode(this), C._ts_node_named_children_wasm(this.tree[0]);
|
|
1067
|
+
const e = getValue(TRANSFER_BUFFER, "i32"), t = getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
|
|
1068
|
+
if (this._namedChildren = new Array(e), e > 0) {
|
|
1069
|
+
let _ = t;
|
|
1070
|
+
for(let t = 0; t < e; t++)this._namedChildren[t] = unmarshalNode(this.tree, _), _ += SIZE_OF_NODE;
|
|
1071
|
+
C._free(t);
|
|
1072
|
+
}
|
|
1073
|
+
}
|
|
1074
|
+
return this._namedChildren;
|
|
1075
|
+
}
|
|
1076
|
+
descendantsOfType(e, t, _) {
|
|
1077
|
+
Array.isArray(e) || (e = [
|
|
1078
|
+
e
|
|
1079
|
+
]), t || (t = ZERO_POINT), _ || (_ = ZERO_POINT);
|
|
1080
|
+
const s = [], r = this.tree.language.types;
|
|
1081
|
+
for(let t = 0, _ = r.length; t < _; t++)e.includes(r[t]) && s.push(t);
|
|
1082
|
+
const a = C._malloc(SIZE_OF_INT * s.length);
|
|
1083
|
+
for(let e = 0, t = s.length; e < t; e++)setValue(a + e * SIZE_OF_INT, s[e], "i32");
|
|
1084
|
+
marshalNode(this), C._ts_node_descendants_of_type_wasm(this.tree[0], a, s.length, t.row, t.column, _.row, _.column);
|
|
1085
|
+
const o = getValue(TRANSFER_BUFFER, "i32"), n = getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32"), l = new Array(o);
|
|
1086
|
+
if (o > 0) {
|
|
1087
|
+
let e = n;
|
|
1088
|
+
for(let t = 0; t < o; t++)l[t] = unmarshalNode(this.tree, e), e += SIZE_OF_NODE;
|
|
1089
|
+
}
|
|
1090
|
+
return C._free(n), C._free(a), l;
|
|
1091
|
+
}
|
|
1092
|
+
get nextSibling() {
|
|
1093
|
+
return marshalNode(this), C._ts_node_next_sibling_wasm(this.tree[0]), unmarshalNode(this.tree);
|
|
1094
|
+
}
|
|
1095
|
+
get previousSibling() {
|
|
1096
|
+
return marshalNode(this), C._ts_node_prev_sibling_wasm(this.tree[0]), unmarshalNode(this.tree);
|
|
1097
|
+
}
|
|
1098
|
+
get nextNamedSibling() {
|
|
1099
|
+
return marshalNode(this), C._ts_node_next_named_sibling_wasm(this.tree[0]), unmarshalNode(this.tree);
|
|
1100
|
+
}
|
|
1101
|
+
get previousNamedSibling() {
|
|
1102
|
+
return marshalNode(this), C._ts_node_prev_named_sibling_wasm(this.tree[0]), unmarshalNode(this.tree);
|
|
1103
|
+
}
|
|
1104
|
+
get descendantCount() {
|
|
1105
|
+
return marshalNode(this), C._ts_node_descendant_count_wasm(this.tree[0]);
|
|
1106
|
+
}
|
|
1107
|
+
get parent() {
|
|
1108
|
+
return marshalNode(this), C._ts_node_parent_wasm(this.tree[0]), unmarshalNode(this.tree);
|
|
1109
|
+
}
|
|
1110
|
+
descendantForIndex(e, t = e) {
|
|
1111
|
+
if ("number" != typeof e || "number" != typeof t) throw new Error("Arguments must be numbers");
|
|
1112
|
+
marshalNode(this);
|
|
1113
|
+
const _ = TRANSFER_BUFFER + SIZE_OF_NODE;
|
|
1114
|
+
return setValue(_, e, "i32"), setValue(_ + SIZE_OF_INT, t, "i32"), C._ts_node_descendant_for_index_wasm(this.tree[0]), unmarshalNode(this.tree);
|
|
1115
|
+
}
|
|
1116
|
+
namedDescendantForIndex(e, t = e) {
|
|
1117
|
+
if ("number" != typeof e || "number" != typeof t) throw new Error("Arguments must be numbers");
|
|
1118
|
+
marshalNode(this);
|
|
1119
|
+
const _ = TRANSFER_BUFFER + SIZE_OF_NODE;
|
|
1120
|
+
return setValue(_, e, "i32"), setValue(_ + SIZE_OF_INT, t, "i32"), C._ts_node_named_descendant_for_index_wasm(this.tree[0]), unmarshalNode(this.tree);
|
|
1121
|
+
}
|
|
1122
|
+
descendantForPosition(e, t = e) {
|
|
1123
|
+
if (!isPoint(e) || !isPoint(t)) throw new Error("Arguments must be {row, column} objects");
|
|
1124
|
+
marshalNode(this);
|
|
1125
|
+
const _ = TRANSFER_BUFFER + SIZE_OF_NODE;
|
|
1126
|
+
return marshalPoint(_, e), marshalPoint(_ + SIZE_OF_POINT, t), C._ts_node_descendant_for_position_wasm(this.tree[0]), unmarshalNode(this.tree);
|
|
1127
|
+
}
|
|
1128
|
+
namedDescendantForPosition(e, t = e) {
|
|
1129
|
+
if (!isPoint(e) || !isPoint(t)) throw new Error("Arguments must be {row, column} objects");
|
|
1130
|
+
marshalNode(this);
|
|
1131
|
+
const _ = TRANSFER_BUFFER + SIZE_OF_NODE;
|
|
1132
|
+
return marshalPoint(_, e), marshalPoint(_ + SIZE_OF_POINT, t), C._ts_node_named_descendant_for_position_wasm(this.tree[0]), unmarshalNode(this.tree);
|
|
1133
|
+
}
|
|
1134
|
+
walk() {
|
|
1135
|
+
return marshalNode(this), C._ts_tree_cursor_new_wasm(this.tree[0]), new TreeCursor(INTERNAL, this.tree);
|
|
1136
|
+
}
|
|
1137
|
+
toString() {
|
|
1138
|
+
marshalNode(this);
|
|
1139
|
+
const e = C._ts_node_to_string_wasm(this.tree[0]), t = AsciiToString(e);
|
|
1140
|
+
return C._free(e), t;
|
|
1141
|
+
}
|
|
1142
|
+
}
|
|
1143
|
+
class TreeCursor {
|
|
1144
|
+
constructor(e, t){
|
|
1145
|
+
assertInternal(e), this.tree = t, unmarshalTreeCursor(this);
|
|
1146
|
+
}
|
|
1147
|
+
delete() {
|
|
1148
|
+
marshalTreeCursor(this), C._ts_tree_cursor_delete_wasm(this.tree[0]), this[0] = this[1] = this[2] = 0;
|
|
1149
|
+
}
|
|
1150
|
+
reset(e) {
|
|
1151
|
+
marshalNode(e), marshalTreeCursor(this, TRANSFER_BUFFER + SIZE_OF_NODE), C._ts_tree_cursor_reset_wasm(this.tree[0]), unmarshalTreeCursor(this);
|
|
1152
|
+
}
|
|
1153
|
+
resetTo(e) {
|
|
1154
|
+
marshalTreeCursor(this, TRANSFER_BUFFER), marshalTreeCursor(e, TRANSFER_BUFFER + SIZE_OF_CURSOR), C._ts_tree_cursor_reset_to_wasm(this.tree[0], e.tree[0]), unmarshalTreeCursor(this);
|
|
1155
|
+
}
|
|
1156
|
+
get nodeType() {
|
|
1157
|
+
return this.tree.language.types[this.nodeTypeId] || "ERROR";
|
|
1158
|
+
}
|
|
1159
|
+
get nodeTypeId() {
|
|
1160
|
+
return marshalTreeCursor(this), C._ts_tree_cursor_current_node_type_id_wasm(this.tree[0]);
|
|
1161
|
+
}
|
|
1162
|
+
get nodeStateId() {
|
|
1163
|
+
return marshalTreeCursor(this), C._ts_tree_cursor_current_node_state_id_wasm(this.tree[0]);
|
|
1164
|
+
}
|
|
1165
|
+
get nodeId() {
|
|
1166
|
+
return marshalTreeCursor(this), C._ts_tree_cursor_current_node_id_wasm(this.tree[0]);
|
|
1167
|
+
}
|
|
1168
|
+
get nodeIsNamed() {
|
|
1169
|
+
return marshalTreeCursor(this), 1 === C._ts_tree_cursor_current_node_is_named_wasm(this.tree[0]);
|
|
1170
|
+
}
|
|
1171
|
+
get nodeIsMissing() {
|
|
1172
|
+
return marshalTreeCursor(this), 1 === C._ts_tree_cursor_current_node_is_missing_wasm(this.tree[0]);
|
|
1173
|
+
}
|
|
1174
|
+
get nodeText() {
|
|
1175
|
+
marshalTreeCursor(this);
|
|
1176
|
+
const e = C._ts_tree_cursor_start_index_wasm(this.tree[0]), t = C._ts_tree_cursor_end_index_wasm(this.tree[0]);
|
|
1177
|
+
return getText(this.tree, e, t);
|
|
1178
|
+
}
|
|
1179
|
+
get startPosition() {
|
|
1180
|
+
return marshalTreeCursor(this), C._ts_tree_cursor_start_position_wasm(this.tree[0]), unmarshalPoint(TRANSFER_BUFFER);
|
|
1181
|
+
}
|
|
1182
|
+
get endPosition() {
|
|
1183
|
+
return marshalTreeCursor(this), C._ts_tree_cursor_end_position_wasm(this.tree[0]), unmarshalPoint(TRANSFER_BUFFER);
|
|
1184
|
+
}
|
|
1185
|
+
get startIndex() {
|
|
1186
|
+
return marshalTreeCursor(this), C._ts_tree_cursor_start_index_wasm(this.tree[0]);
|
|
1187
|
+
}
|
|
1188
|
+
get endIndex() {
|
|
1189
|
+
return marshalTreeCursor(this), C._ts_tree_cursor_end_index_wasm(this.tree[0]);
|
|
1190
|
+
}
|
|
1191
|
+
get currentNode() {
|
|
1192
|
+
return marshalTreeCursor(this), C._ts_tree_cursor_current_node_wasm(this.tree[0]), unmarshalNode(this.tree);
|
|
1193
|
+
}
|
|
1194
|
+
get currentFieldId() {
|
|
1195
|
+
return marshalTreeCursor(this), C._ts_tree_cursor_current_field_id_wasm(this.tree[0]);
|
|
1196
|
+
}
|
|
1197
|
+
get currentFieldName() {
|
|
1198
|
+
return this.tree.language.fields[this.currentFieldId];
|
|
1199
|
+
}
|
|
1200
|
+
get currentDepth() {
|
|
1201
|
+
return marshalTreeCursor(this), C._ts_tree_cursor_current_depth_wasm(this.tree[0]);
|
|
1202
|
+
}
|
|
1203
|
+
get currentDescendantIndex() {
|
|
1204
|
+
return marshalTreeCursor(this), C._ts_tree_cursor_current_descendant_index_wasm(this.tree[0]);
|
|
1205
|
+
}
|
|
1206
|
+
gotoFirstChild() {
|
|
1207
|
+
marshalTreeCursor(this);
|
|
1208
|
+
const e = C._ts_tree_cursor_goto_first_child_wasm(this.tree[0]);
|
|
1209
|
+
return unmarshalTreeCursor(this), 1 === e;
|
|
1210
|
+
}
|
|
1211
|
+
gotoLastChild() {
|
|
1212
|
+
marshalTreeCursor(this);
|
|
1213
|
+
const e = C._ts_tree_cursor_goto_last_child_wasm(this.tree[0]);
|
|
1214
|
+
return unmarshalTreeCursor(this), 1 === e;
|
|
1215
|
+
}
|
|
1216
|
+
gotoFirstChildForIndex(e) {
|
|
1217
|
+
marshalTreeCursor(this), setValue(TRANSFER_BUFFER + SIZE_OF_CURSOR, e, "i32");
|
|
1218
|
+
const t = C._ts_tree_cursor_goto_first_child_for_index_wasm(this.tree[0]);
|
|
1219
|
+
return unmarshalTreeCursor(this), 1 === t;
|
|
1220
|
+
}
|
|
1221
|
+
gotoFirstChildForPosition(e) {
|
|
1222
|
+
marshalTreeCursor(this), marshalPoint(TRANSFER_BUFFER + SIZE_OF_CURSOR, e);
|
|
1223
|
+
const t = C._ts_tree_cursor_goto_first_child_for_position_wasm(this.tree[0]);
|
|
1224
|
+
return unmarshalTreeCursor(this), 1 === t;
|
|
1225
|
+
}
|
|
1226
|
+
gotoNextSibling() {
|
|
1227
|
+
marshalTreeCursor(this);
|
|
1228
|
+
const e = C._ts_tree_cursor_goto_next_sibling_wasm(this.tree[0]);
|
|
1229
|
+
return unmarshalTreeCursor(this), 1 === e;
|
|
1230
|
+
}
|
|
1231
|
+
gotoPreviousSibling() {
|
|
1232
|
+
marshalTreeCursor(this);
|
|
1233
|
+
const e = C._ts_tree_cursor_goto_previous_sibling_wasm(this.tree[0]);
|
|
1234
|
+
return unmarshalTreeCursor(this), 1 === e;
|
|
1235
|
+
}
|
|
1236
|
+
gotoDescendant(e) {
|
|
1237
|
+
marshalTreeCursor(this), C._ts_tree_cursor_goto_descendant_wasm(this.tree[0], e), unmarshalTreeCursor(this);
|
|
1238
|
+
}
|
|
1239
|
+
gotoParent() {
|
|
1240
|
+
marshalTreeCursor(this);
|
|
1241
|
+
const e = C._ts_tree_cursor_goto_parent_wasm(this.tree[0]);
|
|
1242
|
+
return unmarshalTreeCursor(this), 1 === e;
|
|
1243
|
+
}
|
|
1244
|
+
}
|
|
1245
|
+
class Language {
|
|
1246
|
+
constructor(e, t){
|
|
1247
|
+
assertInternal(e), this[0] = t, this.types = new Array(C._ts_language_symbol_count(this[0]));
|
|
1248
|
+
for(let e = 0, t = this.types.length; e < t; e++)C._ts_language_symbol_type(this[0], e) < 2 && (this.types[e] = UTF8ToString(C._ts_language_symbol_name(this[0], e)));
|
|
1249
|
+
this.fields = new Array(C._ts_language_field_count(this[0]) + 1);
|
|
1250
|
+
for(let e = 0, t = this.fields.length; e < t; e++){
|
|
1251
|
+
const t = C._ts_language_field_name_for_id(this[0], e);
|
|
1252
|
+
this.fields[e] = 0 !== t ? UTF8ToString(t) : null;
|
|
1253
|
+
}
|
|
1254
|
+
}
|
|
1255
|
+
get version() {
|
|
1256
|
+
return C._ts_language_version(this[0]);
|
|
1257
|
+
}
|
|
1258
|
+
get fieldCount() {
|
|
1259
|
+
return this.fields.length - 1;
|
|
1260
|
+
}
|
|
1261
|
+
get stateCount() {
|
|
1262
|
+
return C._ts_language_state_count(this[0]);
|
|
1263
|
+
}
|
|
1264
|
+
fieldIdForName(e) {
|
|
1265
|
+
const t = this.fields.indexOf(e);
|
|
1266
|
+
return -1 !== t ? t : null;
|
|
1267
|
+
}
|
|
1268
|
+
fieldNameForId(e) {
|
|
1269
|
+
return this.fields[e] || null;
|
|
1270
|
+
}
|
|
1271
|
+
idForNodeType(e, t) {
|
|
1272
|
+
const _ = lengthBytesUTF8(e), s = C._malloc(_ + 1);
|
|
1273
|
+
stringToUTF8(e, s, _ + 1);
|
|
1274
|
+
const r = C._ts_language_symbol_for_name(this[0], s, _, t);
|
|
1275
|
+
return C._free(s), r || null;
|
|
1276
|
+
}
|
|
1277
|
+
get nodeTypeCount() {
|
|
1278
|
+
return C._ts_language_symbol_count(this[0]);
|
|
1279
|
+
}
|
|
1280
|
+
nodeTypeForId(e) {
|
|
1281
|
+
const t = C._ts_language_symbol_name(this[0], e);
|
|
1282
|
+
return t ? UTF8ToString(t) : null;
|
|
1283
|
+
}
|
|
1284
|
+
nodeTypeIsNamed(e) {
|
|
1285
|
+
return !!C._ts_language_type_is_named_wasm(this[0], e);
|
|
1286
|
+
}
|
|
1287
|
+
nodeTypeIsVisible(e) {
|
|
1288
|
+
return !!C._ts_language_type_is_visible_wasm(this[0], e);
|
|
1289
|
+
}
|
|
1290
|
+
nextState(e, t) {
|
|
1291
|
+
return C._ts_language_next_state(this[0], e, t);
|
|
1292
|
+
}
|
|
1293
|
+
lookaheadIterator(e) {
|
|
1294
|
+
const t = C._ts_lookahead_iterator_new(this[0], e);
|
|
1295
|
+
return t ? new LookaheadIterable(INTERNAL, t, this) : null;
|
|
1296
|
+
}
|
|
1297
|
+
query(e) {
|
|
1298
|
+
const t = lengthBytesUTF8(e), _ = C._malloc(t + 1);
|
|
1299
|
+
stringToUTF8(e, _, t + 1);
|
|
1300
|
+
const s = C._ts_query_new(this[0], _, t, TRANSFER_BUFFER, TRANSFER_BUFFER + SIZE_OF_INT);
|
|
1301
|
+
if (!s) {
|
|
1302
|
+
const t = getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32"), s = getValue(TRANSFER_BUFFER, "i32"), r = UTF8ToString(_, s).length, a = e.substr(r, 100).split("\n")[0];
|
|
1303
|
+
let o, n = a.match(QUERY_WORD_REGEX)[0];
|
|
1304
|
+
switch(t){
|
|
1305
|
+
case 2:
|
|
1306
|
+
o = new RangeError(`Bad node name '${n}'`);
|
|
1307
|
+
break;
|
|
1308
|
+
case 3:
|
|
1309
|
+
o = new RangeError(`Bad field name '${n}'`);
|
|
1310
|
+
break;
|
|
1311
|
+
case 4:
|
|
1312
|
+
o = new RangeError(`Bad capture name @${n}`);
|
|
1313
|
+
break;
|
|
1314
|
+
case 5:
|
|
1315
|
+
o = new TypeError(`Bad pattern structure at offset ${r}: '${a}'...`), n = "";
|
|
1316
|
+
break;
|
|
1317
|
+
default:
|
|
1318
|
+
o = new SyntaxError(`Bad syntax at offset ${r}: '${a}'...`), n = "";
|
|
1319
|
+
}
|
|
1320
|
+
throw o.index = r, o.length = n.length, C._free(_), o;
|
|
1321
|
+
}
|
|
1322
|
+
const r = C._ts_query_string_count(s), a = C._ts_query_capture_count(s), o = C._ts_query_pattern_count(s), n = new Array(a), l = new Array(r);
|
|
1323
|
+
for(let e = 0; e < a; e++){
|
|
1324
|
+
const t = C._ts_query_capture_name_for_id(s, e, TRANSFER_BUFFER), _ = getValue(TRANSFER_BUFFER, "i32");
|
|
1325
|
+
n[e] = UTF8ToString(t, _);
|
|
1326
|
+
}
|
|
1327
|
+
for(let e = 0; e < r; e++){
|
|
1328
|
+
const t = C._ts_query_string_value_for_id(s, e, TRANSFER_BUFFER), _ = getValue(TRANSFER_BUFFER, "i32");
|
|
1329
|
+
l[e] = UTF8ToString(t, _);
|
|
1330
|
+
}
|
|
1331
|
+
const d = new Array(o), u = new Array(o), m = new Array(o), c = new Array(o), w = new Array(o);
|
|
1332
|
+
for(let e = 0; e < o; e++){
|
|
1333
|
+
const t = C._ts_query_predicates_for_pattern(s, e, TRANSFER_BUFFER), _ = getValue(TRANSFER_BUFFER, "i32");
|
|
1334
|
+
c[e] = [], w[e] = [];
|
|
1335
|
+
const r = [];
|
|
1336
|
+
let a = t;
|
|
1337
|
+
for(let t = 0; t < _; t++){
|
|
1338
|
+
const t = getValue(a, "i32");
|
|
1339
|
+
a += SIZE_OF_INT;
|
|
1340
|
+
const _ = getValue(a, "i32");
|
|
1341
|
+
if (a += SIZE_OF_INT, t === PREDICATE_STEP_TYPE_CAPTURE) r.push({
|
|
1342
|
+
type: "capture",
|
|
1343
|
+
name: n[_]
|
|
1344
|
+
});
|
|
1345
|
+
else if (t === PREDICATE_STEP_TYPE_STRING) r.push({
|
|
1346
|
+
type: "string",
|
|
1347
|
+
value: l[_]
|
|
1348
|
+
});
|
|
1349
|
+
else if (r.length > 0) {
|
|
1350
|
+
if ("string" !== r[0].type) throw new Error("Predicates must begin with a literal value");
|
|
1351
|
+
const t = r[0].value;
|
|
1352
|
+
let _, s = !0, a = !0;
|
|
1353
|
+
switch(t){
|
|
1354
|
+
case "any-not-eq?":
|
|
1355
|
+
case "not-eq?":
|
|
1356
|
+
s = !1;
|
|
1357
|
+
case "any-eq?":
|
|
1358
|
+
case "eq?":
|
|
1359
|
+
if (3 !== r.length) throw new Error(`Wrong number of arguments to \`#${t}\` predicate. Expected 2, got ${r.length - 1}`);
|
|
1360
|
+
if ("capture" !== r[1].type) throw new Error(`First argument of \`#${t}\` predicate must be a capture. Got "${r[1].value}"`);
|
|
1361
|
+
if (a = !t.startsWith("any-"), "capture" === r[2].type) {
|
|
1362
|
+
const t = r[1].name, _ = r[2].name;
|
|
1363
|
+
w[e].push((e)=>{
|
|
1364
|
+
const r = [], o = [];
|
|
1365
|
+
for (const s of e)s.name === t && r.push(s.node), s.name === _ && o.push(s.node);
|
|
1366
|
+
const n = (e, t, _)=>_ ? e.text === t.text : e.text !== t.text;
|
|
1367
|
+
return a ? r.every((e)=>o.some((t)=>n(e, t, s))) : r.some((e)=>o.some((t)=>n(e, t, s)));
|
|
1368
|
+
});
|
|
1369
|
+
} else {
|
|
1370
|
+
_ = r[1].name;
|
|
1371
|
+
const t = r[2].value, o = (e)=>e.text === t, n = (e)=>e.text !== t;
|
|
1372
|
+
w[e].push((e)=>{
|
|
1373
|
+
const t = [];
|
|
1374
|
+
for (const s of e)s.name === _ && t.push(s.node);
|
|
1375
|
+
const r = s ? o : n;
|
|
1376
|
+
return a ? t.every(r) : t.some(r);
|
|
1377
|
+
});
|
|
1378
|
+
}
|
|
1379
|
+
break;
|
|
1380
|
+
case "any-not-match?":
|
|
1381
|
+
case "not-match?":
|
|
1382
|
+
s = !1;
|
|
1383
|
+
case "any-match?":
|
|
1384
|
+
case "match?":
|
|
1385
|
+
if (3 !== r.length) throw new Error(`Wrong number of arguments to \`#${t}\` predicate. Expected 2, got ${r.length - 1}.`);
|
|
1386
|
+
if ("capture" !== r[1].type) throw new Error(`First argument of \`#${t}\` predicate must be a capture. Got "${r[1].value}".`);
|
|
1387
|
+
if ("string" !== r[2].type) throw new Error(`Second argument of \`#${t}\` predicate must be a string. Got @${r[2].value}.`);
|
|
1388
|
+
_ = r[1].name;
|
|
1389
|
+
const o = new RegExp(r[2].value);
|
|
1390
|
+
a = !t.startsWith("any-"), w[e].push((e)=>{
|
|
1391
|
+
const t = [];
|
|
1392
|
+
for (const s of e)s.name === _ && t.push(s.node.text);
|
|
1393
|
+
const r = (e, t)=>t ? o.test(e) : !o.test(e);
|
|
1394
|
+
return 0 === t.length ? !s : a ? t.every((e)=>r(e, s)) : t.some((e)=>r(e, s));
|
|
1395
|
+
});
|
|
1396
|
+
break;
|
|
1397
|
+
case "set!":
|
|
1398
|
+
if (r.length < 2 || r.length > 3) throw new Error(`Wrong number of arguments to \`#set!\` predicate. Expected 1 or 2. Got ${r.length - 1}.`);
|
|
1399
|
+
if (r.some((e)=>"string" !== e.type)) throw new Error('Arguments to `#set!` predicate must be a strings.".');
|
|
1400
|
+
d[e] || (d[e] = {}), d[e][r[1].value] = r[2] ? r[2].value : null;
|
|
1401
|
+
break;
|
|
1402
|
+
case "is?":
|
|
1403
|
+
case "is-not?":
|
|
1404
|
+
if (r.length < 2 || r.length > 3) throw new Error(`Wrong number of arguments to \`#${t}\` predicate. Expected 1 or 2. Got ${r.length - 1}.`);
|
|
1405
|
+
if (r.some((e)=>"string" !== e.type)) throw new Error(`Arguments to \`#${t}\` predicate must be a strings.".`);
|
|
1406
|
+
const n = "is?" === t ? u : m;
|
|
1407
|
+
n[e] || (n[e] = {}), n[e][r[1].value] = r[2] ? r[2].value : null;
|
|
1408
|
+
break;
|
|
1409
|
+
case "not-any-of?":
|
|
1410
|
+
s = !1;
|
|
1411
|
+
case "any-of?":
|
|
1412
|
+
if (r.length < 2) throw new Error(`Wrong number of arguments to \`#${t}\` predicate. Expected at least 1. Got ${r.length - 1}.`);
|
|
1413
|
+
if ("capture" !== r[1].type) throw new Error(`First argument of \`#${t}\` predicate must be a capture. Got "${r[1].value}".`);
|
|
1414
|
+
for(let e = 2; e < r.length; e++)if ("string" !== r[e].type) throw new Error(`Arguments to \`#${t}\` predicate must be a strings.".`);
|
|
1415
|
+
_ = r[1].name;
|
|
1416
|
+
const l = r.slice(2).map((e)=>e.value);
|
|
1417
|
+
w[e].push((e)=>{
|
|
1418
|
+
const t = [];
|
|
1419
|
+
for (const s of e)s.name === _ && t.push(s.node.text);
|
|
1420
|
+
return 0 === t.length ? !s : t.every((e)=>l.includes(e)) === s;
|
|
1421
|
+
});
|
|
1422
|
+
break;
|
|
1423
|
+
default:
|
|
1424
|
+
c[e].push({
|
|
1425
|
+
operator: t,
|
|
1426
|
+
operands: r.slice(1)
|
|
1427
|
+
});
|
|
1428
|
+
}
|
|
1429
|
+
r.length = 0;
|
|
1430
|
+
}
|
|
1431
|
+
}
|
|
1432
|
+
Object.freeze(d[e]), Object.freeze(u[e]), Object.freeze(m[e]);
|
|
1433
|
+
}
|
|
1434
|
+
return C._free(_), new Query(INTERNAL, s, n, w, c, Object.freeze(d), Object.freeze(u), Object.freeze(m));
|
|
1435
|
+
}
|
|
1436
|
+
static load(e) {
|
|
1437
|
+
let t;
|
|
1438
|
+
if (e instanceof Uint8Array) t = Promise.resolve(e);
|
|
1439
|
+
else {
|
|
1440
|
+
const _ = e;
|
|
1441
|
+
if ("undefined" != typeof $jGIDp && $jGIDp.versions && $jGIDp.versions.node) {
|
|
1442
|
+
const e = (parcelRequire("jGIDp"));
|
|
1443
|
+
t = Promise.resolve(e.readFileSync(_));
|
|
1444
|
+
} else t = fetch(_).then((e)=>e.arrayBuffer().then((t)=>{
|
|
1445
|
+
if (e.ok) return new Uint8Array(t);
|
|
1446
|
+
{
|
|
1447
|
+
const _ = new TextDecoder("utf-8").decode(t);
|
|
1448
|
+
throw new Error(`Language.load failed with status ${e.status}.\n\n${_}`);
|
|
1449
|
+
}
|
|
1450
|
+
}));
|
|
1451
|
+
}
|
|
1452
|
+
return t.then((e)=>loadWebAssemblyModule(e, {
|
|
1453
|
+
loadAsync: !0
|
|
1454
|
+
})).then((e)=>{
|
|
1455
|
+
const t = Object.keys(e), _ = t.find((e)=>LANGUAGE_FUNCTION_REGEX.test(e) && !e.includes("external_scanner_"));
|
|
1456
|
+
_ || console.log(`Couldn't find language function in WASM file. Symbols:\n${JSON.stringify(t, null, 2)}`);
|
|
1457
|
+
const s = e[_]();
|
|
1458
|
+
return new Language(INTERNAL, s);
|
|
1459
|
+
});
|
|
1460
|
+
}
|
|
1461
|
+
}
|
|
1462
|
+
class LookaheadIterable {
|
|
1463
|
+
constructor(e, t, _){
|
|
1464
|
+
assertInternal(e), this[0] = t, this.language = _;
|
|
1465
|
+
}
|
|
1466
|
+
get currentTypeId() {
|
|
1467
|
+
return C._ts_lookahead_iterator_current_symbol(this[0]);
|
|
1468
|
+
}
|
|
1469
|
+
get currentType() {
|
|
1470
|
+
return this.language.types[this.currentTypeId] || "ERROR";
|
|
1471
|
+
}
|
|
1472
|
+
delete() {
|
|
1473
|
+
C._ts_lookahead_iterator_delete(this[0]), this[0] = 0;
|
|
1474
|
+
}
|
|
1475
|
+
resetState(e) {
|
|
1476
|
+
return C._ts_lookahead_iterator_reset_state(this[0], e);
|
|
1477
|
+
}
|
|
1478
|
+
reset(e, t) {
|
|
1479
|
+
return !!C._ts_lookahead_iterator_reset(this[0], e[0], t) && (this.language = e, !0);
|
|
1480
|
+
}
|
|
1481
|
+
[Symbol.iterator]() {
|
|
1482
|
+
const e = this;
|
|
1483
|
+
return {
|
|
1484
|
+
next: ()=>C._ts_lookahead_iterator_next(e[0]) ? {
|
|
1485
|
+
done: !1,
|
|
1486
|
+
value: e.currentType
|
|
1487
|
+
} : {
|
|
1488
|
+
done: !0,
|
|
1489
|
+
value: ""
|
|
1490
|
+
}
|
|
1491
|
+
};
|
|
1492
|
+
}
|
|
1493
|
+
}
|
|
1494
|
+
class Query {
|
|
1495
|
+
constructor(e, t, _, s, r, a, o, n){
|
|
1496
|
+
assertInternal(e), this[0] = t, this.captureNames = _, this.textPredicates = s, this.predicates = r, this.setProperties = a, this.assertedProperties = o, this.refutedProperties = n, this.exceededMatchLimit = !1;
|
|
1497
|
+
}
|
|
1498
|
+
delete() {
|
|
1499
|
+
C._ts_query_delete(this[0]), this[0] = 0;
|
|
1500
|
+
}
|
|
1501
|
+
matches(e, { startPosition: t = ZERO_POINT, endPosition: _ = ZERO_POINT, startIndex: s = 0, endIndex: r = 0, matchLimit: a = 4294967295, maxStartDepth: o = 4294967295 } = {}) {
|
|
1502
|
+
if ("number" != typeof a) throw new Error("Arguments must be numbers");
|
|
1503
|
+
marshalNode(e), C._ts_query_matches_wasm(this[0], e.tree[0], t.row, t.column, _.row, _.column, s, r, a, o);
|
|
1504
|
+
const n = getValue(TRANSFER_BUFFER, "i32"), l = getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32"), d = getValue(TRANSFER_BUFFER + 2 * SIZE_OF_INT, "i32"), u = new Array(n);
|
|
1505
|
+
this.exceededMatchLimit = Boolean(d);
|
|
1506
|
+
let m = 0, c = l;
|
|
1507
|
+
for(let t = 0; t < n; t++){
|
|
1508
|
+
const t = getValue(c, "i32");
|
|
1509
|
+
c += SIZE_OF_INT;
|
|
1510
|
+
const _ = getValue(c, "i32");
|
|
1511
|
+
c += SIZE_OF_INT;
|
|
1512
|
+
const s = new Array(_);
|
|
1513
|
+
if (c = unmarshalCaptures(this, e.tree, c, s), this.textPredicates[t].every((e)=>e(s))) {
|
|
1514
|
+
u[m] = {
|
|
1515
|
+
pattern: t,
|
|
1516
|
+
captures: s
|
|
1517
|
+
};
|
|
1518
|
+
const e = this.setProperties[t];
|
|
1519
|
+
e && (u[m].setProperties = e);
|
|
1520
|
+
const _ = this.assertedProperties[t];
|
|
1521
|
+
_ && (u[m].assertedProperties = _);
|
|
1522
|
+
const r = this.refutedProperties[t];
|
|
1523
|
+
r && (u[m].refutedProperties = r), m++;
|
|
1524
|
+
}
|
|
1525
|
+
}
|
|
1526
|
+
return u.length = m, C._free(l), u;
|
|
1527
|
+
}
|
|
1528
|
+
captures(e, { startPosition: t = ZERO_POINT, endPosition: _ = ZERO_POINT, startIndex: s = 0, endIndex: r = 0, matchLimit: a = 4294967295, maxStartDepth: o = 4294967295 } = {}) {
|
|
1529
|
+
if ("number" != typeof a) throw new Error("Arguments must be numbers");
|
|
1530
|
+
marshalNode(e), C._ts_query_captures_wasm(this[0], e.tree[0], t.row, t.column, _.row, _.column, s, r, a, o);
|
|
1531
|
+
const n = getValue(TRANSFER_BUFFER, "i32"), l = getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32"), d = getValue(TRANSFER_BUFFER + 2 * SIZE_OF_INT, "i32"), u = [];
|
|
1532
|
+
this.exceededMatchLimit = Boolean(d);
|
|
1533
|
+
const m = [];
|
|
1534
|
+
let c = l;
|
|
1535
|
+
for(let t = 0; t < n; t++){
|
|
1536
|
+
const t = getValue(c, "i32");
|
|
1537
|
+
c += SIZE_OF_INT;
|
|
1538
|
+
const _ = getValue(c, "i32");
|
|
1539
|
+
c += SIZE_OF_INT;
|
|
1540
|
+
const s = getValue(c, "i32");
|
|
1541
|
+
if (c += SIZE_OF_INT, m.length = _, c = unmarshalCaptures(this, e.tree, c, m), this.textPredicates[t].every((e)=>e(m))) {
|
|
1542
|
+
const e = m[s], _ = this.setProperties[t];
|
|
1543
|
+
_ && (e.setProperties = _);
|
|
1544
|
+
const r = this.assertedProperties[t];
|
|
1545
|
+
r && (e.assertedProperties = r);
|
|
1546
|
+
const a = this.refutedProperties[t];
|
|
1547
|
+
a && (e.refutedProperties = a), u.push(e);
|
|
1548
|
+
}
|
|
1549
|
+
}
|
|
1550
|
+
return C._free(l), u;
|
|
1551
|
+
}
|
|
1552
|
+
predicatesForPattern(e) {
|
|
1553
|
+
return this.predicates[e];
|
|
1554
|
+
}
|
|
1555
|
+
disableCapture(e) {
|
|
1556
|
+
const t = lengthBytesUTF8(e), _ = C._malloc(t + 1);
|
|
1557
|
+
stringToUTF8(e, _, t + 1), C._ts_query_disable_capture(this[0], _, t), C._free(_);
|
|
1558
|
+
}
|
|
1559
|
+
didExceedMatchLimit() {
|
|
1560
|
+
return this.exceededMatchLimit;
|
|
1561
|
+
}
|
|
1562
|
+
}
|
|
1563
|
+
function getText(e, t, _) {
|
|
1564
|
+
const s = _ - t;
|
|
1565
|
+
let r = e.textCallback(t, null, _);
|
|
1566
|
+
for(t += r.length; t < _;){
|
|
1567
|
+
const s = e.textCallback(t, null, _);
|
|
1568
|
+
if (!(s && s.length > 0)) break;
|
|
1569
|
+
t += s.length, r += s;
|
|
1570
|
+
}
|
|
1571
|
+
return t > _ && (r = r.slice(0, s)), r;
|
|
1572
|
+
}
|
|
1573
|
+
function unmarshalCaptures(e, t, _, s) {
|
|
1574
|
+
for(let r = 0, a = s.length; r < a; r++){
|
|
1575
|
+
const a = getValue(_, "i32"), o = unmarshalNode(t, _ += SIZE_OF_INT);
|
|
1576
|
+
_ += SIZE_OF_NODE, s[r] = {
|
|
1577
|
+
name: e.captureNames[a],
|
|
1578
|
+
node: o
|
|
1579
|
+
};
|
|
1580
|
+
}
|
|
1581
|
+
return _;
|
|
1582
|
+
}
|
|
1583
|
+
function assertInternal(e) {
|
|
1584
|
+
if (e !== INTERNAL) throw new Error("Illegal constructor");
|
|
1585
|
+
}
|
|
1586
|
+
function isPoint(e) {
|
|
1587
|
+
return e && "number" == typeof e.row && "number" == typeof e.column;
|
|
1588
|
+
}
|
|
1589
|
+
function marshalNode(e) {
|
|
1590
|
+
let t = TRANSFER_BUFFER;
|
|
1591
|
+
setValue(t, e.id, "i32"), t += SIZE_OF_INT, setValue(t, e.startIndex, "i32"), t += SIZE_OF_INT, setValue(t, e.startPosition.row, "i32"), t += SIZE_OF_INT, setValue(t, e.startPosition.column, "i32"), t += SIZE_OF_INT, setValue(t, e[0], "i32");
|
|
1592
|
+
}
|
|
1593
|
+
function unmarshalNode(e, t = TRANSFER_BUFFER) {
|
|
1594
|
+
const _ = getValue(t, "i32");
|
|
1595
|
+
if (0 === _) return null;
|
|
1596
|
+
const s = getValue(t += SIZE_OF_INT, "i32"), r = getValue(t += SIZE_OF_INT, "i32"), a = getValue(t += SIZE_OF_INT, "i32"), o = getValue(t += SIZE_OF_INT, "i32"), n = new Node(INTERNAL, e);
|
|
1597
|
+
return n.id = _, n.startIndex = s, n.startPosition = {
|
|
1598
|
+
row: r,
|
|
1599
|
+
column: a
|
|
1600
|
+
}, n[0] = o, n;
|
|
1601
|
+
}
|
|
1602
|
+
function marshalTreeCursor(e, t = TRANSFER_BUFFER) {
|
|
1603
|
+
setValue(t + 0 * SIZE_OF_INT, e[0], "i32"), setValue(t + 1 * SIZE_OF_INT, e[1], "i32"), setValue(t + 2 * SIZE_OF_INT, e[2], "i32"), setValue(t + 3 * SIZE_OF_INT, e[3], "i32");
|
|
1604
|
+
}
|
|
1605
|
+
function unmarshalTreeCursor(e) {
|
|
1606
|
+
e[0] = getValue(TRANSFER_BUFFER + 0 * SIZE_OF_INT, "i32"), e[1] = getValue(TRANSFER_BUFFER + 1 * SIZE_OF_INT, "i32"), e[2] = getValue(TRANSFER_BUFFER + 2 * SIZE_OF_INT, "i32"), e[3] = getValue(TRANSFER_BUFFER + 3 * SIZE_OF_INT, "i32");
|
|
1607
|
+
}
|
|
1608
|
+
function marshalPoint(e, t) {
|
|
1609
|
+
setValue(e, t.row, "i32"), setValue(e + SIZE_OF_INT, t.column, "i32");
|
|
1610
|
+
}
|
|
1611
|
+
function unmarshalPoint(e) {
|
|
1612
|
+
return {
|
|
1613
|
+
row: getValue(e, "i32") >>> 0,
|
|
1614
|
+
column: getValue(e + SIZE_OF_INT, "i32") >>> 0
|
|
1615
|
+
};
|
|
1616
|
+
}
|
|
1617
|
+
function marshalRange(e, t) {
|
|
1618
|
+
marshalPoint(e, t.startPosition), marshalPoint(e += SIZE_OF_POINT, t.endPosition), setValue(e += SIZE_OF_POINT, t.startIndex, "i32"), setValue(e += SIZE_OF_INT, t.endIndex, "i32"), e += SIZE_OF_INT;
|
|
1619
|
+
}
|
|
1620
|
+
function unmarshalRange(e) {
|
|
1621
|
+
const t = {};
|
|
1622
|
+
return t.startPosition = unmarshalPoint(e), e += SIZE_OF_POINT, t.endPosition = unmarshalPoint(e), e += SIZE_OF_POINT, t.startIndex = getValue(e, "i32") >>> 0, e += SIZE_OF_INT, t.endIndex = getValue(e, "i32") >>> 0, t;
|
|
1623
|
+
}
|
|
1624
|
+
function marshalEdit(e) {
|
|
1625
|
+
let t = TRANSFER_BUFFER;
|
|
1626
|
+
marshalPoint(t, e.startPosition), t += SIZE_OF_POINT, marshalPoint(t, e.oldEndPosition), t += SIZE_OF_POINT, marshalPoint(t, e.newEndPosition), t += SIZE_OF_POINT, setValue(t, e.startIndex, "i32"), t += SIZE_OF_INT, setValue(t, e.oldEndIndex, "i32"), t += SIZE_OF_INT, setValue(t, e.newEndIndex, "i32"), t += SIZE_OF_INT;
|
|
1627
|
+
}
|
|
1628
|
+
for (const e of Object.getOwnPropertyNames(ParserImpl.prototype))Object.defineProperty(Parser.prototype, e, {
|
|
1629
|
+
value: ParserImpl.prototype[e],
|
|
1630
|
+
enumerable: !1,
|
|
1631
|
+
writable: !1
|
|
1632
|
+
});
|
|
1633
|
+
Parser.Language = Language, Module.onRuntimeInitialized = ()=>{
|
|
1634
|
+
ParserImpl.init(), resolveInitPromise();
|
|
1635
|
+
};
|
|
1636
|
+
}));
|
|
1637
|
+
}
|
|
1638
|
+
}
|
|
1639
|
+
return Parser;
|
|
1640
|
+
}();
|
|
1641
|
+
module.exports = TreeSitter;
|
|
1642
|
+
|
|
1643
|
+
});
|
|
1644
|
+
parcelRegister("jGIDp", function(module, exports) {
|
|
1645
|
+
"use strict";
|
|
1646
|
+
|
|
1647
|
+
});
|
|
1648
|
+
|
|
1649
|
+
|
|
1650
|
+
|
|
1651
|
+
var $dc2P8 = parcelRequire("dc2P8");
|
|
1652
|
+
const $142605215cbb4f88$export$b32929182cc4fefe = [
|
|
1653
|
+
"USJ",
|
|
1654
|
+
"table"
|
|
1655
|
+
];
|
|
1656
|
+
const $142605215cbb4f88$export$75b2f422ff60acaf = [
|
|
1657
|
+
"char",
|
|
1658
|
+
"note",
|
|
1659
|
+
"figure"
|
|
1660
|
+
];
|
|
1661
|
+
const $142605215cbb4f88$export$aa24f570494ce8d0 = [
|
|
1662
|
+
"type",
|
|
1663
|
+
"marker",
|
|
1664
|
+
"content",
|
|
1665
|
+
"number",
|
|
1666
|
+
"sid",
|
|
1667
|
+
"code",
|
|
1668
|
+
"caller",
|
|
1669
|
+
"align",
|
|
1670
|
+
"version",
|
|
1671
|
+
"altnumber",
|
|
1672
|
+
"pubnumber",
|
|
1673
|
+
"category"
|
|
1674
|
+
];
|
|
1675
|
+
const $142605215cbb4f88$export$c63c0b6e358f0774 = [
|
|
1676
|
+
"char",
|
|
1677
|
+
"note",
|
|
1678
|
+
"verse",
|
|
1679
|
+
"table:cell"
|
|
1680
|
+
];
|
|
1681
|
+
|
|
1682
|
+
|
|
1683
|
+
class $ce44dcc4919407eb$var$USFMGenerator {
|
|
1684
|
+
constructor(){
|
|
1685
|
+
this.usfmString = "";
|
|
1686
|
+
}
|
|
1687
|
+
usjToUsfm(usjObj, nested = false) {
|
|
1688
|
+
if (!(0, $142605215cbb4f88$export$b32929182cc4fefe).includes(usjObj.type)) {
|
|
1689
|
+
this.usfmString += "\\";
|
|
1690
|
+
if (nested && usjObj.type === "char") this.usfmString += "+";
|
|
1691
|
+
this.usfmString += `${usjObj.marker} `;
|
|
1692
|
+
}
|
|
1693
|
+
[
|
|
1694
|
+
"code",
|
|
1695
|
+
"number",
|
|
1696
|
+
"caller"
|
|
1697
|
+
].forEach((key)=>{
|
|
1698
|
+
if (usjObj[key]) this.usfmString += `${usjObj[key]} `;
|
|
1699
|
+
});
|
|
1700
|
+
if (usjObj.category) this.usfmString += `\\cat ${usjObj.category}\\cat*\n`;
|
|
1701
|
+
if (Array.isArray(usjObj.content)) usjObj.content.forEach((item)=>{
|
|
1702
|
+
if (typeof item === "string") this.usfmString += item;
|
|
1703
|
+
else this.usjToUsfm(item, usjObj.type === "char");
|
|
1704
|
+
});
|
|
1705
|
+
let attributes = [];
|
|
1706
|
+
Object.keys(usjObj).forEach((key)=>{
|
|
1707
|
+
if (!(0, $142605215cbb4f88$export$aa24f570494ce8d0).includes(key)) attributes.push(`${key}="${usjObj[key]}"`);
|
|
1708
|
+
});
|
|
1709
|
+
if (attributes.length > 0) this.usfmString += `|${attributes.join(" ")}`;
|
|
1710
|
+
if ((0, $142605215cbb4f88$export$75b2f422ff60acaf).includes(usjObj.type)) {
|
|
1711
|
+
this.usfmString += `\\`;
|
|
1712
|
+
if (nested && usjObj.type === "char") this.usfmString += "+";
|
|
1713
|
+
this.usfmString += `${usjObj.marker}* `;
|
|
1714
|
+
}
|
|
1715
|
+
if (!(0, $142605215cbb4f88$export$c63c0b6e358f0774).includes(usjObj.type) && this.usfmString[this.usfmString.length - 1] !== "\n") this.usfmString += "\n";
|
|
1716
|
+
return this.usfmString;
|
|
1717
|
+
}
|
|
1718
|
+
}
|
|
1719
|
+
var $ce44dcc4919407eb$export$2e2bcd8739ae039 = $ce44dcc4919407eb$var$USFMGenerator;
|
|
1720
|
+
|
|
1721
|
+
|
|
1722
|
+
//Logics for syntax-tree to dict(USJ) conversions
|
|
1723
|
+
const $28b0061e56e1edf2$export$3ea3efefd6f5792b = [
|
|
1724
|
+
"ide",
|
|
1725
|
+
"usfm",
|
|
1726
|
+
"h",
|
|
1727
|
+
"toc",
|
|
1728
|
+
"toca",
|
|
1729
|
+
"imt",
|
|
1730
|
+
"is",
|
|
1731
|
+
"ip",
|
|
1732
|
+
"ipi",
|
|
1733
|
+
"im",
|
|
1734
|
+
"imi",
|
|
1735
|
+
"ipq",
|
|
1736
|
+
"imq",
|
|
1737
|
+
"ipr",
|
|
1738
|
+
"iq",
|
|
1739
|
+
"ib",
|
|
1740
|
+
"ili",
|
|
1741
|
+
"iot",
|
|
1742
|
+
"io",
|
|
1743
|
+
"iex",
|
|
1744
|
+
"imte",
|
|
1745
|
+
"ie",
|
|
1746
|
+
"mt",
|
|
1747
|
+
"mte",
|
|
1748
|
+
"cl",
|
|
1749
|
+
"cd",
|
|
1750
|
+
"ms",
|
|
1751
|
+
"mr",
|
|
1752
|
+
"s",
|
|
1753
|
+
"sr",
|
|
1754
|
+
"r",
|
|
1755
|
+
"d",
|
|
1756
|
+
"sp",
|
|
1757
|
+
"sd",
|
|
1758
|
+
"q",
|
|
1759
|
+
"qr",
|
|
1760
|
+
"qc",
|
|
1761
|
+
"qa",
|
|
1762
|
+
"qm",
|
|
1763
|
+
"qd",
|
|
1764
|
+
"lh",
|
|
1765
|
+
"li",
|
|
1766
|
+
"lf",
|
|
1767
|
+
"lim",
|
|
1768
|
+
"litl",
|
|
1769
|
+
"sts",
|
|
1770
|
+
"rem",
|
|
1771
|
+
"lit",
|
|
1772
|
+
"restore"
|
|
1773
|
+
];
|
|
1774
|
+
const $28b0061e56e1edf2$export$bfe3d604e5046dbb = [
|
|
1775
|
+
"f",
|
|
1776
|
+
"fe",
|
|
1777
|
+
"ef",
|
|
1778
|
+
"efe",
|
|
1779
|
+
"x",
|
|
1780
|
+
"ex"
|
|
1781
|
+
];
|
|
1782
|
+
const $28b0061e56e1edf2$export$32d1909bfb943eb0 = [
|
|
1783
|
+
"add",
|
|
1784
|
+
"bk",
|
|
1785
|
+
"dc",
|
|
1786
|
+
"ior",
|
|
1787
|
+
"iqt",
|
|
1788
|
+
"k",
|
|
1789
|
+
"litl",
|
|
1790
|
+
"nd",
|
|
1791
|
+
"ord",
|
|
1792
|
+
"pn",
|
|
1793
|
+
"png",
|
|
1794
|
+
"qac",
|
|
1795
|
+
"qs",
|
|
1796
|
+
"qt",
|
|
1797
|
+
"rq",
|
|
1798
|
+
"sig",
|
|
1799
|
+
"sls",
|
|
1800
|
+
"tl",
|
|
1801
|
+
"wj",
|
|
1802
|
+
"em",
|
|
1803
|
+
"bd",
|
|
1804
|
+
"bdit",
|
|
1805
|
+
"it",
|
|
1806
|
+
"no",
|
|
1807
|
+
"sc",
|
|
1808
|
+
"sup",
|
|
1809
|
+
"rb",
|
|
1810
|
+
"pro",
|
|
1811
|
+
"w",
|
|
1812
|
+
"wh",
|
|
1813
|
+
"wa",
|
|
1814
|
+
"wg",
|
|
1815
|
+
"lik",
|
|
1816
|
+
"liv",
|
|
1817
|
+
"jmp",
|
|
1818
|
+
"fr",
|
|
1819
|
+
"ft",
|
|
1820
|
+
"fk",
|
|
1821
|
+
"fq",
|
|
1822
|
+
"fqa",
|
|
1823
|
+
"fl",
|
|
1824
|
+
"fw",
|
|
1825
|
+
"fp",
|
|
1826
|
+
"fv",
|
|
1827
|
+
"fdc",
|
|
1828
|
+
"xo",
|
|
1829
|
+
"xop",
|
|
1830
|
+
"xt",
|
|
1831
|
+
"xta",
|
|
1832
|
+
"xk",
|
|
1833
|
+
"xq",
|
|
1834
|
+
"xot",
|
|
1835
|
+
"xnt",
|
|
1836
|
+
"xdc"
|
|
1837
|
+
];
|
|
1838
|
+
const $28b0061e56e1edf2$export$ec3044778745fabd = $28b0061e56e1edf2$export$32d1909bfb943eb0.map((item)=>item + "Nested");
|
|
1839
|
+
const $28b0061e56e1edf2$export$38bc6f52843beb2a = {
|
|
1840
|
+
w: "lemma",
|
|
1841
|
+
rb: "gloss",
|
|
1842
|
+
xt: "link-href",
|
|
1843
|
+
fig: "alt",
|
|
1844
|
+
xt_standalone: "link-href"
|
|
1845
|
+
};
|
|
1846
|
+
const $28b0061e56e1edf2$export$af42bd8f70df8555 = [
|
|
1847
|
+
"tc",
|
|
1848
|
+
"th",
|
|
1849
|
+
"tcr",
|
|
1850
|
+
"thr"
|
|
1851
|
+
];
|
|
1852
|
+
const $28b0061e56e1edf2$export$c4d2f24f22330b2a = [
|
|
1853
|
+
"fig",
|
|
1854
|
+
"cat",
|
|
1855
|
+
"esb",
|
|
1856
|
+
"b",
|
|
1857
|
+
"ph",
|
|
1858
|
+
"pi"
|
|
1859
|
+
];
|
|
1860
|
+
|
|
1861
|
+
|
|
1862
|
+
class $1bdca1468aa54399$var$USJGenerator {
|
|
1863
|
+
constructor(treeSitterLanguageObj, usfmString, usjRootObj = null){
|
|
1864
|
+
this.usfmLanguage = treeSitterLanguageObj;
|
|
1865
|
+
this.usfm = usfmString;
|
|
1866
|
+
this.jsonRootObj = usjRootObj || {
|
|
1867
|
+
type: "USJ",
|
|
1868
|
+
version: "0.3.0",
|
|
1869
|
+
content: []
|
|
1870
|
+
};
|
|
1871
|
+
}
|
|
1872
|
+
findLastFromJson(jsonObj, typeValue) {
|
|
1873
|
+
let output = null;
|
|
1874
|
+
if (typeValue === jsonObj.type || jsonObj.marker && typeValue === jsonObj.marker) output = jsonObj;
|
|
1875
|
+
if (jsonObj.content) jsonObj.content.forEach((child)=>{
|
|
1876
|
+
if (typeof child === "string") return;
|
|
1877
|
+
const childOutput = this.findLastFromJson(child, typeValue);
|
|
1878
|
+
if (childOutput !== null) output = childOutput;
|
|
1879
|
+
});
|
|
1880
|
+
return output;
|
|
1881
|
+
}
|
|
1882
|
+
nodeToUSJId(node, parentJsonObj) {
|
|
1883
|
+
const idCaptures = this.usfmLanguage.query("(id (bookcode) @book-code (description)? @desc)").captures(node);
|
|
1884
|
+
let code = null;
|
|
1885
|
+
let desc = null;
|
|
1886
|
+
idCaptures.forEach((capture)=>{
|
|
1887
|
+
if (capture.name === "book-code") code = this.usfm.slice(capture.node.startIndex, capture.node.endIndex);
|
|
1888
|
+
else if (capture.name === "desc") desc = this.usfm.slice(capture.node.startIndex, capture.node.endIndex);
|
|
1889
|
+
});
|
|
1890
|
+
const bookJsonObj = {
|
|
1891
|
+
type: "book",
|
|
1892
|
+
marker: "id",
|
|
1893
|
+
code: code,
|
|
1894
|
+
content: []
|
|
1895
|
+
};
|
|
1896
|
+
if (desc && desc.trim() !== "") bookJsonObj.content.push(desc.trim());
|
|
1897
|
+
parentJsonObj.content.push(bookJsonObj);
|
|
1898
|
+
}
|
|
1899
|
+
// Similar conversion methods for other node types
|
|
1900
|
+
nodeToUSJC(node, parentJsonObj) {
|
|
1901
|
+
// Build c, the chapter milestone node in usj
|
|
1902
|
+
const chapCap = this.usfmLanguage.query(`(c (chapterNumber) @chap-num
|
|
1903
|
+
(ca (chapterNumber) @alt-num)?
|
|
1904
|
+
(cp (text) @pub-num)?)`).captures(node);
|
|
1905
|
+
const chapNum = this.usfm.slice(chapCap[0].node.startIndex, chapCap[0].node.endIndex);
|
|
1906
|
+
let chapRef = null;
|
|
1907
|
+
this.jsonRootObj.content.forEach((child)=>{
|
|
1908
|
+
if (child.type === "book") {
|
|
1909
|
+
chapRef = `${child.code} ${chapNum}`;
|
|
1910
|
+
return;
|
|
1911
|
+
}
|
|
1912
|
+
});
|
|
1913
|
+
const chapJsonObj = {
|
|
1914
|
+
type: "chapter",
|
|
1915
|
+
marker: "c",
|
|
1916
|
+
number: chapNum,
|
|
1917
|
+
sid: chapRef
|
|
1918
|
+
};
|
|
1919
|
+
chapCap.forEach((tuple)=>{
|
|
1920
|
+
if (tuple[1] === "alt-num") chapJsonObj.altnumber = this.usfm.substring(tuple[0].startIndex, tuple[0].endIndex).trim();
|
|
1921
|
+
if (tuple[1] === "pub-num") chapJsonObj.pubnumber = this.usfm.substring(tuple[0].startIndex, tuple[0].endIndex).trim();
|
|
1922
|
+
});
|
|
1923
|
+
parentJsonObj.content.push(chapJsonObj);
|
|
1924
|
+
node.children.forEach((child)=>{
|
|
1925
|
+
if ([
|
|
1926
|
+
"cl",
|
|
1927
|
+
"cd"
|
|
1928
|
+
].includes(child.type)) this.nodeToUSJ(child, parentJsonObj);
|
|
1929
|
+
});
|
|
1930
|
+
}
|
|
1931
|
+
nodeToUSJChapter(node, parentJsonObj) {
|
|
1932
|
+
// Build chapter node in USJ
|
|
1933
|
+
node.children.forEach((child)=>{
|
|
1934
|
+
if (child.type === "c") this.nodeToUSJC(child, parentJsonObj);
|
|
1935
|
+
else this.nodeToUSJ(child, parentJsonObj);
|
|
1936
|
+
});
|
|
1937
|
+
}
|
|
1938
|
+
nodeToUSJVerse(node, parentJsonObj) {
|
|
1939
|
+
// Build verse node in USJ
|
|
1940
|
+
const verseNumCap = this.usfmLanguage.query(`
|
|
1941
|
+
(v
|
|
1942
|
+
(verseNumber) @vnum
|
|
1943
|
+
(va (verseNumber) @alt)?
|
|
1944
|
+
(vp (text) @vp)?
|
|
1945
|
+
)`).captures(node);
|
|
1946
|
+
const verseNum = this.usfm.substring(verseNumCap[0].node.startIndex, verseNumCap[0].node.endIndex);
|
|
1947
|
+
const vJsonObj = {
|
|
1948
|
+
type: "verse",
|
|
1949
|
+
marker: "v",
|
|
1950
|
+
number: verseNum.trim()
|
|
1951
|
+
};
|
|
1952
|
+
verseNumCap.forEach((capture)=>{
|
|
1953
|
+
if (capture.name === "alt") {
|
|
1954
|
+
const altNum = this.usfm.slice(capture.node.startIndex, capture.node.endIndex);
|
|
1955
|
+
vJsonObj.altnumber = altNum;
|
|
1956
|
+
} else if (capture.name === "vp") {
|
|
1957
|
+
const vpText = this.usfm.substring(capture.node.startIndex, capture.node.endIndex);
|
|
1958
|
+
vJsonObj.pubnumber = vpText;
|
|
1959
|
+
}
|
|
1960
|
+
});
|
|
1961
|
+
const ref = `${this.findLastFromJson(this.jsonRootObj, "chapter").sid}:${verseNum}`;
|
|
1962
|
+
vJsonObj.sid = ref.trim();
|
|
1963
|
+
parentJsonObj.content.push(vJsonObj);
|
|
1964
|
+
}
|
|
1965
|
+
nodeToUSJCaVa(node, parentJsonObj) {
|
|
1966
|
+
// Build elements for independent ca and va away from c and v
|
|
1967
|
+
const style = node.type;
|
|
1968
|
+
const charJsonObj = {
|
|
1969
|
+
type: "char",
|
|
1970
|
+
marker: style
|
|
1971
|
+
};
|
|
1972
|
+
const altNumMatch = this.usfmLanguage.query(`([
|
|
1973
|
+
(chapterNumber)
|
|
1974
|
+
(verseNumber)
|
|
1975
|
+
] @alt-num)`).captures(node);
|
|
1976
|
+
const altNum = this.usfm.slice(altNumMatch[0].node.startIndex, altNumMatch[0].node.endIndex).trim();
|
|
1977
|
+
charJsonObj.altnumber = altNum;
|
|
1978
|
+
parentJsonObj.content.push(charJsonObj);
|
|
1979
|
+
}
|
|
1980
|
+
nodeToUSJPara(node, parentJsonObj) {
|
|
1981
|
+
// Build paragraph nodes in USJ
|
|
1982
|
+
if (node.children[0].type.endsWith("Block")) node.children[0].children.forEach((child)=>{
|
|
1983
|
+
this.nodeToUSJPara(child, parentJsonObj);
|
|
1984
|
+
});
|
|
1985
|
+
else if (node.type === "paragraph") {
|
|
1986
|
+
const paraTagCap = this.usfmLanguage.query("(paragraph (_) @para-marker)").captures(node)[0];
|
|
1987
|
+
const paraMarker = paraTagCap.node.type;
|
|
1988
|
+
if (paraMarker === "b") this.nodeToUSJSpecial(paraTagCap, parentJsonObj);
|
|
1989
|
+
else if (!paraMarker.endsWith("Block")) {
|
|
1990
|
+
const paraJsonObj = {
|
|
1991
|
+
type: "para",
|
|
1992
|
+
marker: paraMarker,
|
|
1993
|
+
content: []
|
|
1994
|
+
};
|
|
1995
|
+
paraTagCap.node.children.forEach((child)=>{
|
|
1996
|
+
this.nodeToUSJ(child, paraJsonObj);
|
|
1997
|
+
});
|
|
1998
|
+
parentJsonObj.content.push(paraJsonObj);
|
|
1999
|
+
}
|
|
2000
|
+
} else if ([
|
|
2001
|
+
"pi",
|
|
2002
|
+
"ph"
|
|
2003
|
+
].includes(node.type)) {
|
|
2004
|
+
const paraMarker = this.usfm.substring(node.children[0].startIndex, node.children[0].endIndex).replace("\\", "").trim();
|
|
2005
|
+
const paraJsonObj = {
|
|
2006
|
+
type: "para",
|
|
2007
|
+
marker: paraMarker,
|
|
2008
|
+
content: []
|
|
2009
|
+
};
|
|
2010
|
+
node.children.slice(1).forEach((child)=>{
|
|
2011
|
+
this.nodeToUSJ(child, paraJsonObj);
|
|
2012
|
+
});
|
|
2013
|
+
parentJsonObj.content.push(paraJsonObj);
|
|
2014
|
+
}
|
|
2015
|
+
}
|
|
2016
|
+
nodeToUSJNotes(node, parentJsonObj) {
|
|
2017
|
+
// Build USJ nodes for footnotes and cross-references
|
|
2018
|
+
const tagNode = node.children[0];
|
|
2019
|
+
const callerNode = node.children[1];
|
|
2020
|
+
const style = this.usfm.substring(tagNode.startIndex, tagNode.endIndex).replace("\\", "").trim();
|
|
2021
|
+
const noteJsonObj = {
|
|
2022
|
+
type: "note",
|
|
2023
|
+
marker: style,
|
|
2024
|
+
content: []
|
|
2025
|
+
};
|
|
2026
|
+
noteJsonObj.caller = this.usfm.substring(callerNode.startIndex, callerNode.endIndex).trim();
|
|
2027
|
+
for(let i = 2; i < node.children.length - 1; i++)this.nodeToUSJ(node.children[i], noteJsonObj);
|
|
2028
|
+
parentJsonObj.content.push(noteJsonObj);
|
|
2029
|
+
}
|
|
2030
|
+
nodeToUSJChar(node, parentJsonObj) {
|
|
2031
|
+
// Build USJ nodes for character markups, both regular and nested
|
|
2032
|
+
const tagNode = node.children[0];
|
|
2033
|
+
let childrenRange = node.children.length;
|
|
2034
|
+
if (node.children[node.children.length - 1].type.startsWith("\\")) childrenRange -= 1; // Exclude the last node if it starts with '\', treating it as a closing node
|
|
2035
|
+
const style = this.usfm.substring(tagNode.startIndex, tagNode.endIndex).replace("\\", "").replace("+", "").trim();
|
|
2036
|
+
const charJsonObj = {
|
|
2037
|
+
type: "char",
|
|
2038
|
+
marker: style,
|
|
2039
|
+
content: []
|
|
2040
|
+
};
|
|
2041
|
+
// Assume a flag for closed markup, toggle this if your conditions and data structure require
|
|
2042
|
+
// charJsonObj.closed = node.children[node.children.length - 1].type.startsWith('\\');
|
|
2043
|
+
for(let i = 1; i < childrenRange; i++)this.nodeToUSJ(node.children[i], charJsonObj);
|
|
2044
|
+
parentJsonObj.content.push(charJsonObj);
|
|
2045
|
+
}
|
|
2046
|
+
nodeToUSJTable(node, parentJsonObj) {
|
|
2047
|
+
// Handle table related components and convert to USJ
|
|
2048
|
+
if (node.type === "table") {
|
|
2049
|
+
const tableJsonObj = {
|
|
2050
|
+
type: "table",
|
|
2051
|
+
content: []
|
|
2052
|
+
};
|
|
2053
|
+
node.children.forEach((child)=>{
|
|
2054
|
+
this.nodeToUSJ(child, tableJsonObj);
|
|
2055
|
+
});
|
|
2056
|
+
parentJsonObj.content.push(tableJsonObj);
|
|
2057
|
+
} else if (node.type === "tr") {
|
|
2058
|
+
const rowJsonObj = {
|
|
2059
|
+
type: "table:row",
|
|
2060
|
+
marker: "tr",
|
|
2061
|
+
content: []
|
|
2062
|
+
};
|
|
2063
|
+
node.children.slice(1).forEach((child)=>{
|
|
2064
|
+
this.nodeToUSJ(child, rowJsonObj);
|
|
2065
|
+
});
|
|
2066
|
+
parentJsonObj.content.push(rowJsonObj);
|
|
2067
|
+
} else if ((0, $28b0061e56e1edf2$export$af42bd8f70df8555).includes(node.type)) {
|
|
2068
|
+
const tagNode = node.children[0];
|
|
2069
|
+
const style = this.usfm.substring(tagNode.startIndex, tagNode.endIndex).replace("\\", "").trim();
|
|
2070
|
+
const cellJsonObj = {
|
|
2071
|
+
type: "table:cell",
|
|
2072
|
+
marker: style,
|
|
2073
|
+
content: [],
|
|
2074
|
+
align: style.includes("r") ? "end" : "start"
|
|
2075
|
+
};
|
|
2076
|
+
node.children.slice(1).forEach((child)=>{
|
|
2077
|
+
this.nodeToUSJ(child, cellJsonObj);
|
|
2078
|
+
});
|
|
2079
|
+
parentJsonObj.content.push(cellJsonObj);
|
|
2080
|
+
}
|
|
2081
|
+
}
|
|
2082
|
+
nodeToUSJAttrib(node, parentJsonObj) {
|
|
2083
|
+
// Add attribute values to USJ elements
|
|
2084
|
+
const attribNameNode = node.children[0];
|
|
2085
|
+
let attribName = this.usfm.slice(attribNameNode.startIndex, attribNameNode.endIndex).trim();
|
|
2086
|
+
// Handling special cases for attribute names
|
|
2087
|
+
if (attribName === "|") attribName = (0, $28b0061e56e1edf2$export$38bc6f52843beb2a)[node.parent.type];
|
|
2088
|
+
if (attribName === "src") // for \fig
|
|
2089
|
+
attribName = "file";
|
|
2090
|
+
const attribValCap = this.usfmLanguage.query("((attributeValue) @attrib-val)").captures(node);
|
|
2091
|
+
let attribValue = "";
|
|
2092
|
+
if (attribValCap.length > 0) attribValue = this.usfm.substring(attribValCap[0].node.startIndex, attribValCap[0].node.endIndex).trim();
|
|
2093
|
+
parentJsonObj[attribName] = attribValue;
|
|
2094
|
+
}
|
|
2095
|
+
nodeToUSJMilestone(node, parentJsonObj) {
|
|
2096
|
+
// Create ms node in USJ
|
|
2097
|
+
const msNameCap = this.usfmLanguage.query(`(
|
|
2098
|
+
[(milestoneTag)
|
|
2099
|
+
(milestoneStartTag)
|
|
2100
|
+
(milestoneEndTag)
|
|
2101
|
+
(zSpaceTag)
|
|
2102
|
+
] @ms-name)`).captures(node)[0];
|
|
2103
|
+
const style = this.usfm.slice(msNameCap.node.startIndex, msNameCap.node.endIndex).replace("\\", "").trim();
|
|
2104
|
+
const msJsonObj = {
|
|
2105
|
+
type: "ms",
|
|
2106
|
+
marker: style,
|
|
2107
|
+
content: []
|
|
2108
|
+
};
|
|
2109
|
+
node.children.forEach((child)=>{
|
|
2110
|
+
if (child.type.endsWith("Attribute")) this.nodeToUSJ(child, msJsonObj);
|
|
2111
|
+
});
|
|
2112
|
+
// Though normally milestones don't have contents, custom z-namespaces could have them
|
|
2113
|
+
if (!msJsonObj.content.length) delete msJsonObj.content; // Remove empty content array if not used
|
|
2114
|
+
parentJsonObj.content.push(msJsonObj);
|
|
2115
|
+
}
|
|
2116
|
+
nodeToUSJSpecial(node, parentJsonObj) {
|
|
2117
|
+
// Build nodes for esb, cat, fig, optbreak in USJ
|
|
2118
|
+
if (node.type === "esb") {
|
|
2119
|
+
const sidebarJsonObj = {
|
|
2120
|
+
type: "sidebar",
|
|
2121
|
+
marker: "esb",
|
|
2122
|
+
content: []
|
|
2123
|
+
};
|
|
2124
|
+
node.children.slice(1, -1).forEach((child)=>{
|
|
2125
|
+
this.nodeToUSJ(child, sidebarJsonObj);
|
|
2126
|
+
});
|
|
2127
|
+
parentJsonObj.content.push(sidebarJsonObj);
|
|
2128
|
+
} else if (node.type === "cat") {
|
|
2129
|
+
const catCap = this.usfmLanguage.query("((category) @category)").captures(node)[0];
|
|
2130
|
+
const category = this.usfm.substring(catCap[0].startIndex, catCap[0].endIndex).trim();
|
|
2131
|
+
parentJsonObj.category = category;
|
|
2132
|
+
} else if (node.type === "fig") {
|
|
2133
|
+
const figJsonObj = {
|
|
2134
|
+
type: "figure",
|
|
2135
|
+
marker: "fig",
|
|
2136
|
+
content: []
|
|
2137
|
+
};
|
|
2138
|
+
node.children.slice(1, -1).forEach((child)=>{
|
|
2139
|
+
this.nodeToUSJ(child, figJsonObj);
|
|
2140
|
+
});
|
|
2141
|
+
parentJsonObj.content.push(figJsonObj);
|
|
2142
|
+
} else if (node.type === "b") {
|
|
2143
|
+
const bJsonObj = {
|
|
2144
|
+
type: "optbreak",
|
|
2145
|
+
marker: "b"
|
|
2146
|
+
};
|
|
2147
|
+
parentJsonObj.content.push(bJsonObj);
|
|
2148
|
+
} else if (node.type === "usfm") {
|
|
2149
|
+
const verJsonObj = {
|
|
2150
|
+
type: "para",
|
|
2151
|
+
marker: "usfm",
|
|
2152
|
+
content: []
|
|
2153
|
+
};
|
|
2154
|
+
const version = this.usfm.substring(node.startIndex, node.endIndex).replace("\\usfm", "").trim();
|
|
2155
|
+
verJsonObj.content.push(version);
|
|
2156
|
+
parentJsonObj.content.push(verJsonObj);
|
|
2157
|
+
}
|
|
2158
|
+
}
|
|
2159
|
+
nodeToUSJGeneric(node, parentJsonObj) {
|
|
2160
|
+
// Build nodes for para style markers in USJ
|
|
2161
|
+
const tagNode = node.children[0];
|
|
2162
|
+
let style = this.usfm.substring(tagNode.startIndex, tagNode.endIndex);
|
|
2163
|
+
if (style.startsWith("\\")) style = style.replace("\\", "").trim();
|
|
2164
|
+
else style = node.type;
|
|
2165
|
+
// console.log(node.children.length, node.children[0].type, node.children[1].type)
|
|
2166
|
+
let childrenRangeStart = 1;
|
|
2167
|
+
if (node.children.length > 1 && node.children[1].type.startsWith("numbered")) {
|
|
2168
|
+
const numNode = node.children[1];
|
|
2169
|
+
const num = this.usfm.substring(numNode.startIndex, numNode.endIndex);
|
|
2170
|
+
style += num;
|
|
2171
|
+
childrenRangeStart = 2;
|
|
2172
|
+
}
|
|
2173
|
+
const paraJsonObj = {
|
|
2174
|
+
type: "para",
|
|
2175
|
+
marker: style,
|
|
2176
|
+
content: []
|
|
2177
|
+
};
|
|
2178
|
+
parentJsonObj.content.push(paraJsonObj);
|
|
2179
|
+
for(let i = childrenRangeStart; i < node.children.length; i++){
|
|
2180
|
+
const child = node.children[i];
|
|
2181
|
+
if ((0, $28b0061e56e1edf2$export$32d1909bfb943eb0).includes(child.type) || (0, $28b0061e56e1edf2$export$ec3044778745fabd).includes(child.type) || [
|
|
2182
|
+
"text",
|
|
2183
|
+
"footnote",
|
|
2184
|
+
"crossref",
|
|
2185
|
+
"verseText",
|
|
2186
|
+
"v",
|
|
2187
|
+
"b",
|
|
2188
|
+
"milestone",
|
|
2189
|
+
"zNameSpace"
|
|
2190
|
+
].includes(child.type)) // Only nest these types inside the upper para style node
|
|
2191
|
+
this.nodeToUSJ(child, paraJsonObj);
|
|
2192
|
+
else this.nodeToUSJ(child, parentJsonObj);
|
|
2193
|
+
}
|
|
2194
|
+
}
|
|
2195
|
+
nodeToUSJ(node, parentJsonObj) {
|
|
2196
|
+
// Check each node and based on the type convert to corresponding XML element
|
|
2197
|
+
switch(node.type){
|
|
2198
|
+
case "id":
|
|
2199
|
+
this.nodeToUSJId(node, parentJsonObj);
|
|
2200
|
+
break;
|
|
2201
|
+
case "chapter":
|
|
2202
|
+
this.nodeToUSJChapter(node, parentJsonObj);
|
|
2203
|
+
break;
|
|
2204
|
+
case "cl":
|
|
2205
|
+
case "cp":
|
|
2206
|
+
case "cd":
|
|
2207
|
+
case "vp":
|
|
2208
|
+
this.nodeToUSJGeneric(node, parentJsonObj);
|
|
2209
|
+
break;
|
|
2210
|
+
case "ca":
|
|
2211
|
+
case "va":
|
|
2212
|
+
this.nodeToUSJCaVa(node, parentJsonObj);
|
|
2213
|
+
break;
|
|
2214
|
+
case "v":
|
|
2215
|
+
this.nodeToUSJVerse(node, parentJsonObj);
|
|
2216
|
+
break;
|
|
2217
|
+
case "verseText":
|
|
2218
|
+
node.children.forEach((child)=>this.nodeToUSJ(child, parentJsonObj));
|
|
2219
|
+
break;
|
|
2220
|
+
case "paragraph":
|
|
2221
|
+
case "pi":
|
|
2222
|
+
case "ph":
|
|
2223
|
+
this.nodeToUSJPara(node, parentJsonObj);
|
|
2224
|
+
break;
|
|
2225
|
+
case "text":
|
|
2226
|
+
const textVal = this.usfm.substring(node.startIndex, node.endIndex).trim();
|
|
2227
|
+
if (textVal !== "") parentJsonObj.content.push(textVal);
|
|
2228
|
+
break;
|
|
2229
|
+
case "table":
|
|
2230
|
+
case "tr":
|
|
2231
|
+
this.nodeToUSJTable(node, parentJsonObj);
|
|
2232
|
+
break;
|
|
2233
|
+
case "milestone":
|
|
2234
|
+
case "zNameSpace":
|
|
2235
|
+
this.nodeToUSJMilestone(node, parentJsonObj);
|
|
2236
|
+
break;
|
|
2237
|
+
case "esb":
|
|
2238
|
+
case "cat":
|
|
2239
|
+
case "fig":
|
|
2240
|
+
case "usfm":
|
|
2241
|
+
this.nodeToUSJSpecial(node, parentJsonObj);
|
|
2242
|
+
break;
|
|
2243
|
+
default:
|
|
2244
|
+
if ((0, $28b0061e56e1edf2$export$32d1909bfb943eb0).includes(node.type) || (0, $28b0061e56e1edf2$export$ec3044778745fabd).includes(node.type) || [
|
|
2245
|
+
"xt_standalone"
|
|
2246
|
+
].includes(node.type)) this.nodeToUSJChar(node, parentJsonObj);
|
|
2247
|
+
else if (node.type.endsWith("Attribute")) this.nodeToUSJAttrib(node, parentJsonObj);
|
|
2248
|
+
else if ((0, $28b0061e56e1edf2$export$3ea3efefd6f5792b).includes(node.type) || (0, $28b0061e56e1edf2$export$3ea3efefd6f5792b).includes(node.type.replace("\\", "").trim())) this.nodeToUSJGeneric(node, parentJsonObj);
|
|
2249
|
+
else if ([
|
|
2250
|
+
"",
|
|
2251
|
+
"|"
|
|
2252
|
+
].includes(node.type.trim())) break;
|
|
2253
|
+
else if (node.children.length > 0) node.children.forEach((child)=>this.nodeToUSJ(child, parentJsonObj));
|
|
2254
|
+
break;
|
|
2255
|
+
}
|
|
2256
|
+
}
|
|
2257
|
+
}
|
|
2258
|
+
var $1bdca1468aa54399$export$2e2bcd8739ae039 = $1bdca1468aa54399$var$USJGenerator;
|
|
2259
|
+
|
|
2260
|
+
|
|
2261
|
+
const $ab5c81e737a0c6a6$var$MARKERS_WITH_DISCARDABLE_CONTENTS = [
|
|
2262
|
+
"ide",
|
|
2263
|
+
"usfm",
|
|
2264
|
+
"h",
|
|
2265
|
+
"toc",
|
|
2266
|
+
"toca",
|
|
2267
|
+
"imt",
|
|
2268
|
+
"is",
|
|
2269
|
+
"ip",
|
|
2270
|
+
"ipi",
|
|
2271
|
+
"im",
|
|
2272
|
+
"imi",
|
|
2273
|
+
"ipq",
|
|
2274
|
+
"imq",
|
|
2275
|
+
"ipr",
|
|
2276
|
+
"iq",
|
|
2277
|
+
"ib",
|
|
2278
|
+
"ili",
|
|
2279
|
+
"iot",
|
|
2280
|
+
"io",
|
|
2281
|
+
"iex",
|
|
2282
|
+
"imte",
|
|
2283
|
+
"ie",
|
|
2284
|
+
"mt",
|
|
2285
|
+
"mte",
|
|
2286
|
+
"cl",
|
|
2287
|
+
"cd",
|
|
2288
|
+
"ms",
|
|
2289
|
+
"mr",
|
|
2290
|
+
"s",
|
|
2291
|
+
"sr",
|
|
2292
|
+
"r",
|
|
2293
|
+
"d",
|
|
2294
|
+
"sp",
|
|
2295
|
+
"sd",
|
|
2296
|
+
"sts",
|
|
2297
|
+
"rem",
|
|
2298
|
+
"lit",
|
|
2299
|
+
"restore",
|
|
2300
|
+
"f",
|
|
2301
|
+
"fe",
|
|
2302
|
+
"ef",
|
|
2303
|
+
"efe",
|
|
2304
|
+
"x",
|
|
2305
|
+
"ex",
|
|
2306
|
+
"fr",
|
|
2307
|
+
"ft",
|
|
2308
|
+
"fk",
|
|
2309
|
+
"fq",
|
|
2310
|
+
"fqa",
|
|
2311
|
+
"fl",
|
|
2312
|
+
"fw",
|
|
2313
|
+
"fp",
|
|
2314
|
+
"fv",
|
|
2315
|
+
"fdc",
|
|
2316
|
+
"xo",
|
|
2317
|
+
"xop",
|
|
2318
|
+
"xt",
|
|
2319
|
+
"xta",
|
|
2320
|
+
"xk",
|
|
2321
|
+
"xq",
|
|
2322
|
+
"xot",
|
|
2323
|
+
"xnt",
|
|
2324
|
+
"xdc",
|
|
2325
|
+
"jmp",
|
|
2326
|
+
"fig",
|
|
2327
|
+
"cat",
|
|
2328
|
+
"esb",
|
|
2329
|
+
"b"
|
|
2330
|
+
];
|
|
2331
|
+
const $ab5c81e737a0c6a6$var$trailingNumPattern = /\d+$/;
|
|
2332
|
+
const $ab5c81e737a0c6a6$var$punctPatternNoSpaceBefore = /^[,.\-—/;:!?@$%^)}\]>”»]/;
|
|
2333
|
+
const $ab5c81e737a0c6a6$var$punctPatternNoSpaceAfter = /[\-—/`@^&({[<“«]$/;
|
|
2334
|
+
function $ab5c81e737a0c6a6$var$combineConsecutiveTextContents(contentsList) {
|
|
2335
|
+
let textCombinedContents = [];
|
|
2336
|
+
let textContents = "";
|
|
2337
|
+
contentsList.forEach((item)=>{
|
|
2338
|
+
if (typeof item === "string") {
|
|
2339
|
+
if (!(textContents.endsWith(" ") || item.startsWith(" ") || textContents === "" || $ab5c81e737a0c6a6$var$punctPatternNoSpaceBefore.test(item) || $ab5c81e737a0c6a6$var$punctPatternNoSpaceAfter.test(textContents))) textContents += " ";
|
|
2340
|
+
textContents += item;
|
|
2341
|
+
} else {
|
|
2342
|
+
if (textContents !== "") {
|
|
2343
|
+
textCombinedContents.push(textContents);
|
|
2344
|
+
textContents = "";
|
|
2345
|
+
}
|
|
2346
|
+
textCombinedContents.push(item);
|
|
2347
|
+
}
|
|
2348
|
+
});
|
|
2349
|
+
if (textContents !== "") textCombinedContents.push(textContents);
|
|
2350
|
+
return textCombinedContents;
|
|
2351
|
+
}
|
|
2352
|
+
function $ab5c81e737a0c6a6$export$9539ba3a89be1c40(inputUsj, excludeMarkers, combineTexts = true, excludedParent = false) {
|
|
2353
|
+
if (typeof inputUsj === "string") {
|
|
2354
|
+
if (excludedParent && excludeMarkers.includes("text-in-excluded-parent")) return [];
|
|
2355
|
+
return [
|
|
2356
|
+
inputUsj
|
|
2357
|
+
];
|
|
2358
|
+
}
|
|
2359
|
+
let cleanedKids = [];
|
|
2360
|
+
let cleanedMarkers = excludeMarkers.map((marker)=>marker.replace($ab5c81e737a0c6a6$var$trailingNumPattern, ""));
|
|
2361
|
+
let thisMarker = "marker" in inputUsj ? inputUsj.marker.replace($ab5c81e737a0c6a6$var$trailingNumPattern, "") : "";
|
|
2362
|
+
let thisMarkerNeeded = true;
|
|
2363
|
+
let innerContentNeeded = true;
|
|
2364
|
+
excludedParent = false;
|
|
2365
|
+
if (cleanedMarkers.includes(thisMarker)) {
|
|
2366
|
+
thisMarkerNeeded = false;
|
|
2367
|
+
excludedParent = true;
|
|
2368
|
+
if ($ab5c81e737a0c6a6$var$MARKERS_WITH_DISCARDABLE_CONTENTS.includes(thisMarker)) innerContentNeeded = false;
|
|
2369
|
+
}
|
|
2370
|
+
if ((thisMarkerNeeded || innerContentNeeded) && "content" in inputUsj) {
|
|
2371
|
+
inputUsj.content.forEach((item)=>{
|
|
2372
|
+
let cleaned = $ab5c81e737a0c6a6$export$9539ba3a89be1c40(item, excludeMarkers, combineTexts, excludedParent);
|
|
2373
|
+
if (Array.isArray(cleaned)) cleanedKids.push(...cleaned);
|
|
2374
|
+
else cleanedKids.push(cleaned);
|
|
2375
|
+
});
|
|
2376
|
+
if (combineTexts) cleanedKids = $ab5c81e737a0c6a6$var$combineConsecutiveTextContents(cleanedKids);
|
|
2377
|
+
}
|
|
2378
|
+
if (thisMarkerNeeded) {
|
|
2379
|
+
let cleanedUsj = {
|
|
2380
|
+
...inputUsj,
|
|
2381
|
+
content: cleanedKids
|
|
2382
|
+
};
|
|
2383
|
+
return cleanedUsj;
|
|
2384
|
+
}
|
|
2385
|
+
return innerContentNeeded ? cleanedKids : [];
|
|
2386
|
+
}
|
|
2387
|
+
function $ab5c81e737a0c6a6$export$88c58c54200c5b2(inputUsj, includeMarkers, combineTexts = true, excludedParent = false) {
|
|
2388
|
+
if (typeof inputUsj === "string") return excludedParent ? [] : [
|
|
2389
|
+
inputUsj
|
|
2390
|
+
];
|
|
2391
|
+
let cleanedKids = [];
|
|
2392
|
+
let cleanedMarkers = includeMarkers.map((marker)=>marker.replace($ab5c81e737a0c6a6$var$trailingNumPattern, ""));
|
|
2393
|
+
let thisMarker = "marker" in inputUsj ? inputUsj.marker.replace($ab5c81e737a0c6a6$var$trailingNumPattern, "") : "";
|
|
2394
|
+
let thisMarkerNeeded = cleanedMarkers.includes(thisMarker) || thisMarker === "";
|
|
2395
|
+
let innerContentNeeded = thisMarkerNeeded || $ab5c81e737a0c6a6$var$MARKERS_WITH_DISCARDABLE_CONTENTS.includes(thisMarker);
|
|
2396
|
+
if (innerContentNeeded && "content" in inputUsj) {
|
|
2397
|
+
inputUsj.content.forEach((item)=>{
|
|
2398
|
+
let cleaned = $ab5c81e737a0c6a6$export$88c58c54200c5b2(item, includeMarkers, combineTexts, !thisMarkerNeeded);
|
|
2399
|
+
if (Array.isArray(cleaned)) cleanedKids.push(...cleaned);
|
|
2400
|
+
else cleanedKids.push(cleaned);
|
|
2401
|
+
});
|
|
2402
|
+
if (combineTexts) cleanedKids = $ab5c81e737a0c6a6$var$combineConsecutiveTextContents(cleanedKids);
|
|
2403
|
+
}
|
|
2404
|
+
if (thisMarkerNeeded) {
|
|
2405
|
+
let cleanedUsj = {
|
|
2406
|
+
...inputUsj,
|
|
2407
|
+
content: cleanedKids
|
|
2408
|
+
};
|
|
2409
|
+
return cleanedUsj;
|
|
2410
|
+
}
|
|
2411
|
+
return innerContentNeeded ? cleanedKids : [];
|
|
2412
|
+
}
|
|
2413
|
+
|
|
2414
|
+
|
|
2415
|
+
class $236d01ba6f80be5e$var$USFMParser {
|
|
2416
|
+
static language = null;
|
|
2417
|
+
static async init(grammarPath = "node_modules/usfm-grammar/tree-sitter-usfm.wasm", parserPath = "node_modules/usfm-grammar/tree-sitter.wasm") {
|
|
2418
|
+
await (0, (/*@__PURE__*/$parcel$interopDefault($dc2P8))).init({
|
|
2419
|
+
locateFile () {
|
|
2420
|
+
return parserPath;
|
|
2421
|
+
}
|
|
2422
|
+
});
|
|
2423
|
+
$236d01ba6f80be5e$var$USFMParser.language = await (0, (/*@__PURE__*/$parcel$interopDefault($dc2P8))).Language.load(grammarPath);
|
|
2424
|
+
}
|
|
2425
|
+
constructor(){
|
|
2426
|
+
this.parser = null;
|
|
2427
|
+
this.usfm = null;
|
|
2428
|
+
this.usj = null;
|
|
2429
|
+
this.syntaxTree = null;
|
|
2430
|
+
}
|
|
2431
|
+
initializeParser() {
|
|
2432
|
+
if (!$236d01ba6f80be5e$var$USFMParser.language) throw new Error("USFMParser not initialized. Call USFMParser.init() before creating instances.");
|
|
2433
|
+
this.parser = new (0, (/*@__PURE__*/$parcel$interopDefault($dc2P8)))();
|
|
2434
|
+
this.parser.setLanguage($236d01ba6f80be5e$var$USFMParser.language);
|
|
2435
|
+
}
|
|
2436
|
+
usfmToUsj(usfmString) {
|
|
2437
|
+
if (typeof usfmString !== "string" || usfmString === null) throw new Error("Invalid input for USFM. Expected a string.");
|
|
2438
|
+
if (!this.parser) this.initializeParser();
|
|
2439
|
+
this.usfm = usfmString;
|
|
2440
|
+
this.parseUSFM();
|
|
2441
|
+
this.usj = this.convertUSFMToUSJ();
|
|
2442
|
+
return this.usj;
|
|
2443
|
+
}
|
|
2444
|
+
usjToUsfm(usjObject) {
|
|
2445
|
+
if (typeof usjObject !== "object" || usjObject === null) throw new Error("Invalid input for USJ. Expected an object.");
|
|
2446
|
+
if (!this.parser) this.initializeParser();
|
|
2447
|
+
this.usj = usjObject;
|
|
2448
|
+
this.usfm = this.convertUSJToUSFM();
|
|
2449
|
+
return this.usfm;
|
|
2450
|
+
}
|
|
2451
|
+
parseUSFM() {
|
|
2452
|
+
let tree = null;
|
|
2453
|
+
try {
|
|
2454
|
+
tree = this.parser.parse(this.usfm);
|
|
2455
|
+
} catch (err) {
|
|
2456
|
+
console.log(err.toString());
|
|
2457
|
+
}
|
|
2458
|
+
const error = this.checkForErrors(tree);
|
|
2459
|
+
if (error) throw error;
|
|
2460
|
+
this.syntaxTree = tree.rootNode;
|
|
2461
|
+
}
|
|
2462
|
+
checkForErrors(tree) {
|
|
2463
|
+
const errorQuery = this.parser.getLanguage().query("(ERROR) @errors");
|
|
2464
|
+
const errors = errorQuery.captures(tree.rootNode);
|
|
2465
|
+
if (errors.length > 0) {
|
|
2466
|
+
this.errors = errors.map((err)=>`At ${err.node.startPosition.row}:${err.node.startPosition.column}, Error: ${this.usfm.substring(err.node.startIndex, err.node.endIndex)}`);
|
|
2467
|
+
return new Error(`Errors found in USFM: ${this.errors.join(", ")}`);
|
|
2468
|
+
}
|
|
2469
|
+
return null;
|
|
2470
|
+
}
|
|
2471
|
+
convertUSJToUSFM() {
|
|
2472
|
+
const outputUSFM = new (0, $ce44dcc4919407eb$export$2e2bcd8739ae039)().usjToUsfm(this.usj); // Simulated conversion
|
|
2473
|
+
return outputUSFM;
|
|
2474
|
+
}
|
|
2475
|
+
convertUSFMToUSJ({ excludeMarkers: excludeMarkers = null, includeMarkers: includeMarkers = null, ignoreErrors: ignoreErrors = false, combineTexts: combineTexts = true } = {}) {
|
|
2476
|
+
if (!ignoreErrors && this.errors) {
|
|
2477
|
+
let errorString = this.errors.map((err)=>err.join(":")).join("\n ");
|
|
2478
|
+
throw new Error(`Errors present:\n\t${errorString}\nUse ignoreErrors = true to generate output despite errors.`);
|
|
2479
|
+
}
|
|
2480
|
+
let jsonRootObj = {
|
|
2481
|
+
type: "USJ",
|
|
2482
|
+
version: "0.2.0",
|
|
2483
|
+
content: []
|
|
2484
|
+
};
|
|
2485
|
+
let outputUSJ;
|
|
2486
|
+
try {
|
|
2487
|
+
let usjGenerator = new (0, $1bdca1468aa54399$export$2e2bcd8739ae039)($236d01ba6f80be5e$var$USFMParser.language, this.usfm, jsonRootObj);
|
|
2488
|
+
usjGenerator.nodeToUSJ(this.syntaxTree, jsonRootObj);
|
|
2489
|
+
outputUSJ = usjGenerator.jsonRootObj;
|
|
2490
|
+
} catch (err) {
|
|
2491
|
+
let message = "Unable to do the conversion. ";
|
|
2492
|
+
if (this.errors) {
|
|
2493
|
+
let errorString = this.errors.map((err)=>err.join(":")).join("\n ");
|
|
2494
|
+
message += `Could be due to an error in the USFM\n\t${errorString}`;
|
|
2495
|
+
}
|
|
2496
|
+
return null;
|
|
2497
|
+
}
|
|
2498
|
+
if (includeMarkers) outputUSJ = (0, $ab5c81e737a0c6a6$export$88c58c54200c5b2)(outputUSJ, [
|
|
2499
|
+
...includeMarkers,
|
|
2500
|
+
"USJ"
|
|
2501
|
+
], combineTexts);
|
|
2502
|
+
if (excludeMarkers) outputUSJ = (0, $ab5c81e737a0c6a6$export$9539ba3a89be1c40)(outputUSJ, excludeMarkers, combineTexts);
|
|
2503
|
+
return outputUSJ;
|
|
2504
|
+
}
|
|
2505
|
+
}
|
|
2506
|
+
var $236d01ba6f80be5e$export$2e2bcd8739ae039 = $236d01ba6f80be5e$var$USFMParser;
|
|
2507
|
+
|
|
2508
|
+
|
|
2509
|
+
console.log("COmes in index.js");
|
|
2510
|
+
|
|
2511
|
+
|
|
2512
|
+
export {$236d01ba6f80be5e$export$2e2bcd8739ae039 as USFMParser};
|
|
2513
|
+
//# sourceMappingURL=index.mjs.map
|