@code0123/opencode-android-arm64 1.1.55 → 1.1.57
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/bin/opencode +3 -1
- package/package.json +1 -77
- package/runtime/highlights-eq9cgrbb.scm +604 -0
- package/runtime/highlights-ghv9g403.scm +205 -0
- package/runtime/highlights-hk7bwhj4.scm +284 -0
- package/runtime/highlights-r812a2qc.scm +150 -0
- package/runtime/highlights-x6tmsnaa.scm +115 -0
- package/runtime/index.js +287124 -0
- package/runtime/injections-73j83es3.scm +27 -0
- package/runtime/parser.worker.js +4081 -0
- package/runtime/tree-sitter-3jzf13jk.wasm +0 -0
- package/runtime/tree-sitter-bash-hq5s6fxb.wasm +0 -0
- package/runtime/tree-sitter-javascript-nd0q4pe9.wasm +0 -0
- package/runtime/tree-sitter-markdown-411r6y9b.wasm +0 -0
- package/runtime/tree-sitter-markdown_inline-j5349f42.wasm +0 -0
- package/runtime/tree-sitter-typescript-zxjzwt75.wasm +0 -0
- package/runtime/tree-sitter-zig-e78zbjpm.wasm +0 -0
- package/runtime/worker.js +208338 -0
- package/parsers-config.ts +0 -253
- package/src/acp/README.md +0 -164
- package/src/acp/agent.ts +0 -1676
- package/src/acp/session.ts +0 -117
- package/src/acp/types.ts +0 -23
- package/src/agent/agent.ts +0 -338
- package/src/agent/generate.txt +0 -75
- package/src/agent/prompt/compaction.txt +0 -12
- package/src/agent/prompt/explore.txt +0 -18
- package/src/agent/prompt/summary.txt +0 -11
- package/src/agent/prompt/title.txt +0 -44
- package/src/auth/index.ts +0 -70
- package/src/bun/index.ts +0 -137
- package/src/bun/registry.ts +0 -48
- package/src/bus/bus-event.ts +0 -43
- package/src/bus/global.ts +0 -10
- package/src/bus/index.ts +0 -105
- package/src/cli/bootstrap.ts +0 -17
- package/src/cli/cmd/acp.ts +0 -70
- package/src/cli/cmd/agent.ts +0 -257
- package/src/cli/cmd/auth.ts +0 -400
- package/src/cli/cmd/cmd.ts +0 -7
- package/src/cli/cmd/debug/agent.ts +0 -167
- package/src/cli/cmd/debug/config.ts +0 -16
- package/src/cli/cmd/debug/file.ts +0 -97
- package/src/cli/cmd/debug/index.ts +0 -48
- package/src/cli/cmd/debug/lsp.ts +0 -52
- package/src/cli/cmd/debug/ripgrep.ts +0 -87
- package/src/cli/cmd/debug/scrap.ts +0 -16
- package/src/cli/cmd/debug/skill.ts +0 -16
- package/src/cli/cmd/debug/snapshot.ts +0 -52
- package/src/cli/cmd/export.ts +0 -88
- package/src/cli/cmd/generate.ts +0 -38
- package/src/cli/cmd/github.ts +0 -1540
- package/src/cli/cmd/import.ts +0 -147
- package/src/cli/cmd/mcp.ts +0 -755
- package/src/cli/cmd/models.ts +0 -77
- package/src/cli/cmd/pr.ts +0 -112
- package/src/cli/cmd/run.ts +0 -598
- package/src/cli/cmd/serve.ts +0 -20
- package/src/cli/cmd/session.ts +0 -135
- package/src/cli/cmd/stats.ts +0 -426
- package/src/cli/cmd/tui/app.tsx +0 -801
- package/src/cli/cmd/tui/attach.ts +0 -52
- package/src/cli/cmd/tui/component/border.tsx +0 -21
- package/src/cli/cmd/tui/component/dialog-agent.tsx +0 -31
- package/src/cli/cmd/tui/component/dialog-command.tsx +0 -148
- package/src/cli/cmd/tui/component/dialog-mcp.tsx +0 -86
- package/src/cli/cmd/tui/component/dialog-model.tsx +0 -234
- package/src/cli/cmd/tui/component/dialog-provider.tsx +0 -266
- package/src/cli/cmd/tui/component/dialog-session-list.tsx +0 -108
- package/src/cli/cmd/tui/component/dialog-session-rename.tsx +0 -31
- package/src/cli/cmd/tui/component/dialog-skill.tsx +0 -36
- package/src/cli/cmd/tui/component/dialog-stash.tsx +0 -87
- package/src/cli/cmd/tui/component/dialog-status.tsx +0 -177
- package/src/cli/cmd/tui/component/dialog-tag.tsx +0 -44
- package/src/cli/cmd/tui/component/dialog-theme-list.tsx +0 -50
- package/src/cli/cmd/tui/component/logo.tsx +0 -85
- package/src/cli/cmd/tui/component/prompt/autocomplete.tsx +0 -666
- package/src/cli/cmd/tui/component/prompt/frecency.tsx +0 -89
- package/src/cli/cmd/tui/component/prompt/history.tsx +0 -108
- package/src/cli/cmd/tui/component/prompt/index.tsx +0 -1132
- package/src/cli/cmd/tui/component/prompt/stash.tsx +0 -101
- package/src/cli/cmd/tui/component/spinner.tsx +0 -24
- package/src/cli/cmd/tui/component/textarea-keybindings.ts +0 -73
- package/src/cli/cmd/tui/component/tips.tsx +0 -153
- package/src/cli/cmd/tui/component/todo-item.tsx +0 -32
- package/src/cli/cmd/tui/context/args.tsx +0 -15
- package/src/cli/cmd/tui/context/directory.ts +0 -13
- package/src/cli/cmd/tui/context/exit.tsx +0 -52
- package/src/cli/cmd/tui/context/helper.tsx +0 -25
- package/src/cli/cmd/tui/context/keybind.tsx +0 -100
- package/src/cli/cmd/tui/context/kv.tsx +0 -52
- package/src/cli/cmd/tui/context/local.tsx +0 -409
- package/src/cli/cmd/tui/context/prompt.tsx +0 -18
- package/src/cli/cmd/tui/context/route.tsx +0 -46
- package/src/cli/cmd/tui/context/sdk.tsx +0 -101
- package/src/cli/cmd/tui/context/sync.tsx +0 -470
- package/src/cli/cmd/tui/context/theme/aura.json +0 -69
- package/src/cli/cmd/tui/context/theme/ayu.json +0 -80
- package/src/cli/cmd/tui/context/theme/carbonfox.json +0 -248
- package/src/cli/cmd/tui/context/theme/catppuccin-frappe.json +0 -233
- package/src/cli/cmd/tui/context/theme/catppuccin-macchiato.json +0 -233
- package/src/cli/cmd/tui/context/theme/catppuccin.json +0 -112
- package/src/cli/cmd/tui/context/theme/cobalt2.json +0 -228
- package/src/cli/cmd/tui/context/theme/cursor.json +0 -249
- package/src/cli/cmd/tui/context/theme/dracula.json +0 -219
- package/src/cli/cmd/tui/context/theme/everforest.json +0 -241
- package/src/cli/cmd/tui/context/theme/flexoki.json +0 -237
- package/src/cli/cmd/tui/context/theme/github.json +0 -233
- package/src/cli/cmd/tui/context/theme/gruvbox.json +0 -242
- package/src/cli/cmd/tui/context/theme/kanagawa.json +0 -77
- package/src/cli/cmd/tui/context/theme/lucent-orng.json +0 -237
- package/src/cli/cmd/tui/context/theme/material.json +0 -235
- package/src/cli/cmd/tui/context/theme/matrix.json +0 -77
- package/src/cli/cmd/tui/context/theme/mercury.json +0 -252
- package/src/cli/cmd/tui/context/theme/monokai.json +0 -221
- package/src/cli/cmd/tui/context/theme/nightowl.json +0 -221
- package/src/cli/cmd/tui/context/theme/nord.json +0 -223
- package/src/cli/cmd/tui/context/theme/one-dark.json +0 -84
- package/src/cli/cmd/tui/context/theme/opencode.json +0 -245
- package/src/cli/cmd/tui/context/theme/orng.json +0 -249
- package/src/cli/cmd/tui/context/theme/osaka-jade.json +0 -93
- package/src/cli/cmd/tui/context/theme/palenight.json +0 -222
- package/src/cli/cmd/tui/context/theme/rosepine.json +0 -234
- package/src/cli/cmd/tui/context/theme/solarized.json +0 -223
- package/src/cli/cmd/tui/context/theme/synthwave84.json +0 -226
- package/src/cli/cmd/tui/context/theme/tokyonight.json +0 -243
- package/src/cli/cmd/tui/context/theme/vercel.json +0 -245
- package/src/cli/cmd/tui/context/theme/vesper.json +0 -218
- package/src/cli/cmd/tui/context/theme/zenburn.json +0 -223
- package/src/cli/cmd/tui/context/theme.tsx +0 -1152
- package/src/cli/cmd/tui/event.ts +0 -48
- package/src/cli/cmd/tui/routes/home.tsx +0 -140
- package/src/cli/cmd/tui/routes/session/dialog-fork-from-timeline.tsx +0 -64
- package/src/cli/cmd/tui/routes/session/dialog-message.tsx +0 -109
- package/src/cli/cmd/tui/routes/session/dialog-subagent.tsx +0 -26
- package/src/cli/cmd/tui/routes/session/dialog-timeline.tsx +0 -47
- package/src/cli/cmd/tui/routes/session/footer.tsx +0 -91
- package/src/cli/cmd/tui/routes/session/header.tsx +0 -142
- package/src/cli/cmd/tui/routes/session/index.tsx +0 -2126
- package/src/cli/cmd/tui/routes/session/permission.tsx +0 -508
- package/src/cli/cmd/tui/routes/session/question.tsx +0 -466
- package/src/cli/cmd/tui/routes/session/sidebar.tsx +0 -313
- package/src/cli/cmd/tui/thread.ts +0 -175
- package/src/cli/cmd/tui/ui/dialog-alert.tsx +0 -68
- package/src/cli/cmd/tui/ui/dialog-confirm.tsx +0 -93
- package/src/cli/cmd/tui/ui/dialog-export-options.tsx +0 -215
- package/src/cli/cmd/tui/ui/dialog-help.tsx +0 -49
- package/src/cli/cmd/tui/ui/dialog-prompt.tsx +0 -88
- package/src/cli/cmd/tui/ui/dialog-select.tsx +0 -399
- package/src/cli/cmd/tui/ui/dialog.tsx +0 -167
- package/src/cli/cmd/tui/ui/link.tsx +0 -28
- package/src/cli/cmd/tui/ui/spinner.ts +0 -368
- package/src/cli/cmd/tui/ui/toast.tsx +0 -100
- package/src/cli/cmd/tui/util/clipboard.ts +0 -159
- package/src/cli/cmd/tui/util/editor.ts +0 -32
- package/src/cli/cmd/tui/util/signal.ts +0 -7
- package/src/cli/cmd/tui/util/terminal.ts +0 -114
- package/src/cli/cmd/tui/util/transcript.ts +0 -98
- package/src/cli/cmd/tui/worker.ts +0 -152
- package/src/cli/cmd/uninstall.ts +0 -357
- package/src/cli/cmd/upgrade.ts +0 -73
- package/src/cli/cmd/web.ts +0 -81
- package/src/cli/error.ts +0 -57
- package/src/cli/logo.ts +0 -6
- package/src/cli/network.ts +0 -60
- package/src/cli/ui.ts +0 -113
- package/src/cli/upgrade.ts +0 -25
- package/src/command/index.ts +0 -150
- package/src/command/template/initialize.txt +0 -10
- package/src/command/template/review.txt +0 -99
- package/src/config/config.ts +0 -1477
- package/src/config/markdown.ts +0 -98
- package/src/env/index.ts +0 -28
- package/src/file/ignore.ts +0 -83
- package/src/file/index.ts +0 -583
- package/src/file/ripgrep.ts +0 -384
- package/src/file/time.ts +0 -69
- package/src/file/watcher.ts +0 -148
- package/src/flag/flag.ts +0 -93
- package/src/format/formatter.ts +0 -366
- package/src/format/index.ts +0 -137
- package/src/global/index.ts +0 -55
- package/src/id/id.ts +0 -83
- package/src/ide/index.ts +0 -76
- package/src/index.ts +0 -159
- package/src/installation/index.ts +0 -246
- package/src/lsp/client.ts +0 -252
- package/src/lsp/index.ts +0 -485
- package/src/lsp/language.ts +0 -119
- package/src/lsp/server.ts +0 -2046
- package/src/mcp/auth.ts +0 -132
- package/src/mcp/index.ts +0 -934
- package/src/mcp/oauth-callback.ts +0 -200
- package/src/mcp/oauth-provider.ts +0 -154
- package/src/patch/index.ts +0 -680
- package/src/permission/arity.ts +0 -163
- package/src/permission/index.ts +0 -210
- package/src/permission/next.ts +0 -280
- package/src/plugin/codex.ts +0 -624
- package/src/plugin/copilot.ts +0 -327
- package/src/plugin/index.ts +0 -138
- package/src/project/bootstrap.ts +0 -35
- package/src/project/instance.ts +0 -114
- package/src/project/project.ts +0 -371
- package/src/project/state.ts +0 -70
- package/src/project/vcs.ts +0 -76
- package/src/provider/auth.ts +0 -147
- package/src/provider/models-snapshot.ts +0 -38414
- package/src/provider/models.ts +0 -133
- package/src/provider/provider.ts +0 -1262
- package/src/provider/sdk/copilot/README.md +0 -5
- package/src/provider/sdk/copilot/chat/convert-to-openai-compatible-chat-messages.ts +0 -164
- package/src/provider/sdk/copilot/chat/get-response-metadata.ts +0 -15
- package/src/provider/sdk/copilot/chat/map-openai-compatible-finish-reason.ts +0 -17
- package/src/provider/sdk/copilot/chat/openai-compatible-api-types.ts +0 -64
- package/src/provider/sdk/copilot/chat/openai-compatible-chat-language-model.ts +0 -780
- package/src/provider/sdk/copilot/chat/openai-compatible-chat-options.ts +0 -28
- package/src/provider/sdk/copilot/chat/openai-compatible-metadata-extractor.ts +0 -44
- package/src/provider/sdk/copilot/chat/openai-compatible-prepare-tools.ts +0 -87
- package/src/provider/sdk/copilot/copilot-provider.ts +0 -100
- package/src/provider/sdk/copilot/index.ts +0 -2
- package/src/provider/sdk/copilot/openai-compatible-error.ts +0 -27
- package/src/provider/sdk/copilot/responses/convert-to-openai-responses-input.ts +0 -303
- package/src/provider/sdk/copilot/responses/map-openai-responses-finish-reason.ts +0 -22
- package/src/provider/sdk/copilot/responses/openai-config.ts +0 -18
- package/src/provider/sdk/copilot/responses/openai-error.ts +0 -22
- package/src/provider/sdk/copilot/responses/openai-responses-api-types.ts +0 -207
- package/src/provider/sdk/copilot/responses/openai-responses-language-model.ts +0 -1732
- package/src/provider/sdk/copilot/responses/openai-responses-prepare-tools.ts +0 -177
- package/src/provider/sdk/copilot/responses/openai-responses-settings.ts +0 -1
- package/src/provider/sdk/copilot/responses/tool/code-interpreter.ts +0 -88
- package/src/provider/sdk/copilot/responses/tool/file-search.ts +0 -128
- package/src/provider/sdk/copilot/responses/tool/image-generation.ts +0 -115
- package/src/provider/sdk/copilot/responses/tool/local-shell.ts +0 -65
- package/src/provider/sdk/copilot/responses/tool/web-search-preview.ts +0 -104
- package/src/provider/sdk/copilot/responses/tool/web-search.ts +0 -103
- package/src/provider/transform.ts +0 -828
- package/src/pty/index.ts +0 -250
- package/src/question/index.ts +0 -171
- package/src/scheduler/index.ts +0 -61
- package/src/server/error.ts +0 -36
- package/src/server/event.ts +0 -7
- package/src/server/mdns.ts +0 -60
- package/src/server/routes/config.ts +0 -92
- package/src/server/routes/experimental.ts +0 -208
- package/src/server/routes/file.ts +0 -197
- package/src/server/routes/global.ts +0 -183
- package/src/server/routes/mcp.ts +0 -225
- package/src/server/routes/permission.ts +0 -68
- package/src/server/routes/project.ts +0 -82
- package/src/server/routes/provider.ts +0 -165
- package/src/server/routes/pty.ts +0 -169
- package/src/server/routes/question.ts +0 -98
- package/src/server/routes/session.ts +0 -939
- package/src/server/routes/tui.ts +0 -379
- package/src/server/server.ts +0 -613
- package/src/session/compaction.ts +0 -226
- package/src/session/index.ts +0 -517
- package/src/session/instruction.ts +0 -197
- package/src/session/llm.ts +0 -289
- package/src/session/message-v2.ts +0 -802
- package/src/session/message.ts +0 -189
- package/src/session/processor.ts +0 -407
- package/src/session/prompt/anthropic-20250930.txt +0 -166
- package/src/session/prompt/anthropic.txt +0 -105
- package/src/session/prompt/beast.txt +0 -147
- package/src/session/prompt/build-switch.txt +0 -5
- package/src/session/prompt/codex_header.txt +0 -79
- package/src/session/prompt/copilot-gpt-5.txt +0 -143
- package/src/session/prompt/gemini.txt +0 -155
- package/src/session/prompt/max-steps.txt +0 -16
- package/src/session/prompt/plan-reminder-anthropic.txt +0 -67
- package/src/session/prompt/plan.txt +0 -26
- package/src/session/prompt/qwen.txt +0 -109
- package/src/session/prompt/trinity.txt +0 -97
- package/src/session/prompt.ts +0 -1866
- package/src/session/retry.ts +0 -97
- package/src/session/revert.ts +0 -121
- package/src/session/status.ts +0 -76
- package/src/session/summary.ts +0 -217
- package/src/session/system.ts +0 -54
- package/src/session/todo.ts +0 -37
- package/src/share/share-next.ts +0 -200
- package/src/share/share.ts +0 -92
- package/src/shell/shell.ts +0 -67
- package/src/skill/discovery.ts +0 -97
- package/src/skill/index.ts +0 -1
- package/src/skill/skill.ts +0 -188
- package/src/snapshot/index.ts +0 -255
- package/src/storage/storage.ts +0 -227
- package/src/tool/apply_patch.ts +0 -281
- package/src/tool/apply_patch.txt +0 -33
- package/src/tool/bash.ts +0 -269
- package/src/tool/bash.txt +0 -115
- package/src/tool/batch.ts +0 -175
- package/src/tool/batch.txt +0 -24
- package/src/tool/codesearch.ts +0 -132
- package/src/tool/codesearch.txt +0 -12
- package/src/tool/edit.ts +0 -655
- package/src/tool/edit.txt +0 -10
- package/src/tool/external-directory.ts +0 -32
- package/src/tool/glob.ts +0 -78
- package/src/tool/glob.txt +0 -6
- package/src/tool/grep.ts +0 -147
- package/src/tool/grep.txt +0 -8
- package/src/tool/invalid.ts +0 -17
- package/src/tool/ls.ts +0 -121
- package/src/tool/ls.txt +0 -1
- package/src/tool/lsp.ts +0 -96
- package/src/tool/lsp.txt +0 -19
- package/src/tool/multiedit.ts +0 -46
- package/src/tool/multiedit.txt +0 -41
- package/src/tool/plan-enter.txt +0 -14
- package/src/tool/plan-exit.txt +0 -13
- package/src/tool/plan.ts +0 -130
- package/src/tool/question.ts +0 -33
- package/src/tool/question.txt +0 -10
- package/src/tool/read.ts +0 -211
- package/src/tool/read.txt +0 -12
- package/src/tool/registry.ts +0 -160
- package/src/tool/skill.ts +0 -123
- package/src/tool/task.ts +0 -165
- package/src/tool/task.txt +0 -60
- package/src/tool/todo.ts +0 -53
- package/src/tool/todoread.txt +0 -14
- package/src/tool/todowrite.txt +0 -167
- package/src/tool/tool.ts +0 -89
- package/src/tool/truncation.ts +0 -106
- package/src/tool/webfetch.ts +0 -186
- package/src/tool/webfetch.txt +0 -13
- package/src/tool/websearch.ts +0 -150
- package/src/tool/websearch.txt +0 -14
- package/src/tool/write.ts +0 -85
- package/src/tool/write.txt +0 -8
- package/src/util/abort.ts +0 -35
- package/src/util/archive.ts +0 -16
- package/src/util/color.ts +0 -19
- package/src/util/context.ts +0 -25
- package/src/util/defer.ts +0 -12
- package/src/util/eventloop.ts +0 -20
- package/src/util/filesystem.ts +0 -93
- package/src/util/fn.ts +0 -11
- package/src/util/format.ts +0 -20
- package/src/util/iife.ts +0 -3
- package/src/util/keybind.ts +0 -103
- package/src/util/lazy.ts +0 -18
- package/src/util/locale.ts +0 -81
- package/src/util/lock.ts +0 -98
- package/src/util/log.ts +0 -180
- package/src/util/proxied.ts +0 -3
- package/src/util/queue.ts +0 -32
- package/src/util/rpc.ts +0 -66
- package/src/util/scrap.ts +0 -10
- package/src/util/signal.ts +0 -12
- package/src/util/timeout.ts +0 -14
- package/src/util/token.ts +0 -7
- package/src/util/wildcard.ts +0 -56
- package/src/worktree/index.ts +0 -574
- package/tsconfig.json +0 -10
|
@@ -0,0 +1,4081 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __toESM = (mod, isNodeMode, target) => {
|
|
8
|
+
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
9
|
+
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
10
|
+
for (let key of __getOwnPropNames(mod))
|
|
11
|
+
if (!__hasOwnProp.call(to, key))
|
|
12
|
+
__defProp(to, key, {
|
|
13
|
+
get: () => mod[key],
|
|
14
|
+
enumerable: true
|
|
15
|
+
});
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
19
|
+
var __require = import.meta.require;
|
|
20
|
+
|
|
21
|
+
// ../../node_modules/.bun/web-tree-sitter@0.25.10/node_modules/web-tree-sitter/tree-sitter.wasm
|
|
22
|
+
var require_tree_sitter = __commonJS((exports, module2) => {
|
|
23
|
+
module2.exports = "./tree-sitter-3jzf13jk.wasm";
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
// ../../node_modules/.bun/web-tree-sitter@0.25.10/node_modules/web-tree-sitter/tree-sitter.js
|
|
27
|
+
var __defProp2 = Object.defineProperty;
|
|
28
|
+
var __name = (target, value) => __defProp2(target, "name", { value, configurable: true });
|
|
29
|
+
var SIZE_OF_SHORT = 2;
|
|
30
|
+
var SIZE_OF_INT = 4;
|
|
31
|
+
var SIZE_OF_CURSOR = 4 * SIZE_OF_INT;
|
|
32
|
+
var SIZE_OF_NODE = 5 * SIZE_OF_INT;
|
|
33
|
+
var SIZE_OF_POINT = 2 * SIZE_OF_INT;
|
|
34
|
+
var SIZE_OF_RANGE = 2 * SIZE_OF_INT + 2 * SIZE_OF_POINT;
|
|
35
|
+
var ZERO_POINT = { row: 0, column: 0 };
|
|
36
|
+
var INTERNAL = Symbol("INTERNAL");
|
|
37
|
+
function assertInternal(x) {
|
|
38
|
+
if (x !== INTERNAL)
|
|
39
|
+
throw new Error("Illegal constructor");
|
|
40
|
+
}
|
|
41
|
+
__name(assertInternal, "assertInternal");
|
|
42
|
+
function isPoint(point) {
|
|
43
|
+
return !!point && typeof point.row === "number" && typeof point.column === "number";
|
|
44
|
+
}
|
|
45
|
+
__name(isPoint, "isPoint");
|
|
46
|
+
function setModule(module2) {
|
|
47
|
+
C = module2;
|
|
48
|
+
}
|
|
49
|
+
__name(setModule, "setModule");
|
|
50
|
+
var C;
|
|
51
|
+
var LookaheadIterator = class {
|
|
52
|
+
static {
|
|
53
|
+
__name(this, "LookaheadIterator");
|
|
54
|
+
}
|
|
55
|
+
[0] = 0;
|
|
56
|
+
language;
|
|
57
|
+
constructor(internal, address, language) {
|
|
58
|
+
assertInternal(internal);
|
|
59
|
+
this[0] = address;
|
|
60
|
+
this.language = language;
|
|
61
|
+
}
|
|
62
|
+
get currentTypeId() {
|
|
63
|
+
return C._ts_lookahead_iterator_current_symbol(this[0]);
|
|
64
|
+
}
|
|
65
|
+
get currentType() {
|
|
66
|
+
return this.language.types[this.currentTypeId] || "ERROR";
|
|
67
|
+
}
|
|
68
|
+
delete() {
|
|
69
|
+
C._ts_lookahead_iterator_delete(this[0]);
|
|
70
|
+
this[0] = 0;
|
|
71
|
+
}
|
|
72
|
+
reset(language, stateId) {
|
|
73
|
+
if (C._ts_lookahead_iterator_reset(this[0], language[0], stateId)) {
|
|
74
|
+
this.language = language;
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
resetState(stateId) {
|
|
80
|
+
return Boolean(C._ts_lookahead_iterator_reset_state(this[0], stateId));
|
|
81
|
+
}
|
|
82
|
+
[Symbol.iterator]() {
|
|
83
|
+
return {
|
|
84
|
+
next: /* @__PURE__ */ __name(() => {
|
|
85
|
+
if (C._ts_lookahead_iterator_next(this[0])) {
|
|
86
|
+
return { done: false, value: this.currentType };
|
|
87
|
+
}
|
|
88
|
+
return { done: true, value: "" };
|
|
89
|
+
}, "next")
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
function getText(tree, startIndex, endIndex, startPosition) {
|
|
94
|
+
const length = endIndex - startIndex;
|
|
95
|
+
let result = tree.textCallback(startIndex, startPosition);
|
|
96
|
+
if (result) {
|
|
97
|
+
startIndex += result.length;
|
|
98
|
+
while (startIndex < endIndex) {
|
|
99
|
+
const string = tree.textCallback(startIndex, startPosition);
|
|
100
|
+
if (string && string.length > 0) {
|
|
101
|
+
startIndex += string.length;
|
|
102
|
+
result += string;
|
|
103
|
+
} else {
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
if (startIndex > endIndex) {
|
|
108
|
+
result = result.slice(0, length);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return result ?? "";
|
|
112
|
+
}
|
|
113
|
+
__name(getText, "getText");
|
|
114
|
+
var Tree = class _Tree {
|
|
115
|
+
static {
|
|
116
|
+
__name(this, "Tree");
|
|
117
|
+
}
|
|
118
|
+
[0] = 0;
|
|
119
|
+
textCallback;
|
|
120
|
+
language;
|
|
121
|
+
constructor(internal, address, language, textCallback) {
|
|
122
|
+
assertInternal(internal);
|
|
123
|
+
this[0] = address;
|
|
124
|
+
this.language = language;
|
|
125
|
+
this.textCallback = textCallback;
|
|
126
|
+
}
|
|
127
|
+
copy() {
|
|
128
|
+
const address = C._ts_tree_copy(this[0]);
|
|
129
|
+
return new _Tree(INTERNAL, address, this.language, this.textCallback);
|
|
130
|
+
}
|
|
131
|
+
delete() {
|
|
132
|
+
C._ts_tree_delete(this[0]);
|
|
133
|
+
this[0] = 0;
|
|
134
|
+
}
|
|
135
|
+
get rootNode() {
|
|
136
|
+
C._ts_tree_root_node_wasm(this[0]);
|
|
137
|
+
return unmarshalNode(this);
|
|
138
|
+
}
|
|
139
|
+
rootNodeWithOffset(offsetBytes, offsetExtent) {
|
|
140
|
+
const address = TRANSFER_BUFFER + SIZE_OF_NODE;
|
|
141
|
+
C.setValue(address, offsetBytes, "i32");
|
|
142
|
+
marshalPoint(address + SIZE_OF_INT, offsetExtent);
|
|
143
|
+
C._ts_tree_root_node_with_offset_wasm(this[0]);
|
|
144
|
+
return unmarshalNode(this);
|
|
145
|
+
}
|
|
146
|
+
edit(edit) {
|
|
147
|
+
marshalEdit(edit);
|
|
148
|
+
C._ts_tree_edit_wasm(this[0]);
|
|
149
|
+
}
|
|
150
|
+
walk() {
|
|
151
|
+
return this.rootNode.walk();
|
|
152
|
+
}
|
|
153
|
+
getChangedRanges(other) {
|
|
154
|
+
if (!(other instanceof _Tree)) {
|
|
155
|
+
throw new TypeError("Argument must be a Tree");
|
|
156
|
+
}
|
|
157
|
+
C._ts_tree_get_changed_ranges_wasm(this[0], other[0]);
|
|
158
|
+
const count = C.getValue(TRANSFER_BUFFER, "i32");
|
|
159
|
+
const buffer = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
|
|
160
|
+
const result = new Array(count);
|
|
161
|
+
if (count > 0) {
|
|
162
|
+
let address = buffer;
|
|
163
|
+
for (let i2 = 0;i2 < count; i2++) {
|
|
164
|
+
result[i2] = unmarshalRange(address);
|
|
165
|
+
address += SIZE_OF_RANGE;
|
|
166
|
+
}
|
|
167
|
+
C._free(buffer);
|
|
168
|
+
}
|
|
169
|
+
return result;
|
|
170
|
+
}
|
|
171
|
+
getIncludedRanges() {
|
|
172
|
+
C._ts_tree_included_ranges_wasm(this[0]);
|
|
173
|
+
const count = C.getValue(TRANSFER_BUFFER, "i32");
|
|
174
|
+
const buffer = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
|
|
175
|
+
const result = new Array(count);
|
|
176
|
+
if (count > 0) {
|
|
177
|
+
let address = buffer;
|
|
178
|
+
for (let i2 = 0;i2 < count; i2++) {
|
|
179
|
+
result[i2] = unmarshalRange(address);
|
|
180
|
+
address += SIZE_OF_RANGE;
|
|
181
|
+
}
|
|
182
|
+
C._free(buffer);
|
|
183
|
+
}
|
|
184
|
+
return result;
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
var TreeCursor = class _TreeCursor {
|
|
188
|
+
static {
|
|
189
|
+
__name(this, "TreeCursor");
|
|
190
|
+
}
|
|
191
|
+
[0] = 0;
|
|
192
|
+
[1] = 0;
|
|
193
|
+
[2] = 0;
|
|
194
|
+
[3] = 0;
|
|
195
|
+
tree;
|
|
196
|
+
constructor(internal, tree) {
|
|
197
|
+
assertInternal(internal);
|
|
198
|
+
this.tree = tree;
|
|
199
|
+
unmarshalTreeCursor(this);
|
|
200
|
+
}
|
|
201
|
+
copy() {
|
|
202
|
+
const copy = new _TreeCursor(INTERNAL, this.tree);
|
|
203
|
+
C._ts_tree_cursor_copy_wasm(this.tree[0]);
|
|
204
|
+
unmarshalTreeCursor(copy);
|
|
205
|
+
return copy;
|
|
206
|
+
}
|
|
207
|
+
delete() {
|
|
208
|
+
marshalTreeCursor(this);
|
|
209
|
+
C._ts_tree_cursor_delete_wasm(this.tree[0]);
|
|
210
|
+
this[0] = this[1] = this[2] = 0;
|
|
211
|
+
}
|
|
212
|
+
get currentNode() {
|
|
213
|
+
marshalTreeCursor(this);
|
|
214
|
+
C._ts_tree_cursor_current_node_wasm(this.tree[0]);
|
|
215
|
+
return unmarshalNode(this.tree);
|
|
216
|
+
}
|
|
217
|
+
get currentFieldId() {
|
|
218
|
+
marshalTreeCursor(this);
|
|
219
|
+
return C._ts_tree_cursor_current_field_id_wasm(this.tree[0]);
|
|
220
|
+
}
|
|
221
|
+
get currentFieldName() {
|
|
222
|
+
return this.tree.language.fields[this.currentFieldId];
|
|
223
|
+
}
|
|
224
|
+
get currentDepth() {
|
|
225
|
+
marshalTreeCursor(this);
|
|
226
|
+
return C._ts_tree_cursor_current_depth_wasm(this.tree[0]);
|
|
227
|
+
}
|
|
228
|
+
get currentDescendantIndex() {
|
|
229
|
+
marshalTreeCursor(this);
|
|
230
|
+
return C._ts_tree_cursor_current_descendant_index_wasm(this.tree[0]);
|
|
231
|
+
}
|
|
232
|
+
get nodeType() {
|
|
233
|
+
return this.tree.language.types[this.nodeTypeId] || "ERROR";
|
|
234
|
+
}
|
|
235
|
+
get nodeTypeId() {
|
|
236
|
+
marshalTreeCursor(this);
|
|
237
|
+
return C._ts_tree_cursor_current_node_type_id_wasm(this.tree[0]);
|
|
238
|
+
}
|
|
239
|
+
get nodeStateId() {
|
|
240
|
+
marshalTreeCursor(this);
|
|
241
|
+
return C._ts_tree_cursor_current_node_state_id_wasm(this.tree[0]);
|
|
242
|
+
}
|
|
243
|
+
get nodeId() {
|
|
244
|
+
marshalTreeCursor(this);
|
|
245
|
+
return C._ts_tree_cursor_current_node_id_wasm(this.tree[0]);
|
|
246
|
+
}
|
|
247
|
+
get nodeIsNamed() {
|
|
248
|
+
marshalTreeCursor(this);
|
|
249
|
+
return C._ts_tree_cursor_current_node_is_named_wasm(this.tree[0]) === 1;
|
|
250
|
+
}
|
|
251
|
+
get nodeIsMissing() {
|
|
252
|
+
marshalTreeCursor(this);
|
|
253
|
+
return C._ts_tree_cursor_current_node_is_missing_wasm(this.tree[0]) === 1;
|
|
254
|
+
}
|
|
255
|
+
get nodeText() {
|
|
256
|
+
marshalTreeCursor(this);
|
|
257
|
+
const startIndex = C._ts_tree_cursor_start_index_wasm(this.tree[0]);
|
|
258
|
+
const endIndex = C._ts_tree_cursor_end_index_wasm(this.tree[0]);
|
|
259
|
+
C._ts_tree_cursor_start_position_wasm(this.tree[0]);
|
|
260
|
+
const startPosition = unmarshalPoint(TRANSFER_BUFFER);
|
|
261
|
+
return getText(this.tree, startIndex, endIndex, startPosition);
|
|
262
|
+
}
|
|
263
|
+
get startPosition() {
|
|
264
|
+
marshalTreeCursor(this);
|
|
265
|
+
C._ts_tree_cursor_start_position_wasm(this.tree[0]);
|
|
266
|
+
return unmarshalPoint(TRANSFER_BUFFER);
|
|
267
|
+
}
|
|
268
|
+
get endPosition() {
|
|
269
|
+
marshalTreeCursor(this);
|
|
270
|
+
C._ts_tree_cursor_end_position_wasm(this.tree[0]);
|
|
271
|
+
return unmarshalPoint(TRANSFER_BUFFER);
|
|
272
|
+
}
|
|
273
|
+
get startIndex() {
|
|
274
|
+
marshalTreeCursor(this);
|
|
275
|
+
return C._ts_tree_cursor_start_index_wasm(this.tree[0]);
|
|
276
|
+
}
|
|
277
|
+
get endIndex() {
|
|
278
|
+
marshalTreeCursor(this);
|
|
279
|
+
return C._ts_tree_cursor_end_index_wasm(this.tree[0]);
|
|
280
|
+
}
|
|
281
|
+
gotoFirstChild() {
|
|
282
|
+
marshalTreeCursor(this);
|
|
283
|
+
const result = C._ts_tree_cursor_goto_first_child_wasm(this.tree[0]);
|
|
284
|
+
unmarshalTreeCursor(this);
|
|
285
|
+
return result === 1;
|
|
286
|
+
}
|
|
287
|
+
gotoLastChild() {
|
|
288
|
+
marshalTreeCursor(this);
|
|
289
|
+
const result = C._ts_tree_cursor_goto_last_child_wasm(this.tree[0]);
|
|
290
|
+
unmarshalTreeCursor(this);
|
|
291
|
+
return result === 1;
|
|
292
|
+
}
|
|
293
|
+
gotoParent() {
|
|
294
|
+
marshalTreeCursor(this);
|
|
295
|
+
const result = C._ts_tree_cursor_goto_parent_wasm(this.tree[0]);
|
|
296
|
+
unmarshalTreeCursor(this);
|
|
297
|
+
return result === 1;
|
|
298
|
+
}
|
|
299
|
+
gotoNextSibling() {
|
|
300
|
+
marshalTreeCursor(this);
|
|
301
|
+
const result = C._ts_tree_cursor_goto_next_sibling_wasm(this.tree[0]);
|
|
302
|
+
unmarshalTreeCursor(this);
|
|
303
|
+
return result === 1;
|
|
304
|
+
}
|
|
305
|
+
gotoPreviousSibling() {
|
|
306
|
+
marshalTreeCursor(this);
|
|
307
|
+
const result = C._ts_tree_cursor_goto_previous_sibling_wasm(this.tree[0]);
|
|
308
|
+
unmarshalTreeCursor(this);
|
|
309
|
+
return result === 1;
|
|
310
|
+
}
|
|
311
|
+
gotoDescendant(goalDescendantIndex) {
|
|
312
|
+
marshalTreeCursor(this);
|
|
313
|
+
C._ts_tree_cursor_goto_descendant_wasm(this.tree[0], goalDescendantIndex);
|
|
314
|
+
unmarshalTreeCursor(this);
|
|
315
|
+
}
|
|
316
|
+
gotoFirstChildForIndex(goalIndex) {
|
|
317
|
+
marshalTreeCursor(this);
|
|
318
|
+
C.setValue(TRANSFER_BUFFER + SIZE_OF_CURSOR, goalIndex, "i32");
|
|
319
|
+
const result = C._ts_tree_cursor_goto_first_child_for_index_wasm(this.tree[0]);
|
|
320
|
+
unmarshalTreeCursor(this);
|
|
321
|
+
return result === 1;
|
|
322
|
+
}
|
|
323
|
+
gotoFirstChildForPosition(goalPosition) {
|
|
324
|
+
marshalTreeCursor(this);
|
|
325
|
+
marshalPoint(TRANSFER_BUFFER + SIZE_OF_CURSOR, goalPosition);
|
|
326
|
+
const result = C._ts_tree_cursor_goto_first_child_for_position_wasm(this.tree[0]);
|
|
327
|
+
unmarshalTreeCursor(this);
|
|
328
|
+
return result === 1;
|
|
329
|
+
}
|
|
330
|
+
reset(node) {
|
|
331
|
+
marshalNode(node);
|
|
332
|
+
marshalTreeCursor(this, TRANSFER_BUFFER + SIZE_OF_NODE);
|
|
333
|
+
C._ts_tree_cursor_reset_wasm(this.tree[0]);
|
|
334
|
+
unmarshalTreeCursor(this);
|
|
335
|
+
}
|
|
336
|
+
resetTo(cursor) {
|
|
337
|
+
marshalTreeCursor(this, TRANSFER_BUFFER);
|
|
338
|
+
marshalTreeCursor(cursor, TRANSFER_BUFFER + SIZE_OF_CURSOR);
|
|
339
|
+
C._ts_tree_cursor_reset_to_wasm(this.tree[0], cursor.tree[0]);
|
|
340
|
+
unmarshalTreeCursor(this);
|
|
341
|
+
}
|
|
342
|
+
};
|
|
343
|
+
var Node = class {
|
|
344
|
+
static {
|
|
345
|
+
__name(this, "Node");
|
|
346
|
+
}
|
|
347
|
+
[0] = 0;
|
|
348
|
+
_children;
|
|
349
|
+
_namedChildren;
|
|
350
|
+
constructor(internal, {
|
|
351
|
+
id,
|
|
352
|
+
tree,
|
|
353
|
+
startIndex,
|
|
354
|
+
startPosition,
|
|
355
|
+
other
|
|
356
|
+
}) {
|
|
357
|
+
assertInternal(internal);
|
|
358
|
+
this[0] = other;
|
|
359
|
+
this.id = id;
|
|
360
|
+
this.tree = tree;
|
|
361
|
+
this.startIndex = startIndex;
|
|
362
|
+
this.startPosition = startPosition;
|
|
363
|
+
}
|
|
364
|
+
id;
|
|
365
|
+
startIndex;
|
|
366
|
+
startPosition;
|
|
367
|
+
tree;
|
|
368
|
+
get typeId() {
|
|
369
|
+
marshalNode(this);
|
|
370
|
+
return C._ts_node_symbol_wasm(this.tree[0]);
|
|
371
|
+
}
|
|
372
|
+
get grammarId() {
|
|
373
|
+
marshalNode(this);
|
|
374
|
+
return C._ts_node_grammar_symbol_wasm(this.tree[0]);
|
|
375
|
+
}
|
|
376
|
+
get type() {
|
|
377
|
+
return this.tree.language.types[this.typeId] || "ERROR";
|
|
378
|
+
}
|
|
379
|
+
get grammarType() {
|
|
380
|
+
return this.tree.language.types[this.grammarId] || "ERROR";
|
|
381
|
+
}
|
|
382
|
+
get isNamed() {
|
|
383
|
+
marshalNode(this);
|
|
384
|
+
return C._ts_node_is_named_wasm(this.tree[0]) === 1;
|
|
385
|
+
}
|
|
386
|
+
get isExtra() {
|
|
387
|
+
marshalNode(this);
|
|
388
|
+
return C._ts_node_is_extra_wasm(this.tree[0]) === 1;
|
|
389
|
+
}
|
|
390
|
+
get isError() {
|
|
391
|
+
marshalNode(this);
|
|
392
|
+
return C._ts_node_is_error_wasm(this.tree[0]) === 1;
|
|
393
|
+
}
|
|
394
|
+
get isMissing() {
|
|
395
|
+
marshalNode(this);
|
|
396
|
+
return C._ts_node_is_missing_wasm(this.tree[0]) === 1;
|
|
397
|
+
}
|
|
398
|
+
get hasChanges() {
|
|
399
|
+
marshalNode(this);
|
|
400
|
+
return C._ts_node_has_changes_wasm(this.tree[0]) === 1;
|
|
401
|
+
}
|
|
402
|
+
get hasError() {
|
|
403
|
+
marshalNode(this);
|
|
404
|
+
return C._ts_node_has_error_wasm(this.tree[0]) === 1;
|
|
405
|
+
}
|
|
406
|
+
get endIndex() {
|
|
407
|
+
marshalNode(this);
|
|
408
|
+
return C._ts_node_end_index_wasm(this.tree[0]);
|
|
409
|
+
}
|
|
410
|
+
get endPosition() {
|
|
411
|
+
marshalNode(this);
|
|
412
|
+
C._ts_node_end_point_wasm(this.tree[0]);
|
|
413
|
+
return unmarshalPoint(TRANSFER_BUFFER);
|
|
414
|
+
}
|
|
415
|
+
get text() {
|
|
416
|
+
return getText(this.tree, this.startIndex, this.endIndex, this.startPosition);
|
|
417
|
+
}
|
|
418
|
+
get parseState() {
|
|
419
|
+
marshalNode(this);
|
|
420
|
+
return C._ts_node_parse_state_wasm(this.tree[0]);
|
|
421
|
+
}
|
|
422
|
+
get nextParseState() {
|
|
423
|
+
marshalNode(this);
|
|
424
|
+
return C._ts_node_next_parse_state_wasm(this.tree[0]);
|
|
425
|
+
}
|
|
426
|
+
equals(other) {
|
|
427
|
+
return this.tree === other.tree && this.id === other.id;
|
|
428
|
+
}
|
|
429
|
+
child(index) {
|
|
430
|
+
marshalNode(this);
|
|
431
|
+
C._ts_node_child_wasm(this.tree[0], index);
|
|
432
|
+
return unmarshalNode(this.tree);
|
|
433
|
+
}
|
|
434
|
+
namedChild(index) {
|
|
435
|
+
marshalNode(this);
|
|
436
|
+
C._ts_node_named_child_wasm(this.tree[0], index);
|
|
437
|
+
return unmarshalNode(this.tree);
|
|
438
|
+
}
|
|
439
|
+
childForFieldId(fieldId) {
|
|
440
|
+
marshalNode(this);
|
|
441
|
+
C._ts_node_child_by_field_id_wasm(this.tree[0], fieldId);
|
|
442
|
+
return unmarshalNode(this.tree);
|
|
443
|
+
}
|
|
444
|
+
childForFieldName(fieldName) {
|
|
445
|
+
const fieldId = this.tree.language.fields.indexOf(fieldName);
|
|
446
|
+
if (fieldId !== -1)
|
|
447
|
+
return this.childForFieldId(fieldId);
|
|
448
|
+
return null;
|
|
449
|
+
}
|
|
450
|
+
fieldNameForChild(index) {
|
|
451
|
+
marshalNode(this);
|
|
452
|
+
const address = C._ts_node_field_name_for_child_wasm(this.tree[0], index);
|
|
453
|
+
if (!address)
|
|
454
|
+
return null;
|
|
455
|
+
return C.AsciiToString(address);
|
|
456
|
+
}
|
|
457
|
+
fieldNameForNamedChild(index) {
|
|
458
|
+
marshalNode(this);
|
|
459
|
+
const address = C._ts_node_field_name_for_named_child_wasm(this.tree[0], index);
|
|
460
|
+
if (!address)
|
|
461
|
+
return null;
|
|
462
|
+
return C.AsciiToString(address);
|
|
463
|
+
}
|
|
464
|
+
childrenForFieldName(fieldName) {
|
|
465
|
+
const fieldId = this.tree.language.fields.indexOf(fieldName);
|
|
466
|
+
if (fieldId !== -1 && fieldId !== 0)
|
|
467
|
+
return this.childrenForFieldId(fieldId);
|
|
468
|
+
return [];
|
|
469
|
+
}
|
|
470
|
+
childrenForFieldId(fieldId) {
|
|
471
|
+
marshalNode(this);
|
|
472
|
+
C._ts_node_children_by_field_id_wasm(this.tree[0], fieldId);
|
|
473
|
+
const count = C.getValue(TRANSFER_BUFFER, "i32");
|
|
474
|
+
const buffer = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
|
|
475
|
+
const result = new Array(count);
|
|
476
|
+
if (count > 0) {
|
|
477
|
+
let address = buffer;
|
|
478
|
+
for (let i2 = 0;i2 < count; i2++) {
|
|
479
|
+
result[i2] = unmarshalNode(this.tree, address);
|
|
480
|
+
address += SIZE_OF_NODE;
|
|
481
|
+
}
|
|
482
|
+
C._free(buffer);
|
|
483
|
+
}
|
|
484
|
+
return result;
|
|
485
|
+
}
|
|
486
|
+
firstChildForIndex(index) {
|
|
487
|
+
marshalNode(this);
|
|
488
|
+
const address = TRANSFER_BUFFER + SIZE_OF_NODE;
|
|
489
|
+
C.setValue(address, index, "i32");
|
|
490
|
+
C._ts_node_first_child_for_byte_wasm(this.tree[0]);
|
|
491
|
+
return unmarshalNode(this.tree);
|
|
492
|
+
}
|
|
493
|
+
firstNamedChildForIndex(index) {
|
|
494
|
+
marshalNode(this);
|
|
495
|
+
const address = TRANSFER_BUFFER + SIZE_OF_NODE;
|
|
496
|
+
C.setValue(address, index, "i32");
|
|
497
|
+
C._ts_node_first_named_child_for_byte_wasm(this.tree[0]);
|
|
498
|
+
return unmarshalNode(this.tree);
|
|
499
|
+
}
|
|
500
|
+
get childCount() {
|
|
501
|
+
marshalNode(this);
|
|
502
|
+
return C._ts_node_child_count_wasm(this.tree[0]);
|
|
503
|
+
}
|
|
504
|
+
get namedChildCount() {
|
|
505
|
+
marshalNode(this);
|
|
506
|
+
return C._ts_node_named_child_count_wasm(this.tree[0]);
|
|
507
|
+
}
|
|
508
|
+
get firstChild() {
|
|
509
|
+
return this.child(0);
|
|
510
|
+
}
|
|
511
|
+
get firstNamedChild() {
|
|
512
|
+
return this.namedChild(0);
|
|
513
|
+
}
|
|
514
|
+
get lastChild() {
|
|
515
|
+
return this.child(this.childCount - 1);
|
|
516
|
+
}
|
|
517
|
+
get lastNamedChild() {
|
|
518
|
+
return this.namedChild(this.namedChildCount - 1);
|
|
519
|
+
}
|
|
520
|
+
get children() {
|
|
521
|
+
if (!this._children) {
|
|
522
|
+
marshalNode(this);
|
|
523
|
+
C._ts_node_children_wasm(this.tree[0]);
|
|
524
|
+
const count = C.getValue(TRANSFER_BUFFER, "i32");
|
|
525
|
+
const buffer = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
|
|
526
|
+
this._children = new Array(count);
|
|
527
|
+
if (count > 0) {
|
|
528
|
+
let address = buffer;
|
|
529
|
+
for (let i2 = 0;i2 < count; i2++) {
|
|
530
|
+
this._children[i2] = unmarshalNode(this.tree, address);
|
|
531
|
+
address += SIZE_OF_NODE;
|
|
532
|
+
}
|
|
533
|
+
C._free(buffer);
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
return this._children;
|
|
537
|
+
}
|
|
538
|
+
get namedChildren() {
|
|
539
|
+
if (!this._namedChildren) {
|
|
540
|
+
marshalNode(this);
|
|
541
|
+
C._ts_node_named_children_wasm(this.tree[0]);
|
|
542
|
+
const count = C.getValue(TRANSFER_BUFFER, "i32");
|
|
543
|
+
const buffer = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
|
|
544
|
+
this._namedChildren = new Array(count);
|
|
545
|
+
if (count > 0) {
|
|
546
|
+
let address = buffer;
|
|
547
|
+
for (let i2 = 0;i2 < count; i2++) {
|
|
548
|
+
this._namedChildren[i2] = unmarshalNode(this.tree, address);
|
|
549
|
+
address += SIZE_OF_NODE;
|
|
550
|
+
}
|
|
551
|
+
C._free(buffer);
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
return this._namedChildren;
|
|
555
|
+
}
|
|
556
|
+
descendantsOfType(types, startPosition = ZERO_POINT, endPosition = ZERO_POINT) {
|
|
557
|
+
if (!Array.isArray(types))
|
|
558
|
+
types = [types];
|
|
559
|
+
const symbols = [];
|
|
560
|
+
const typesBySymbol = this.tree.language.types;
|
|
561
|
+
for (const node_type of types) {
|
|
562
|
+
if (node_type == "ERROR") {
|
|
563
|
+
symbols.push(65535);
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
for (let i2 = 0, n = typesBySymbol.length;i2 < n; i2++) {
|
|
567
|
+
if (types.includes(typesBySymbol[i2])) {
|
|
568
|
+
symbols.push(i2);
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
const symbolsAddress = C._malloc(SIZE_OF_INT * symbols.length);
|
|
572
|
+
for (let i2 = 0, n = symbols.length;i2 < n; i2++) {
|
|
573
|
+
C.setValue(symbolsAddress + i2 * SIZE_OF_INT, symbols[i2], "i32");
|
|
574
|
+
}
|
|
575
|
+
marshalNode(this);
|
|
576
|
+
C._ts_node_descendants_of_type_wasm(this.tree[0], symbolsAddress, symbols.length, startPosition.row, startPosition.column, endPosition.row, endPosition.column);
|
|
577
|
+
const descendantCount = C.getValue(TRANSFER_BUFFER, "i32");
|
|
578
|
+
const descendantAddress = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
|
|
579
|
+
const result = new Array(descendantCount);
|
|
580
|
+
if (descendantCount > 0) {
|
|
581
|
+
let address = descendantAddress;
|
|
582
|
+
for (let i2 = 0;i2 < descendantCount; i2++) {
|
|
583
|
+
result[i2] = unmarshalNode(this.tree, address);
|
|
584
|
+
address += SIZE_OF_NODE;
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
C._free(descendantAddress);
|
|
588
|
+
C._free(symbolsAddress);
|
|
589
|
+
return result;
|
|
590
|
+
}
|
|
591
|
+
get nextSibling() {
|
|
592
|
+
marshalNode(this);
|
|
593
|
+
C._ts_node_next_sibling_wasm(this.tree[0]);
|
|
594
|
+
return unmarshalNode(this.tree);
|
|
595
|
+
}
|
|
596
|
+
get previousSibling() {
|
|
597
|
+
marshalNode(this);
|
|
598
|
+
C._ts_node_prev_sibling_wasm(this.tree[0]);
|
|
599
|
+
return unmarshalNode(this.tree);
|
|
600
|
+
}
|
|
601
|
+
get nextNamedSibling() {
|
|
602
|
+
marshalNode(this);
|
|
603
|
+
C._ts_node_next_named_sibling_wasm(this.tree[0]);
|
|
604
|
+
return unmarshalNode(this.tree);
|
|
605
|
+
}
|
|
606
|
+
get previousNamedSibling() {
|
|
607
|
+
marshalNode(this);
|
|
608
|
+
C._ts_node_prev_named_sibling_wasm(this.tree[0]);
|
|
609
|
+
return unmarshalNode(this.tree);
|
|
610
|
+
}
|
|
611
|
+
get descendantCount() {
|
|
612
|
+
marshalNode(this);
|
|
613
|
+
return C._ts_node_descendant_count_wasm(this.tree[0]);
|
|
614
|
+
}
|
|
615
|
+
get parent() {
|
|
616
|
+
marshalNode(this);
|
|
617
|
+
C._ts_node_parent_wasm(this.tree[0]);
|
|
618
|
+
return unmarshalNode(this.tree);
|
|
619
|
+
}
|
|
620
|
+
childWithDescendant(descendant) {
|
|
621
|
+
marshalNode(this);
|
|
622
|
+
marshalNode(descendant, 1);
|
|
623
|
+
C._ts_node_child_with_descendant_wasm(this.tree[0]);
|
|
624
|
+
return unmarshalNode(this.tree);
|
|
625
|
+
}
|
|
626
|
+
descendantForIndex(start2, end = start2) {
|
|
627
|
+
if (typeof start2 !== "number" || typeof end !== "number") {
|
|
628
|
+
throw new Error("Arguments must be numbers");
|
|
629
|
+
}
|
|
630
|
+
marshalNode(this);
|
|
631
|
+
const address = TRANSFER_BUFFER + SIZE_OF_NODE;
|
|
632
|
+
C.setValue(address, start2, "i32");
|
|
633
|
+
C.setValue(address + SIZE_OF_INT, end, "i32");
|
|
634
|
+
C._ts_node_descendant_for_index_wasm(this.tree[0]);
|
|
635
|
+
return unmarshalNode(this.tree);
|
|
636
|
+
}
|
|
637
|
+
namedDescendantForIndex(start2, end = start2) {
|
|
638
|
+
if (typeof start2 !== "number" || typeof end !== "number") {
|
|
639
|
+
throw new Error("Arguments must be numbers");
|
|
640
|
+
}
|
|
641
|
+
marshalNode(this);
|
|
642
|
+
const address = TRANSFER_BUFFER + SIZE_OF_NODE;
|
|
643
|
+
C.setValue(address, start2, "i32");
|
|
644
|
+
C.setValue(address + SIZE_OF_INT, end, "i32");
|
|
645
|
+
C._ts_node_named_descendant_for_index_wasm(this.tree[0]);
|
|
646
|
+
return unmarshalNode(this.tree);
|
|
647
|
+
}
|
|
648
|
+
descendantForPosition(start2, end = start2) {
|
|
649
|
+
if (!isPoint(start2) || !isPoint(end)) {
|
|
650
|
+
throw new Error("Arguments must be {row, column} objects");
|
|
651
|
+
}
|
|
652
|
+
marshalNode(this);
|
|
653
|
+
const address = TRANSFER_BUFFER + SIZE_OF_NODE;
|
|
654
|
+
marshalPoint(address, start2);
|
|
655
|
+
marshalPoint(address + SIZE_OF_POINT, end);
|
|
656
|
+
C._ts_node_descendant_for_position_wasm(this.tree[0]);
|
|
657
|
+
return unmarshalNode(this.tree);
|
|
658
|
+
}
|
|
659
|
+
namedDescendantForPosition(start2, end = start2) {
|
|
660
|
+
if (!isPoint(start2) || !isPoint(end)) {
|
|
661
|
+
throw new Error("Arguments must be {row, column} objects");
|
|
662
|
+
}
|
|
663
|
+
marshalNode(this);
|
|
664
|
+
const address = TRANSFER_BUFFER + SIZE_OF_NODE;
|
|
665
|
+
marshalPoint(address, start2);
|
|
666
|
+
marshalPoint(address + SIZE_OF_POINT, end);
|
|
667
|
+
C._ts_node_named_descendant_for_position_wasm(this.tree[0]);
|
|
668
|
+
return unmarshalNode(this.tree);
|
|
669
|
+
}
|
|
670
|
+
walk() {
|
|
671
|
+
marshalNode(this);
|
|
672
|
+
C._ts_tree_cursor_new_wasm(this.tree[0]);
|
|
673
|
+
return new TreeCursor(INTERNAL, this.tree);
|
|
674
|
+
}
|
|
675
|
+
edit(edit) {
|
|
676
|
+
if (this.startIndex >= edit.oldEndIndex) {
|
|
677
|
+
this.startIndex = edit.newEndIndex + (this.startIndex - edit.oldEndIndex);
|
|
678
|
+
let subbedPointRow;
|
|
679
|
+
let subbedPointColumn;
|
|
680
|
+
if (this.startPosition.row > edit.oldEndPosition.row) {
|
|
681
|
+
subbedPointRow = this.startPosition.row - edit.oldEndPosition.row;
|
|
682
|
+
subbedPointColumn = this.startPosition.column;
|
|
683
|
+
} else {
|
|
684
|
+
subbedPointRow = 0;
|
|
685
|
+
subbedPointColumn = this.startPosition.column;
|
|
686
|
+
if (this.startPosition.column >= edit.oldEndPosition.column) {
|
|
687
|
+
subbedPointColumn = this.startPosition.column - edit.oldEndPosition.column;
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
if (subbedPointRow > 0) {
|
|
691
|
+
this.startPosition.row += subbedPointRow;
|
|
692
|
+
this.startPosition.column = subbedPointColumn;
|
|
693
|
+
} else {
|
|
694
|
+
this.startPosition.column += subbedPointColumn;
|
|
695
|
+
}
|
|
696
|
+
} else if (this.startIndex > edit.startIndex) {
|
|
697
|
+
this.startIndex = edit.newEndIndex;
|
|
698
|
+
this.startPosition.row = edit.newEndPosition.row;
|
|
699
|
+
this.startPosition.column = edit.newEndPosition.column;
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
toString() {
|
|
703
|
+
marshalNode(this);
|
|
704
|
+
const address = C._ts_node_to_string_wasm(this.tree[0]);
|
|
705
|
+
const result = C.AsciiToString(address);
|
|
706
|
+
C._free(address);
|
|
707
|
+
return result;
|
|
708
|
+
}
|
|
709
|
+
};
|
|
710
|
+
function unmarshalCaptures(query, tree, address, patternIndex, result) {
|
|
711
|
+
for (let i2 = 0, n = result.length;i2 < n; i2++) {
|
|
712
|
+
const captureIndex = C.getValue(address, "i32");
|
|
713
|
+
address += SIZE_OF_INT;
|
|
714
|
+
const node = unmarshalNode(tree, address);
|
|
715
|
+
address += SIZE_OF_NODE;
|
|
716
|
+
result[i2] = { patternIndex, name: query.captureNames[captureIndex], node };
|
|
717
|
+
}
|
|
718
|
+
return address;
|
|
719
|
+
}
|
|
720
|
+
__name(unmarshalCaptures, "unmarshalCaptures");
|
|
721
|
+
function marshalNode(node, index = 0) {
|
|
722
|
+
let address = TRANSFER_BUFFER + index * SIZE_OF_NODE;
|
|
723
|
+
C.setValue(address, node.id, "i32");
|
|
724
|
+
address += SIZE_OF_INT;
|
|
725
|
+
C.setValue(address, node.startIndex, "i32");
|
|
726
|
+
address += SIZE_OF_INT;
|
|
727
|
+
C.setValue(address, node.startPosition.row, "i32");
|
|
728
|
+
address += SIZE_OF_INT;
|
|
729
|
+
C.setValue(address, node.startPosition.column, "i32");
|
|
730
|
+
address += SIZE_OF_INT;
|
|
731
|
+
C.setValue(address, node[0], "i32");
|
|
732
|
+
}
|
|
733
|
+
__name(marshalNode, "marshalNode");
|
|
734
|
+
function unmarshalNode(tree, address = TRANSFER_BUFFER) {
|
|
735
|
+
const id = C.getValue(address, "i32");
|
|
736
|
+
address += SIZE_OF_INT;
|
|
737
|
+
if (id === 0)
|
|
738
|
+
return null;
|
|
739
|
+
const index = C.getValue(address, "i32");
|
|
740
|
+
address += SIZE_OF_INT;
|
|
741
|
+
const row = C.getValue(address, "i32");
|
|
742
|
+
address += SIZE_OF_INT;
|
|
743
|
+
const column = C.getValue(address, "i32");
|
|
744
|
+
address += SIZE_OF_INT;
|
|
745
|
+
const other = C.getValue(address, "i32");
|
|
746
|
+
const result = new Node(INTERNAL, {
|
|
747
|
+
id,
|
|
748
|
+
tree,
|
|
749
|
+
startIndex: index,
|
|
750
|
+
startPosition: { row, column },
|
|
751
|
+
other
|
|
752
|
+
});
|
|
753
|
+
return result;
|
|
754
|
+
}
|
|
755
|
+
__name(unmarshalNode, "unmarshalNode");
|
|
756
|
+
function marshalTreeCursor(cursor, address = TRANSFER_BUFFER) {
|
|
757
|
+
C.setValue(address + 0 * SIZE_OF_INT, cursor[0], "i32");
|
|
758
|
+
C.setValue(address + 1 * SIZE_OF_INT, cursor[1], "i32");
|
|
759
|
+
C.setValue(address + 2 * SIZE_OF_INT, cursor[2], "i32");
|
|
760
|
+
C.setValue(address + 3 * SIZE_OF_INT, cursor[3], "i32");
|
|
761
|
+
}
|
|
762
|
+
__name(marshalTreeCursor, "marshalTreeCursor");
|
|
763
|
+
function unmarshalTreeCursor(cursor) {
|
|
764
|
+
cursor[0] = C.getValue(TRANSFER_BUFFER + 0 * SIZE_OF_INT, "i32");
|
|
765
|
+
cursor[1] = C.getValue(TRANSFER_BUFFER + 1 * SIZE_OF_INT, "i32");
|
|
766
|
+
cursor[2] = C.getValue(TRANSFER_BUFFER + 2 * SIZE_OF_INT, "i32");
|
|
767
|
+
cursor[3] = C.getValue(TRANSFER_BUFFER + 3 * SIZE_OF_INT, "i32");
|
|
768
|
+
}
|
|
769
|
+
__name(unmarshalTreeCursor, "unmarshalTreeCursor");
|
|
770
|
+
function marshalPoint(address, point) {
|
|
771
|
+
C.setValue(address, point.row, "i32");
|
|
772
|
+
C.setValue(address + SIZE_OF_INT, point.column, "i32");
|
|
773
|
+
}
|
|
774
|
+
__name(marshalPoint, "marshalPoint");
|
|
775
|
+
function unmarshalPoint(address) {
|
|
776
|
+
const result = {
|
|
777
|
+
row: C.getValue(address, "i32") >>> 0,
|
|
778
|
+
column: C.getValue(address + SIZE_OF_INT, "i32") >>> 0
|
|
779
|
+
};
|
|
780
|
+
return result;
|
|
781
|
+
}
|
|
782
|
+
__name(unmarshalPoint, "unmarshalPoint");
|
|
783
|
+
function marshalRange(address, range) {
|
|
784
|
+
marshalPoint(address, range.startPosition);
|
|
785
|
+
address += SIZE_OF_POINT;
|
|
786
|
+
marshalPoint(address, range.endPosition);
|
|
787
|
+
address += SIZE_OF_POINT;
|
|
788
|
+
C.setValue(address, range.startIndex, "i32");
|
|
789
|
+
address += SIZE_OF_INT;
|
|
790
|
+
C.setValue(address, range.endIndex, "i32");
|
|
791
|
+
address += SIZE_OF_INT;
|
|
792
|
+
}
|
|
793
|
+
__name(marshalRange, "marshalRange");
|
|
794
|
+
function unmarshalRange(address) {
|
|
795
|
+
const result = {};
|
|
796
|
+
result.startPosition = unmarshalPoint(address);
|
|
797
|
+
address += SIZE_OF_POINT;
|
|
798
|
+
result.endPosition = unmarshalPoint(address);
|
|
799
|
+
address += SIZE_OF_POINT;
|
|
800
|
+
result.startIndex = C.getValue(address, "i32") >>> 0;
|
|
801
|
+
address += SIZE_OF_INT;
|
|
802
|
+
result.endIndex = C.getValue(address, "i32") >>> 0;
|
|
803
|
+
return result;
|
|
804
|
+
}
|
|
805
|
+
__name(unmarshalRange, "unmarshalRange");
|
|
806
|
+
function marshalEdit(edit, address = TRANSFER_BUFFER) {
|
|
807
|
+
marshalPoint(address, edit.startPosition);
|
|
808
|
+
address += SIZE_OF_POINT;
|
|
809
|
+
marshalPoint(address, edit.oldEndPosition);
|
|
810
|
+
address += SIZE_OF_POINT;
|
|
811
|
+
marshalPoint(address, edit.newEndPosition);
|
|
812
|
+
address += SIZE_OF_POINT;
|
|
813
|
+
C.setValue(address, edit.startIndex, "i32");
|
|
814
|
+
address += SIZE_OF_INT;
|
|
815
|
+
C.setValue(address, edit.oldEndIndex, "i32");
|
|
816
|
+
address += SIZE_OF_INT;
|
|
817
|
+
C.setValue(address, edit.newEndIndex, "i32");
|
|
818
|
+
address += SIZE_OF_INT;
|
|
819
|
+
}
|
|
820
|
+
__name(marshalEdit, "marshalEdit");
|
|
821
|
+
function unmarshalLanguageMetadata(address) {
|
|
822
|
+
const major_version = C.getValue(address, "i32");
|
|
823
|
+
const minor_version = C.getValue(address += SIZE_OF_INT, "i32");
|
|
824
|
+
const patch_version = C.getValue(address += SIZE_OF_INT, "i32");
|
|
825
|
+
return { major_version, minor_version, patch_version };
|
|
826
|
+
}
|
|
827
|
+
__name(unmarshalLanguageMetadata, "unmarshalLanguageMetadata");
|
|
828
|
+
var PREDICATE_STEP_TYPE_CAPTURE = 1;
|
|
829
|
+
var PREDICATE_STEP_TYPE_STRING = 2;
|
|
830
|
+
var QUERY_WORD_REGEX = /[\w-]+/g;
|
|
831
|
+
var CaptureQuantifier = {
|
|
832
|
+
Zero: 0,
|
|
833
|
+
ZeroOrOne: 1,
|
|
834
|
+
ZeroOrMore: 2,
|
|
835
|
+
One: 3,
|
|
836
|
+
OneOrMore: 4
|
|
837
|
+
};
|
|
838
|
+
var isCaptureStep = /* @__PURE__ */ __name((step) => step.type === "capture", "isCaptureStep");
|
|
839
|
+
var isStringStep = /* @__PURE__ */ __name((step) => step.type === "string", "isStringStep");
|
|
840
|
+
var QueryErrorKind = {
|
|
841
|
+
Syntax: 1,
|
|
842
|
+
NodeName: 2,
|
|
843
|
+
FieldName: 3,
|
|
844
|
+
CaptureName: 4,
|
|
845
|
+
PatternStructure: 5
|
|
846
|
+
};
|
|
847
|
+
var QueryError = class _QueryError extends Error {
|
|
848
|
+
constructor(kind, info2, index, length) {
|
|
849
|
+
super(_QueryError.formatMessage(kind, info2));
|
|
850
|
+
this.kind = kind;
|
|
851
|
+
this.info = info2;
|
|
852
|
+
this.index = index;
|
|
853
|
+
this.length = length;
|
|
854
|
+
this.name = "QueryError";
|
|
855
|
+
}
|
|
856
|
+
static {
|
|
857
|
+
__name(this, "QueryError");
|
|
858
|
+
}
|
|
859
|
+
static formatMessage(kind, info2) {
|
|
860
|
+
switch (kind) {
|
|
861
|
+
case QueryErrorKind.NodeName:
|
|
862
|
+
return `Bad node name '${info2.word}'`;
|
|
863
|
+
case QueryErrorKind.FieldName:
|
|
864
|
+
return `Bad field name '${info2.word}'`;
|
|
865
|
+
case QueryErrorKind.CaptureName:
|
|
866
|
+
return `Bad capture name @${info2.word}`;
|
|
867
|
+
case QueryErrorKind.PatternStructure:
|
|
868
|
+
return `Bad pattern structure at offset ${info2.suffix}`;
|
|
869
|
+
case QueryErrorKind.Syntax:
|
|
870
|
+
return `Bad syntax at offset ${info2.suffix}`;
|
|
871
|
+
}
|
|
872
|
+
}
|
|
873
|
+
};
|
|
874
|
+
function parseAnyPredicate(steps, index, operator, textPredicates) {
|
|
875
|
+
if (steps.length !== 3) {
|
|
876
|
+
throw new Error(`Wrong number of arguments to \`#${operator}\` predicate. Expected 2, got ${steps.length - 1}`);
|
|
877
|
+
}
|
|
878
|
+
if (!isCaptureStep(steps[1])) {
|
|
879
|
+
throw new Error(`First argument of \`#${operator}\` predicate must be a capture. Got "${steps[1].value}"`);
|
|
880
|
+
}
|
|
881
|
+
const isPositive = operator === "eq?" || operator === "any-eq?";
|
|
882
|
+
const matchAll = !operator.startsWith("any-");
|
|
883
|
+
if (isCaptureStep(steps[2])) {
|
|
884
|
+
const captureName1 = steps[1].name;
|
|
885
|
+
const captureName2 = steps[2].name;
|
|
886
|
+
textPredicates[index].push((captures) => {
|
|
887
|
+
const nodes1 = [];
|
|
888
|
+
const nodes2 = [];
|
|
889
|
+
for (const c of captures) {
|
|
890
|
+
if (c.name === captureName1)
|
|
891
|
+
nodes1.push(c.node);
|
|
892
|
+
if (c.name === captureName2)
|
|
893
|
+
nodes2.push(c.node);
|
|
894
|
+
}
|
|
895
|
+
const compare = /* @__PURE__ */ __name((n1, n2, positive) => {
|
|
896
|
+
return positive ? n1.text === n2.text : n1.text !== n2.text;
|
|
897
|
+
}, "compare");
|
|
898
|
+
return matchAll ? nodes1.every((n1) => nodes2.some((n2) => compare(n1, n2, isPositive))) : nodes1.some((n1) => nodes2.some((n2) => compare(n1, n2, isPositive)));
|
|
899
|
+
});
|
|
900
|
+
} else {
|
|
901
|
+
const captureName = steps[1].name;
|
|
902
|
+
const stringValue = steps[2].value;
|
|
903
|
+
const matches = /* @__PURE__ */ __name((n) => n.text === stringValue, "matches");
|
|
904
|
+
const doesNotMatch = /* @__PURE__ */ __name((n) => n.text !== stringValue, "doesNotMatch");
|
|
905
|
+
textPredicates[index].push((captures) => {
|
|
906
|
+
const nodes = [];
|
|
907
|
+
for (const c of captures) {
|
|
908
|
+
if (c.name === captureName)
|
|
909
|
+
nodes.push(c.node);
|
|
910
|
+
}
|
|
911
|
+
const test = isPositive ? matches : doesNotMatch;
|
|
912
|
+
return matchAll ? nodes.every(test) : nodes.some(test);
|
|
913
|
+
});
|
|
914
|
+
}
|
|
915
|
+
}
|
|
916
|
+
__name(parseAnyPredicate, "parseAnyPredicate");
|
|
917
|
+
function parseMatchPredicate(steps, index, operator, textPredicates) {
|
|
918
|
+
if (steps.length !== 3) {
|
|
919
|
+
throw new Error(`Wrong number of arguments to \`#${operator}\` predicate. Expected 2, got ${steps.length - 1}.`);
|
|
920
|
+
}
|
|
921
|
+
if (steps[1].type !== "capture") {
|
|
922
|
+
throw new Error(`First argument of \`#${operator}\` predicate must be a capture. Got "${steps[1].value}".`);
|
|
923
|
+
}
|
|
924
|
+
if (steps[2].type !== "string") {
|
|
925
|
+
throw new Error(`Second argument of \`#${operator}\` predicate must be a string. Got @${steps[2].name}.`);
|
|
926
|
+
}
|
|
927
|
+
const isPositive = operator === "match?" || operator === "any-match?";
|
|
928
|
+
const matchAll = !operator.startsWith("any-");
|
|
929
|
+
const captureName = steps[1].name;
|
|
930
|
+
const regex = new RegExp(steps[2].value);
|
|
931
|
+
textPredicates[index].push((captures) => {
|
|
932
|
+
const nodes = [];
|
|
933
|
+
for (const c of captures) {
|
|
934
|
+
if (c.name === captureName)
|
|
935
|
+
nodes.push(c.node.text);
|
|
936
|
+
}
|
|
937
|
+
const test = /* @__PURE__ */ __name((text, positive) => {
|
|
938
|
+
return positive ? regex.test(text) : !regex.test(text);
|
|
939
|
+
}, "test");
|
|
940
|
+
if (nodes.length === 0)
|
|
941
|
+
return !isPositive;
|
|
942
|
+
return matchAll ? nodes.every((text) => test(text, isPositive)) : nodes.some((text) => test(text, isPositive));
|
|
943
|
+
});
|
|
944
|
+
}
|
|
945
|
+
__name(parseMatchPredicate, "parseMatchPredicate");
|
|
946
|
+
function parseAnyOfPredicate(steps, index, operator, textPredicates) {
|
|
947
|
+
if (steps.length < 2) {
|
|
948
|
+
throw new Error(`Wrong number of arguments to \`#${operator}\` predicate. Expected at least 1. Got ${steps.length - 1}.`);
|
|
949
|
+
}
|
|
950
|
+
if (steps[1].type !== "capture") {
|
|
951
|
+
throw new Error(`First argument of \`#${operator}\` predicate must be a capture. Got "${steps[1].value}".`);
|
|
952
|
+
}
|
|
953
|
+
const isPositive = operator === "any-of?";
|
|
954
|
+
const captureName = steps[1].name;
|
|
955
|
+
const stringSteps = steps.slice(2);
|
|
956
|
+
if (!stringSteps.every(isStringStep)) {
|
|
957
|
+
throw new Error(`Arguments to \`#${operator}\` predicate must be strings.".`);
|
|
958
|
+
}
|
|
959
|
+
const values = stringSteps.map((s) => s.value);
|
|
960
|
+
textPredicates[index].push((captures) => {
|
|
961
|
+
const nodes = [];
|
|
962
|
+
for (const c of captures) {
|
|
963
|
+
if (c.name === captureName)
|
|
964
|
+
nodes.push(c.node.text);
|
|
965
|
+
}
|
|
966
|
+
if (nodes.length === 0)
|
|
967
|
+
return !isPositive;
|
|
968
|
+
return nodes.every((text) => values.includes(text)) === isPositive;
|
|
969
|
+
});
|
|
970
|
+
}
|
|
971
|
+
__name(parseAnyOfPredicate, "parseAnyOfPredicate");
|
|
972
|
+
function parseIsPredicate(steps, index, operator, assertedProperties, refutedProperties) {
|
|
973
|
+
if (steps.length < 2 || steps.length > 3) {
|
|
974
|
+
throw new Error(`Wrong number of arguments to \`#${operator}\` predicate. Expected 1 or 2. Got ${steps.length - 1}.`);
|
|
975
|
+
}
|
|
976
|
+
if (!steps.every(isStringStep)) {
|
|
977
|
+
throw new Error(`Arguments to \`#${operator}\` predicate must be strings.".`);
|
|
978
|
+
}
|
|
979
|
+
const properties = operator === "is?" ? assertedProperties : refutedProperties;
|
|
980
|
+
if (!properties[index])
|
|
981
|
+
properties[index] = {};
|
|
982
|
+
properties[index][steps[1].value] = steps[2]?.value ?? null;
|
|
983
|
+
}
|
|
984
|
+
__name(parseIsPredicate, "parseIsPredicate");
|
|
985
|
+
function parseSetDirective(steps, index, setProperties) {
|
|
986
|
+
if (steps.length < 2 || steps.length > 3) {
|
|
987
|
+
throw new Error(`Wrong number of arguments to \`#set!\` predicate. Expected 1 or 2. Got ${steps.length - 1}.`);
|
|
988
|
+
}
|
|
989
|
+
if (!steps.every(isStringStep)) {
|
|
990
|
+
throw new Error(`Arguments to \`#set!\` predicate must be strings.".`);
|
|
991
|
+
}
|
|
992
|
+
if (!setProperties[index])
|
|
993
|
+
setProperties[index] = {};
|
|
994
|
+
setProperties[index][steps[1].value] = steps[2]?.value ?? null;
|
|
995
|
+
}
|
|
996
|
+
__name(parseSetDirective, "parseSetDirective");
|
|
997
|
+
function parsePattern(index, stepType, stepValueId, captureNames, stringValues, steps, textPredicates, predicates, setProperties, assertedProperties, refutedProperties) {
|
|
998
|
+
if (stepType === PREDICATE_STEP_TYPE_CAPTURE) {
|
|
999
|
+
const name2 = captureNames[stepValueId];
|
|
1000
|
+
steps.push({ type: "capture", name: name2 });
|
|
1001
|
+
} else if (stepType === PREDICATE_STEP_TYPE_STRING) {
|
|
1002
|
+
steps.push({ type: "string", value: stringValues[stepValueId] });
|
|
1003
|
+
} else if (steps.length > 0) {
|
|
1004
|
+
if (steps[0].type !== "string") {
|
|
1005
|
+
throw new Error("Predicates must begin with a literal value");
|
|
1006
|
+
}
|
|
1007
|
+
const operator = steps[0].value;
|
|
1008
|
+
switch (operator) {
|
|
1009
|
+
case "any-not-eq?":
|
|
1010
|
+
case "not-eq?":
|
|
1011
|
+
case "any-eq?":
|
|
1012
|
+
case "eq?":
|
|
1013
|
+
parseAnyPredicate(steps, index, operator, textPredicates);
|
|
1014
|
+
break;
|
|
1015
|
+
case "any-not-match?":
|
|
1016
|
+
case "not-match?":
|
|
1017
|
+
case "any-match?":
|
|
1018
|
+
case "match?":
|
|
1019
|
+
parseMatchPredicate(steps, index, operator, textPredicates);
|
|
1020
|
+
break;
|
|
1021
|
+
case "not-any-of?":
|
|
1022
|
+
case "any-of?":
|
|
1023
|
+
parseAnyOfPredicate(steps, index, operator, textPredicates);
|
|
1024
|
+
break;
|
|
1025
|
+
case "is?":
|
|
1026
|
+
case "is-not?":
|
|
1027
|
+
parseIsPredicate(steps, index, operator, assertedProperties, refutedProperties);
|
|
1028
|
+
break;
|
|
1029
|
+
case "set!":
|
|
1030
|
+
parseSetDirective(steps, index, setProperties);
|
|
1031
|
+
break;
|
|
1032
|
+
default:
|
|
1033
|
+
predicates[index].push({ operator, operands: steps.slice(1) });
|
|
1034
|
+
}
|
|
1035
|
+
steps.length = 0;
|
|
1036
|
+
}
|
|
1037
|
+
}
|
|
1038
|
+
__name(parsePattern, "parsePattern");
|
|
1039
|
+
var Query = class {
|
|
1040
|
+
static {
|
|
1041
|
+
__name(this, "Query");
|
|
1042
|
+
}
|
|
1043
|
+
[0] = 0;
|
|
1044
|
+
exceededMatchLimit;
|
|
1045
|
+
textPredicates;
|
|
1046
|
+
captureNames;
|
|
1047
|
+
captureQuantifiers;
|
|
1048
|
+
predicates;
|
|
1049
|
+
setProperties;
|
|
1050
|
+
assertedProperties;
|
|
1051
|
+
refutedProperties;
|
|
1052
|
+
matchLimit;
|
|
1053
|
+
constructor(language, source) {
|
|
1054
|
+
const sourceLength = C.lengthBytesUTF8(source);
|
|
1055
|
+
const sourceAddress = C._malloc(sourceLength + 1);
|
|
1056
|
+
C.stringToUTF8(source, sourceAddress, sourceLength + 1);
|
|
1057
|
+
const address = C._ts_query_new(language[0], sourceAddress, sourceLength, TRANSFER_BUFFER, TRANSFER_BUFFER + SIZE_OF_INT);
|
|
1058
|
+
if (!address) {
|
|
1059
|
+
const errorId = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
|
|
1060
|
+
const errorByte = C.getValue(TRANSFER_BUFFER, "i32");
|
|
1061
|
+
const errorIndex = C.UTF8ToString(sourceAddress, errorByte).length;
|
|
1062
|
+
const suffix = source.slice(errorIndex, errorIndex + 100).split(`
|
|
1063
|
+
`)[0];
|
|
1064
|
+
const word = suffix.match(QUERY_WORD_REGEX)?.[0] ?? "";
|
|
1065
|
+
C._free(sourceAddress);
|
|
1066
|
+
switch (errorId) {
|
|
1067
|
+
case QueryErrorKind.Syntax:
|
|
1068
|
+
throw new QueryError(QueryErrorKind.Syntax, { suffix: `${errorIndex}: '${suffix}'...` }, errorIndex, 0);
|
|
1069
|
+
case QueryErrorKind.NodeName:
|
|
1070
|
+
throw new QueryError(errorId, { word }, errorIndex, word.length);
|
|
1071
|
+
case QueryErrorKind.FieldName:
|
|
1072
|
+
throw new QueryError(errorId, { word }, errorIndex, word.length);
|
|
1073
|
+
case QueryErrorKind.CaptureName:
|
|
1074
|
+
throw new QueryError(errorId, { word }, errorIndex, word.length);
|
|
1075
|
+
case QueryErrorKind.PatternStructure:
|
|
1076
|
+
throw new QueryError(errorId, { suffix: `${errorIndex}: '${suffix}'...` }, errorIndex, 0);
|
|
1077
|
+
}
|
|
1078
|
+
}
|
|
1079
|
+
const stringCount = C._ts_query_string_count(address);
|
|
1080
|
+
const captureCount = C._ts_query_capture_count(address);
|
|
1081
|
+
const patternCount = C._ts_query_pattern_count(address);
|
|
1082
|
+
const captureNames = new Array(captureCount);
|
|
1083
|
+
const captureQuantifiers = new Array(patternCount);
|
|
1084
|
+
const stringValues = new Array(stringCount);
|
|
1085
|
+
for (let i2 = 0;i2 < captureCount; i2++) {
|
|
1086
|
+
const nameAddress = C._ts_query_capture_name_for_id(address, i2, TRANSFER_BUFFER);
|
|
1087
|
+
const nameLength = C.getValue(TRANSFER_BUFFER, "i32");
|
|
1088
|
+
captureNames[i2] = C.UTF8ToString(nameAddress, nameLength);
|
|
1089
|
+
}
|
|
1090
|
+
for (let i2 = 0;i2 < patternCount; i2++) {
|
|
1091
|
+
const captureQuantifiersArray = new Array(captureCount);
|
|
1092
|
+
for (let j = 0;j < captureCount; j++) {
|
|
1093
|
+
const quantifier = C._ts_query_capture_quantifier_for_id(address, i2, j);
|
|
1094
|
+
captureQuantifiersArray[j] = quantifier;
|
|
1095
|
+
}
|
|
1096
|
+
captureQuantifiers[i2] = captureQuantifiersArray;
|
|
1097
|
+
}
|
|
1098
|
+
for (let i2 = 0;i2 < stringCount; i2++) {
|
|
1099
|
+
const valueAddress = C._ts_query_string_value_for_id(address, i2, TRANSFER_BUFFER);
|
|
1100
|
+
const nameLength = C.getValue(TRANSFER_BUFFER, "i32");
|
|
1101
|
+
stringValues[i2] = C.UTF8ToString(valueAddress, nameLength);
|
|
1102
|
+
}
|
|
1103
|
+
const setProperties = new Array(patternCount);
|
|
1104
|
+
const assertedProperties = new Array(patternCount);
|
|
1105
|
+
const refutedProperties = new Array(patternCount);
|
|
1106
|
+
const predicates = new Array(patternCount);
|
|
1107
|
+
const textPredicates = new Array(patternCount);
|
|
1108
|
+
for (let i2 = 0;i2 < patternCount; i2++) {
|
|
1109
|
+
const predicatesAddress = C._ts_query_predicates_for_pattern(address, i2, TRANSFER_BUFFER);
|
|
1110
|
+
const stepCount = C.getValue(TRANSFER_BUFFER, "i32");
|
|
1111
|
+
predicates[i2] = [];
|
|
1112
|
+
textPredicates[i2] = [];
|
|
1113
|
+
const steps = new Array;
|
|
1114
|
+
let stepAddress = predicatesAddress;
|
|
1115
|
+
for (let j = 0;j < stepCount; j++) {
|
|
1116
|
+
const stepType = C.getValue(stepAddress, "i32");
|
|
1117
|
+
stepAddress += SIZE_OF_INT;
|
|
1118
|
+
const stepValueId = C.getValue(stepAddress, "i32");
|
|
1119
|
+
stepAddress += SIZE_OF_INT;
|
|
1120
|
+
parsePattern(i2, stepType, stepValueId, captureNames, stringValues, steps, textPredicates, predicates, setProperties, assertedProperties, refutedProperties);
|
|
1121
|
+
}
|
|
1122
|
+
Object.freeze(textPredicates[i2]);
|
|
1123
|
+
Object.freeze(predicates[i2]);
|
|
1124
|
+
Object.freeze(setProperties[i2]);
|
|
1125
|
+
Object.freeze(assertedProperties[i2]);
|
|
1126
|
+
Object.freeze(refutedProperties[i2]);
|
|
1127
|
+
}
|
|
1128
|
+
C._free(sourceAddress);
|
|
1129
|
+
this[0] = address;
|
|
1130
|
+
this.captureNames = captureNames;
|
|
1131
|
+
this.captureQuantifiers = captureQuantifiers;
|
|
1132
|
+
this.textPredicates = textPredicates;
|
|
1133
|
+
this.predicates = predicates;
|
|
1134
|
+
this.setProperties = setProperties;
|
|
1135
|
+
this.assertedProperties = assertedProperties;
|
|
1136
|
+
this.refutedProperties = refutedProperties;
|
|
1137
|
+
this.exceededMatchLimit = false;
|
|
1138
|
+
}
|
|
1139
|
+
delete() {
|
|
1140
|
+
C._ts_query_delete(this[0]);
|
|
1141
|
+
this[0] = 0;
|
|
1142
|
+
}
|
|
1143
|
+
matches(node, options = {}) {
|
|
1144
|
+
const startPosition = options.startPosition ?? ZERO_POINT;
|
|
1145
|
+
const endPosition = options.endPosition ?? ZERO_POINT;
|
|
1146
|
+
const startIndex = options.startIndex ?? 0;
|
|
1147
|
+
const endIndex = options.endIndex ?? 0;
|
|
1148
|
+
const matchLimit = options.matchLimit ?? 4294967295;
|
|
1149
|
+
const maxStartDepth = options.maxStartDepth ?? 4294967295;
|
|
1150
|
+
const timeoutMicros = options.timeoutMicros ?? 0;
|
|
1151
|
+
const progressCallback = options.progressCallback;
|
|
1152
|
+
if (typeof matchLimit !== "number") {
|
|
1153
|
+
throw new Error("Arguments must be numbers");
|
|
1154
|
+
}
|
|
1155
|
+
this.matchLimit = matchLimit;
|
|
1156
|
+
if (endIndex !== 0 && startIndex > endIndex) {
|
|
1157
|
+
throw new Error("`startIndex` cannot be greater than `endIndex`");
|
|
1158
|
+
}
|
|
1159
|
+
if (endPosition !== ZERO_POINT && (startPosition.row > endPosition.row || startPosition.row === endPosition.row && startPosition.column > endPosition.column)) {
|
|
1160
|
+
throw new Error("`startPosition` cannot be greater than `endPosition`");
|
|
1161
|
+
}
|
|
1162
|
+
if (progressCallback) {
|
|
1163
|
+
C.currentQueryProgressCallback = progressCallback;
|
|
1164
|
+
}
|
|
1165
|
+
marshalNode(node);
|
|
1166
|
+
C._ts_query_matches_wasm(this[0], node.tree[0], startPosition.row, startPosition.column, endPosition.row, endPosition.column, startIndex, endIndex, matchLimit, maxStartDepth, timeoutMicros);
|
|
1167
|
+
const rawCount = C.getValue(TRANSFER_BUFFER, "i32");
|
|
1168
|
+
const startAddress = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
|
|
1169
|
+
const didExceedMatchLimit = C.getValue(TRANSFER_BUFFER + 2 * SIZE_OF_INT, "i32");
|
|
1170
|
+
const result = new Array(rawCount);
|
|
1171
|
+
this.exceededMatchLimit = Boolean(didExceedMatchLimit);
|
|
1172
|
+
let filteredCount = 0;
|
|
1173
|
+
let address = startAddress;
|
|
1174
|
+
for (let i2 = 0;i2 < rawCount; i2++) {
|
|
1175
|
+
const patternIndex = C.getValue(address, "i32");
|
|
1176
|
+
address += SIZE_OF_INT;
|
|
1177
|
+
const captureCount = C.getValue(address, "i32");
|
|
1178
|
+
address += SIZE_OF_INT;
|
|
1179
|
+
const captures = new Array(captureCount);
|
|
1180
|
+
address = unmarshalCaptures(this, node.tree, address, patternIndex, captures);
|
|
1181
|
+
if (this.textPredicates[patternIndex].every((p) => p(captures))) {
|
|
1182
|
+
result[filteredCount] = { pattern: patternIndex, patternIndex, captures };
|
|
1183
|
+
const setProperties = this.setProperties[patternIndex];
|
|
1184
|
+
result[filteredCount].setProperties = setProperties;
|
|
1185
|
+
const assertedProperties = this.assertedProperties[patternIndex];
|
|
1186
|
+
result[filteredCount].assertedProperties = assertedProperties;
|
|
1187
|
+
const refutedProperties = this.refutedProperties[patternIndex];
|
|
1188
|
+
result[filteredCount].refutedProperties = refutedProperties;
|
|
1189
|
+
filteredCount++;
|
|
1190
|
+
}
|
|
1191
|
+
}
|
|
1192
|
+
result.length = filteredCount;
|
|
1193
|
+
C._free(startAddress);
|
|
1194
|
+
C.currentQueryProgressCallback = null;
|
|
1195
|
+
return result;
|
|
1196
|
+
}
|
|
1197
|
+
captures(node, options = {}) {
|
|
1198
|
+
const startPosition = options.startPosition ?? ZERO_POINT;
|
|
1199
|
+
const endPosition = options.endPosition ?? ZERO_POINT;
|
|
1200
|
+
const startIndex = options.startIndex ?? 0;
|
|
1201
|
+
const endIndex = options.endIndex ?? 0;
|
|
1202
|
+
const matchLimit = options.matchLimit ?? 4294967295;
|
|
1203
|
+
const maxStartDepth = options.maxStartDepth ?? 4294967295;
|
|
1204
|
+
const timeoutMicros = options.timeoutMicros ?? 0;
|
|
1205
|
+
const progressCallback = options.progressCallback;
|
|
1206
|
+
if (typeof matchLimit !== "number") {
|
|
1207
|
+
throw new Error("Arguments must be numbers");
|
|
1208
|
+
}
|
|
1209
|
+
this.matchLimit = matchLimit;
|
|
1210
|
+
if (endIndex !== 0 && startIndex > endIndex) {
|
|
1211
|
+
throw new Error("`startIndex` cannot be greater than `endIndex`");
|
|
1212
|
+
}
|
|
1213
|
+
if (endPosition !== ZERO_POINT && (startPosition.row > endPosition.row || startPosition.row === endPosition.row && startPosition.column > endPosition.column)) {
|
|
1214
|
+
throw new Error("`startPosition` cannot be greater than `endPosition`");
|
|
1215
|
+
}
|
|
1216
|
+
if (progressCallback) {
|
|
1217
|
+
C.currentQueryProgressCallback = progressCallback;
|
|
1218
|
+
}
|
|
1219
|
+
marshalNode(node);
|
|
1220
|
+
C._ts_query_captures_wasm(this[0], node.tree[0], startPosition.row, startPosition.column, endPosition.row, endPosition.column, startIndex, endIndex, matchLimit, maxStartDepth, timeoutMicros);
|
|
1221
|
+
const count = C.getValue(TRANSFER_BUFFER, "i32");
|
|
1222
|
+
const startAddress = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
|
|
1223
|
+
const didExceedMatchLimit = C.getValue(TRANSFER_BUFFER + 2 * SIZE_OF_INT, "i32");
|
|
1224
|
+
const result = new Array;
|
|
1225
|
+
this.exceededMatchLimit = Boolean(didExceedMatchLimit);
|
|
1226
|
+
const captures = new Array;
|
|
1227
|
+
let address = startAddress;
|
|
1228
|
+
for (let i2 = 0;i2 < count; i2++) {
|
|
1229
|
+
const patternIndex = C.getValue(address, "i32");
|
|
1230
|
+
address += SIZE_OF_INT;
|
|
1231
|
+
const captureCount = C.getValue(address, "i32");
|
|
1232
|
+
address += SIZE_OF_INT;
|
|
1233
|
+
const captureIndex = C.getValue(address, "i32");
|
|
1234
|
+
address += SIZE_OF_INT;
|
|
1235
|
+
captures.length = captureCount;
|
|
1236
|
+
address = unmarshalCaptures(this, node.tree, address, patternIndex, captures);
|
|
1237
|
+
if (this.textPredicates[patternIndex].every((p) => p(captures))) {
|
|
1238
|
+
const capture = captures[captureIndex];
|
|
1239
|
+
const setProperties = this.setProperties[patternIndex];
|
|
1240
|
+
capture.setProperties = setProperties;
|
|
1241
|
+
const assertedProperties = this.assertedProperties[patternIndex];
|
|
1242
|
+
capture.assertedProperties = assertedProperties;
|
|
1243
|
+
const refutedProperties = this.refutedProperties[patternIndex];
|
|
1244
|
+
capture.refutedProperties = refutedProperties;
|
|
1245
|
+
result.push(capture);
|
|
1246
|
+
}
|
|
1247
|
+
}
|
|
1248
|
+
C._free(startAddress);
|
|
1249
|
+
C.currentQueryProgressCallback = null;
|
|
1250
|
+
return result;
|
|
1251
|
+
}
|
|
1252
|
+
predicatesForPattern(patternIndex) {
|
|
1253
|
+
return this.predicates[patternIndex];
|
|
1254
|
+
}
|
|
1255
|
+
disableCapture(captureName) {
|
|
1256
|
+
const captureNameLength = C.lengthBytesUTF8(captureName);
|
|
1257
|
+
const captureNameAddress = C._malloc(captureNameLength + 1);
|
|
1258
|
+
C.stringToUTF8(captureName, captureNameAddress, captureNameLength + 1);
|
|
1259
|
+
C._ts_query_disable_capture(this[0], captureNameAddress, captureNameLength);
|
|
1260
|
+
C._free(captureNameAddress);
|
|
1261
|
+
}
|
|
1262
|
+
disablePattern(patternIndex) {
|
|
1263
|
+
if (patternIndex >= this.predicates.length) {
|
|
1264
|
+
throw new Error(`Pattern index is ${patternIndex} but the pattern count is ${this.predicates.length}`);
|
|
1265
|
+
}
|
|
1266
|
+
C._ts_query_disable_pattern(this[0], patternIndex);
|
|
1267
|
+
}
|
|
1268
|
+
didExceedMatchLimit() {
|
|
1269
|
+
return this.exceededMatchLimit;
|
|
1270
|
+
}
|
|
1271
|
+
startIndexForPattern(patternIndex) {
|
|
1272
|
+
if (patternIndex >= this.predicates.length) {
|
|
1273
|
+
throw new Error(`Pattern index is ${patternIndex} but the pattern count is ${this.predicates.length}`);
|
|
1274
|
+
}
|
|
1275
|
+
return C._ts_query_start_byte_for_pattern(this[0], patternIndex);
|
|
1276
|
+
}
|
|
1277
|
+
endIndexForPattern(patternIndex) {
|
|
1278
|
+
if (patternIndex >= this.predicates.length) {
|
|
1279
|
+
throw new Error(`Pattern index is ${patternIndex} but the pattern count is ${this.predicates.length}`);
|
|
1280
|
+
}
|
|
1281
|
+
return C._ts_query_end_byte_for_pattern(this[0], patternIndex);
|
|
1282
|
+
}
|
|
1283
|
+
patternCount() {
|
|
1284
|
+
return C._ts_query_pattern_count(this[0]);
|
|
1285
|
+
}
|
|
1286
|
+
captureIndexForName(captureName) {
|
|
1287
|
+
return this.captureNames.indexOf(captureName);
|
|
1288
|
+
}
|
|
1289
|
+
isPatternRooted(patternIndex) {
|
|
1290
|
+
return C._ts_query_is_pattern_rooted(this[0], patternIndex) === 1;
|
|
1291
|
+
}
|
|
1292
|
+
isPatternNonLocal(patternIndex) {
|
|
1293
|
+
return C._ts_query_is_pattern_non_local(this[0], patternIndex) === 1;
|
|
1294
|
+
}
|
|
1295
|
+
isPatternGuaranteedAtStep(byteIndex) {
|
|
1296
|
+
return C._ts_query_is_pattern_guaranteed_at_step(this[0], byteIndex) === 1;
|
|
1297
|
+
}
|
|
1298
|
+
};
|
|
1299
|
+
var LANGUAGE_FUNCTION_REGEX = /^tree_sitter_\w+$/;
|
|
1300
|
+
var Language = class _Language {
|
|
1301
|
+
static {
|
|
1302
|
+
__name(this, "Language");
|
|
1303
|
+
}
|
|
1304
|
+
[0] = 0;
|
|
1305
|
+
types;
|
|
1306
|
+
fields;
|
|
1307
|
+
constructor(internal, address) {
|
|
1308
|
+
assertInternal(internal);
|
|
1309
|
+
this[0] = address;
|
|
1310
|
+
this.types = new Array(C._ts_language_symbol_count(this[0]));
|
|
1311
|
+
for (let i2 = 0, n = this.types.length;i2 < n; i2++) {
|
|
1312
|
+
if (C._ts_language_symbol_type(this[0], i2) < 2) {
|
|
1313
|
+
this.types[i2] = C.UTF8ToString(C._ts_language_symbol_name(this[0], i2));
|
|
1314
|
+
}
|
|
1315
|
+
}
|
|
1316
|
+
this.fields = new Array(C._ts_language_field_count(this[0]) + 1);
|
|
1317
|
+
for (let i2 = 0, n = this.fields.length;i2 < n; i2++) {
|
|
1318
|
+
const fieldName = C._ts_language_field_name_for_id(this[0], i2);
|
|
1319
|
+
if (fieldName !== 0) {
|
|
1320
|
+
this.fields[i2] = C.UTF8ToString(fieldName);
|
|
1321
|
+
} else {
|
|
1322
|
+
this.fields[i2] = null;
|
|
1323
|
+
}
|
|
1324
|
+
}
|
|
1325
|
+
}
|
|
1326
|
+
get name() {
|
|
1327
|
+
const ptr = C._ts_language_name(this[0]);
|
|
1328
|
+
if (ptr === 0)
|
|
1329
|
+
return null;
|
|
1330
|
+
return C.UTF8ToString(ptr);
|
|
1331
|
+
}
|
|
1332
|
+
get version() {
|
|
1333
|
+
return C._ts_language_version(this[0]);
|
|
1334
|
+
}
|
|
1335
|
+
get abiVersion() {
|
|
1336
|
+
return C._ts_language_abi_version(this[0]);
|
|
1337
|
+
}
|
|
1338
|
+
get metadata() {
|
|
1339
|
+
C._ts_language_metadata(this[0]);
|
|
1340
|
+
const length = C.getValue(TRANSFER_BUFFER, "i32");
|
|
1341
|
+
const address = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
|
|
1342
|
+
if (length === 0)
|
|
1343
|
+
return null;
|
|
1344
|
+
return unmarshalLanguageMetadata(address);
|
|
1345
|
+
}
|
|
1346
|
+
get fieldCount() {
|
|
1347
|
+
return this.fields.length - 1;
|
|
1348
|
+
}
|
|
1349
|
+
get stateCount() {
|
|
1350
|
+
return C._ts_language_state_count(this[0]);
|
|
1351
|
+
}
|
|
1352
|
+
fieldIdForName(fieldName) {
|
|
1353
|
+
const result = this.fields.indexOf(fieldName);
|
|
1354
|
+
return result !== -1 ? result : null;
|
|
1355
|
+
}
|
|
1356
|
+
fieldNameForId(fieldId) {
|
|
1357
|
+
return this.fields[fieldId] ?? null;
|
|
1358
|
+
}
|
|
1359
|
+
idForNodeType(type, named) {
|
|
1360
|
+
const typeLength = C.lengthBytesUTF8(type);
|
|
1361
|
+
const typeAddress = C._malloc(typeLength + 1);
|
|
1362
|
+
C.stringToUTF8(type, typeAddress, typeLength + 1);
|
|
1363
|
+
const result = C._ts_language_symbol_for_name(this[0], typeAddress, typeLength, named ? 1 : 0);
|
|
1364
|
+
C._free(typeAddress);
|
|
1365
|
+
return result || null;
|
|
1366
|
+
}
|
|
1367
|
+
get nodeTypeCount() {
|
|
1368
|
+
return C._ts_language_symbol_count(this[0]);
|
|
1369
|
+
}
|
|
1370
|
+
nodeTypeForId(typeId) {
|
|
1371
|
+
const name2 = C._ts_language_symbol_name(this[0], typeId);
|
|
1372
|
+
return name2 ? C.UTF8ToString(name2) : null;
|
|
1373
|
+
}
|
|
1374
|
+
nodeTypeIsNamed(typeId) {
|
|
1375
|
+
return C._ts_language_type_is_named_wasm(this[0], typeId) ? true : false;
|
|
1376
|
+
}
|
|
1377
|
+
nodeTypeIsVisible(typeId) {
|
|
1378
|
+
return C._ts_language_type_is_visible_wasm(this[0], typeId) ? true : false;
|
|
1379
|
+
}
|
|
1380
|
+
get supertypes() {
|
|
1381
|
+
C._ts_language_supertypes_wasm(this[0]);
|
|
1382
|
+
const count = C.getValue(TRANSFER_BUFFER, "i32");
|
|
1383
|
+
const buffer = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
|
|
1384
|
+
const result = new Array(count);
|
|
1385
|
+
if (count > 0) {
|
|
1386
|
+
let address = buffer;
|
|
1387
|
+
for (let i2 = 0;i2 < count; i2++) {
|
|
1388
|
+
result[i2] = C.getValue(address, "i16");
|
|
1389
|
+
address += SIZE_OF_SHORT;
|
|
1390
|
+
}
|
|
1391
|
+
}
|
|
1392
|
+
return result;
|
|
1393
|
+
}
|
|
1394
|
+
subtypes(supertype) {
|
|
1395
|
+
C._ts_language_subtypes_wasm(this[0], supertype);
|
|
1396
|
+
const count = C.getValue(TRANSFER_BUFFER, "i32");
|
|
1397
|
+
const buffer = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
|
|
1398
|
+
const result = new Array(count);
|
|
1399
|
+
if (count > 0) {
|
|
1400
|
+
let address = buffer;
|
|
1401
|
+
for (let i2 = 0;i2 < count; i2++) {
|
|
1402
|
+
result[i2] = C.getValue(address, "i16");
|
|
1403
|
+
address += SIZE_OF_SHORT;
|
|
1404
|
+
}
|
|
1405
|
+
}
|
|
1406
|
+
return result;
|
|
1407
|
+
}
|
|
1408
|
+
nextState(stateId, typeId) {
|
|
1409
|
+
return C._ts_language_next_state(this[0], stateId, typeId);
|
|
1410
|
+
}
|
|
1411
|
+
lookaheadIterator(stateId) {
|
|
1412
|
+
const address = C._ts_lookahead_iterator_new(this[0], stateId);
|
|
1413
|
+
if (address)
|
|
1414
|
+
return new LookaheadIterator(INTERNAL, address, this);
|
|
1415
|
+
return null;
|
|
1416
|
+
}
|
|
1417
|
+
query(source) {
|
|
1418
|
+
console.warn("Language.query is deprecated. Use new Query(language, source) instead.");
|
|
1419
|
+
return new Query(this, source);
|
|
1420
|
+
}
|
|
1421
|
+
static async load(input) {
|
|
1422
|
+
let bytes;
|
|
1423
|
+
if (input instanceof Uint8Array) {
|
|
1424
|
+
bytes = Promise.resolve(input);
|
|
1425
|
+
} else {
|
|
1426
|
+
if (globalThis.process?.versions.node) {
|
|
1427
|
+
const fs2 = await import("fs/promises");
|
|
1428
|
+
bytes = fs2.readFile(input);
|
|
1429
|
+
} else {
|
|
1430
|
+
bytes = fetch(input).then((response) => response.arrayBuffer().then((buffer) => {
|
|
1431
|
+
if (response.ok) {
|
|
1432
|
+
return new Uint8Array(buffer);
|
|
1433
|
+
} else {
|
|
1434
|
+
const body2 = new TextDecoder("utf-8").decode(buffer);
|
|
1435
|
+
throw new Error(`Language.load failed with status ${response.status}.
|
|
1436
|
+
|
|
1437
|
+
${body2}`);
|
|
1438
|
+
}
|
|
1439
|
+
}));
|
|
1440
|
+
}
|
|
1441
|
+
}
|
|
1442
|
+
const mod = await C.loadWebAssemblyModule(await bytes, { loadAsync: true });
|
|
1443
|
+
const symbolNames = Object.keys(mod);
|
|
1444
|
+
const functionName = symbolNames.find((key) => LANGUAGE_FUNCTION_REGEX.test(key) && !key.includes("external_scanner_"));
|
|
1445
|
+
if (!functionName) {
|
|
1446
|
+
console.log(`Couldn't find language function in WASM file. Symbols:
|
|
1447
|
+
${JSON.stringify(symbolNames, null, 2)}`);
|
|
1448
|
+
throw new Error("Language.load failed: no language function found in WASM file");
|
|
1449
|
+
}
|
|
1450
|
+
const languageAddress = mod[functionName]();
|
|
1451
|
+
return new _Language(INTERNAL, languageAddress);
|
|
1452
|
+
}
|
|
1453
|
+
};
|
|
1454
|
+
var Module2 = (() => {
|
|
1455
|
+
var _scriptName = import.meta.url;
|
|
1456
|
+
return async function(moduleArg = {}) {
|
|
1457
|
+
var moduleRtn;
|
|
1458
|
+
var Module = moduleArg;
|
|
1459
|
+
var readyPromiseResolve, readyPromiseReject;
|
|
1460
|
+
var readyPromise = new Promise((resolve, reject) => {
|
|
1461
|
+
readyPromiseResolve = resolve;
|
|
1462
|
+
readyPromiseReject = reject;
|
|
1463
|
+
});
|
|
1464
|
+
var ENVIRONMENT_IS_WEB = typeof window == "object";
|
|
1465
|
+
var ENVIRONMENT_IS_WORKER = typeof WorkerGlobalScope != "undefined";
|
|
1466
|
+
var ENVIRONMENT_IS_NODE = typeof process == "object" && typeof process.versions == "object" && typeof process.versions.node == "string" && process.type != "renderer";
|
|
1467
|
+
var ENVIRONMENT_IS_SHELL = !ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_NODE && !ENVIRONMENT_IS_WORKER;
|
|
1468
|
+
if (ENVIRONMENT_IS_NODE) {
|
|
1469
|
+
const { createRequire } = await import("module");
|
|
1470
|
+
var require = createRequire(import.meta.url);
|
|
1471
|
+
}
|
|
1472
|
+
Module.currentQueryProgressCallback = null;
|
|
1473
|
+
Module.currentProgressCallback = null;
|
|
1474
|
+
Module.currentLogCallback = null;
|
|
1475
|
+
Module.currentParseCallback = null;
|
|
1476
|
+
var moduleOverrides = Object.assign({}, Module);
|
|
1477
|
+
var arguments_ = [];
|
|
1478
|
+
var thisProgram = "./this.program";
|
|
1479
|
+
var quit_ = /* @__PURE__ */ __name((status, toThrow) => {
|
|
1480
|
+
throw toThrow;
|
|
1481
|
+
}, "quit_");
|
|
1482
|
+
var scriptDirectory = "";
|
|
1483
|
+
function locateFile(path) {
|
|
1484
|
+
if (Module["locateFile"]) {
|
|
1485
|
+
return Module["locateFile"](path, scriptDirectory);
|
|
1486
|
+
}
|
|
1487
|
+
return scriptDirectory + path;
|
|
1488
|
+
}
|
|
1489
|
+
__name(locateFile, "locateFile");
|
|
1490
|
+
var readAsync, readBinary;
|
|
1491
|
+
if (ENVIRONMENT_IS_NODE) {
|
|
1492
|
+
var fs = require("fs");
|
|
1493
|
+
var nodePath = require("path");
|
|
1494
|
+
if (!import.meta.url.startsWith("data:")) {
|
|
1495
|
+
scriptDirectory = nodePath.dirname(require("url").fileURLToPath(import.meta.url)) + "/";
|
|
1496
|
+
}
|
|
1497
|
+
readBinary = /* @__PURE__ */ __name((filename) => {
|
|
1498
|
+
filename = isFileURI(filename) ? new URL(filename) : filename;
|
|
1499
|
+
var ret = fs.readFileSync(filename);
|
|
1500
|
+
return ret;
|
|
1501
|
+
}, "readBinary");
|
|
1502
|
+
readAsync = /* @__PURE__ */ __name(async (filename, binary2 = true) => {
|
|
1503
|
+
filename = isFileURI(filename) ? new URL(filename) : filename;
|
|
1504
|
+
var ret = fs.readFileSync(filename, binary2 ? undefined : "utf8");
|
|
1505
|
+
return ret;
|
|
1506
|
+
}, "readAsync");
|
|
1507
|
+
if (!Module["thisProgram"] && process.argv.length > 1) {
|
|
1508
|
+
thisProgram = process.argv[1].replace(/\\/g, "/");
|
|
1509
|
+
}
|
|
1510
|
+
arguments_ = process.argv.slice(2);
|
|
1511
|
+
quit_ = /* @__PURE__ */ __name((status, toThrow) => {
|
|
1512
|
+
process.exitCode = status;
|
|
1513
|
+
throw toThrow;
|
|
1514
|
+
}, "quit_");
|
|
1515
|
+
} else if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) {
|
|
1516
|
+
if (ENVIRONMENT_IS_WORKER) {
|
|
1517
|
+
scriptDirectory = self.location.href;
|
|
1518
|
+
} else if (typeof document != "undefined" && document.currentScript) {
|
|
1519
|
+
scriptDirectory = document.currentScript.src;
|
|
1520
|
+
}
|
|
1521
|
+
if (_scriptName) {
|
|
1522
|
+
scriptDirectory = _scriptName;
|
|
1523
|
+
}
|
|
1524
|
+
if (scriptDirectory.startsWith("blob:")) {
|
|
1525
|
+
scriptDirectory = "";
|
|
1526
|
+
} else {
|
|
1527
|
+
scriptDirectory = scriptDirectory.slice(0, scriptDirectory.replace(/[?#].*/, "").lastIndexOf("/") + 1);
|
|
1528
|
+
}
|
|
1529
|
+
{
|
|
1530
|
+
if (ENVIRONMENT_IS_WORKER) {
|
|
1531
|
+
readBinary = /* @__PURE__ */ __name((url) => {
|
|
1532
|
+
var xhr = new XMLHttpRequest;
|
|
1533
|
+
xhr.open("GET", url, false);
|
|
1534
|
+
xhr.responseType = "arraybuffer";
|
|
1535
|
+
xhr.send(null);
|
|
1536
|
+
return new Uint8Array(xhr.response);
|
|
1537
|
+
}, "readBinary");
|
|
1538
|
+
}
|
|
1539
|
+
readAsync = /* @__PURE__ */ __name(async (url) => {
|
|
1540
|
+
if (isFileURI(url)) {
|
|
1541
|
+
return new Promise((resolve, reject) => {
|
|
1542
|
+
var xhr = new XMLHttpRequest;
|
|
1543
|
+
xhr.open("GET", url, true);
|
|
1544
|
+
xhr.responseType = "arraybuffer";
|
|
1545
|
+
xhr.onload = () => {
|
|
1546
|
+
if (xhr.status == 200 || xhr.status == 0 && xhr.response) {
|
|
1547
|
+
resolve(xhr.response);
|
|
1548
|
+
return;
|
|
1549
|
+
}
|
|
1550
|
+
reject(xhr.status);
|
|
1551
|
+
};
|
|
1552
|
+
xhr.onerror = reject;
|
|
1553
|
+
xhr.send(null);
|
|
1554
|
+
});
|
|
1555
|
+
}
|
|
1556
|
+
var response = await fetch(url, {
|
|
1557
|
+
credentials: "same-origin"
|
|
1558
|
+
});
|
|
1559
|
+
if (response.ok) {
|
|
1560
|
+
return response.arrayBuffer();
|
|
1561
|
+
}
|
|
1562
|
+
throw new Error(response.status + " : " + response.url);
|
|
1563
|
+
}, "readAsync");
|
|
1564
|
+
}
|
|
1565
|
+
} else {}
|
|
1566
|
+
var out = Module["print"] || console.log.bind(console);
|
|
1567
|
+
var err = Module["printErr"] || console.error.bind(console);
|
|
1568
|
+
Object.assign(Module, moduleOverrides);
|
|
1569
|
+
moduleOverrides = null;
|
|
1570
|
+
if (Module["arguments"])
|
|
1571
|
+
arguments_ = Module["arguments"];
|
|
1572
|
+
if (Module["thisProgram"])
|
|
1573
|
+
thisProgram = Module["thisProgram"];
|
|
1574
|
+
var dynamicLibraries = Module["dynamicLibraries"] || [];
|
|
1575
|
+
var wasmBinary = Module["wasmBinary"];
|
|
1576
|
+
var wasmMemory;
|
|
1577
|
+
var ABORT = false;
|
|
1578
|
+
var EXITSTATUS;
|
|
1579
|
+
function assert(condition, text) {
|
|
1580
|
+
if (!condition) {
|
|
1581
|
+
abort(text);
|
|
1582
|
+
}
|
|
1583
|
+
}
|
|
1584
|
+
__name(assert, "assert");
|
|
1585
|
+
var HEAP, HEAP8, HEAPU8, HEAP16, HEAPU16, HEAP32, HEAPU32, HEAPF32, HEAP64, HEAPU64, HEAPF64;
|
|
1586
|
+
var HEAP_DATA_VIEW;
|
|
1587
|
+
var runtimeInitialized = false;
|
|
1588
|
+
var isFileURI = /* @__PURE__ */ __name((filename) => filename.startsWith("file://"), "isFileURI");
|
|
1589
|
+
function updateMemoryViews() {
|
|
1590
|
+
var b = wasmMemory.buffer;
|
|
1591
|
+
Module["HEAP_DATA_VIEW"] = HEAP_DATA_VIEW = new DataView(b);
|
|
1592
|
+
Module["HEAP8"] = HEAP8 = new Int8Array(b);
|
|
1593
|
+
Module["HEAP16"] = HEAP16 = new Int16Array(b);
|
|
1594
|
+
Module["HEAPU8"] = HEAPU8 = new Uint8Array(b);
|
|
1595
|
+
Module["HEAPU16"] = HEAPU16 = new Uint16Array(b);
|
|
1596
|
+
Module["HEAP32"] = HEAP32 = new Int32Array(b);
|
|
1597
|
+
Module["HEAPU32"] = HEAPU32 = new Uint32Array(b);
|
|
1598
|
+
Module["HEAPF32"] = HEAPF32 = new Float32Array(b);
|
|
1599
|
+
Module["HEAPF64"] = HEAPF64 = new Float64Array(b);
|
|
1600
|
+
Module["HEAP64"] = HEAP64 = new BigInt64Array(b);
|
|
1601
|
+
Module["HEAPU64"] = HEAPU64 = new BigUint64Array(b);
|
|
1602
|
+
}
|
|
1603
|
+
__name(updateMemoryViews, "updateMemoryViews");
|
|
1604
|
+
if (Module["wasmMemory"]) {
|
|
1605
|
+
wasmMemory = Module["wasmMemory"];
|
|
1606
|
+
} else {
|
|
1607
|
+
var INITIAL_MEMORY = Module["INITIAL_MEMORY"] || 33554432;
|
|
1608
|
+
wasmMemory = new WebAssembly.Memory({
|
|
1609
|
+
initial: INITIAL_MEMORY / 65536,
|
|
1610
|
+
maximum: 32768
|
|
1611
|
+
});
|
|
1612
|
+
}
|
|
1613
|
+
updateMemoryViews();
|
|
1614
|
+
var __RELOC_FUNCS__ = [];
|
|
1615
|
+
function preRun() {
|
|
1616
|
+
if (Module["preRun"]) {
|
|
1617
|
+
if (typeof Module["preRun"] == "function")
|
|
1618
|
+
Module["preRun"] = [Module["preRun"]];
|
|
1619
|
+
while (Module["preRun"].length) {
|
|
1620
|
+
addOnPreRun(Module["preRun"].shift());
|
|
1621
|
+
}
|
|
1622
|
+
}
|
|
1623
|
+
callRuntimeCallbacks(onPreRuns);
|
|
1624
|
+
}
|
|
1625
|
+
__name(preRun, "preRun");
|
|
1626
|
+
function initRuntime() {
|
|
1627
|
+
runtimeInitialized = true;
|
|
1628
|
+
callRuntimeCallbacks(__RELOC_FUNCS__);
|
|
1629
|
+
wasmExports["__wasm_call_ctors"]();
|
|
1630
|
+
callRuntimeCallbacks(onPostCtors);
|
|
1631
|
+
}
|
|
1632
|
+
__name(initRuntime, "initRuntime");
|
|
1633
|
+
function preMain() {}
|
|
1634
|
+
__name(preMain, "preMain");
|
|
1635
|
+
function postRun() {
|
|
1636
|
+
if (Module["postRun"]) {
|
|
1637
|
+
if (typeof Module["postRun"] == "function")
|
|
1638
|
+
Module["postRun"] = [Module["postRun"]];
|
|
1639
|
+
while (Module["postRun"].length) {
|
|
1640
|
+
addOnPostRun(Module["postRun"].shift());
|
|
1641
|
+
}
|
|
1642
|
+
}
|
|
1643
|
+
callRuntimeCallbacks(onPostRuns);
|
|
1644
|
+
}
|
|
1645
|
+
__name(postRun, "postRun");
|
|
1646
|
+
var runDependencies = 0;
|
|
1647
|
+
var dependenciesFulfilled = null;
|
|
1648
|
+
function getUniqueRunDependency(id) {
|
|
1649
|
+
return id;
|
|
1650
|
+
}
|
|
1651
|
+
__name(getUniqueRunDependency, "getUniqueRunDependency");
|
|
1652
|
+
function addRunDependency(id) {
|
|
1653
|
+
runDependencies++;
|
|
1654
|
+
Module["monitorRunDependencies"]?.(runDependencies);
|
|
1655
|
+
}
|
|
1656
|
+
__name(addRunDependency, "addRunDependency");
|
|
1657
|
+
function removeRunDependency(id) {
|
|
1658
|
+
runDependencies--;
|
|
1659
|
+
Module["monitorRunDependencies"]?.(runDependencies);
|
|
1660
|
+
if (runDependencies == 0) {
|
|
1661
|
+
if (dependenciesFulfilled) {
|
|
1662
|
+
var callback = dependenciesFulfilled;
|
|
1663
|
+
dependenciesFulfilled = null;
|
|
1664
|
+
callback();
|
|
1665
|
+
}
|
|
1666
|
+
}
|
|
1667
|
+
}
|
|
1668
|
+
__name(removeRunDependency, "removeRunDependency");
|
|
1669
|
+
function abort(what) {
|
|
1670
|
+
Module["onAbort"]?.(what);
|
|
1671
|
+
what = "Aborted(" + what + ")";
|
|
1672
|
+
err(what);
|
|
1673
|
+
ABORT = true;
|
|
1674
|
+
what += ". Build with -sASSERTIONS for more info.";
|
|
1675
|
+
var e = new WebAssembly.RuntimeError(what);
|
|
1676
|
+
readyPromiseReject(e);
|
|
1677
|
+
throw e;
|
|
1678
|
+
}
|
|
1679
|
+
__name(abort, "abort");
|
|
1680
|
+
var wasmBinaryFile;
|
|
1681
|
+
function findWasmBinary() {
|
|
1682
|
+
if (Module["locateFile"]) {
|
|
1683
|
+
return locateFile("tree-sitter.wasm");
|
|
1684
|
+
}
|
|
1685
|
+
return new URL("tree-sitter.wasm", import.meta.url).href;
|
|
1686
|
+
}
|
|
1687
|
+
__name(findWasmBinary, "findWasmBinary");
|
|
1688
|
+
function getBinarySync(file) {
|
|
1689
|
+
if (file == wasmBinaryFile && wasmBinary) {
|
|
1690
|
+
return new Uint8Array(wasmBinary);
|
|
1691
|
+
}
|
|
1692
|
+
if (readBinary) {
|
|
1693
|
+
return readBinary(file);
|
|
1694
|
+
}
|
|
1695
|
+
throw "both async and sync fetching of the wasm failed";
|
|
1696
|
+
}
|
|
1697
|
+
__name(getBinarySync, "getBinarySync");
|
|
1698
|
+
async function getWasmBinary(binaryFile) {
|
|
1699
|
+
if (!wasmBinary) {
|
|
1700
|
+
try {
|
|
1701
|
+
var response = await readAsync(binaryFile);
|
|
1702
|
+
return new Uint8Array(response);
|
|
1703
|
+
} catch {}
|
|
1704
|
+
}
|
|
1705
|
+
return getBinarySync(binaryFile);
|
|
1706
|
+
}
|
|
1707
|
+
__name(getWasmBinary, "getWasmBinary");
|
|
1708
|
+
async function instantiateArrayBuffer(binaryFile, imports) {
|
|
1709
|
+
try {
|
|
1710
|
+
var binary2 = await getWasmBinary(binaryFile);
|
|
1711
|
+
var instance2 = await WebAssembly.instantiate(binary2, imports);
|
|
1712
|
+
return instance2;
|
|
1713
|
+
} catch (reason) {
|
|
1714
|
+
err(`failed to asynchronously prepare wasm: ${reason}`);
|
|
1715
|
+
abort(reason);
|
|
1716
|
+
}
|
|
1717
|
+
}
|
|
1718
|
+
__name(instantiateArrayBuffer, "instantiateArrayBuffer");
|
|
1719
|
+
async function instantiateAsync(binary2, binaryFile, imports) {
|
|
1720
|
+
if (!binary2 && typeof WebAssembly.instantiateStreaming == "function" && !isFileURI(binaryFile) && !ENVIRONMENT_IS_NODE) {
|
|
1721
|
+
try {
|
|
1722
|
+
var response = fetch(binaryFile, {
|
|
1723
|
+
credentials: "same-origin"
|
|
1724
|
+
});
|
|
1725
|
+
var instantiationResult = await WebAssembly.instantiateStreaming(response, imports);
|
|
1726
|
+
return instantiationResult;
|
|
1727
|
+
} catch (reason) {
|
|
1728
|
+
err(`wasm streaming compile failed: ${reason}`);
|
|
1729
|
+
err("falling back to ArrayBuffer instantiation");
|
|
1730
|
+
}
|
|
1731
|
+
}
|
|
1732
|
+
return instantiateArrayBuffer(binaryFile, imports);
|
|
1733
|
+
}
|
|
1734
|
+
__name(instantiateAsync, "instantiateAsync");
|
|
1735
|
+
function getWasmImports() {
|
|
1736
|
+
return {
|
|
1737
|
+
env: wasmImports,
|
|
1738
|
+
wasi_snapshot_preview1: wasmImports,
|
|
1739
|
+
"GOT.mem": new Proxy(wasmImports, GOTHandler),
|
|
1740
|
+
"GOT.func": new Proxy(wasmImports, GOTHandler)
|
|
1741
|
+
};
|
|
1742
|
+
}
|
|
1743
|
+
__name(getWasmImports, "getWasmImports");
|
|
1744
|
+
async function createWasm() {
|
|
1745
|
+
function receiveInstance(instance2, module2) {
|
|
1746
|
+
wasmExports = instance2.exports;
|
|
1747
|
+
wasmExports = relocateExports(wasmExports, 1024);
|
|
1748
|
+
var metadata2 = getDylinkMetadata(module2);
|
|
1749
|
+
if (metadata2.neededDynlibs) {
|
|
1750
|
+
dynamicLibraries = metadata2.neededDynlibs.concat(dynamicLibraries);
|
|
1751
|
+
}
|
|
1752
|
+
mergeLibSymbols(wasmExports, "main");
|
|
1753
|
+
LDSO.init();
|
|
1754
|
+
loadDylibs();
|
|
1755
|
+
__RELOC_FUNCS__.push(wasmExports["__wasm_apply_data_relocs"]);
|
|
1756
|
+
removeRunDependency("wasm-instantiate");
|
|
1757
|
+
return wasmExports;
|
|
1758
|
+
}
|
|
1759
|
+
__name(receiveInstance, "receiveInstance");
|
|
1760
|
+
addRunDependency("wasm-instantiate");
|
|
1761
|
+
function receiveInstantiationResult(result2) {
|
|
1762
|
+
return receiveInstance(result2["instance"], result2["module"]);
|
|
1763
|
+
}
|
|
1764
|
+
__name(receiveInstantiationResult, "receiveInstantiationResult");
|
|
1765
|
+
var info2 = getWasmImports();
|
|
1766
|
+
if (Module["instantiateWasm"]) {
|
|
1767
|
+
return new Promise((resolve, reject) => {
|
|
1768
|
+
Module["instantiateWasm"](info2, (mod, inst) => {
|
|
1769
|
+
receiveInstance(mod, inst);
|
|
1770
|
+
resolve(mod.exports);
|
|
1771
|
+
});
|
|
1772
|
+
});
|
|
1773
|
+
}
|
|
1774
|
+
wasmBinaryFile ??= findWasmBinary();
|
|
1775
|
+
try {
|
|
1776
|
+
var result = await instantiateAsync(wasmBinary, wasmBinaryFile, info2);
|
|
1777
|
+
var exports = receiveInstantiationResult(result);
|
|
1778
|
+
return exports;
|
|
1779
|
+
} catch (e) {
|
|
1780
|
+
readyPromiseReject(e);
|
|
1781
|
+
return Promise.reject(e);
|
|
1782
|
+
}
|
|
1783
|
+
}
|
|
1784
|
+
__name(createWasm, "createWasm");
|
|
1785
|
+
var ASM_CONSTS = {};
|
|
1786
|
+
|
|
1787
|
+
class ExitStatus {
|
|
1788
|
+
static {
|
|
1789
|
+
__name(this, "ExitStatus");
|
|
1790
|
+
}
|
|
1791
|
+
name = "ExitStatus";
|
|
1792
|
+
constructor(status) {
|
|
1793
|
+
this.message = `Program terminated with exit(${status})`;
|
|
1794
|
+
this.status = status;
|
|
1795
|
+
}
|
|
1796
|
+
}
|
|
1797
|
+
var GOT = {};
|
|
1798
|
+
var currentModuleWeakSymbols = /* @__PURE__ */ new Set([]);
|
|
1799
|
+
var GOTHandler = {
|
|
1800
|
+
get(obj, symName) {
|
|
1801
|
+
var rtn = GOT[symName];
|
|
1802
|
+
if (!rtn) {
|
|
1803
|
+
rtn = GOT[symName] = new WebAssembly.Global({
|
|
1804
|
+
value: "i32",
|
|
1805
|
+
mutable: true
|
|
1806
|
+
});
|
|
1807
|
+
}
|
|
1808
|
+
if (!currentModuleWeakSymbols.has(symName)) {
|
|
1809
|
+
rtn.required = true;
|
|
1810
|
+
}
|
|
1811
|
+
return rtn;
|
|
1812
|
+
}
|
|
1813
|
+
};
|
|
1814
|
+
var LE_HEAP_LOAD_F32 = /* @__PURE__ */ __name((byteOffset) => HEAP_DATA_VIEW.getFloat32(byteOffset, true), "LE_HEAP_LOAD_F32");
|
|
1815
|
+
var LE_HEAP_LOAD_F64 = /* @__PURE__ */ __name((byteOffset) => HEAP_DATA_VIEW.getFloat64(byteOffset, true), "LE_HEAP_LOAD_F64");
|
|
1816
|
+
var LE_HEAP_LOAD_I16 = /* @__PURE__ */ __name((byteOffset) => HEAP_DATA_VIEW.getInt16(byteOffset, true), "LE_HEAP_LOAD_I16");
|
|
1817
|
+
var LE_HEAP_LOAD_I32 = /* @__PURE__ */ __name((byteOffset) => HEAP_DATA_VIEW.getInt32(byteOffset, true), "LE_HEAP_LOAD_I32");
|
|
1818
|
+
var LE_HEAP_LOAD_U16 = /* @__PURE__ */ __name((byteOffset) => HEAP_DATA_VIEW.getUint16(byteOffset, true), "LE_HEAP_LOAD_U16");
|
|
1819
|
+
var LE_HEAP_LOAD_U32 = /* @__PURE__ */ __name((byteOffset) => HEAP_DATA_VIEW.getUint32(byteOffset, true), "LE_HEAP_LOAD_U32");
|
|
1820
|
+
var LE_HEAP_STORE_F32 = /* @__PURE__ */ __name((byteOffset, value) => HEAP_DATA_VIEW.setFloat32(byteOffset, value, true), "LE_HEAP_STORE_F32");
|
|
1821
|
+
var LE_HEAP_STORE_F64 = /* @__PURE__ */ __name((byteOffset, value) => HEAP_DATA_VIEW.setFloat64(byteOffset, value, true), "LE_HEAP_STORE_F64");
|
|
1822
|
+
var LE_HEAP_STORE_I16 = /* @__PURE__ */ __name((byteOffset, value) => HEAP_DATA_VIEW.setInt16(byteOffset, value, true), "LE_HEAP_STORE_I16");
|
|
1823
|
+
var LE_HEAP_STORE_I32 = /* @__PURE__ */ __name((byteOffset, value) => HEAP_DATA_VIEW.setInt32(byteOffset, value, true), "LE_HEAP_STORE_I32");
|
|
1824
|
+
var LE_HEAP_STORE_U16 = /* @__PURE__ */ __name((byteOffset, value) => HEAP_DATA_VIEW.setUint16(byteOffset, value, true), "LE_HEAP_STORE_U16");
|
|
1825
|
+
var LE_HEAP_STORE_U32 = /* @__PURE__ */ __name((byteOffset, value) => HEAP_DATA_VIEW.setUint32(byteOffset, value, true), "LE_HEAP_STORE_U32");
|
|
1826
|
+
var callRuntimeCallbacks = /* @__PURE__ */ __name((callbacks) => {
|
|
1827
|
+
while (callbacks.length > 0) {
|
|
1828
|
+
callbacks.shift()(Module);
|
|
1829
|
+
}
|
|
1830
|
+
}, "callRuntimeCallbacks");
|
|
1831
|
+
var onPostRuns = [];
|
|
1832
|
+
var addOnPostRun = /* @__PURE__ */ __name((cb) => onPostRuns.unshift(cb), "addOnPostRun");
|
|
1833
|
+
var onPreRuns = [];
|
|
1834
|
+
var addOnPreRun = /* @__PURE__ */ __name((cb) => onPreRuns.unshift(cb), "addOnPreRun");
|
|
1835
|
+
var UTF8Decoder = typeof TextDecoder != "undefined" ? new TextDecoder : undefined;
|
|
1836
|
+
var UTF8ArrayToString = /* @__PURE__ */ __name((heapOrArray, idx = 0, maxBytesToRead = NaN) => {
|
|
1837
|
+
var endIdx = idx + maxBytesToRead;
|
|
1838
|
+
var endPtr = idx;
|
|
1839
|
+
while (heapOrArray[endPtr] && !(endPtr >= endIdx))
|
|
1840
|
+
++endPtr;
|
|
1841
|
+
if (endPtr - idx > 16 && heapOrArray.buffer && UTF8Decoder) {
|
|
1842
|
+
return UTF8Decoder.decode(heapOrArray.subarray(idx, endPtr));
|
|
1843
|
+
}
|
|
1844
|
+
var str = "";
|
|
1845
|
+
while (idx < endPtr) {
|
|
1846
|
+
var u0 = heapOrArray[idx++];
|
|
1847
|
+
if (!(u0 & 128)) {
|
|
1848
|
+
str += String.fromCharCode(u0);
|
|
1849
|
+
continue;
|
|
1850
|
+
}
|
|
1851
|
+
var u1 = heapOrArray[idx++] & 63;
|
|
1852
|
+
if ((u0 & 224) == 192) {
|
|
1853
|
+
str += String.fromCharCode((u0 & 31) << 6 | u1);
|
|
1854
|
+
continue;
|
|
1855
|
+
}
|
|
1856
|
+
var u2 = heapOrArray[idx++] & 63;
|
|
1857
|
+
if ((u0 & 240) == 224) {
|
|
1858
|
+
u0 = (u0 & 15) << 12 | u1 << 6 | u2;
|
|
1859
|
+
} else {
|
|
1860
|
+
u0 = (u0 & 7) << 18 | u1 << 12 | u2 << 6 | heapOrArray[idx++] & 63;
|
|
1861
|
+
}
|
|
1862
|
+
if (u0 < 65536) {
|
|
1863
|
+
str += String.fromCharCode(u0);
|
|
1864
|
+
} else {
|
|
1865
|
+
var ch = u0 - 65536;
|
|
1866
|
+
str += String.fromCharCode(55296 | ch >> 10, 56320 | ch & 1023);
|
|
1867
|
+
}
|
|
1868
|
+
}
|
|
1869
|
+
return str;
|
|
1870
|
+
}, "UTF8ArrayToString");
|
|
1871
|
+
var getDylinkMetadata = /* @__PURE__ */ __name((binary2) => {
|
|
1872
|
+
var offset = 0;
|
|
1873
|
+
var end = 0;
|
|
1874
|
+
function getU8() {
|
|
1875
|
+
return binary2[offset++];
|
|
1876
|
+
}
|
|
1877
|
+
__name(getU8, "getU8");
|
|
1878
|
+
function getLEB() {
|
|
1879
|
+
var ret = 0;
|
|
1880
|
+
var mul = 1;
|
|
1881
|
+
while (true) {
|
|
1882
|
+
var byte = binary2[offset++];
|
|
1883
|
+
ret += (byte & 127) * mul;
|
|
1884
|
+
mul *= 128;
|
|
1885
|
+
if (!(byte & 128))
|
|
1886
|
+
break;
|
|
1887
|
+
}
|
|
1888
|
+
return ret;
|
|
1889
|
+
}
|
|
1890
|
+
__name(getLEB, "getLEB");
|
|
1891
|
+
function getString() {
|
|
1892
|
+
var len = getLEB();
|
|
1893
|
+
offset += len;
|
|
1894
|
+
return UTF8ArrayToString(binary2, offset - len, len);
|
|
1895
|
+
}
|
|
1896
|
+
__name(getString, "getString");
|
|
1897
|
+
function failIf(condition, message) {
|
|
1898
|
+
if (condition)
|
|
1899
|
+
throw new Error(message);
|
|
1900
|
+
}
|
|
1901
|
+
__name(failIf, "failIf");
|
|
1902
|
+
var name2 = "dylink.0";
|
|
1903
|
+
if (binary2 instanceof WebAssembly.Module) {
|
|
1904
|
+
var dylinkSection = WebAssembly.Module.customSections(binary2, name2);
|
|
1905
|
+
if (dylinkSection.length === 0) {
|
|
1906
|
+
name2 = "dylink";
|
|
1907
|
+
dylinkSection = WebAssembly.Module.customSections(binary2, name2);
|
|
1908
|
+
}
|
|
1909
|
+
failIf(dylinkSection.length === 0, "need dylink section");
|
|
1910
|
+
binary2 = new Uint8Array(dylinkSection[0]);
|
|
1911
|
+
end = binary2.length;
|
|
1912
|
+
} else {
|
|
1913
|
+
var int32View = new Uint32Array(new Uint8Array(binary2.subarray(0, 24)).buffer);
|
|
1914
|
+
var magicNumberFound = int32View[0] == 1836278016 || int32View[0] == 6386541;
|
|
1915
|
+
failIf(!magicNumberFound, "need to see wasm magic number");
|
|
1916
|
+
failIf(binary2[8] !== 0, "need the dylink section to be first");
|
|
1917
|
+
offset = 9;
|
|
1918
|
+
var section_size = getLEB();
|
|
1919
|
+
end = offset + section_size;
|
|
1920
|
+
name2 = getString();
|
|
1921
|
+
}
|
|
1922
|
+
var customSection = {
|
|
1923
|
+
neededDynlibs: [],
|
|
1924
|
+
tlsExports: /* @__PURE__ */ new Set,
|
|
1925
|
+
weakImports: /* @__PURE__ */ new Set
|
|
1926
|
+
};
|
|
1927
|
+
if (name2 == "dylink") {
|
|
1928
|
+
customSection.memorySize = getLEB();
|
|
1929
|
+
customSection.memoryAlign = getLEB();
|
|
1930
|
+
customSection.tableSize = getLEB();
|
|
1931
|
+
customSection.tableAlign = getLEB();
|
|
1932
|
+
var neededDynlibsCount = getLEB();
|
|
1933
|
+
for (var i2 = 0;i2 < neededDynlibsCount; ++i2) {
|
|
1934
|
+
var libname = getString();
|
|
1935
|
+
customSection.neededDynlibs.push(libname);
|
|
1936
|
+
}
|
|
1937
|
+
} else {
|
|
1938
|
+
failIf(name2 !== "dylink.0");
|
|
1939
|
+
var WASM_DYLINK_MEM_INFO = 1;
|
|
1940
|
+
var WASM_DYLINK_NEEDED = 2;
|
|
1941
|
+
var WASM_DYLINK_EXPORT_INFO = 3;
|
|
1942
|
+
var WASM_DYLINK_IMPORT_INFO = 4;
|
|
1943
|
+
var WASM_SYMBOL_TLS = 256;
|
|
1944
|
+
var WASM_SYMBOL_BINDING_MASK = 3;
|
|
1945
|
+
var WASM_SYMBOL_BINDING_WEAK = 1;
|
|
1946
|
+
while (offset < end) {
|
|
1947
|
+
var subsectionType = getU8();
|
|
1948
|
+
var subsectionSize = getLEB();
|
|
1949
|
+
if (subsectionType === WASM_DYLINK_MEM_INFO) {
|
|
1950
|
+
customSection.memorySize = getLEB();
|
|
1951
|
+
customSection.memoryAlign = getLEB();
|
|
1952
|
+
customSection.tableSize = getLEB();
|
|
1953
|
+
customSection.tableAlign = getLEB();
|
|
1954
|
+
} else if (subsectionType === WASM_DYLINK_NEEDED) {
|
|
1955
|
+
var neededDynlibsCount = getLEB();
|
|
1956
|
+
for (var i2 = 0;i2 < neededDynlibsCount; ++i2) {
|
|
1957
|
+
libname = getString();
|
|
1958
|
+
customSection.neededDynlibs.push(libname);
|
|
1959
|
+
}
|
|
1960
|
+
} else if (subsectionType === WASM_DYLINK_EXPORT_INFO) {
|
|
1961
|
+
var count = getLEB();
|
|
1962
|
+
while (count--) {
|
|
1963
|
+
var symname = getString();
|
|
1964
|
+
var flags2 = getLEB();
|
|
1965
|
+
if (flags2 & WASM_SYMBOL_TLS) {
|
|
1966
|
+
customSection.tlsExports.add(symname);
|
|
1967
|
+
}
|
|
1968
|
+
}
|
|
1969
|
+
} else if (subsectionType === WASM_DYLINK_IMPORT_INFO) {
|
|
1970
|
+
var count = getLEB();
|
|
1971
|
+
while (count--) {
|
|
1972
|
+
var modname = getString();
|
|
1973
|
+
var symname = getString();
|
|
1974
|
+
var flags2 = getLEB();
|
|
1975
|
+
if ((flags2 & WASM_SYMBOL_BINDING_MASK) == WASM_SYMBOL_BINDING_WEAK) {
|
|
1976
|
+
customSection.weakImports.add(symname);
|
|
1977
|
+
}
|
|
1978
|
+
}
|
|
1979
|
+
} else {
|
|
1980
|
+
offset += subsectionSize;
|
|
1981
|
+
}
|
|
1982
|
+
}
|
|
1983
|
+
}
|
|
1984
|
+
return customSection;
|
|
1985
|
+
}, "getDylinkMetadata");
|
|
1986
|
+
function getValue(ptr, type = "i8") {
|
|
1987
|
+
if (type.endsWith("*"))
|
|
1988
|
+
type = "*";
|
|
1989
|
+
switch (type) {
|
|
1990
|
+
case "i1":
|
|
1991
|
+
return HEAP8[ptr];
|
|
1992
|
+
case "i8":
|
|
1993
|
+
return HEAP8[ptr];
|
|
1994
|
+
case "i16":
|
|
1995
|
+
return LE_HEAP_LOAD_I16((ptr >> 1) * 2);
|
|
1996
|
+
case "i32":
|
|
1997
|
+
return LE_HEAP_LOAD_I32((ptr >> 2) * 4);
|
|
1998
|
+
case "i64":
|
|
1999
|
+
return HEAP64[ptr >> 3];
|
|
2000
|
+
case "float":
|
|
2001
|
+
return LE_HEAP_LOAD_F32((ptr >> 2) * 4);
|
|
2002
|
+
case "double":
|
|
2003
|
+
return LE_HEAP_LOAD_F64((ptr >> 3) * 8);
|
|
2004
|
+
case "*":
|
|
2005
|
+
return LE_HEAP_LOAD_U32((ptr >> 2) * 4);
|
|
2006
|
+
default:
|
|
2007
|
+
abort(`invalid type for getValue: ${type}`);
|
|
2008
|
+
}
|
|
2009
|
+
}
|
|
2010
|
+
__name(getValue, "getValue");
|
|
2011
|
+
var newDSO = /* @__PURE__ */ __name((name2, handle2, syms) => {
|
|
2012
|
+
var dso = {
|
|
2013
|
+
refcount: Infinity,
|
|
2014
|
+
name: name2,
|
|
2015
|
+
exports: syms,
|
|
2016
|
+
global: true
|
|
2017
|
+
};
|
|
2018
|
+
LDSO.loadedLibsByName[name2] = dso;
|
|
2019
|
+
if (handle2 != null) {
|
|
2020
|
+
LDSO.loadedLibsByHandle[handle2] = dso;
|
|
2021
|
+
}
|
|
2022
|
+
return dso;
|
|
2023
|
+
}, "newDSO");
|
|
2024
|
+
var LDSO = {
|
|
2025
|
+
loadedLibsByName: {},
|
|
2026
|
+
loadedLibsByHandle: {},
|
|
2027
|
+
init() {
|
|
2028
|
+
newDSO("__main__", 0, wasmImports);
|
|
2029
|
+
}
|
|
2030
|
+
};
|
|
2031
|
+
var ___heap_base = 78224;
|
|
2032
|
+
var alignMemory = /* @__PURE__ */ __name((size, alignment) => Math.ceil(size / alignment) * alignment, "alignMemory");
|
|
2033
|
+
var getMemory = /* @__PURE__ */ __name((size) => {
|
|
2034
|
+
if (runtimeInitialized) {
|
|
2035
|
+
return _calloc(size, 1);
|
|
2036
|
+
}
|
|
2037
|
+
var ret = ___heap_base;
|
|
2038
|
+
var end = ret + alignMemory(size, 16);
|
|
2039
|
+
___heap_base = end;
|
|
2040
|
+
GOT["__heap_base"].value = end;
|
|
2041
|
+
return ret;
|
|
2042
|
+
}, "getMemory");
|
|
2043
|
+
var isInternalSym = /* @__PURE__ */ __name((symName) => ["__cpp_exception", "__c_longjmp", "__wasm_apply_data_relocs", "__dso_handle", "__tls_size", "__tls_align", "__set_stack_limits", "_emscripten_tls_init", "__wasm_init_tls", "__wasm_call_ctors", "__start_em_asm", "__stop_em_asm", "__start_em_js", "__stop_em_js"].includes(symName) || symName.startsWith("__em_js__"), "isInternalSym");
|
|
2044
|
+
var uleb128Encode = /* @__PURE__ */ __name((n, target) => {
|
|
2045
|
+
if (n < 128) {
|
|
2046
|
+
target.push(n);
|
|
2047
|
+
} else {
|
|
2048
|
+
target.push(n % 128 | 128, n >> 7);
|
|
2049
|
+
}
|
|
2050
|
+
}, "uleb128Encode");
|
|
2051
|
+
var sigToWasmTypes = /* @__PURE__ */ __name((sig) => {
|
|
2052
|
+
var typeNames = {
|
|
2053
|
+
i: "i32",
|
|
2054
|
+
j: "i64",
|
|
2055
|
+
f: "f32",
|
|
2056
|
+
d: "f64",
|
|
2057
|
+
e: "externref",
|
|
2058
|
+
p: "i32"
|
|
2059
|
+
};
|
|
2060
|
+
var type = {
|
|
2061
|
+
parameters: [],
|
|
2062
|
+
results: sig[0] == "v" ? [] : [typeNames[sig[0]]]
|
|
2063
|
+
};
|
|
2064
|
+
for (var i2 = 1;i2 < sig.length; ++i2) {
|
|
2065
|
+
type.parameters.push(typeNames[sig[i2]]);
|
|
2066
|
+
}
|
|
2067
|
+
return type;
|
|
2068
|
+
}, "sigToWasmTypes");
|
|
2069
|
+
var generateFuncType = /* @__PURE__ */ __name((sig, target) => {
|
|
2070
|
+
var sigRet = sig.slice(0, 1);
|
|
2071
|
+
var sigParam = sig.slice(1);
|
|
2072
|
+
var typeCodes = {
|
|
2073
|
+
i: 127,
|
|
2074
|
+
p: 127,
|
|
2075
|
+
j: 126,
|
|
2076
|
+
f: 125,
|
|
2077
|
+
d: 124,
|
|
2078
|
+
e: 111
|
|
2079
|
+
};
|
|
2080
|
+
target.push(96);
|
|
2081
|
+
uleb128Encode(sigParam.length, target);
|
|
2082
|
+
for (var i2 = 0;i2 < sigParam.length; ++i2) {
|
|
2083
|
+
target.push(typeCodes[sigParam[i2]]);
|
|
2084
|
+
}
|
|
2085
|
+
if (sigRet == "v") {
|
|
2086
|
+
target.push(0);
|
|
2087
|
+
} else {
|
|
2088
|
+
target.push(1, typeCodes[sigRet]);
|
|
2089
|
+
}
|
|
2090
|
+
}, "generateFuncType");
|
|
2091
|
+
var convertJsFunctionToWasm = /* @__PURE__ */ __name((func2, sig) => {
|
|
2092
|
+
if (typeof WebAssembly.Function == "function") {
|
|
2093
|
+
return new WebAssembly.Function(sigToWasmTypes(sig), func2);
|
|
2094
|
+
}
|
|
2095
|
+
var typeSectionBody = [1];
|
|
2096
|
+
generateFuncType(sig, typeSectionBody);
|
|
2097
|
+
var bytes = [
|
|
2098
|
+
0,
|
|
2099
|
+
97,
|
|
2100
|
+
115,
|
|
2101
|
+
109,
|
|
2102
|
+
1,
|
|
2103
|
+
0,
|
|
2104
|
+
0,
|
|
2105
|
+
0,
|
|
2106
|
+
1
|
|
2107
|
+
];
|
|
2108
|
+
uleb128Encode(typeSectionBody.length, bytes);
|
|
2109
|
+
bytes.push(...typeSectionBody);
|
|
2110
|
+
bytes.push(2, 7, 1, 1, 101, 1, 102, 0, 0, 7, 5, 1, 1, 102, 0, 0);
|
|
2111
|
+
var module2 = new WebAssembly.Module(new Uint8Array(bytes));
|
|
2112
|
+
var instance2 = new WebAssembly.Instance(module2, {
|
|
2113
|
+
e: {
|
|
2114
|
+
f: func2
|
|
2115
|
+
}
|
|
2116
|
+
});
|
|
2117
|
+
var wrappedFunc = instance2.exports["f"];
|
|
2118
|
+
return wrappedFunc;
|
|
2119
|
+
}, "convertJsFunctionToWasm");
|
|
2120
|
+
var wasmTableMirror = [];
|
|
2121
|
+
var wasmTable = new WebAssembly.Table({
|
|
2122
|
+
initial: 31,
|
|
2123
|
+
element: "anyfunc"
|
|
2124
|
+
});
|
|
2125
|
+
var getWasmTableEntry = /* @__PURE__ */ __name((funcPtr) => {
|
|
2126
|
+
var func2 = wasmTableMirror[funcPtr];
|
|
2127
|
+
if (!func2) {
|
|
2128
|
+
if (funcPtr >= wasmTableMirror.length)
|
|
2129
|
+
wasmTableMirror.length = funcPtr + 1;
|
|
2130
|
+
wasmTableMirror[funcPtr] = func2 = wasmTable.get(funcPtr);
|
|
2131
|
+
}
|
|
2132
|
+
return func2;
|
|
2133
|
+
}, "getWasmTableEntry");
|
|
2134
|
+
var updateTableMap = /* @__PURE__ */ __name((offset, count) => {
|
|
2135
|
+
if (functionsInTableMap) {
|
|
2136
|
+
for (var i2 = offset;i2 < offset + count; i2++) {
|
|
2137
|
+
var item = getWasmTableEntry(i2);
|
|
2138
|
+
if (item) {
|
|
2139
|
+
functionsInTableMap.set(item, i2);
|
|
2140
|
+
}
|
|
2141
|
+
}
|
|
2142
|
+
}
|
|
2143
|
+
}, "updateTableMap");
|
|
2144
|
+
var functionsInTableMap;
|
|
2145
|
+
var getFunctionAddress = /* @__PURE__ */ __name((func2) => {
|
|
2146
|
+
if (!functionsInTableMap) {
|
|
2147
|
+
functionsInTableMap = /* @__PURE__ */ new WeakMap;
|
|
2148
|
+
updateTableMap(0, wasmTable.length);
|
|
2149
|
+
}
|
|
2150
|
+
return functionsInTableMap.get(func2) || 0;
|
|
2151
|
+
}, "getFunctionAddress");
|
|
2152
|
+
var freeTableIndexes = [];
|
|
2153
|
+
var getEmptyTableSlot = /* @__PURE__ */ __name(() => {
|
|
2154
|
+
if (freeTableIndexes.length) {
|
|
2155
|
+
return freeTableIndexes.pop();
|
|
2156
|
+
}
|
|
2157
|
+
try {
|
|
2158
|
+
wasmTable.grow(1);
|
|
2159
|
+
} catch (err2) {
|
|
2160
|
+
if (!(err2 instanceof RangeError)) {
|
|
2161
|
+
throw err2;
|
|
2162
|
+
}
|
|
2163
|
+
throw "Unable to grow wasm table. Set ALLOW_TABLE_GROWTH.";
|
|
2164
|
+
}
|
|
2165
|
+
return wasmTable.length - 1;
|
|
2166
|
+
}, "getEmptyTableSlot");
|
|
2167
|
+
var setWasmTableEntry = /* @__PURE__ */ __name((idx, func2) => {
|
|
2168
|
+
wasmTable.set(idx, func2);
|
|
2169
|
+
wasmTableMirror[idx] = wasmTable.get(idx);
|
|
2170
|
+
}, "setWasmTableEntry");
|
|
2171
|
+
var addFunction = /* @__PURE__ */ __name((func2, sig) => {
|
|
2172
|
+
var rtn = getFunctionAddress(func2);
|
|
2173
|
+
if (rtn) {
|
|
2174
|
+
return rtn;
|
|
2175
|
+
}
|
|
2176
|
+
var ret = getEmptyTableSlot();
|
|
2177
|
+
try {
|
|
2178
|
+
setWasmTableEntry(ret, func2);
|
|
2179
|
+
} catch (err2) {
|
|
2180
|
+
if (!(err2 instanceof TypeError)) {
|
|
2181
|
+
throw err2;
|
|
2182
|
+
}
|
|
2183
|
+
var wrapped = convertJsFunctionToWasm(func2, sig);
|
|
2184
|
+
setWasmTableEntry(ret, wrapped);
|
|
2185
|
+
}
|
|
2186
|
+
functionsInTableMap.set(func2, ret);
|
|
2187
|
+
return ret;
|
|
2188
|
+
}, "addFunction");
|
|
2189
|
+
var updateGOT = /* @__PURE__ */ __name((exports, replace) => {
|
|
2190
|
+
for (var symName in exports) {
|
|
2191
|
+
if (isInternalSym(symName)) {
|
|
2192
|
+
continue;
|
|
2193
|
+
}
|
|
2194
|
+
var value = exports[symName];
|
|
2195
|
+
GOT[symName] ||= new WebAssembly.Global({
|
|
2196
|
+
value: "i32",
|
|
2197
|
+
mutable: true
|
|
2198
|
+
});
|
|
2199
|
+
if (replace || GOT[symName].value == 0) {
|
|
2200
|
+
if (typeof value == "function") {
|
|
2201
|
+
GOT[symName].value = addFunction(value);
|
|
2202
|
+
} else if (typeof value == "number") {
|
|
2203
|
+
GOT[symName].value = value;
|
|
2204
|
+
} else {
|
|
2205
|
+
err(`unhandled export type for '${symName}': ${typeof value}`);
|
|
2206
|
+
}
|
|
2207
|
+
}
|
|
2208
|
+
}
|
|
2209
|
+
}, "updateGOT");
|
|
2210
|
+
var relocateExports = /* @__PURE__ */ __name((exports, memoryBase2, replace) => {
|
|
2211
|
+
var relocated = {};
|
|
2212
|
+
for (var e in exports) {
|
|
2213
|
+
var value = exports[e];
|
|
2214
|
+
if (typeof value == "object") {
|
|
2215
|
+
value = value.value;
|
|
2216
|
+
}
|
|
2217
|
+
if (typeof value == "number") {
|
|
2218
|
+
value += memoryBase2;
|
|
2219
|
+
}
|
|
2220
|
+
relocated[e] = value;
|
|
2221
|
+
}
|
|
2222
|
+
updateGOT(relocated, replace);
|
|
2223
|
+
return relocated;
|
|
2224
|
+
}, "relocateExports");
|
|
2225
|
+
var isSymbolDefined = /* @__PURE__ */ __name((symName) => {
|
|
2226
|
+
var existing = wasmImports[symName];
|
|
2227
|
+
if (!existing || existing.stub) {
|
|
2228
|
+
return false;
|
|
2229
|
+
}
|
|
2230
|
+
return true;
|
|
2231
|
+
}, "isSymbolDefined");
|
|
2232
|
+
var dynCall = /* @__PURE__ */ __name((sig, ptr, args2 = []) => {
|
|
2233
|
+
var rtn = getWasmTableEntry(ptr)(...args2);
|
|
2234
|
+
return rtn;
|
|
2235
|
+
}, "dynCall");
|
|
2236
|
+
var stackSave = /* @__PURE__ */ __name(() => _emscripten_stack_get_current(), "stackSave");
|
|
2237
|
+
var stackRestore = /* @__PURE__ */ __name((val) => __emscripten_stack_restore(val), "stackRestore");
|
|
2238
|
+
var createInvokeFunction = /* @__PURE__ */ __name((sig) => (ptr, ...args2) => {
|
|
2239
|
+
var sp = stackSave();
|
|
2240
|
+
try {
|
|
2241
|
+
return dynCall(sig, ptr, args2);
|
|
2242
|
+
} catch (e) {
|
|
2243
|
+
stackRestore(sp);
|
|
2244
|
+
if (e !== e + 0)
|
|
2245
|
+
throw e;
|
|
2246
|
+
_setThrew(1, 0);
|
|
2247
|
+
if (sig[0] == "j")
|
|
2248
|
+
return 0n;
|
|
2249
|
+
}
|
|
2250
|
+
}, "createInvokeFunction");
|
|
2251
|
+
var resolveGlobalSymbol = /* @__PURE__ */ __name((symName, direct = false) => {
|
|
2252
|
+
var sym;
|
|
2253
|
+
if (isSymbolDefined(symName)) {
|
|
2254
|
+
sym = wasmImports[symName];
|
|
2255
|
+
} else if (symName.startsWith("invoke_")) {
|
|
2256
|
+
sym = wasmImports[symName] = createInvokeFunction(symName.split("_")[1]);
|
|
2257
|
+
}
|
|
2258
|
+
return {
|
|
2259
|
+
sym,
|
|
2260
|
+
name: symName
|
|
2261
|
+
};
|
|
2262
|
+
}, "resolveGlobalSymbol");
|
|
2263
|
+
var onPostCtors = [];
|
|
2264
|
+
var addOnPostCtor = /* @__PURE__ */ __name((cb) => onPostCtors.unshift(cb), "addOnPostCtor");
|
|
2265
|
+
var UTF8ToString = /* @__PURE__ */ __name((ptr, maxBytesToRead) => ptr ? UTF8ArrayToString(HEAPU8, ptr, maxBytesToRead) : "", "UTF8ToString");
|
|
2266
|
+
var loadWebAssemblyModule = /* @__PURE__ */ __name((binary, flags, libName, localScope, handle) => {
|
|
2267
|
+
var metadata = getDylinkMetadata(binary);
|
|
2268
|
+
currentModuleWeakSymbols = metadata.weakImports;
|
|
2269
|
+
function loadModule() {
|
|
2270
|
+
var memAlign = Math.pow(2, metadata.memoryAlign);
|
|
2271
|
+
var memoryBase = metadata.memorySize ? alignMemory(getMemory(metadata.memorySize + memAlign), memAlign) : 0;
|
|
2272
|
+
var tableBase = metadata.tableSize ? wasmTable.length : 0;
|
|
2273
|
+
if (handle) {
|
|
2274
|
+
HEAP8[handle + 8] = 1;
|
|
2275
|
+
LE_HEAP_STORE_U32((handle + 12 >> 2) * 4, memoryBase);
|
|
2276
|
+
LE_HEAP_STORE_I32((handle + 16 >> 2) * 4, metadata.memorySize);
|
|
2277
|
+
LE_HEAP_STORE_U32((handle + 20 >> 2) * 4, tableBase);
|
|
2278
|
+
LE_HEAP_STORE_I32((handle + 24 >> 2) * 4, metadata.tableSize);
|
|
2279
|
+
}
|
|
2280
|
+
if (metadata.tableSize) {
|
|
2281
|
+
wasmTable.grow(metadata.tableSize);
|
|
2282
|
+
}
|
|
2283
|
+
var moduleExports;
|
|
2284
|
+
function resolveSymbol(sym) {
|
|
2285
|
+
var resolved = resolveGlobalSymbol(sym).sym;
|
|
2286
|
+
if (!resolved && localScope) {
|
|
2287
|
+
resolved = localScope[sym];
|
|
2288
|
+
}
|
|
2289
|
+
if (!resolved) {
|
|
2290
|
+
resolved = moduleExports[sym];
|
|
2291
|
+
}
|
|
2292
|
+
return resolved;
|
|
2293
|
+
}
|
|
2294
|
+
__name(resolveSymbol, "resolveSymbol");
|
|
2295
|
+
var proxyHandler = {
|
|
2296
|
+
get(stubs, prop) {
|
|
2297
|
+
switch (prop) {
|
|
2298
|
+
case "__memory_base":
|
|
2299
|
+
return memoryBase;
|
|
2300
|
+
case "__table_base":
|
|
2301
|
+
return tableBase;
|
|
2302
|
+
}
|
|
2303
|
+
if (prop in wasmImports && !wasmImports[prop].stub) {
|
|
2304
|
+
var res = wasmImports[prop];
|
|
2305
|
+
return res;
|
|
2306
|
+
}
|
|
2307
|
+
if (!(prop in stubs)) {
|
|
2308
|
+
var resolved;
|
|
2309
|
+
stubs[prop] = (...args2) => {
|
|
2310
|
+
resolved ||= resolveSymbol(prop);
|
|
2311
|
+
return resolved(...args2);
|
|
2312
|
+
};
|
|
2313
|
+
}
|
|
2314
|
+
return stubs[prop];
|
|
2315
|
+
}
|
|
2316
|
+
};
|
|
2317
|
+
var proxy = new Proxy({}, proxyHandler);
|
|
2318
|
+
var info = {
|
|
2319
|
+
"GOT.mem": new Proxy({}, GOTHandler),
|
|
2320
|
+
"GOT.func": new Proxy({}, GOTHandler),
|
|
2321
|
+
env: proxy,
|
|
2322
|
+
wasi_snapshot_preview1: proxy
|
|
2323
|
+
};
|
|
2324
|
+
function postInstantiation(module, instance) {
|
|
2325
|
+
updateTableMap(tableBase, metadata.tableSize);
|
|
2326
|
+
moduleExports = relocateExports(instance.exports, memoryBase);
|
|
2327
|
+
if (!flags.allowUndefined) {
|
|
2328
|
+
reportUndefinedSymbols();
|
|
2329
|
+
}
|
|
2330
|
+
function addEmAsm(addr, body) {
|
|
2331
|
+
var args = [];
|
|
2332
|
+
var arity = 0;
|
|
2333
|
+
for (;arity < 16; arity++) {
|
|
2334
|
+
if (body.indexOf("$" + arity) != -1) {
|
|
2335
|
+
args.push("$" + arity);
|
|
2336
|
+
} else {
|
|
2337
|
+
break;
|
|
2338
|
+
}
|
|
2339
|
+
}
|
|
2340
|
+
args = args.join(",");
|
|
2341
|
+
var func = `(${args}) => { ${body} };`;
|
|
2342
|
+
ASM_CONSTS[start] = eval(func);
|
|
2343
|
+
}
|
|
2344
|
+
__name(addEmAsm, "addEmAsm");
|
|
2345
|
+
if ("__start_em_asm" in moduleExports) {
|
|
2346
|
+
var start = moduleExports["__start_em_asm"];
|
|
2347
|
+
var stop = moduleExports["__stop_em_asm"];
|
|
2348
|
+
while (start < stop) {
|
|
2349
|
+
var jsString = UTF8ToString(start);
|
|
2350
|
+
addEmAsm(start, jsString);
|
|
2351
|
+
start = HEAPU8.indexOf(0, start) + 1;
|
|
2352
|
+
}
|
|
2353
|
+
}
|
|
2354
|
+
function addEmJs(name, cSig, body) {
|
|
2355
|
+
var jsArgs = [];
|
|
2356
|
+
cSig = cSig.slice(1, -1);
|
|
2357
|
+
if (cSig != "void") {
|
|
2358
|
+
cSig = cSig.split(",");
|
|
2359
|
+
for (var i in cSig) {
|
|
2360
|
+
var jsArg = cSig[i].split(" ").pop();
|
|
2361
|
+
jsArgs.push(jsArg.replace("*", ""));
|
|
2362
|
+
}
|
|
2363
|
+
}
|
|
2364
|
+
var func = `(${jsArgs}) => ${body};`;
|
|
2365
|
+
moduleExports[name] = eval(func);
|
|
2366
|
+
}
|
|
2367
|
+
__name(addEmJs, "addEmJs");
|
|
2368
|
+
for (var name in moduleExports) {
|
|
2369
|
+
if (name.startsWith("__em_js__")) {
|
|
2370
|
+
var start = moduleExports[name];
|
|
2371
|
+
var jsString = UTF8ToString(start);
|
|
2372
|
+
var parts = jsString.split("<::>");
|
|
2373
|
+
addEmJs(name.replace("__em_js__", ""), parts[0], parts[1]);
|
|
2374
|
+
delete moduleExports[name];
|
|
2375
|
+
}
|
|
2376
|
+
}
|
|
2377
|
+
var applyRelocs = moduleExports["__wasm_apply_data_relocs"];
|
|
2378
|
+
if (applyRelocs) {
|
|
2379
|
+
if (runtimeInitialized) {
|
|
2380
|
+
applyRelocs();
|
|
2381
|
+
} else {
|
|
2382
|
+
__RELOC_FUNCS__.push(applyRelocs);
|
|
2383
|
+
}
|
|
2384
|
+
}
|
|
2385
|
+
var init = moduleExports["__wasm_call_ctors"];
|
|
2386
|
+
if (init) {
|
|
2387
|
+
if (runtimeInitialized) {
|
|
2388
|
+
init();
|
|
2389
|
+
} else {
|
|
2390
|
+
addOnPostCtor(init);
|
|
2391
|
+
}
|
|
2392
|
+
}
|
|
2393
|
+
return moduleExports;
|
|
2394
|
+
}
|
|
2395
|
+
__name(postInstantiation, "postInstantiation");
|
|
2396
|
+
if (flags.loadAsync) {
|
|
2397
|
+
if (binary instanceof WebAssembly.Module) {
|
|
2398
|
+
var instance = new WebAssembly.Instance(binary, info);
|
|
2399
|
+
return Promise.resolve(postInstantiation(binary, instance));
|
|
2400
|
+
}
|
|
2401
|
+
return WebAssembly.instantiate(binary, info).then((result) => postInstantiation(result.module, result.instance));
|
|
2402
|
+
}
|
|
2403
|
+
var module = binary instanceof WebAssembly.Module ? binary : new WebAssembly.Module(binary);
|
|
2404
|
+
var instance = new WebAssembly.Instance(module, info);
|
|
2405
|
+
return postInstantiation(module, instance);
|
|
2406
|
+
}
|
|
2407
|
+
__name(loadModule, "loadModule");
|
|
2408
|
+
if (flags.loadAsync) {
|
|
2409
|
+
return metadata.neededDynlibs.reduce((chain, dynNeeded) => chain.then(() => loadDynamicLibrary(dynNeeded, flags, localScope)), Promise.resolve()).then(loadModule);
|
|
2410
|
+
}
|
|
2411
|
+
metadata.neededDynlibs.forEach((needed) => loadDynamicLibrary(needed, flags, localScope));
|
|
2412
|
+
return loadModule();
|
|
2413
|
+
}, "loadWebAssemblyModule");
|
|
2414
|
+
var mergeLibSymbols = /* @__PURE__ */ __name((exports, libName2) => {
|
|
2415
|
+
for (var [sym, exp] of Object.entries(exports)) {
|
|
2416
|
+
const setImport = /* @__PURE__ */ __name((target) => {
|
|
2417
|
+
if (!isSymbolDefined(target)) {
|
|
2418
|
+
wasmImports[target] = exp;
|
|
2419
|
+
}
|
|
2420
|
+
}, "setImport");
|
|
2421
|
+
setImport(sym);
|
|
2422
|
+
const main_alias = "__main_argc_argv";
|
|
2423
|
+
if (sym == "main") {
|
|
2424
|
+
setImport(main_alias);
|
|
2425
|
+
}
|
|
2426
|
+
if (sym == main_alias) {
|
|
2427
|
+
setImport("main");
|
|
2428
|
+
}
|
|
2429
|
+
}
|
|
2430
|
+
}, "mergeLibSymbols");
|
|
2431
|
+
var asyncLoad = /* @__PURE__ */ __name(async (url) => {
|
|
2432
|
+
var arrayBuffer = await readAsync(url);
|
|
2433
|
+
return new Uint8Array(arrayBuffer);
|
|
2434
|
+
}, "asyncLoad");
|
|
2435
|
+
function loadDynamicLibrary(libName2, flags2 = {
|
|
2436
|
+
global: true,
|
|
2437
|
+
nodelete: true
|
|
2438
|
+
}, localScope2, handle2) {
|
|
2439
|
+
var dso = LDSO.loadedLibsByName[libName2];
|
|
2440
|
+
if (dso) {
|
|
2441
|
+
if (!flags2.global) {
|
|
2442
|
+
if (localScope2) {
|
|
2443
|
+
Object.assign(localScope2, dso.exports);
|
|
2444
|
+
}
|
|
2445
|
+
} else if (!dso.global) {
|
|
2446
|
+
dso.global = true;
|
|
2447
|
+
mergeLibSymbols(dso.exports, libName2);
|
|
2448
|
+
}
|
|
2449
|
+
if (flags2.nodelete && dso.refcount !== Infinity) {
|
|
2450
|
+
dso.refcount = Infinity;
|
|
2451
|
+
}
|
|
2452
|
+
dso.refcount++;
|
|
2453
|
+
if (handle2) {
|
|
2454
|
+
LDSO.loadedLibsByHandle[handle2] = dso;
|
|
2455
|
+
}
|
|
2456
|
+
return flags2.loadAsync ? Promise.resolve(true) : true;
|
|
2457
|
+
}
|
|
2458
|
+
dso = newDSO(libName2, handle2, "loading");
|
|
2459
|
+
dso.refcount = flags2.nodelete ? Infinity : 1;
|
|
2460
|
+
dso.global = flags2.global;
|
|
2461
|
+
function loadLibData() {
|
|
2462
|
+
if (handle2) {
|
|
2463
|
+
var data = LE_HEAP_LOAD_U32((handle2 + 28 >> 2) * 4);
|
|
2464
|
+
var dataSize = LE_HEAP_LOAD_U32((handle2 + 32 >> 2) * 4);
|
|
2465
|
+
if (data && dataSize) {
|
|
2466
|
+
var libData = HEAP8.slice(data, data + dataSize);
|
|
2467
|
+
return flags2.loadAsync ? Promise.resolve(libData) : libData;
|
|
2468
|
+
}
|
|
2469
|
+
}
|
|
2470
|
+
var libFile = locateFile(libName2);
|
|
2471
|
+
if (flags2.loadAsync) {
|
|
2472
|
+
return asyncLoad(libFile);
|
|
2473
|
+
}
|
|
2474
|
+
if (!readBinary) {
|
|
2475
|
+
throw new Error(`${libFile}: file not found, and synchronous loading of external files is not available`);
|
|
2476
|
+
}
|
|
2477
|
+
return readBinary(libFile);
|
|
2478
|
+
}
|
|
2479
|
+
__name(loadLibData, "loadLibData");
|
|
2480
|
+
function getExports() {
|
|
2481
|
+
if (flags2.loadAsync) {
|
|
2482
|
+
return loadLibData().then((libData) => loadWebAssemblyModule(libData, flags2, libName2, localScope2, handle2));
|
|
2483
|
+
}
|
|
2484
|
+
return loadWebAssemblyModule(loadLibData(), flags2, libName2, localScope2, handle2);
|
|
2485
|
+
}
|
|
2486
|
+
__name(getExports, "getExports");
|
|
2487
|
+
function moduleLoaded(exports) {
|
|
2488
|
+
if (dso.global) {
|
|
2489
|
+
mergeLibSymbols(exports, libName2);
|
|
2490
|
+
} else if (localScope2) {
|
|
2491
|
+
Object.assign(localScope2, exports);
|
|
2492
|
+
}
|
|
2493
|
+
dso.exports = exports;
|
|
2494
|
+
}
|
|
2495
|
+
__name(moduleLoaded, "moduleLoaded");
|
|
2496
|
+
if (flags2.loadAsync) {
|
|
2497
|
+
return getExports().then((exports) => {
|
|
2498
|
+
moduleLoaded(exports);
|
|
2499
|
+
return true;
|
|
2500
|
+
});
|
|
2501
|
+
}
|
|
2502
|
+
moduleLoaded(getExports());
|
|
2503
|
+
return true;
|
|
2504
|
+
}
|
|
2505
|
+
__name(loadDynamicLibrary, "loadDynamicLibrary");
|
|
2506
|
+
var reportUndefinedSymbols = /* @__PURE__ */ __name(() => {
|
|
2507
|
+
for (var [symName, entry] of Object.entries(GOT)) {
|
|
2508
|
+
if (entry.value == 0) {
|
|
2509
|
+
var value = resolveGlobalSymbol(symName, true).sym;
|
|
2510
|
+
if (!value && !entry.required) {
|
|
2511
|
+
continue;
|
|
2512
|
+
}
|
|
2513
|
+
if (typeof value == "function") {
|
|
2514
|
+
entry.value = addFunction(value, value.sig);
|
|
2515
|
+
} else if (typeof value == "number") {
|
|
2516
|
+
entry.value = value;
|
|
2517
|
+
} else {
|
|
2518
|
+
throw new Error(`bad export type for '${symName}': ${typeof value}`);
|
|
2519
|
+
}
|
|
2520
|
+
}
|
|
2521
|
+
}
|
|
2522
|
+
}, "reportUndefinedSymbols");
|
|
2523
|
+
var loadDylibs = /* @__PURE__ */ __name(() => {
|
|
2524
|
+
if (!dynamicLibraries.length) {
|
|
2525
|
+
reportUndefinedSymbols();
|
|
2526
|
+
return;
|
|
2527
|
+
}
|
|
2528
|
+
addRunDependency("loadDylibs");
|
|
2529
|
+
dynamicLibraries.reduce((chain, lib) => chain.then(() => loadDynamicLibrary(lib, {
|
|
2530
|
+
loadAsync: true,
|
|
2531
|
+
global: true,
|
|
2532
|
+
nodelete: true,
|
|
2533
|
+
allowUndefined: true
|
|
2534
|
+
})), Promise.resolve()).then(() => {
|
|
2535
|
+
reportUndefinedSymbols();
|
|
2536
|
+
removeRunDependency("loadDylibs");
|
|
2537
|
+
});
|
|
2538
|
+
}, "loadDylibs");
|
|
2539
|
+
var noExitRuntime = Module["noExitRuntime"] || true;
|
|
2540
|
+
function setValue(ptr, value, type = "i8") {
|
|
2541
|
+
if (type.endsWith("*"))
|
|
2542
|
+
type = "*";
|
|
2543
|
+
switch (type) {
|
|
2544
|
+
case "i1":
|
|
2545
|
+
HEAP8[ptr] = value;
|
|
2546
|
+
break;
|
|
2547
|
+
case "i8":
|
|
2548
|
+
HEAP8[ptr] = value;
|
|
2549
|
+
break;
|
|
2550
|
+
case "i16":
|
|
2551
|
+
LE_HEAP_STORE_I16((ptr >> 1) * 2, value);
|
|
2552
|
+
break;
|
|
2553
|
+
case "i32":
|
|
2554
|
+
LE_HEAP_STORE_I32((ptr >> 2) * 4, value);
|
|
2555
|
+
break;
|
|
2556
|
+
case "i64":
|
|
2557
|
+
HEAP64[ptr >> 3] = BigInt(value);
|
|
2558
|
+
break;
|
|
2559
|
+
case "float":
|
|
2560
|
+
LE_HEAP_STORE_F32((ptr >> 2) * 4, value);
|
|
2561
|
+
break;
|
|
2562
|
+
case "double":
|
|
2563
|
+
LE_HEAP_STORE_F64((ptr >> 3) * 8, value);
|
|
2564
|
+
break;
|
|
2565
|
+
case "*":
|
|
2566
|
+
LE_HEAP_STORE_U32((ptr >> 2) * 4, value);
|
|
2567
|
+
break;
|
|
2568
|
+
default:
|
|
2569
|
+
abort(`invalid type for setValue: ${type}`);
|
|
2570
|
+
}
|
|
2571
|
+
}
|
|
2572
|
+
__name(setValue, "setValue");
|
|
2573
|
+
var ___memory_base = new WebAssembly.Global({
|
|
2574
|
+
value: "i32",
|
|
2575
|
+
mutable: false
|
|
2576
|
+
}, 1024);
|
|
2577
|
+
var ___stack_pointer = new WebAssembly.Global({
|
|
2578
|
+
value: "i32",
|
|
2579
|
+
mutable: true
|
|
2580
|
+
}, 78224);
|
|
2581
|
+
var ___table_base = new WebAssembly.Global({
|
|
2582
|
+
value: "i32",
|
|
2583
|
+
mutable: false
|
|
2584
|
+
}, 1);
|
|
2585
|
+
var __abort_js = /* @__PURE__ */ __name(() => abort(""), "__abort_js");
|
|
2586
|
+
__abort_js.sig = "v";
|
|
2587
|
+
var _emscripten_get_now = /* @__PURE__ */ __name(() => performance.now(), "_emscripten_get_now");
|
|
2588
|
+
_emscripten_get_now.sig = "d";
|
|
2589
|
+
var _emscripten_date_now = /* @__PURE__ */ __name(() => Date.now(), "_emscripten_date_now");
|
|
2590
|
+
_emscripten_date_now.sig = "d";
|
|
2591
|
+
var nowIsMonotonic = 1;
|
|
2592
|
+
var checkWasiClock = /* @__PURE__ */ __name((clock_id) => clock_id >= 0 && clock_id <= 3, "checkWasiClock");
|
|
2593
|
+
var INT53_MAX = 9007199254740992;
|
|
2594
|
+
var INT53_MIN = -9007199254740992;
|
|
2595
|
+
var bigintToI53Checked = /* @__PURE__ */ __name((num) => num < INT53_MIN || num > INT53_MAX ? NaN : Number(num), "bigintToI53Checked");
|
|
2596
|
+
function _clock_time_get(clk_id, ignored_precision, ptime) {
|
|
2597
|
+
ignored_precision = bigintToI53Checked(ignored_precision);
|
|
2598
|
+
if (!checkWasiClock(clk_id)) {
|
|
2599
|
+
return 28;
|
|
2600
|
+
}
|
|
2601
|
+
var now;
|
|
2602
|
+
if (clk_id === 0) {
|
|
2603
|
+
now = _emscripten_date_now();
|
|
2604
|
+
} else if (nowIsMonotonic) {
|
|
2605
|
+
now = _emscripten_get_now();
|
|
2606
|
+
} else {
|
|
2607
|
+
return 52;
|
|
2608
|
+
}
|
|
2609
|
+
var nsec = Math.round(now * 1000 * 1000);
|
|
2610
|
+
HEAP64[ptime >> 3] = BigInt(nsec);
|
|
2611
|
+
return 0;
|
|
2612
|
+
}
|
|
2613
|
+
__name(_clock_time_get, "_clock_time_get");
|
|
2614
|
+
_clock_time_get.sig = "iijp";
|
|
2615
|
+
var getHeapMax = /* @__PURE__ */ __name(() => 2147483648, "getHeapMax");
|
|
2616
|
+
var growMemory = /* @__PURE__ */ __name((size) => {
|
|
2617
|
+
var b = wasmMemory.buffer;
|
|
2618
|
+
var pages = (size - b.byteLength + 65535) / 65536 | 0;
|
|
2619
|
+
try {
|
|
2620
|
+
wasmMemory.grow(pages);
|
|
2621
|
+
updateMemoryViews();
|
|
2622
|
+
return 1;
|
|
2623
|
+
} catch (e) {}
|
|
2624
|
+
}, "growMemory");
|
|
2625
|
+
var _emscripten_resize_heap = /* @__PURE__ */ __name((requestedSize) => {
|
|
2626
|
+
var oldSize = HEAPU8.length;
|
|
2627
|
+
requestedSize >>>= 0;
|
|
2628
|
+
var maxHeapSize = getHeapMax();
|
|
2629
|
+
if (requestedSize > maxHeapSize) {
|
|
2630
|
+
return false;
|
|
2631
|
+
}
|
|
2632
|
+
for (var cutDown = 1;cutDown <= 4; cutDown *= 2) {
|
|
2633
|
+
var overGrownHeapSize = oldSize * (1 + 0.2 / cutDown);
|
|
2634
|
+
overGrownHeapSize = Math.min(overGrownHeapSize, requestedSize + 100663296);
|
|
2635
|
+
var newSize = Math.min(maxHeapSize, alignMemory(Math.max(requestedSize, overGrownHeapSize), 65536));
|
|
2636
|
+
var replacement = growMemory(newSize);
|
|
2637
|
+
if (replacement) {
|
|
2638
|
+
return true;
|
|
2639
|
+
}
|
|
2640
|
+
}
|
|
2641
|
+
return false;
|
|
2642
|
+
}, "_emscripten_resize_heap");
|
|
2643
|
+
_emscripten_resize_heap.sig = "ip";
|
|
2644
|
+
var _fd_close = /* @__PURE__ */ __name((fd) => 52, "_fd_close");
|
|
2645
|
+
_fd_close.sig = "ii";
|
|
2646
|
+
function _fd_seek(fd, offset, whence, newOffset) {
|
|
2647
|
+
offset = bigintToI53Checked(offset);
|
|
2648
|
+
return 70;
|
|
2649
|
+
}
|
|
2650
|
+
__name(_fd_seek, "_fd_seek");
|
|
2651
|
+
_fd_seek.sig = "iijip";
|
|
2652
|
+
var printCharBuffers = [null, [], []];
|
|
2653
|
+
var printChar = /* @__PURE__ */ __name((stream, curr) => {
|
|
2654
|
+
var buffer = printCharBuffers[stream];
|
|
2655
|
+
if (curr === 0 || curr === 10) {
|
|
2656
|
+
(stream === 1 ? out : err)(UTF8ArrayToString(buffer));
|
|
2657
|
+
buffer.length = 0;
|
|
2658
|
+
} else {
|
|
2659
|
+
buffer.push(curr);
|
|
2660
|
+
}
|
|
2661
|
+
}, "printChar");
|
|
2662
|
+
var flush_NO_FILESYSTEM = /* @__PURE__ */ __name(() => {
|
|
2663
|
+
if (printCharBuffers[1].length)
|
|
2664
|
+
printChar(1, 10);
|
|
2665
|
+
if (printCharBuffers[2].length)
|
|
2666
|
+
printChar(2, 10);
|
|
2667
|
+
}, "flush_NO_FILESYSTEM");
|
|
2668
|
+
var SYSCALLS = {
|
|
2669
|
+
varargs: undefined,
|
|
2670
|
+
getStr(ptr) {
|
|
2671
|
+
var ret = UTF8ToString(ptr);
|
|
2672
|
+
return ret;
|
|
2673
|
+
}
|
|
2674
|
+
};
|
|
2675
|
+
var _fd_write = /* @__PURE__ */ __name((fd, iov, iovcnt, pnum) => {
|
|
2676
|
+
var num = 0;
|
|
2677
|
+
for (var i2 = 0;i2 < iovcnt; i2++) {
|
|
2678
|
+
var ptr = LE_HEAP_LOAD_U32((iov >> 2) * 4);
|
|
2679
|
+
var len = LE_HEAP_LOAD_U32((iov + 4 >> 2) * 4);
|
|
2680
|
+
iov += 8;
|
|
2681
|
+
for (var j = 0;j < len; j++) {
|
|
2682
|
+
printChar(fd, HEAPU8[ptr + j]);
|
|
2683
|
+
}
|
|
2684
|
+
num += len;
|
|
2685
|
+
}
|
|
2686
|
+
LE_HEAP_STORE_U32((pnum >> 2) * 4, num);
|
|
2687
|
+
return 0;
|
|
2688
|
+
}, "_fd_write");
|
|
2689
|
+
_fd_write.sig = "iippp";
|
|
2690
|
+
function _tree_sitter_log_callback(isLexMessage, messageAddress) {
|
|
2691
|
+
if (Module.currentLogCallback) {
|
|
2692
|
+
const message = UTF8ToString(messageAddress);
|
|
2693
|
+
Module.currentLogCallback(message, isLexMessage !== 0);
|
|
2694
|
+
}
|
|
2695
|
+
}
|
|
2696
|
+
__name(_tree_sitter_log_callback, "_tree_sitter_log_callback");
|
|
2697
|
+
function _tree_sitter_parse_callback(inputBufferAddress, index, row, column, lengthAddress) {
|
|
2698
|
+
const INPUT_BUFFER_SIZE = 10240;
|
|
2699
|
+
const string = Module.currentParseCallback(index, {
|
|
2700
|
+
row,
|
|
2701
|
+
column
|
|
2702
|
+
});
|
|
2703
|
+
if (typeof string === "string") {
|
|
2704
|
+
setValue(lengthAddress, string.length, "i32");
|
|
2705
|
+
stringToUTF16(string, inputBufferAddress, INPUT_BUFFER_SIZE);
|
|
2706
|
+
} else {
|
|
2707
|
+
setValue(lengthAddress, 0, "i32");
|
|
2708
|
+
}
|
|
2709
|
+
}
|
|
2710
|
+
__name(_tree_sitter_parse_callback, "_tree_sitter_parse_callback");
|
|
2711
|
+
function _tree_sitter_progress_callback(currentOffset, hasError) {
|
|
2712
|
+
if (Module.currentProgressCallback) {
|
|
2713
|
+
return Module.currentProgressCallback({
|
|
2714
|
+
currentOffset,
|
|
2715
|
+
hasError
|
|
2716
|
+
});
|
|
2717
|
+
}
|
|
2718
|
+
return false;
|
|
2719
|
+
}
|
|
2720
|
+
__name(_tree_sitter_progress_callback, "_tree_sitter_progress_callback");
|
|
2721
|
+
function _tree_sitter_query_progress_callback(currentOffset) {
|
|
2722
|
+
if (Module.currentQueryProgressCallback) {
|
|
2723
|
+
return Module.currentQueryProgressCallback({
|
|
2724
|
+
currentOffset
|
|
2725
|
+
});
|
|
2726
|
+
}
|
|
2727
|
+
return false;
|
|
2728
|
+
}
|
|
2729
|
+
__name(_tree_sitter_query_progress_callback, "_tree_sitter_query_progress_callback");
|
|
2730
|
+
var runtimeKeepaliveCounter = 0;
|
|
2731
|
+
var keepRuntimeAlive = /* @__PURE__ */ __name(() => noExitRuntime || runtimeKeepaliveCounter > 0, "keepRuntimeAlive");
|
|
2732
|
+
var _proc_exit = /* @__PURE__ */ __name((code) => {
|
|
2733
|
+
EXITSTATUS = code;
|
|
2734
|
+
if (!keepRuntimeAlive()) {
|
|
2735
|
+
Module["onExit"]?.(code);
|
|
2736
|
+
ABORT = true;
|
|
2737
|
+
}
|
|
2738
|
+
quit_(code, new ExitStatus(code));
|
|
2739
|
+
}, "_proc_exit");
|
|
2740
|
+
_proc_exit.sig = "vi";
|
|
2741
|
+
var exitJS = /* @__PURE__ */ __name((status, implicit) => {
|
|
2742
|
+
EXITSTATUS = status;
|
|
2743
|
+
_proc_exit(status);
|
|
2744
|
+
}, "exitJS");
|
|
2745
|
+
var handleException = /* @__PURE__ */ __name((e) => {
|
|
2746
|
+
if (e instanceof ExitStatus || e == "unwind") {
|
|
2747
|
+
return EXITSTATUS;
|
|
2748
|
+
}
|
|
2749
|
+
quit_(1, e);
|
|
2750
|
+
}, "handleException");
|
|
2751
|
+
var lengthBytesUTF8 = /* @__PURE__ */ __name((str) => {
|
|
2752
|
+
var len = 0;
|
|
2753
|
+
for (var i2 = 0;i2 < str.length; ++i2) {
|
|
2754
|
+
var c = str.charCodeAt(i2);
|
|
2755
|
+
if (c <= 127) {
|
|
2756
|
+
len++;
|
|
2757
|
+
} else if (c <= 2047) {
|
|
2758
|
+
len += 2;
|
|
2759
|
+
} else if (c >= 55296 && c <= 57343) {
|
|
2760
|
+
len += 4;
|
|
2761
|
+
++i2;
|
|
2762
|
+
} else {
|
|
2763
|
+
len += 3;
|
|
2764
|
+
}
|
|
2765
|
+
}
|
|
2766
|
+
return len;
|
|
2767
|
+
}, "lengthBytesUTF8");
|
|
2768
|
+
var stringToUTF8Array = /* @__PURE__ */ __name((str, heap, outIdx, maxBytesToWrite) => {
|
|
2769
|
+
if (!(maxBytesToWrite > 0))
|
|
2770
|
+
return 0;
|
|
2771
|
+
var startIdx = outIdx;
|
|
2772
|
+
var endIdx = outIdx + maxBytesToWrite - 1;
|
|
2773
|
+
for (var i2 = 0;i2 < str.length; ++i2) {
|
|
2774
|
+
var u = str.charCodeAt(i2);
|
|
2775
|
+
if (u >= 55296 && u <= 57343) {
|
|
2776
|
+
var u1 = str.charCodeAt(++i2);
|
|
2777
|
+
u = 65536 + ((u & 1023) << 10) | u1 & 1023;
|
|
2778
|
+
}
|
|
2779
|
+
if (u <= 127) {
|
|
2780
|
+
if (outIdx >= endIdx)
|
|
2781
|
+
break;
|
|
2782
|
+
heap[outIdx++] = u;
|
|
2783
|
+
} else if (u <= 2047) {
|
|
2784
|
+
if (outIdx + 1 >= endIdx)
|
|
2785
|
+
break;
|
|
2786
|
+
heap[outIdx++] = 192 | u >> 6;
|
|
2787
|
+
heap[outIdx++] = 128 | u & 63;
|
|
2788
|
+
} else if (u <= 65535) {
|
|
2789
|
+
if (outIdx + 2 >= endIdx)
|
|
2790
|
+
break;
|
|
2791
|
+
heap[outIdx++] = 224 | u >> 12;
|
|
2792
|
+
heap[outIdx++] = 128 | u >> 6 & 63;
|
|
2793
|
+
heap[outIdx++] = 128 | u & 63;
|
|
2794
|
+
} else {
|
|
2795
|
+
if (outIdx + 3 >= endIdx)
|
|
2796
|
+
break;
|
|
2797
|
+
heap[outIdx++] = 240 | u >> 18;
|
|
2798
|
+
heap[outIdx++] = 128 | u >> 12 & 63;
|
|
2799
|
+
heap[outIdx++] = 128 | u >> 6 & 63;
|
|
2800
|
+
heap[outIdx++] = 128 | u & 63;
|
|
2801
|
+
}
|
|
2802
|
+
}
|
|
2803
|
+
heap[outIdx] = 0;
|
|
2804
|
+
return outIdx - startIdx;
|
|
2805
|
+
}, "stringToUTF8Array");
|
|
2806
|
+
var stringToUTF8 = /* @__PURE__ */ __name((str, outPtr, maxBytesToWrite) => stringToUTF8Array(str, HEAPU8, outPtr, maxBytesToWrite), "stringToUTF8");
|
|
2807
|
+
var stackAlloc = /* @__PURE__ */ __name((sz) => __emscripten_stack_alloc(sz), "stackAlloc");
|
|
2808
|
+
var stringToUTF8OnStack = /* @__PURE__ */ __name((str) => {
|
|
2809
|
+
var size = lengthBytesUTF8(str) + 1;
|
|
2810
|
+
var ret = stackAlloc(size);
|
|
2811
|
+
stringToUTF8(str, ret, size);
|
|
2812
|
+
return ret;
|
|
2813
|
+
}, "stringToUTF8OnStack");
|
|
2814
|
+
var AsciiToString = /* @__PURE__ */ __name((ptr) => {
|
|
2815
|
+
var str = "";
|
|
2816
|
+
while (true) {
|
|
2817
|
+
var ch = HEAPU8[ptr++];
|
|
2818
|
+
if (!ch)
|
|
2819
|
+
return str;
|
|
2820
|
+
str += String.fromCharCode(ch);
|
|
2821
|
+
}
|
|
2822
|
+
}, "AsciiToString");
|
|
2823
|
+
var stringToUTF16 = /* @__PURE__ */ __name((str, outPtr, maxBytesToWrite) => {
|
|
2824
|
+
maxBytesToWrite ??= 2147483647;
|
|
2825
|
+
if (maxBytesToWrite < 2)
|
|
2826
|
+
return 0;
|
|
2827
|
+
maxBytesToWrite -= 2;
|
|
2828
|
+
var startPtr = outPtr;
|
|
2829
|
+
var numCharsToWrite = maxBytesToWrite < str.length * 2 ? maxBytesToWrite / 2 : str.length;
|
|
2830
|
+
for (var i2 = 0;i2 < numCharsToWrite; ++i2) {
|
|
2831
|
+
var codeUnit = str.charCodeAt(i2);
|
|
2832
|
+
LE_HEAP_STORE_I16((outPtr >> 1) * 2, codeUnit);
|
|
2833
|
+
outPtr += 2;
|
|
2834
|
+
}
|
|
2835
|
+
LE_HEAP_STORE_I16((outPtr >> 1) * 2, 0);
|
|
2836
|
+
return outPtr - startPtr;
|
|
2837
|
+
}, "stringToUTF16");
|
|
2838
|
+
var wasmImports = {
|
|
2839
|
+
__heap_base: ___heap_base,
|
|
2840
|
+
__indirect_function_table: wasmTable,
|
|
2841
|
+
__memory_base: ___memory_base,
|
|
2842
|
+
__stack_pointer: ___stack_pointer,
|
|
2843
|
+
__table_base: ___table_base,
|
|
2844
|
+
_abort_js: __abort_js,
|
|
2845
|
+
clock_time_get: _clock_time_get,
|
|
2846
|
+
emscripten_resize_heap: _emscripten_resize_heap,
|
|
2847
|
+
fd_close: _fd_close,
|
|
2848
|
+
fd_seek: _fd_seek,
|
|
2849
|
+
fd_write: _fd_write,
|
|
2850
|
+
memory: wasmMemory,
|
|
2851
|
+
tree_sitter_log_callback: _tree_sitter_log_callback,
|
|
2852
|
+
tree_sitter_parse_callback: _tree_sitter_parse_callback,
|
|
2853
|
+
tree_sitter_progress_callback: _tree_sitter_progress_callback,
|
|
2854
|
+
tree_sitter_query_progress_callback: _tree_sitter_query_progress_callback
|
|
2855
|
+
};
|
|
2856
|
+
var wasmExports = await createWasm();
|
|
2857
|
+
var ___wasm_call_ctors = wasmExports["__wasm_call_ctors"];
|
|
2858
|
+
var _malloc = Module["_malloc"] = wasmExports["malloc"];
|
|
2859
|
+
var _calloc = Module["_calloc"] = wasmExports["calloc"];
|
|
2860
|
+
var _realloc = Module["_realloc"] = wasmExports["realloc"];
|
|
2861
|
+
var _free = Module["_free"] = wasmExports["free"];
|
|
2862
|
+
var _memcmp = Module["_memcmp"] = wasmExports["memcmp"];
|
|
2863
|
+
var _ts_language_symbol_count = Module["_ts_language_symbol_count"] = wasmExports["ts_language_symbol_count"];
|
|
2864
|
+
var _ts_language_state_count = Module["_ts_language_state_count"] = wasmExports["ts_language_state_count"];
|
|
2865
|
+
var _ts_language_version = Module["_ts_language_version"] = wasmExports["ts_language_version"];
|
|
2866
|
+
var _ts_language_abi_version = Module["_ts_language_abi_version"] = wasmExports["ts_language_abi_version"];
|
|
2867
|
+
var _ts_language_metadata = Module["_ts_language_metadata"] = wasmExports["ts_language_metadata"];
|
|
2868
|
+
var _ts_language_name = Module["_ts_language_name"] = wasmExports["ts_language_name"];
|
|
2869
|
+
var _ts_language_field_count = Module["_ts_language_field_count"] = wasmExports["ts_language_field_count"];
|
|
2870
|
+
var _ts_language_next_state = Module["_ts_language_next_state"] = wasmExports["ts_language_next_state"];
|
|
2871
|
+
var _ts_language_symbol_name = Module["_ts_language_symbol_name"] = wasmExports["ts_language_symbol_name"];
|
|
2872
|
+
var _ts_language_symbol_for_name = Module["_ts_language_symbol_for_name"] = wasmExports["ts_language_symbol_for_name"];
|
|
2873
|
+
var _strncmp = Module["_strncmp"] = wasmExports["strncmp"];
|
|
2874
|
+
var _ts_language_symbol_type = Module["_ts_language_symbol_type"] = wasmExports["ts_language_symbol_type"];
|
|
2875
|
+
var _ts_language_field_name_for_id = Module["_ts_language_field_name_for_id"] = wasmExports["ts_language_field_name_for_id"];
|
|
2876
|
+
var _ts_lookahead_iterator_new = Module["_ts_lookahead_iterator_new"] = wasmExports["ts_lookahead_iterator_new"];
|
|
2877
|
+
var _ts_lookahead_iterator_delete = Module["_ts_lookahead_iterator_delete"] = wasmExports["ts_lookahead_iterator_delete"];
|
|
2878
|
+
var _ts_lookahead_iterator_reset_state = Module["_ts_lookahead_iterator_reset_state"] = wasmExports["ts_lookahead_iterator_reset_state"];
|
|
2879
|
+
var _ts_lookahead_iterator_reset = Module["_ts_lookahead_iterator_reset"] = wasmExports["ts_lookahead_iterator_reset"];
|
|
2880
|
+
var _ts_lookahead_iterator_next = Module["_ts_lookahead_iterator_next"] = wasmExports["ts_lookahead_iterator_next"];
|
|
2881
|
+
var _ts_lookahead_iterator_current_symbol = Module["_ts_lookahead_iterator_current_symbol"] = wasmExports["ts_lookahead_iterator_current_symbol"];
|
|
2882
|
+
var _ts_parser_delete = Module["_ts_parser_delete"] = wasmExports["ts_parser_delete"];
|
|
2883
|
+
var _ts_parser_reset = Module["_ts_parser_reset"] = wasmExports["ts_parser_reset"];
|
|
2884
|
+
var _ts_parser_set_language = Module["_ts_parser_set_language"] = wasmExports["ts_parser_set_language"];
|
|
2885
|
+
var _ts_parser_timeout_micros = Module["_ts_parser_timeout_micros"] = wasmExports["ts_parser_timeout_micros"];
|
|
2886
|
+
var _ts_parser_set_timeout_micros = Module["_ts_parser_set_timeout_micros"] = wasmExports["ts_parser_set_timeout_micros"];
|
|
2887
|
+
var _ts_parser_set_included_ranges = Module["_ts_parser_set_included_ranges"] = wasmExports["ts_parser_set_included_ranges"];
|
|
2888
|
+
var _ts_query_new = Module["_ts_query_new"] = wasmExports["ts_query_new"];
|
|
2889
|
+
var _ts_query_delete = Module["_ts_query_delete"] = wasmExports["ts_query_delete"];
|
|
2890
|
+
var _iswspace = Module["_iswspace"] = wasmExports["iswspace"];
|
|
2891
|
+
var _iswalnum = Module["_iswalnum"] = wasmExports["iswalnum"];
|
|
2892
|
+
var _ts_query_pattern_count = Module["_ts_query_pattern_count"] = wasmExports["ts_query_pattern_count"];
|
|
2893
|
+
var _ts_query_capture_count = Module["_ts_query_capture_count"] = wasmExports["ts_query_capture_count"];
|
|
2894
|
+
var _ts_query_string_count = Module["_ts_query_string_count"] = wasmExports["ts_query_string_count"];
|
|
2895
|
+
var _ts_query_capture_name_for_id = Module["_ts_query_capture_name_for_id"] = wasmExports["ts_query_capture_name_for_id"];
|
|
2896
|
+
var _ts_query_capture_quantifier_for_id = Module["_ts_query_capture_quantifier_for_id"] = wasmExports["ts_query_capture_quantifier_for_id"];
|
|
2897
|
+
var _ts_query_string_value_for_id = Module["_ts_query_string_value_for_id"] = wasmExports["ts_query_string_value_for_id"];
|
|
2898
|
+
var _ts_query_predicates_for_pattern = Module["_ts_query_predicates_for_pattern"] = wasmExports["ts_query_predicates_for_pattern"];
|
|
2899
|
+
var _ts_query_start_byte_for_pattern = Module["_ts_query_start_byte_for_pattern"] = wasmExports["ts_query_start_byte_for_pattern"];
|
|
2900
|
+
var _ts_query_end_byte_for_pattern = Module["_ts_query_end_byte_for_pattern"] = wasmExports["ts_query_end_byte_for_pattern"];
|
|
2901
|
+
var _ts_query_is_pattern_rooted = Module["_ts_query_is_pattern_rooted"] = wasmExports["ts_query_is_pattern_rooted"];
|
|
2902
|
+
var _ts_query_is_pattern_non_local = Module["_ts_query_is_pattern_non_local"] = wasmExports["ts_query_is_pattern_non_local"];
|
|
2903
|
+
var _ts_query_is_pattern_guaranteed_at_step = Module["_ts_query_is_pattern_guaranteed_at_step"] = wasmExports["ts_query_is_pattern_guaranteed_at_step"];
|
|
2904
|
+
var _ts_query_disable_capture = Module["_ts_query_disable_capture"] = wasmExports["ts_query_disable_capture"];
|
|
2905
|
+
var _ts_query_disable_pattern = Module["_ts_query_disable_pattern"] = wasmExports["ts_query_disable_pattern"];
|
|
2906
|
+
var _ts_tree_copy = Module["_ts_tree_copy"] = wasmExports["ts_tree_copy"];
|
|
2907
|
+
var _ts_tree_delete = Module["_ts_tree_delete"] = wasmExports["ts_tree_delete"];
|
|
2908
|
+
var _ts_init = Module["_ts_init"] = wasmExports["ts_init"];
|
|
2909
|
+
var _ts_parser_new_wasm = Module["_ts_parser_new_wasm"] = wasmExports["ts_parser_new_wasm"];
|
|
2910
|
+
var _ts_parser_enable_logger_wasm = Module["_ts_parser_enable_logger_wasm"] = wasmExports["ts_parser_enable_logger_wasm"];
|
|
2911
|
+
var _ts_parser_parse_wasm = Module["_ts_parser_parse_wasm"] = wasmExports["ts_parser_parse_wasm"];
|
|
2912
|
+
var _ts_parser_included_ranges_wasm = Module["_ts_parser_included_ranges_wasm"] = wasmExports["ts_parser_included_ranges_wasm"];
|
|
2913
|
+
var _ts_language_type_is_named_wasm = Module["_ts_language_type_is_named_wasm"] = wasmExports["ts_language_type_is_named_wasm"];
|
|
2914
|
+
var _ts_language_type_is_visible_wasm = Module["_ts_language_type_is_visible_wasm"] = wasmExports["ts_language_type_is_visible_wasm"];
|
|
2915
|
+
var _ts_language_supertypes_wasm = Module["_ts_language_supertypes_wasm"] = wasmExports["ts_language_supertypes_wasm"];
|
|
2916
|
+
var _ts_language_subtypes_wasm = Module["_ts_language_subtypes_wasm"] = wasmExports["ts_language_subtypes_wasm"];
|
|
2917
|
+
var _ts_tree_root_node_wasm = Module["_ts_tree_root_node_wasm"] = wasmExports["ts_tree_root_node_wasm"];
|
|
2918
|
+
var _ts_tree_root_node_with_offset_wasm = Module["_ts_tree_root_node_with_offset_wasm"] = wasmExports["ts_tree_root_node_with_offset_wasm"];
|
|
2919
|
+
var _ts_tree_edit_wasm = Module["_ts_tree_edit_wasm"] = wasmExports["ts_tree_edit_wasm"];
|
|
2920
|
+
var _ts_tree_included_ranges_wasm = Module["_ts_tree_included_ranges_wasm"] = wasmExports["ts_tree_included_ranges_wasm"];
|
|
2921
|
+
var _ts_tree_get_changed_ranges_wasm = Module["_ts_tree_get_changed_ranges_wasm"] = wasmExports["ts_tree_get_changed_ranges_wasm"];
|
|
2922
|
+
var _ts_tree_cursor_new_wasm = Module["_ts_tree_cursor_new_wasm"] = wasmExports["ts_tree_cursor_new_wasm"];
|
|
2923
|
+
var _ts_tree_cursor_copy_wasm = Module["_ts_tree_cursor_copy_wasm"] = wasmExports["ts_tree_cursor_copy_wasm"];
|
|
2924
|
+
var _ts_tree_cursor_delete_wasm = Module["_ts_tree_cursor_delete_wasm"] = wasmExports["ts_tree_cursor_delete_wasm"];
|
|
2925
|
+
var _ts_tree_cursor_reset_wasm = Module["_ts_tree_cursor_reset_wasm"] = wasmExports["ts_tree_cursor_reset_wasm"];
|
|
2926
|
+
var _ts_tree_cursor_reset_to_wasm = Module["_ts_tree_cursor_reset_to_wasm"] = wasmExports["ts_tree_cursor_reset_to_wasm"];
|
|
2927
|
+
var _ts_tree_cursor_goto_first_child_wasm = Module["_ts_tree_cursor_goto_first_child_wasm"] = wasmExports["ts_tree_cursor_goto_first_child_wasm"];
|
|
2928
|
+
var _ts_tree_cursor_goto_last_child_wasm = Module["_ts_tree_cursor_goto_last_child_wasm"] = wasmExports["ts_tree_cursor_goto_last_child_wasm"];
|
|
2929
|
+
var _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"];
|
|
2930
|
+
var _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"];
|
|
2931
|
+
var _ts_tree_cursor_goto_next_sibling_wasm = Module["_ts_tree_cursor_goto_next_sibling_wasm"] = wasmExports["ts_tree_cursor_goto_next_sibling_wasm"];
|
|
2932
|
+
var _ts_tree_cursor_goto_previous_sibling_wasm = Module["_ts_tree_cursor_goto_previous_sibling_wasm"] = wasmExports["ts_tree_cursor_goto_previous_sibling_wasm"];
|
|
2933
|
+
var _ts_tree_cursor_goto_descendant_wasm = Module["_ts_tree_cursor_goto_descendant_wasm"] = wasmExports["ts_tree_cursor_goto_descendant_wasm"];
|
|
2934
|
+
var _ts_tree_cursor_goto_parent_wasm = Module["_ts_tree_cursor_goto_parent_wasm"] = wasmExports["ts_tree_cursor_goto_parent_wasm"];
|
|
2935
|
+
var _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"];
|
|
2936
|
+
var _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"];
|
|
2937
|
+
var _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"];
|
|
2938
|
+
var _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"];
|
|
2939
|
+
var _ts_tree_cursor_current_node_id_wasm = Module["_ts_tree_cursor_current_node_id_wasm"] = wasmExports["ts_tree_cursor_current_node_id_wasm"];
|
|
2940
|
+
var _ts_tree_cursor_start_position_wasm = Module["_ts_tree_cursor_start_position_wasm"] = wasmExports["ts_tree_cursor_start_position_wasm"];
|
|
2941
|
+
var _ts_tree_cursor_end_position_wasm = Module["_ts_tree_cursor_end_position_wasm"] = wasmExports["ts_tree_cursor_end_position_wasm"];
|
|
2942
|
+
var _ts_tree_cursor_start_index_wasm = Module["_ts_tree_cursor_start_index_wasm"] = wasmExports["ts_tree_cursor_start_index_wasm"];
|
|
2943
|
+
var _ts_tree_cursor_end_index_wasm = Module["_ts_tree_cursor_end_index_wasm"] = wasmExports["ts_tree_cursor_end_index_wasm"];
|
|
2944
|
+
var _ts_tree_cursor_current_field_id_wasm = Module["_ts_tree_cursor_current_field_id_wasm"] = wasmExports["ts_tree_cursor_current_field_id_wasm"];
|
|
2945
|
+
var _ts_tree_cursor_current_depth_wasm = Module["_ts_tree_cursor_current_depth_wasm"] = wasmExports["ts_tree_cursor_current_depth_wasm"];
|
|
2946
|
+
var _ts_tree_cursor_current_descendant_index_wasm = Module["_ts_tree_cursor_current_descendant_index_wasm"] = wasmExports["ts_tree_cursor_current_descendant_index_wasm"];
|
|
2947
|
+
var _ts_tree_cursor_current_node_wasm = Module["_ts_tree_cursor_current_node_wasm"] = wasmExports["ts_tree_cursor_current_node_wasm"];
|
|
2948
|
+
var _ts_node_symbol_wasm = Module["_ts_node_symbol_wasm"] = wasmExports["ts_node_symbol_wasm"];
|
|
2949
|
+
var _ts_node_field_name_for_child_wasm = Module["_ts_node_field_name_for_child_wasm"] = wasmExports["ts_node_field_name_for_child_wasm"];
|
|
2950
|
+
var _ts_node_field_name_for_named_child_wasm = Module["_ts_node_field_name_for_named_child_wasm"] = wasmExports["ts_node_field_name_for_named_child_wasm"];
|
|
2951
|
+
var _ts_node_children_by_field_id_wasm = Module["_ts_node_children_by_field_id_wasm"] = wasmExports["ts_node_children_by_field_id_wasm"];
|
|
2952
|
+
var _ts_node_first_child_for_byte_wasm = Module["_ts_node_first_child_for_byte_wasm"] = wasmExports["ts_node_first_child_for_byte_wasm"];
|
|
2953
|
+
var _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"];
|
|
2954
|
+
var _ts_node_grammar_symbol_wasm = Module["_ts_node_grammar_symbol_wasm"] = wasmExports["ts_node_grammar_symbol_wasm"];
|
|
2955
|
+
var _ts_node_child_count_wasm = Module["_ts_node_child_count_wasm"] = wasmExports["ts_node_child_count_wasm"];
|
|
2956
|
+
var _ts_node_named_child_count_wasm = Module["_ts_node_named_child_count_wasm"] = wasmExports["ts_node_named_child_count_wasm"];
|
|
2957
|
+
var _ts_node_child_wasm = Module["_ts_node_child_wasm"] = wasmExports["ts_node_child_wasm"];
|
|
2958
|
+
var _ts_node_named_child_wasm = Module["_ts_node_named_child_wasm"] = wasmExports["ts_node_named_child_wasm"];
|
|
2959
|
+
var _ts_node_child_by_field_id_wasm = Module["_ts_node_child_by_field_id_wasm"] = wasmExports["ts_node_child_by_field_id_wasm"];
|
|
2960
|
+
var _ts_node_next_sibling_wasm = Module["_ts_node_next_sibling_wasm"] = wasmExports["ts_node_next_sibling_wasm"];
|
|
2961
|
+
var _ts_node_prev_sibling_wasm = Module["_ts_node_prev_sibling_wasm"] = wasmExports["ts_node_prev_sibling_wasm"];
|
|
2962
|
+
var _ts_node_next_named_sibling_wasm = Module["_ts_node_next_named_sibling_wasm"] = wasmExports["ts_node_next_named_sibling_wasm"];
|
|
2963
|
+
var _ts_node_prev_named_sibling_wasm = Module["_ts_node_prev_named_sibling_wasm"] = wasmExports["ts_node_prev_named_sibling_wasm"];
|
|
2964
|
+
var _ts_node_descendant_count_wasm = Module["_ts_node_descendant_count_wasm"] = wasmExports["ts_node_descendant_count_wasm"];
|
|
2965
|
+
var _ts_node_parent_wasm = Module["_ts_node_parent_wasm"] = wasmExports["ts_node_parent_wasm"];
|
|
2966
|
+
var _ts_node_child_with_descendant_wasm = Module["_ts_node_child_with_descendant_wasm"] = wasmExports["ts_node_child_with_descendant_wasm"];
|
|
2967
|
+
var _ts_node_descendant_for_index_wasm = Module["_ts_node_descendant_for_index_wasm"] = wasmExports["ts_node_descendant_for_index_wasm"];
|
|
2968
|
+
var _ts_node_named_descendant_for_index_wasm = Module["_ts_node_named_descendant_for_index_wasm"] = wasmExports["ts_node_named_descendant_for_index_wasm"];
|
|
2969
|
+
var _ts_node_descendant_for_position_wasm = Module["_ts_node_descendant_for_position_wasm"] = wasmExports["ts_node_descendant_for_position_wasm"];
|
|
2970
|
+
var _ts_node_named_descendant_for_position_wasm = Module["_ts_node_named_descendant_for_position_wasm"] = wasmExports["ts_node_named_descendant_for_position_wasm"];
|
|
2971
|
+
var _ts_node_start_point_wasm = Module["_ts_node_start_point_wasm"] = wasmExports["ts_node_start_point_wasm"];
|
|
2972
|
+
var _ts_node_end_point_wasm = Module["_ts_node_end_point_wasm"] = wasmExports["ts_node_end_point_wasm"];
|
|
2973
|
+
var _ts_node_start_index_wasm = Module["_ts_node_start_index_wasm"] = wasmExports["ts_node_start_index_wasm"];
|
|
2974
|
+
var _ts_node_end_index_wasm = Module["_ts_node_end_index_wasm"] = wasmExports["ts_node_end_index_wasm"];
|
|
2975
|
+
var _ts_node_to_string_wasm = Module["_ts_node_to_string_wasm"] = wasmExports["ts_node_to_string_wasm"];
|
|
2976
|
+
var _ts_node_children_wasm = Module["_ts_node_children_wasm"] = wasmExports["ts_node_children_wasm"];
|
|
2977
|
+
var _ts_node_named_children_wasm = Module["_ts_node_named_children_wasm"] = wasmExports["ts_node_named_children_wasm"];
|
|
2978
|
+
var _ts_node_descendants_of_type_wasm = Module["_ts_node_descendants_of_type_wasm"] = wasmExports["ts_node_descendants_of_type_wasm"];
|
|
2979
|
+
var _ts_node_is_named_wasm = Module["_ts_node_is_named_wasm"] = wasmExports["ts_node_is_named_wasm"];
|
|
2980
|
+
var _ts_node_has_changes_wasm = Module["_ts_node_has_changes_wasm"] = wasmExports["ts_node_has_changes_wasm"];
|
|
2981
|
+
var _ts_node_has_error_wasm = Module["_ts_node_has_error_wasm"] = wasmExports["ts_node_has_error_wasm"];
|
|
2982
|
+
var _ts_node_is_error_wasm = Module["_ts_node_is_error_wasm"] = wasmExports["ts_node_is_error_wasm"];
|
|
2983
|
+
var _ts_node_is_missing_wasm = Module["_ts_node_is_missing_wasm"] = wasmExports["ts_node_is_missing_wasm"];
|
|
2984
|
+
var _ts_node_is_extra_wasm = Module["_ts_node_is_extra_wasm"] = wasmExports["ts_node_is_extra_wasm"];
|
|
2985
|
+
var _ts_node_parse_state_wasm = Module["_ts_node_parse_state_wasm"] = wasmExports["ts_node_parse_state_wasm"];
|
|
2986
|
+
var _ts_node_next_parse_state_wasm = Module["_ts_node_next_parse_state_wasm"] = wasmExports["ts_node_next_parse_state_wasm"];
|
|
2987
|
+
var _ts_query_matches_wasm = Module["_ts_query_matches_wasm"] = wasmExports["ts_query_matches_wasm"];
|
|
2988
|
+
var _ts_query_captures_wasm = Module["_ts_query_captures_wasm"] = wasmExports["ts_query_captures_wasm"];
|
|
2989
|
+
var _memset = Module["_memset"] = wasmExports["memset"];
|
|
2990
|
+
var _memcpy = Module["_memcpy"] = wasmExports["memcpy"];
|
|
2991
|
+
var _memmove = Module["_memmove"] = wasmExports["memmove"];
|
|
2992
|
+
var _iswalpha = Module["_iswalpha"] = wasmExports["iswalpha"];
|
|
2993
|
+
var _iswblank = Module["_iswblank"] = wasmExports["iswblank"];
|
|
2994
|
+
var _iswdigit = Module["_iswdigit"] = wasmExports["iswdigit"];
|
|
2995
|
+
var _iswlower = Module["_iswlower"] = wasmExports["iswlower"];
|
|
2996
|
+
var _iswupper = Module["_iswupper"] = wasmExports["iswupper"];
|
|
2997
|
+
var _iswxdigit = Module["_iswxdigit"] = wasmExports["iswxdigit"];
|
|
2998
|
+
var _memchr = Module["_memchr"] = wasmExports["memchr"];
|
|
2999
|
+
var _strlen = Module["_strlen"] = wasmExports["strlen"];
|
|
3000
|
+
var _strcmp = Module["_strcmp"] = wasmExports["strcmp"];
|
|
3001
|
+
var _strncat = Module["_strncat"] = wasmExports["strncat"];
|
|
3002
|
+
var _strncpy = Module["_strncpy"] = wasmExports["strncpy"];
|
|
3003
|
+
var _towlower = Module["_towlower"] = wasmExports["towlower"];
|
|
3004
|
+
var _towupper = Module["_towupper"] = wasmExports["towupper"];
|
|
3005
|
+
var _setThrew = wasmExports["setThrew"];
|
|
3006
|
+
var __emscripten_stack_restore = wasmExports["_emscripten_stack_restore"];
|
|
3007
|
+
var __emscripten_stack_alloc = wasmExports["_emscripten_stack_alloc"];
|
|
3008
|
+
var _emscripten_stack_get_current = wasmExports["emscripten_stack_get_current"];
|
|
3009
|
+
var ___wasm_apply_data_relocs = wasmExports["__wasm_apply_data_relocs"];
|
|
3010
|
+
Module["setValue"] = setValue;
|
|
3011
|
+
Module["getValue"] = getValue;
|
|
3012
|
+
Module["UTF8ToString"] = UTF8ToString;
|
|
3013
|
+
Module["stringToUTF8"] = stringToUTF8;
|
|
3014
|
+
Module["lengthBytesUTF8"] = lengthBytesUTF8;
|
|
3015
|
+
Module["AsciiToString"] = AsciiToString;
|
|
3016
|
+
Module["stringToUTF16"] = stringToUTF16;
|
|
3017
|
+
Module["loadWebAssemblyModule"] = loadWebAssemblyModule;
|
|
3018
|
+
function callMain(args2 = []) {
|
|
3019
|
+
var entryFunction = resolveGlobalSymbol("main").sym;
|
|
3020
|
+
if (!entryFunction)
|
|
3021
|
+
return;
|
|
3022
|
+
args2.unshift(thisProgram);
|
|
3023
|
+
var argc = args2.length;
|
|
3024
|
+
var argv = stackAlloc((argc + 1) * 4);
|
|
3025
|
+
var argv_ptr = argv;
|
|
3026
|
+
args2.forEach((arg) => {
|
|
3027
|
+
LE_HEAP_STORE_U32((argv_ptr >> 2) * 4, stringToUTF8OnStack(arg));
|
|
3028
|
+
argv_ptr += 4;
|
|
3029
|
+
});
|
|
3030
|
+
LE_HEAP_STORE_U32((argv_ptr >> 2) * 4, 0);
|
|
3031
|
+
try {
|
|
3032
|
+
var ret = entryFunction(argc, argv);
|
|
3033
|
+
exitJS(ret, true);
|
|
3034
|
+
return ret;
|
|
3035
|
+
} catch (e) {
|
|
3036
|
+
return handleException(e);
|
|
3037
|
+
}
|
|
3038
|
+
}
|
|
3039
|
+
__name(callMain, "callMain");
|
|
3040
|
+
function run(args2 = arguments_) {
|
|
3041
|
+
if (runDependencies > 0) {
|
|
3042
|
+
dependenciesFulfilled = run;
|
|
3043
|
+
return;
|
|
3044
|
+
}
|
|
3045
|
+
preRun();
|
|
3046
|
+
if (runDependencies > 0) {
|
|
3047
|
+
dependenciesFulfilled = run;
|
|
3048
|
+
return;
|
|
3049
|
+
}
|
|
3050
|
+
function doRun() {
|
|
3051
|
+
Module["calledRun"] = true;
|
|
3052
|
+
if (ABORT)
|
|
3053
|
+
return;
|
|
3054
|
+
initRuntime();
|
|
3055
|
+
preMain();
|
|
3056
|
+
readyPromiseResolve(Module);
|
|
3057
|
+
Module["onRuntimeInitialized"]?.();
|
|
3058
|
+
var noInitialRun = Module["noInitialRun"];
|
|
3059
|
+
if (!noInitialRun)
|
|
3060
|
+
callMain(args2);
|
|
3061
|
+
postRun();
|
|
3062
|
+
}
|
|
3063
|
+
__name(doRun, "doRun");
|
|
3064
|
+
if (Module["setStatus"]) {
|
|
3065
|
+
Module["setStatus"]("Running...");
|
|
3066
|
+
setTimeout(() => {
|
|
3067
|
+
setTimeout(() => Module["setStatus"](""), 1);
|
|
3068
|
+
doRun();
|
|
3069
|
+
}, 1);
|
|
3070
|
+
} else {
|
|
3071
|
+
doRun();
|
|
3072
|
+
}
|
|
3073
|
+
}
|
|
3074
|
+
__name(run, "run");
|
|
3075
|
+
if (Module["preInit"]) {
|
|
3076
|
+
if (typeof Module["preInit"] == "function")
|
|
3077
|
+
Module["preInit"] = [Module["preInit"]];
|
|
3078
|
+
while (Module["preInit"].length > 0) {
|
|
3079
|
+
Module["preInit"].pop()();
|
|
3080
|
+
}
|
|
3081
|
+
}
|
|
3082
|
+
run();
|
|
3083
|
+
moduleRtn = readyPromise;
|
|
3084
|
+
return moduleRtn;
|
|
3085
|
+
};
|
|
3086
|
+
})();
|
|
3087
|
+
var tree_sitter_default = Module2;
|
|
3088
|
+
var Module3 = null;
|
|
3089
|
+
async function initializeBinding(moduleOptions) {
|
|
3090
|
+
if (!Module3) {
|
|
3091
|
+
Module3 = await tree_sitter_default(moduleOptions);
|
|
3092
|
+
}
|
|
3093
|
+
return Module3;
|
|
3094
|
+
}
|
|
3095
|
+
__name(initializeBinding, "initializeBinding");
|
|
3096
|
+
function checkModule() {
|
|
3097
|
+
return !!Module3;
|
|
3098
|
+
}
|
|
3099
|
+
__name(checkModule, "checkModule");
|
|
3100
|
+
var TRANSFER_BUFFER;
|
|
3101
|
+
var LANGUAGE_VERSION;
|
|
3102
|
+
var MIN_COMPATIBLE_VERSION;
|
|
3103
|
+
var Parser = class {
|
|
3104
|
+
static {
|
|
3105
|
+
__name(this, "Parser");
|
|
3106
|
+
}
|
|
3107
|
+
[0] = 0;
|
|
3108
|
+
[1] = 0;
|
|
3109
|
+
logCallback = null;
|
|
3110
|
+
language = null;
|
|
3111
|
+
static async init(moduleOptions) {
|
|
3112
|
+
setModule(await initializeBinding(moduleOptions));
|
|
3113
|
+
TRANSFER_BUFFER = C._ts_init();
|
|
3114
|
+
LANGUAGE_VERSION = C.getValue(TRANSFER_BUFFER, "i32");
|
|
3115
|
+
MIN_COMPATIBLE_VERSION = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
|
|
3116
|
+
}
|
|
3117
|
+
constructor() {
|
|
3118
|
+
this.initialize();
|
|
3119
|
+
}
|
|
3120
|
+
initialize() {
|
|
3121
|
+
if (!checkModule()) {
|
|
3122
|
+
throw new Error("cannot construct a Parser before calling `init()`");
|
|
3123
|
+
}
|
|
3124
|
+
C._ts_parser_new_wasm();
|
|
3125
|
+
this[0] = C.getValue(TRANSFER_BUFFER, "i32");
|
|
3126
|
+
this[1] = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
|
|
3127
|
+
}
|
|
3128
|
+
delete() {
|
|
3129
|
+
C._ts_parser_delete(this[0]);
|
|
3130
|
+
C._free(this[1]);
|
|
3131
|
+
this[0] = 0;
|
|
3132
|
+
this[1] = 0;
|
|
3133
|
+
}
|
|
3134
|
+
setLanguage(language) {
|
|
3135
|
+
let address;
|
|
3136
|
+
if (!language) {
|
|
3137
|
+
address = 0;
|
|
3138
|
+
this.language = null;
|
|
3139
|
+
} else if (language.constructor === Language) {
|
|
3140
|
+
address = language[0];
|
|
3141
|
+
const version = C._ts_language_version(address);
|
|
3142
|
+
if (version < MIN_COMPATIBLE_VERSION || LANGUAGE_VERSION < version) {
|
|
3143
|
+
throw new Error(`Incompatible language version ${version}. Compatibility range ${MIN_COMPATIBLE_VERSION} through ${LANGUAGE_VERSION}.`);
|
|
3144
|
+
}
|
|
3145
|
+
this.language = language;
|
|
3146
|
+
} else {
|
|
3147
|
+
throw new Error("Argument must be a Language");
|
|
3148
|
+
}
|
|
3149
|
+
C._ts_parser_set_language(this[0], address);
|
|
3150
|
+
return this;
|
|
3151
|
+
}
|
|
3152
|
+
parse(callback, oldTree, options) {
|
|
3153
|
+
if (typeof callback === "string") {
|
|
3154
|
+
C.currentParseCallback = (index) => callback.slice(index);
|
|
3155
|
+
} else if (typeof callback === "function") {
|
|
3156
|
+
C.currentParseCallback = callback;
|
|
3157
|
+
} else {
|
|
3158
|
+
throw new Error("Argument must be a string or a function");
|
|
3159
|
+
}
|
|
3160
|
+
if (options?.progressCallback) {
|
|
3161
|
+
C.currentProgressCallback = options.progressCallback;
|
|
3162
|
+
} else {
|
|
3163
|
+
C.currentProgressCallback = null;
|
|
3164
|
+
}
|
|
3165
|
+
if (this.logCallback) {
|
|
3166
|
+
C.currentLogCallback = this.logCallback;
|
|
3167
|
+
C._ts_parser_enable_logger_wasm(this[0], 1);
|
|
3168
|
+
} else {
|
|
3169
|
+
C.currentLogCallback = null;
|
|
3170
|
+
C._ts_parser_enable_logger_wasm(this[0], 0);
|
|
3171
|
+
}
|
|
3172
|
+
let rangeCount = 0;
|
|
3173
|
+
let rangeAddress = 0;
|
|
3174
|
+
if (options?.includedRanges) {
|
|
3175
|
+
rangeCount = options.includedRanges.length;
|
|
3176
|
+
rangeAddress = C._calloc(rangeCount, SIZE_OF_RANGE);
|
|
3177
|
+
let address = rangeAddress;
|
|
3178
|
+
for (let i2 = 0;i2 < rangeCount; i2++) {
|
|
3179
|
+
marshalRange(address, options.includedRanges[i2]);
|
|
3180
|
+
address += SIZE_OF_RANGE;
|
|
3181
|
+
}
|
|
3182
|
+
}
|
|
3183
|
+
const treeAddress = C._ts_parser_parse_wasm(this[0], this[1], oldTree ? oldTree[0] : 0, rangeAddress, rangeCount);
|
|
3184
|
+
if (!treeAddress) {
|
|
3185
|
+
C.currentParseCallback = null;
|
|
3186
|
+
C.currentLogCallback = null;
|
|
3187
|
+
C.currentProgressCallback = null;
|
|
3188
|
+
return null;
|
|
3189
|
+
}
|
|
3190
|
+
if (!this.language) {
|
|
3191
|
+
throw new Error("Parser must have a language to parse");
|
|
3192
|
+
}
|
|
3193
|
+
const result = new Tree(INTERNAL, treeAddress, this.language, C.currentParseCallback);
|
|
3194
|
+
C.currentParseCallback = null;
|
|
3195
|
+
C.currentLogCallback = null;
|
|
3196
|
+
C.currentProgressCallback = null;
|
|
3197
|
+
return result;
|
|
3198
|
+
}
|
|
3199
|
+
reset() {
|
|
3200
|
+
C._ts_parser_reset(this[0]);
|
|
3201
|
+
}
|
|
3202
|
+
getIncludedRanges() {
|
|
3203
|
+
C._ts_parser_included_ranges_wasm(this[0]);
|
|
3204
|
+
const count = C.getValue(TRANSFER_BUFFER, "i32");
|
|
3205
|
+
const buffer = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
|
|
3206
|
+
const result = new Array(count);
|
|
3207
|
+
if (count > 0) {
|
|
3208
|
+
let address = buffer;
|
|
3209
|
+
for (let i2 = 0;i2 < count; i2++) {
|
|
3210
|
+
result[i2] = unmarshalRange(address);
|
|
3211
|
+
address += SIZE_OF_RANGE;
|
|
3212
|
+
}
|
|
3213
|
+
C._free(buffer);
|
|
3214
|
+
}
|
|
3215
|
+
return result;
|
|
3216
|
+
}
|
|
3217
|
+
getTimeoutMicros() {
|
|
3218
|
+
return C._ts_parser_timeout_micros(this[0]);
|
|
3219
|
+
}
|
|
3220
|
+
setTimeoutMicros(timeout) {
|
|
3221
|
+
C._ts_parser_set_timeout_micros(this[0], 0, timeout);
|
|
3222
|
+
}
|
|
3223
|
+
setLogger(callback) {
|
|
3224
|
+
if (!callback) {
|
|
3225
|
+
this.logCallback = null;
|
|
3226
|
+
} else if (typeof callback !== "function") {
|
|
3227
|
+
throw new Error("Logger callback must be a function");
|
|
3228
|
+
} else {
|
|
3229
|
+
this.logCallback = callback;
|
|
3230
|
+
}
|
|
3231
|
+
return this;
|
|
3232
|
+
}
|
|
3233
|
+
getLogger() {
|
|
3234
|
+
return this.logCallback;
|
|
3235
|
+
}
|
|
3236
|
+
};
|
|
3237
|
+
|
|
3238
|
+
// ../../node_modules/.bun/@opentui+core@0.1.77+2b53f2de03b5b2e3/node_modules/@opentui/core/parser.worker.js
|
|
3239
|
+
import { mkdir as mkdir2 } from "fs/promises";
|
|
3240
|
+
import * as path2 from "path";
|
|
3241
|
+
import { mkdir, writeFile } from "fs/promises";
|
|
3242
|
+
import * as path from "path";
|
|
3243
|
+
import { isMainThread } from "worker_threads";
|
|
3244
|
+
import { basename as basename2, join as join22 } from "path";
|
|
3245
|
+
class DownloadUtils {
|
|
3246
|
+
static hashUrl(url) {
|
|
3247
|
+
let hash = 0;
|
|
3248
|
+
for (let i2 = 0;i2 < url.length; i2++) {
|
|
3249
|
+
const char = url.charCodeAt(i2);
|
|
3250
|
+
hash = (hash << 5) - hash + char;
|
|
3251
|
+
hash = hash & hash;
|
|
3252
|
+
}
|
|
3253
|
+
return Math.abs(hash).toString(16);
|
|
3254
|
+
}
|
|
3255
|
+
static async downloadOrLoad(source, cacheDir, cacheSubdir, fileExtension, useHashForCache = true, filetype) {
|
|
3256
|
+
const isUrl = source.startsWith("http://") || source.startsWith("https://");
|
|
3257
|
+
if (isUrl) {
|
|
3258
|
+
let cacheFileName;
|
|
3259
|
+
if (useHashForCache) {
|
|
3260
|
+
const hash = this.hashUrl(source);
|
|
3261
|
+
cacheFileName = filetype ? `${filetype}-${hash}${fileExtension}` : `${hash}${fileExtension}`;
|
|
3262
|
+
} else {
|
|
3263
|
+
cacheFileName = path.basename(source);
|
|
3264
|
+
}
|
|
3265
|
+
const cacheFile = path.join(cacheDir, cacheSubdir, cacheFileName);
|
|
3266
|
+
await mkdir(path.dirname(cacheFile), { recursive: true });
|
|
3267
|
+
try {
|
|
3268
|
+
const cachedContent = await Bun.file(cacheFile).arrayBuffer();
|
|
3269
|
+
if (cachedContent.byteLength > 0) {
|
|
3270
|
+
console.log(`Loaded from cache: ${cacheFile} (${source})`);
|
|
3271
|
+
return { content: cachedContent, filePath: cacheFile };
|
|
3272
|
+
}
|
|
3273
|
+
} catch (error) {}
|
|
3274
|
+
try {
|
|
3275
|
+
console.log(`Downloading from URL: ${source}`);
|
|
3276
|
+
const response = await fetch(source);
|
|
3277
|
+
if (!response.ok) {
|
|
3278
|
+
return { error: `Failed to fetch from ${source}: ${response.statusText}` };
|
|
3279
|
+
}
|
|
3280
|
+
const content = await response.arrayBuffer();
|
|
3281
|
+
try {
|
|
3282
|
+
await writeFile(cacheFile, Buffer.from(content));
|
|
3283
|
+
console.log(`Cached: ${source}`);
|
|
3284
|
+
} catch (cacheError) {
|
|
3285
|
+
console.warn(`Failed to cache: ${cacheError}`);
|
|
3286
|
+
}
|
|
3287
|
+
return { content, filePath: cacheFile };
|
|
3288
|
+
} catch (error) {
|
|
3289
|
+
return { error: `Error downloading from ${source}: ${error}` };
|
|
3290
|
+
}
|
|
3291
|
+
} else {
|
|
3292
|
+
try {
|
|
3293
|
+
console.log(`Loading from local path: ${source}`);
|
|
3294
|
+
const content = await Bun.file(source).arrayBuffer();
|
|
3295
|
+
return { content, filePath: source };
|
|
3296
|
+
} catch (error) {
|
|
3297
|
+
return { error: `Error loading from local path ${source}: ${error}` };
|
|
3298
|
+
}
|
|
3299
|
+
}
|
|
3300
|
+
}
|
|
3301
|
+
static async downloadToPath(source, targetPath) {
|
|
3302
|
+
const isUrl = source.startsWith("http://") || source.startsWith("https://");
|
|
3303
|
+
await mkdir(path.dirname(targetPath), { recursive: true });
|
|
3304
|
+
if (isUrl) {
|
|
3305
|
+
try {
|
|
3306
|
+
console.log(`Downloading from URL: ${source}`);
|
|
3307
|
+
const response = await fetch(source);
|
|
3308
|
+
if (!response.ok) {
|
|
3309
|
+
return { error: `Failed to fetch from ${source}: ${response.statusText}` };
|
|
3310
|
+
}
|
|
3311
|
+
const content = await response.arrayBuffer();
|
|
3312
|
+
await writeFile(targetPath, Buffer.from(content));
|
|
3313
|
+
console.log(`Downloaded: ${source} -> ${targetPath}`);
|
|
3314
|
+
return { content, filePath: targetPath };
|
|
3315
|
+
} catch (error) {
|
|
3316
|
+
return { error: `Error downloading from ${source}: ${error}` };
|
|
3317
|
+
}
|
|
3318
|
+
} else {
|
|
3319
|
+
try {
|
|
3320
|
+
console.log(`Copying from local path: ${source}`);
|
|
3321
|
+
const content = await Bun.file(source).arrayBuffer();
|
|
3322
|
+
await writeFile(targetPath, Buffer.from(content));
|
|
3323
|
+
return { content, filePath: targetPath };
|
|
3324
|
+
} catch (error) {
|
|
3325
|
+
return { error: `Error copying from local path ${source}: ${error}` };
|
|
3326
|
+
}
|
|
3327
|
+
}
|
|
3328
|
+
}
|
|
3329
|
+
static async fetchHighlightQueries(sources, cacheDir, filetype) {
|
|
3330
|
+
const queryPromises = sources.map((source) => this.fetchHighlightQuery(source, cacheDir, filetype));
|
|
3331
|
+
const queryResults = await Promise.all(queryPromises);
|
|
3332
|
+
const validQueries = queryResults.filter((query) => query.trim().length > 0);
|
|
3333
|
+
return validQueries.join(`
|
|
3334
|
+
`);
|
|
3335
|
+
}
|
|
3336
|
+
static async fetchHighlightQuery(source, cacheDir, filetype) {
|
|
3337
|
+
const result = await this.downloadOrLoad(source, cacheDir, "queries", ".scm", true, filetype);
|
|
3338
|
+
if (result.error) {
|
|
3339
|
+
console.error(`Error fetching highlight query from ${source}:`, result.error);
|
|
3340
|
+
return "";
|
|
3341
|
+
}
|
|
3342
|
+
if (result.content) {
|
|
3343
|
+
return new TextDecoder().decode(result.content);
|
|
3344
|
+
}
|
|
3345
|
+
return "";
|
|
3346
|
+
}
|
|
3347
|
+
}
|
|
3348
|
+
function isBunfsPath(path22) {
|
|
3349
|
+
return path22.includes("$bunfs") || /^B:[\\/]~BUN/i.test(path22);
|
|
3350
|
+
}
|
|
3351
|
+
function getBunfsRootPath() {
|
|
3352
|
+
return process.platform === "win32" ? "B:\\~BUN\\root" : "/$bunfs/root";
|
|
3353
|
+
}
|
|
3354
|
+
function normalizeBunfsPath(fileName) {
|
|
3355
|
+
return join22(getBunfsRootPath(), basename2(fileName));
|
|
3356
|
+
}
|
|
3357
|
+
var self2 = globalThis;
|
|
3358
|
+
|
|
3359
|
+
class ParserWorker {
|
|
3360
|
+
bufferParsers = new Map;
|
|
3361
|
+
filetypeParserOptions = new Map;
|
|
3362
|
+
filetypeParsers = new Map;
|
|
3363
|
+
filetypeParserPromises = new Map;
|
|
3364
|
+
reusableParsers = new Map;
|
|
3365
|
+
reusableParserPromises = new Map;
|
|
3366
|
+
initializePromise;
|
|
3367
|
+
performance;
|
|
3368
|
+
dataPath;
|
|
3369
|
+
tsDataPath;
|
|
3370
|
+
initialized = false;
|
|
3371
|
+
constructor() {
|
|
3372
|
+
this.performance = {
|
|
3373
|
+
averageParseTime: 0,
|
|
3374
|
+
parseTimes: [],
|
|
3375
|
+
averageQueryTime: 0,
|
|
3376
|
+
queryTimes: []
|
|
3377
|
+
};
|
|
3378
|
+
}
|
|
3379
|
+
async fetchQueries(sources, filetype) {
|
|
3380
|
+
if (!this.tsDataPath) {
|
|
3381
|
+
return "";
|
|
3382
|
+
}
|
|
3383
|
+
return DownloadUtils.fetchHighlightQueries(sources, this.tsDataPath, filetype);
|
|
3384
|
+
}
|
|
3385
|
+
async initialize({ dataPath }) {
|
|
3386
|
+
if (this.initializePromise) {
|
|
3387
|
+
return this.initializePromise;
|
|
3388
|
+
}
|
|
3389
|
+
this.initializePromise = new Promise(async (resolve, reject) => {
|
|
3390
|
+
this.dataPath = dataPath;
|
|
3391
|
+
this.tsDataPath = path2.join(dataPath, "tree-sitter");
|
|
3392
|
+
try {
|
|
3393
|
+
await mkdir2(path2.join(this.tsDataPath, "languages"), { recursive: true });
|
|
3394
|
+
await mkdir2(path2.join(this.tsDataPath, "queries"), { recursive: true });
|
|
3395
|
+
let { default: treeWasm } = await Promise.resolve().then(() => __toESM(require_tree_sitter(), 1));
|
|
3396
|
+
if (isBunfsPath(treeWasm)) {
|
|
3397
|
+
treeWasm = normalizeBunfsPath(path2.parse(treeWasm).base);
|
|
3398
|
+
}
|
|
3399
|
+
await Parser.init({
|
|
3400
|
+
locateFile() {
|
|
3401
|
+
return treeWasm;
|
|
3402
|
+
}
|
|
3403
|
+
});
|
|
3404
|
+
this.initialized = true;
|
|
3405
|
+
resolve();
|
|
3406
|
+
} catch (error) {
|
|
3407
|
+
reject(error);
|
|
3408
|
+
}
|
|
3409
|
+
});
|
|
3410
|
+
return this.initializePromise;
|
|
3411
|
+
}
|
|
3412
|
+
addFiletypeParser(filetypeParser) {
|
|
3413
|
+
this.filetypeParserOptions.set(filetypeParser.filetype, filetypeParser);
|
|
3414
|
+
}
|
|
3415
|
+
async createQueries(filetypeParser, language) {
|
|
3416
|
+
try {
|
|
3417
|
+
const highlightQueryContent = await this.fetchQueries(filetypeParser.queries.highlights, filetypeParser.filetype);
|
|
3418
|
+
if (!highlightQueryContent) {
|
|
3419
|
+
console.error("Failed to fetch highlight queries for:", filetypeParser.filetype);
|
|
3420
|
+
return;
|
|
3421
|
+
}
|
|
3422
|
+
const highlightsQuery = new Query(language, highlightQueryContent);
|
|
3423
|
+
const result = {
|
|
3424
|
+
highlights: highlightsQuery
|
|
3425
|
+
};
|
|
3426
|
+
if (filetypeParser.queries.injections && filetypeParser.queries.injections.length > 0) {
|
|
3427
|
+
const injectionQueryContent = await this.fetchQueries(filetypeParser.queries.injections, filetypeParser.filetype);
|
|
3428
|
+
if (injectionQueryContent) {
|
|
3429
|
+
result.injections = new Query(language, injectionQueryContent);
|
|
3430
|
+
}
|
|
3431
|
+
}
|
|
3432
|
+
return result;
|
|
3433
|
+
} catch (error) {
|
|
3434
|
+
console.error("Error creating queries for", filetypeParser.filetype, filetypeParser.queries);
|
|
3435
|
+
console.error(error);
|
|
3436
|
+
return;
|
|
3437
|
+
}
|
|
3438
|
+
}
|
|
3439
|
+
async loadLanguage(languageSource) {
|
|
3440
|
+
if (!this.initialized || !this.tsDataPath) {
|
|
3441
|
+
return;
|
|
3442
|
+
}
|
|
3443
|
+
const result = await DownloadUtils.downloadOrLoad(languageSource, this.tsDataPath, "languages", ".wasm", false);
|
|
3444
|
+
if (result.error) {
|
|
3445
|
+
console.error(`Error loading language ${languageSource}:`, result.error);
|
|
3446
|
+
return;
|
|
3447
|
+
}
|
|
3448
|
+
if (!result.filePath) {
|
|
3449
|
+
return;
|
|
3450
|
+
}
|
|
3451
|
+
const normalizedPath = result.filePath.replaceAll("\\", "/");
|
|
3452
|
+
try {
|
|
3453
|
+
const language = await Language.load(normalizedPath);
|
|
3454
|
+
return language;
|
|
3455
|
+
} catch (error) {
|
|
3456
|
+
console.error(`Error loading language from ${normalizedPath}:`, error);
|
|
3457
|
+
return;
|
|
3458
|
+
}
|
|
3459
|
+
}
|
|
3460
|
+
async resolveFiletypeParser(filetype) {
|
|
3461
|
+
if (this.filetypeParsers.has(filetype)) {
|
|
3462
|
+
return this.filetypeParsers.get(filetype);
|
|
3463
|
+
}
|
|
3464
|
+
if (this.filetypeParserPromises.has(filetype)) {
|
|
3465
|
+
return this.filetypeParserPromises.get(filetype);
|
|
3466
|
+
}
|
|
3467
|
+
const loadingPromise = this.loadFiletypeParser(filetype);
|
|
3468
|
+
this.filetypeParserPromises.set(filetype, loadingPromise);
|
|
3469
|
+
try {
|
|
3470
|
+
const result = await loadingPromise;
|
|
3471
|
+
if (result) {
|
|
3472
|
+
this.filetypeParsers.set(filetype, result);
|
|
3473
|
+
}
|
|
3474
|
+
return result;
|
|
3475
|
+
} finally {
|
|
3476
|
+
this.filetypeParserPromises.delete(filetype);
|
|
3477
|
+
}
|
|
3478
|
+
}
|
|
3479
|
+
async loadFiletypeParser(filetype) {
|
|
3480
|
+
const filetypeParserOptions = this.filetypeParserOptions.get(filetype);
|
|
3481
|
+
if (!filetypeParserOptions) {
|
|
3482
|
+
return;
|
|
3483
|
+
}
|
|
3484
|
+
const language = await this.loadLanguage(filetypeParserOptions.wasm);
|
|
3485
|
+
if (!language) {
|
|
3486
|
+
return;
|
|
3487
|
+
}
|
|
3488
|
+
const queries = await this.createQueries(filetypeParserOptions, language);
|
|
3489
|
+
if (!queries) {
|
|
3490
|
+
console.error("Failed to create queries for:", filetype);
|
|
3491
|
+
return;
|
|
3492
|
+
}
|
|
3493
|
+
const filetypeParser = {
|
|
3494
|
+
...filetypeParserOptions,
|
|
3495
|
+
queries,
|
|
3496
|
+
language
|
|
3497
|
+
};
|
|
3498
|
+
return filetypeParser;
|
|
3499
|
+
}
|
|
3500
|
+
async preloadParser(filetype) {
|
|
3501
|
+
return this.resolveFiletypeParser(filetype);
|
|
3502
|
+
}
|
|
3503
|
+
async getReusableParser(filetype) {
|
|
3504
|
+
if (this.reusableParsers.has(filetype)) {
|
|
3505
|
+
return this.reusableParsers.get(filetype);
|
|
3506
|
+
}
|
|
3507
|
+
if (this.reusableParserPromises.has(filetype)) {
|
|
3508
|
+
return this.reusableParserPromises.get(filetype);
|
|
3509
|
+
}
|
|
3510
|
+
const creationPromise = this.createReusableParser(filetype);
|
|
3511
|
+
this.reusableParserPromises.set(filetype, creationPromise);
|
|
3512
|
+
try {
|
|
3513
|
+
const result = await creationPromise;
|
|
3514
|
+
if (result) {
|
|
3515
|
+
this.reusableParsers.set(filetype, result);
|
|
3516
|
+
}
|
|
3517
|
+
return result;
|
|
3518
|
+
} finally {
|
|
3519
|
+
this.reusableParserPromises.delete(filetype);
|
|
3520
|
+
}
|
|
3521
|
+
}
|
|
3522
|
+
async createReusableParser(filetype) {
|
|
3523
|
+
const filetypeParser = await this.resolveFiletypeParser(filetype);
|
|
3524
|
+
if (!filetypeParser) {
|
|
3525
|
+
return;
|
|
3526
|
+
}
|
|
3527
|
+
const parser = new Parser;
|
|
3528
|
+
parser.setLanguage(filetypeParser.language);
|
|
3529
|
+
const reusableState = {
|
|
3530
|
+
parser,
|
|
3531
|
+
filetypeParser,
|
|
3532
|
+
queries: filetypeParser.queries
|
|
3533
|
+
};
|
|
3534
|
+
return reusableState;
|
|
3535
|
+
}
|
|
3536
|
+
async handleInitializeParser(bufferId, version, content, filetype, messageId) {
|
|
3537
|
+
const filetypeParser = await this.resolveFiletypeParser(filetype);
|
|
3538
|
+
if (!filetypeParser) {
|
|
3539
|
+
self2.postMessage({
|
|
3540
|
+
type: "PARSER_INIT_RESPONSE",
|
|
3541
|
+
bufferId,
|
|
3542
|
+
messageId,
|
|
3543
|
+
hasParser: false,
|
|
3544
|
+
warning: `No parser available for filetype ${filetype}`
|
|
3545
|
+
});
|
|
3546
|
+
return;
|
|
3547
|
+
}
|
|
3548
|
+
const parser = new Parser;
|
|
3549
|
+
parser.setLanguage(filetypeParser.language);
|
|
3550
|
+
const tree = parser.parse(content);
|
|
3551
|
+
if (!tree) {
|
|
3552
|
+
self2.postMessage({
|
|
3553
|
+
type: "PARSER_INIT_RESPONSE",
|
|
3554
|
+
bufferId,
|
|
3555
|
+
messageId,
|
|
3556
|
+
hasParser: false,
|
|
3557
|
+
error: "Failed to parse buffer"
|
|
3558
|
+
});
|
|
3559
|
+
return;
|
|
3560
|
+
}
|
|
3561
|
+
const parserState = {
|
|
3562
|
+
parser,
|
|
3563
|
+
tree,
|
|
3564
|
+
queries: filetypeParser.queries,
|
|
3565
|
+
filetype,
|
|
3566
|
+
content,
|
|
3567
|
+
injectionMapping: filetypeParser.injectionMapping
|
|
3568
|
+
};
|
|
3569
|
+
this.bufferParsers.set(bufferId, parserState);
|
|
3570
|
+
self2.postMessage({
|
|
3571
|
+
type: "PARSER_INIT_RESPONSE",
|
|
3572
|
+
bufferId,
|
|
3573
|
+
messageId,
|
|
3574
|
+
hasParser: true
|
|
3575
|
+
});
|
|
3576
|
+
const highlights = await this.initialQuery(parserState);
|
|
3577
|
+
self2.postMessage({
|
|
3578
|
+
type: "HIGHLIGHT_RESPONSE",
|
|
3579
|
+
bufferId,
|
|
3580
|
+
version,
|
|
3581
|
+
...highlights
|
|
3582
|
+
});
|
|
3583
|
+
}
|
|
3584
|
+
async initialQuery(parserState) {
|
|
3585
|
+
const query = parserState.queries.highlights;
|
|
3586
|
+
const matches = query.captures(parserState.tree.rootNode);
|
|
3587
|
+
let injectionRanges = new Map;
|
|
3588
|
+
if (parserState.queries.injections) {
|
|
3589
|
+
const injectionResult = await this.processInjections(parserState);
|
|
3590
|
+
matches.push(...injectionResult.captures);
|
|
3591
|
+
injectionRanges = injectionResult.injectionRanges;
|
|
3592
|
+
}
|
|
3593
|
+
return this.getHighlights(parserState, matches, injectionRanges);
|
|
3594
|
+
}
|
|
3595
|
+
getNodeText(node, content) {
|
|
3596
|
+
return content.substring(node.startIndex, node.endIndex);
|
|
3597
|
+
}
|
|
3598
|
+
async processInjections(parserState) {
|
|
3599
|
+
const injectionMatches = [];
|
|
3600
|
+
const injectionRanges = new Map;
|
|
3601
|
+
if (!parserState.queries.injections) {
|
|
3602
|
+
return { captures: injectionMatches, injectionRanges };
|
|
3603
|
+
}
|
|
3604
|
+
const content = parserState.content;
|
|
3605
|
+
const injectionCaptures = parserState.queries.injections.captures(parserState.tree.rootNode);
|
|
3606
|
+
const languageGroups = new Map;
|
|
3607
|
+
const injectionMapping = parserState.injectionMapping;
|
|
3608
|
+
for (const capture of injectionCaptures) {
|
|
3609
|
+
const captureName = capture.name;
|
|
3610
|
+
if (captureName === "injection.content" || captureName.includes("injection")) {
|
|
3611
|
+
const nodeType = capture.node.type;
|
|
3612
|
+
let targetLanguage;
|
|
3613
|
+
if (injectionMapping?.nodeTypes && injectionMapping.nodeTypes[nodeType]) {
|
|
3614
|
+
targetLanguage = injectionMapping.nodeTypes[nodeType];
|
|
3615
|
+
} else if (nodeType === "code_fence_content") {
|
|
3616
|
+
const parent = capture.node.parent;
|
|
3617
|
+
if (parent) {
|
|
3618
|
+
const infoString = parent.children.find((child) => child.type === "info_string");
|
|
3619
|
+
if (infoString) {
|
|
3620
|
+
const languageNode = infoString.children.find((child) => child.type === "language");
|
|
3621
|
+
if (languageNode) {
|
|
3622
|
+
const languageName = this.getNodeText(languageNode, content);
|
|
3623
|
+
if (injectionMapping?.infoStringMap && injectionMapping.infoStringMap[languageName]) {
|
|
3624
|
+
targetLanguage = injectionMapping.infoStringMap[languageName];
|
|
3625
|
+
} else {
|
|
3626
|
+
targetLanguage = languageName;
|
|
3627
|
+
}
|
|
3628
|
+
}
|
|
3629
|
+
}
|
|
3630
|
+
}
|
|
3631
|
+
}
|
|
3632
|
+
if (targetLanguage) {
|
|
3633
|
+
if (!languageGroups.has(targetLanguage)) {
|
|
3634
|
+
languageGroups.set(targetLanguage, []);
|
|
3635
|
+
}
|
|
3636
|
+
languageGroups.get(targetLanguage).push({ node: capture.node, name: capture.name });
|
|
3637
|
+
}
|
|
3638
|
+
}
|
|
3639
|
+
}
|
|
3640
|
+
for (const [language, captures] of languageGroups.entries()) {
|
|
3641
|
+
const injectedParser = await this.getReusableParser(language);
|
|
3642
|
+
if (!injectedParser) {
|
|
3643
|
+
console.warn(`No parser found for injection language: ${language}`);
|
|
3644
|
+
continue;
|
|
3645
|
+
}
|
|
3646
|
+
if (!injectionRanges.has(language)) {
|
|
3647
|
+
injectionRanges.set(language, []);
|
|
3648
|
+
}
|
|
3649
|
+
const parser = injectedParser.parser;
|
|
3650
|
+
for (const { node: injectionNode } of captures) {
|
|
3651
|
+
try {
|
|
3652
|
+
injectionRanges.get(language).push({
|
|
3653
|
+
start: injectionNode.startIndex,
|
|
3654
|
+
end: injectionNode.endIndex
|
|
3655
|
+
});
|
|
3656
|
+
const injectionContent = this.getNodeText(injectionNode, content);
|
|
3657
|
+
const tree = parser.parse(injectionContent);
|
|
3658
|
+
if (tree) {
|
|
3659
|
+
const matches = injectedParser.queries.highlights.captures(tree.rootNode);
|
|
3660
|
+
for (const match of matches) {
|
|
3661
|
+
const offsetCapture = {
|
|
3662
|
+
name: match.name,
|
|
3663
|
+
patternIndex: match.patternIndex,
|
|
3664
|
+
_injectedQuery: injectedParser.queries.highlights,
|
|
3665
|
+
node: {
|
|
3666
|
+
...match.node,
|
|
3667
|
+
startPosition: {
|
|
3668
|
+
row: match.node.startPosition.row + injectionNode.startPosition.row,
|
|
3669
|
+
column: match.node.startPosition.row === 0 ? match.node.startPosition.column + injectionNode.startPosition.column : match.node.startPosition.column
|
|
3670
|
+
},
|
|
3671
|
+
endPosition: {
|
|
3672
|
+
row: match.node.endPosition.row + injectionNode.startPosition.row,
|
|
3673
|
+
column: match.node.endPosition.row === 0 ? match.node.endPosition.column + injectionNode.startPosition.column : match.node.endPosition.column
|
|
3674
|
+
},
|
|
3675
|
+
startIndex: match.node.startIndex + injectionNode.startIndex,
|
|
3676
|
+
endIndex: match.node.endIndex + injectionNode.startIndex
|
|
3677
|
+
}
|
|
3678
|
+
};
|
|
3679
|
+
injectionMatches.push(offsetCapture);
|
|
3680
|
+
}
|
|
3681
|
+
tree.delete();
|
|
3682
|
+
}
|
|
3683
|
+
} catch (error) {
|
|
3684
|
+
console.error(`Error processing injection for language ${language}:`, error);
|
|
3685
|
+
}
|
|
3686
|
+
}
|
|
3687
|
+
}
|
|
3688
|
+
return { captures: injectionMatches, injectionRanges };
|
|
3689
|
+
}
|
|
3690
|
+
editToRange(edit) {
|
|
3691
|
+
return {
|
|
3692
|
+
startPosition: {
|
|
3693
|
+
column: edit.startPosition.column,
|
|
3694
|
+
row: edit.startPosition.row
|
|
3695
|
+
},
|
|
3696
|
+
endPosition: {
|
|
3697
|
+
column: edit.newEndPosition.column,
|
|
3698
|
+
row: edit.newEndPosition.row
|
|
3699
|
+
},
|
|
3700
|
+
startIndex: edit.startIndex,
|
|
3701
|
+
endIndex: edit.newEndIndex
|
|
3702
|
+
};
|
|
3703
|
+
}
|
|
3704
|
+
async handleEdits(bufferId, content, edits) {
|
|
3705
|
+
const parserState = this.bufferParsers.get(bufferId);
|
|
3706
|
+
if (!parserState) {
|
|
3707
|
+
return { warning: "No parser state found for buffer" };
|
|
3708
|
+
}
|
|
3709
|
+
parserState.content = content;
|
|
3710
|
+
for (const edit of edits) {
|
|
3711
|
+
parserState.tree.edit(edit);
|
|
3712
|
+
}
|
|
3713
|
+
const startParse = performance.now();
|
|
3714
|
+
const newTree = parserState.parser.parse(content, parserState.tree);
|
|
3715
|
+
const endParse = performance.now();
|
|
3716
|
+
const parseTime = endParse - startParse;
|
|
3717
|
+
this.performance.parseTimes.push(parseTime);
|
|
3718
|
+
if (this.performance.parseTimes.length > 10) {
|
|
3719
|
+
this.performance.parseTimes.shift();
|
|
3720
|
+
}
|
|
3721
|
+
this.performance.averageParseTime = this.performance.parseTimes.reduce((acc, time) => acc + time, 0) / this.performance.parseTimes.length;
|
|
3722
|
+
if (!newTree) {
|
|
3723
|
+
return { error: "Failed to parse buffer" };
|
|
3724
|
+
}
|
|
3725
|
+
const changedRanges = parserState.tree.getChangedRanges(newTree);
|
|
3726
|
+
parserState.tree = newTree;
|
|
3727
|
+
const startQuery = performance.now();
|
|
3728
|
+
const matches = [];
|
|
3729
|
+
if (changedRanges.length === 0) {
|
|
3730
|
+
edits.forEach((edit) => {
|
|
3731
|
+
const range = this.editToRange(edit);
|
|
3732
|
+
changedRanges.push(range);
|
|
3733
|
+
});
|
|
3734
|
+
}
|
|
3735
|
+
for (const range of changedRanges) {
|
|
3736
|
+
let node = parserState.tree.rootNode.descendantForPosition(range.startPosition, range.endPosition);
|
|
3737
|
+
if (!node) {
|
|
3738
|
+
continue;
|
|
3739
|
+
}
|
|
3740
|
+
if (node.equals(parserState.tree.rootNode)) {
|
|
3741
|
+
const rangeCaptures = parserState.queries.highlights.captures(node, {
|
|
3742
|
+
startIndex: range.startIndex - 100,
|
|
3743
|
+
endIndex: range.endIndex + 1000
|
|
3744
|
+
});
|
|
3745
|
+
matches.push(...rangeCaptures);
|
|
3746
|
+
continue;
|
|
3747
|
+
}
|
|
3748
|
+
while (node && !this.nodeContainsRange(node, range)) {
|
|
3749
|
+
node = node.parent;
|
|
3750
|
+
}
|
|
3751
|
+
if (!node) {
|
|
3752
|
+
node = parserState.tree.rootNode;
|
|
3753
|
+
}
|
|
3754
|
+
const nodeCaptures = parserState.queries.highlights.captures(node);
|
|
3755
|
+
matches.push(...nodeCaptures);
|
|
3756
|
+
}
|
|
3757
|
+
let injectionRanges = new Map;
|
|
3758
|
+
if (parserState.queries.injections) {
|
|
3759
|
+
const injectionResult = await this.processInjections(parserState);
|
|
3760
|
+
matches.push(...injectionResult.captures);
|
|
3761
|
+
injectionRanges = injectionResult.injectionRanges;
|
|
3762
|
+
}
|
|
3763
|
+
const endQuery = performance.now();
|
|
3764
|
+
const queryTime = endQuery - startQuery;
|
|
3765
|
+
this.performance.queryTimes.push(queryTime);
|
|
3766
|
+
if (this.performance.queryTimes.length > 10) {
|
|
3767
|
+
this.performance.queryTimes.shift();
|
|
3768
|
+
}
|
|
3769
|
+
this.performance.averageQueryTime = this.performance.queryTimes.reduce((acc, time) => acc + time, 0) / this.performance.queryTimes.length;
|
|
3770
|
+
return this.getHighlights(parserState, matches, injectionRanges);
|
|
3771
|
+
}
|
|
3772
|
+
nodeContainsRange(node, range) {
|
|
3773
|
+
return node.startPosition.row <= range.startPosition.row && node.endPosition.row >= range.endPosition.row && (node.startPosition.row < range.startPosition.row || node.startPosition.column <= range.startPosition.column) && (node.endPosition.row > range.endPosition.row || node.endPosition.column >= range.endPosition.column);
|
|
3774
|
+
}
|
|
3775
|
+
getHighlights(parserState, matches, injectionRanges) {
|
|
3776
|
+
const lineHighlights = new Map;
|
|
3777
|
+
const droppedHighlights = new Map;
|
|
3778
|
+
for (const match of matches) {
|
|
3779
|
+
const node = match.node;
|
|
3780
|
+
const startLine = node.startPosition.row;
|
|
3781
|
+
const endLine = node.endPosition.row;
|
|
3782
|
+
const highlight = {
|
|
3783
|
+
startCol: node.startPosition.column,
|
|
3784
|
+
endCol: node.endPosition.column,
|
|
3785
|
+
group: match.name
|
|
3786
|
+
};
|
|
3787
|
+
if (!lineHighlights.has(startLine)) {
|
|
3788
|
+
lineHighlights.set(startLine, new Map);
|
|
3789
|
+
droppedHighlights.set(startLine, new Map);
|
|
3790
|
+
}
|
|
3791
|
+
if (lineHighlights.get(startLine)?.has(node.id)) {
|
|
3792
|
+
droppedHighlights.get(startLine)?.set(node.id, lineHighlights.get(startLine)?.get(node.id));
|
|
3793
|
+
}
|
|
3794
|
+
lineHighlights.get(startLine)?.set(node.id, highlight);
|
|
3795
|
+
if (startLine !== endLine) {
|
|
3796
|
+
for (let line = startLine + 1;line <= endLine; line++) {
|
|
3797
|
+
if (!lineHighlights.has(line)) {
|
|
3798
|
+
lineHighlights.set(line, new Map);
|
|
3799
|
+
}
|
|
3800
|
+
const hl = {
|
|
3801
|
+
startCol: 0,
|
|
3802
|
+
endCol: node.endPosition.column,
|
|
3803
|
+
group: match.name
|
|
3804
|
+
};
|
|
3805
|
+
lineHighlights.get(line)?.set(node.id, hl);
|
|
3806
|
+
}
|
|
3807
|
+
}
|
|
3808
|
+
}
|
|
3809
|
+
return {
|
|
3810
|
+
highlights: Array.from(lineHighlights.entries()).map(([line, lineHighlights2]) => ({
|
|
3811
|
+
line,
|
|
3812
|
+
highlights: Array.from(lineHighlights2.values()),
|
|
3813
|
+
droppedHighlights: droppedHighlights.get(line) ? Array.from(droppedHighlights.get(line).values()) : []
|
|
3814
|
+
}))
|
|
3815
|
+
};
|
|
3816
|
+
}
|
|
3817
|
+
getSimpleHighlights(matches, injectionRanges) {
|
|
3818
|
+
const highlights = [];
|
|
3819
|
+
const flatInjectionRanges = [];
|
|
3820
|
+
for (const [lang, ranges] of injectionRanges.entries()) {
|
|
3821
|
+
for (const range of ranges) {
|
|
3822
|
+
flatInjectionRanges.push({ ...range, lang });
|
|
3823
|
+
}
|
|
3824
|
+
}
|
|
3825
|
+
for (const match of matches) {
|
|
3826
|
+
const node = match.node;
|
|
3827
|
+
let isInjection = false;
|
|
3828
|
+
let injectionLang;
|
|
3829
|
+
let containsInjection = false;
|
|
3830
|
+
for (const injRange of flatInjectionRanges) {
|
|
3831
|
+
if (node.startIndex >= injRange.start && node.endIndex <= injRange.end) {
|
|
3832
|
+
isInjection = true;
|
|
3833
|
+
injectionLang = injRange.lang;
|
|
3834
|
+
break;
|
|
3835
|
+
} else if (node.startIndex <= injRange.start && node.endIndex >= injRange.end) {
|
|
3836
|
+
containsInjection = true;
|
|
3837
|
+
break;
|
|
3838
|
+
}
|
|
3839
|
+
}
|
|
3840
|
+
const matchQuery = match._injectedQuery;
|
|
3841
|
+
const patternProperties = matchQuery?.setProperties?.[match.patternIndex];
|
|
3842
|
+
const concealValue = patternProperties?.conceal ?? match.setProperties?.conceal;
|
|
3843
|
+
const concealLines = patternProperties?.conceal_lines ?? match.setProperties?.conceal_lines;
|
|
3844
|
+
const meta = {};
|
|
3845
|
+
if (isInjection && injectionLang) {
|
|
3846
|
+
meta.isInjection = true;
|
|
3847
|
+
meta.injectionLang = injectionLang;
|
|
3848
|
+
}
|
|
3849
|
+
if (containsInjection) {
|
|
3850
|
+
meta.containsInjection = true;
|
|
3851
|
+
}
|
|
3852
|
+
if (concealValue !== undefined) {
|
|
3853
|
+
meta.conceal = concealValue;
|
|
3854
|
+
}
|
|
3855
|
+
if (concealLines !== undefined) {
|
|
3856
|
+
meta.concealLines = concealLines;
|
|
3857
|
+
}
|
|
3858
|
+
if (Object.keys(meta).length > 0) {
|
|
3859
|
+
highlights.push([node.startIndex, node.endIndex, match.name, meta]);
|
|
3860
|
+
} else {
|
|
3861
|
+
highlights.push([node.startIndex, node.endIndex, match.name]);
|
|
3862
|
+
}
|
|
3863
|
+
}
|
|
3864
|
+
highlights.sort((a, b) => a[0] - b[0]);
|
|
3865
|
+
return highlights;
|
|
3866
|
+
}
|
|
3867
|
+
async handleResetBuffer(bufferId, version, content) {
|
|
3868
|
+
const parserState = this.bufferParsers.get(bufferId);
|
|
3869
|
+
if (!parserState) {
|
|
3870
|
+
return { warning: "No parser state found for buffer" };
|
|
3871
|
+
}
|
|
3872
|
+
parserState.content = content;
|
|
3873
|
+
const newTree = parserState.parser.parse(content);
|
|
3874
|
+
if (!newTree) {
|
|
3875
|
+
return { error: "Failed to parse buffer during reset" };
|
|
3876
|
+
}
|
|
3877
|
+
parserState.tree = newTree;
|
|
3878
|
+
const matches = parserState.queries.highlights.captures(parserState.tree.rootNode);
|
|
3879
|
+
let injectionRanges = new Map;
|
|
3880
|
+
if (parserState.queries.injections) {
|
|
3881
|
+
const injectionResult = await this.processInjections(parserState);
|
|
3882
|
+
matches.push(...injectionResult.captures);
|
|
3883
|
+
injectionRanges = injectionResult.injectionRanges;
|
|
3884
|
+
}
|
|
3885
|
+
return this.getHighlights(parserState, matches, injectionRanges);
|
|
3886
|
+
}
|
|
3887
|
+
disposeBuffer(bufferId) {
|
|
3888
|
+
const parserState = this.bufferParsers.get(bufferId);
|
|
3889
|
+
if (!parserState) {
|
|
3890
|
+
return;
|
|
3891
|
+
}
|
|
3892
|
+
parserState.tree.delete();
|
|
3893
|
+
parserState.parser.delete();
|
|
3894
|
+
this.bufferParsers.delete(bufferId);
|
|
3895
|
+
}
|
|
3896
|
+
async handleOneShotHighlight(content, filetype, messageId) {
|
|
3897
|
+
const reusableState = await this.getReusableParser(filetype);
|
|
3898
|
+
if (!reusableState) {
|
|
3899
|
+
self2.postMessage({
|
|
3900
|
+
type: "ONESHOT_HIGHLIGHT_RESPONSE",
|
|
3901
|
+
messageId,
|
|
3902
|
+
hasParser: false,
|
|
3903
|
+
warning: `No parser available for filetype ${filetype}`
|
|
3904
|
+
});
|
|
3905
|
+
return;
|
|
3906
|
+
}
|
|
3907
|
+
const parseContent = filetype === "markdown" && content.endsWith("```") ? content + `
|
|
3908
|
+
` : content;
|
|
3909
|
+
const tree = reusableState.parser.parse(parseContent);
|
|
3910
|
+
if (!tree) {
|
|
3911
|
+
self2.postMessage({
|
|
3912
|
+
type: "ONESHOT_HIGHLIGHT_RESPONSE",
|
|
3913
|
+
messageId,
|
|
3914
|
+
hasParser: false,
|
|
3915
|
+
error: "Failed to parse content"
|
|
3916
|
+
});
|
|
3917
|
+
return;
|
|
3918
|
+
}
|
|
3919
|
+
try {
|
|
3920
|
+
const matches = reusableState.filetypeParser.queries.highlights.captures(tree.rootNode);
|
|
3921
|
+
let injectionRanges = new Map;
|
|
3922
|
+
if (reusableState.filetypeParser.queries.injections) {
|
|
3923
|
+
const parserState = {
|
|
3924
|
+
parser: reusableState.parser,
|
|
3925
|
+
tree,
|
|
3926
|
+
queries: reusableState.filetypeParser.queries,
|
|
3927
|
+
filetype,
|
|
3928
|
+
content,
|
|
3929
|
+
injectionMapping: reusableState.filetypeParser.injectionMapping
|
|
3930
|
+
};
|
|
3931
|
+
const injectionResult = await this.processInjections(parserState);
|
|
3932
|
+
matches.push(...injectionResult.captures);
|
|
3933
|
+
injectionRanges = injectionResult.injectionRanges;
|
|
3934
|
+
}
|
|
3935
|
+
const highlights = this.getSimpleHighlights(matches, injectionRanges);
|
|
3936
|
+
self2.postMessage({
|
|
3937
|
+
type: "ONESHOT_HIGHLIGHT_RESPONSE",
|
|
3938
|
+
messageId,
|
|
3939
|
+
hasParser: true,
|
|
3940
|
+
highlights
|
|
3941
|
+
});
|
|
3942
|
+
} finally {
|
|
3943
|
+
tree.delete();
|
|
3944
|
+
}
|
|
3945
|
+
}
|
|
3946
|
+
async updateDataPath(dataPath) {
|
|
3947
|
+
this.dataPath = dataPath;
|
|
3948
|
+
this.tsDataPath = path2.join(dataPath, "tree-sitter");
|
|
3949
|
+
try {
|
|
3950
|
+
await mkdir2(path2.join(this.tsDataPath, "languages"), { recursive: true });
|
|
3951
|
+
await mkdir2(path2.join(this.tsDataPath, "queries"), { recursive: true });
|
|
3952
|
+
} catch (error) {
|
|
3953
|
+
throw new Error(`Failed to update data path: ${error}`);
|
|
3954
|
+
}
|
|
3955
|
+
}
|
|
3956
|
+
async clearCache() {
|
|
3957
|
+
if (!this.dataPath || !this.tsDataPath) {
|
|
3958
|
+
throw new Error("No data path configured");
|
|
3959
|
+
}
|
|
3960
|
+
const { rm } = await import("fs/promises");
|
|
3961
|
+
try {
|
|
3962
|
+
const treeSitterPath = path2.join(this.dataPath, "tree-sitter");
|
|
3963
|
+
await rm(treeSitterPath, { recursive: true, force: true });
|
|
3964
|
+
await mkdir2(path2.join(treeSitterPath, "languages"), { recursive: true });
|
|
3965
|
+
await mkdir2(path2.join(treeSitterPath, "queries"), { recursive: true });
|
|
3966
|
+
this.filetypeParsers.clear();
|
|
3967
|
+
this.filetypeParserPromises.clear();
|
|
3968
|
+
this.reusableParsers.clear();
|
|
3969
|
+
this.reusableParserPromises.clear();
|
|
3970
|
+
} catch (error) {
|
|
3971
|
+
throw new Error(`Failed to clear cache: ${error}`);
|
|
3972
|
+
}
|
|
3973
|
+
}
|
|
3974
|
+
}
|
|
3975
|
+
if (!isMainThread) {
|
|
3976
|
+
let logMessage = function(type, ...args2) {
|
|
3977
|
+
self2.postMessage({
|
|
3978
|
+
type: "WORKER_LOG",
|
|
3979
|
+
logType: type,
|
|
3980
|
+
data: args2
|
|
3981
|
+
});
|
|
3982
|
+
};
|
|
3983
|
+
const worker = new ParserWorker;
|
|
3984
|
+
console.log = (...args2) => logMessage("log", ...args2);
|
|
3985
|
+
console.error = (...args2) => logMessage("error", ...args2);
|
|
3986
|
+
console.warn = (...args2) => logMessage("warn", ...args2);
|
|
3987
|
+
self2.onmessage = async (e) => {
|
|
3988
|
+
const { type, bufferId, version, content, filetype, edits, filetypeParser, messageId, dataPath } = e.data;
|
|
3989
|
+
try {
|
|
3990
|
+
switch (type) {
|
|
3991
|
+
case "INIT":
|
|
3992
|
+
try {
|
|
3993
|
+
await worker.initialize({ dataPath });
|
|
3994
|
+
self2.postMessage({ type: "INIT_RESPONSE" });
|
|
3995
|
+
} catch (error) {
|
|
3996
|
+
self2.postMessage({
|
|
3997
|
+
type: "INIT_RESPONSE",
|
|
3998
|
+
error: error instanceof Error ? error.stack || error.message : String(error)
|
|
3999
|
+
});
|
|
4000
|
+
}
|
|
4001
|
+
break;
|
|
4002
|
+
case "ADD_FILETYPE_PARSER":
|
|
4003
|
+
worker.addFiletypeParser(filetypeParser);
|
|
4004
|
+
break;
|
|
4005
|
+
case "PRELOAD_PARSER":
|
|
4006
|
+
const maybeParser = await worker.preloadParser(filetype);
|
|
4007
|
+
self2.postMessage({ type: "PRELOAD_PARSER_RESPONSE", messageId, hasParser: !!maybeParser });
|
|
4008
|
+
break;
|
|
4009
|
+
case "INITIALIZE_PARSER":
|
|
4010
|
+
await worker.handleInitializeParser(bufferId, version, content, filetype, messageId);
|
|
4011
|
+
break;
|
|
4012
|
+
case "HANDLE_EDITS":
|
|
4013
|
+
const response = await worker.handleEdits(bufferId, content, edits);
|
|
4014
|
+
if (response.highlights && response.highlights.length > 0) {
|
|
4015
|
+
self2.postMessage({ type: "HIGHLIGHT_RESPONSE", bufferId, version, ...response });
|
|
4016
|
+
} else if (response.warning) {
|
|
4017
|
+
self2.postMessage({ type: "WARNING", bufferId, warning: response.warning });
|
|
4018
|
+
} else if (response.error) {
|
|
4019
|
+
self2.postMessage({ type: "ERROR", bufferId, error: response.error });
|
|
4020
|
+
}
|
|
4021
|
+
break;
|
|
4022
|
+
case "GET_PERFORMANCE":
|
|
4023
|
+
self2.postMessage({ type: "PERFORMANCE_RESPONSE", performance: worker.performance, messageId });
|
|
4024
|
+
break;
|
|
4025
|
+
case "RESET_BUFFER":
|
|
4026
|
+
const resetResponse = await worker.handleResetBuffer(bufferId, version, content);
|
|
4027
|
+
if (resetResponse.highlights && resetResponse.highlights.length > 0) {
|
|
4028
|
+
self2.postMessage({ type: "HIGHLIGHT_RESPONSE", bufferId, version, ...resetResponse });
|
|
4029
|
+
} else if (resetResponse.warning) {
|
|
4030
|
+
self2.postMessage({ type: "WARNING", bufferId, warning: resetResponse.warning });
|
|
4031
|
+
} else if (resetResponse.error) {
|
|
4032
|
+
self2.postMessage({ type: "ERROR", bufferId, error: resetResponse.error });
|
|
4033
|
+
}
|
|
4034
|
+
break;
|
|
4035
|
+
case "DISPOSE_BUFFER":
|
|
4036
|
+
worker.disposeBuffer(bufferId);
|
|
4037
|
+
self2.postMessage({ type: "BUFFER_DISPOSED", bufferId });
|
|
4038
|
+
break;
|
|
4039
|
+
case "ONESHOT_HIGHLIGHT":
|
|
4040
|
+
await worker.handleOneShotHighlight(content, filetype, messageId);
|
|
4041
|
+
break;
|
|
4042
|
+
case "UPDATE_DATA_PATH":
|
|
4043
|
+
try {
|
|
4044
|
+
await worker.updateDataPath(dataPath);
|
|
4045
|
+
self2.postMessage({ type: "UPDATE_DATA_PATH_RESPONSE", messageId });
|
|
4046
|
+
} catch (error) {
|
|
4047
|
+
self2.postMessage({
|
|
4048
|
+
type: "UPDATE_DATA_PATH_RESPONSE",
|
|
4049
|
+
messageId,
|
|
4050
|
+
error: error instanceof Error ? error.message : String(error)
|
|
4051
|
+
});
|
|
4052
|
+
}
|
|
4053
|
+
break;
|
|
4054
|
+
case "CLEAR_CACHE":
|
|
4055
|
+
try {
|
|
4056
|
+
await worker.clearCache();
|
|
4057
|
+
self2.postMessage({ type: "CLEAR_CACHE_RESPONSE", messageId });
|
|
4058
|
+
} catch (error) {
|
|
4059
|
+
self2.postMessage({
|
|
4060
|
+
type: "CLEAR_CACHE_RESPONSE",
|
|
4061
|
+
messageId,
|
|
4062
|
+
error: error instanceof Error ? error.message : String(error)
|
|
4063
|
+
});
|
|
4064
|
+
}
|
|
4065
|
+
break;
|
|
4066
|
+
default:
|
|
4067
|
+
self2.postMessage({
|
|
4068
|
+
type: "ERROR",
|
|
4069
|
+
bufferId,
|
|
4070
|
+
error: `Unknown message type: ${type}`
|
|
4071
|
+
});
|
|
4072
|
+
}
|
|
4073
|
+
} catch (error) {
|
|
4074
|
+
self2.postMessage({
|
|
4075
|
+
type: "ERROR",
|
|
4076
|
+
bufferId,
|
|
4077
|
+
error: error instanceof Error ? error.stack || error.message : String(error)
|
|
4078
|
+
});
|
|
4079
|
+
}
|
|
4080
|
+
};
|
|
4081
|
+
}
|