diff --git a/.cirrus.yml b/.cirrus.yml index f7159e7a55..3bf5c134e1 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -1,5 +1,5 @@ env: - PYTHON_VERSION: 3.10 + PYTHON_VERSION: 3.12 GITHUB_TOKEN: ENCRYPTED[!b0ff4671044672be50914a3a10b49af642bd8e0e681a6f4e5855ec5230a5cf9afbc53d9e90239b8d2c79455f014f383f!] # The above token, is a GitHub API Token, that allows us to download RipGrep without concern of API limits @@ -86,6 +86,7 @@ arm_linux_task: libnss3 xvfb - gem install fpm + - python3 -m pip install setuptools - git submodule init - git submodule update - sed -i -e "s/[0-9]*-dev/`date -u +%Y%m%d%H`/g" package.json @@ -133,6 +134,7 @@ silicon_mac_task: ROLLING_UPLOAD_TOKEN: ENCRYPTED[690950798401ec3715e9d20ac29a0859d3c58097038081ff6afeaf4721e661672d34eb952d8a6442bc7410821ab8545a] prepare_script: - brew install node@16 yarn git python@$PYTHON_VERSION + - python3 -m pip install setuptools - git submodule init - git submodule update - ln -s /opt/homebrew/bin/python$PYTHON_VERSION /opt/homebrew/bin/python diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f56ab7a977..3173604236 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,7 +10,7 @@ on: env: # Variables needed for build information GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - PYTHON_VERSION: '3.11' + PYTHON_VERSION: '3.12' NODE_VERSION: 16 ROLLING_UPLOAD_TOKEN: ${{ secrets.ROLLING_RELEASE_UPLOAD_TOKEN }} # Below variables allow us to quickly control visual tests for each platform @@ -22,7 +22,7 @@ jobs: build: strategy: matrix: - os: [ ubuntu-latest, windows-latest, macos-latest ] + os: [ ubuntu-20.04, windows-latest, macos-latest ] fail-fast: false runs-on: ${{ matrix.os }} @@ -40,6 +40,12 @@ jobs: with: python-version: ${{ env.PYTHON_VERSION }} + - name: Install Python setuptools + # This is needed for Python 3.12+, since many versions of node-gyp + # are incompatible with Python 3.12+, which no-longer ships 'distutils' + # out of the box. 'setuptools' package provides 'distutils'. + run: python3 -m pip install setuptools + - name: Setup Git Submodule run: | git submodule init @@ -92,7 +98,7 @@ jobs: TEAM_ID: ${{ secrets.TEAM_ID }} uses: nick-fields/retry@943e742917ac94714d2f408a0e8320f2d1fcafcd with: - timeout_minutes: 30 + timeout_minutes: 45 max_attempts: 3 retry_on: error command: yarn dist @@ -101,7 +107,7 @@ jobs: if: ${{ runner.os == 'macOS' && github.event_name != 'push' }} uses: nick-fields/retry@943e742917ac94714d2f408a0e8320f2d1fcafcd with: - timeout_minutes: 30 + timeout_minutes: 45 max_attempts: 3 retry_on: error command: yarn dist diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml index a4805e2ff3..a6899e8bca 100644 --- a/.github/workflows/documentation.yml +++ b/.github/workflows/documentation.yml @@ -27,6 +27,12 @@ jobs: with: node-version: ${{ matrix.node-version }} + - name: Install Python setuptools + # This is needed for Python 3.12+, since many versions of node-gyp + # are incompatible with Python 3.12+, which no-longer ships 'distutils' + # out of the box. 'setuptools' package provides 'distutils'. + run: python3 -m pip install setuptools + - name: Install Dependencies run: yarn install diff --git a/.github/workflows/editor-tests.yml b/.github/workflows/editor-tests.yml index c96f6dbe39..18a6c18839 100644 --- a/.github/workflows/editor-tests.yml +++ b/.github/workflows/editor-tests.yml @@ -28,6 +28,12 @@ jobs: with: node-version: 16 + - name: Install Python setuptools + # This is needed for Python 3.12+, since many versions of node-gyp + # are incompatible with Python 3.12+, which no-longer ships 'distutils' + # out of the box. 'setuptools' package provides 'distutils'. + run: python3 -m pip install setuptools + - name: Install Dependencies run: yarn install diff --git a/.github/workflows/package-tests-linux.yml b/.github/workflows/package-tests-linux.yml index 6cf60e6ca8..ab7659fb76 100644 --- a/.github/workflows/package-tests-linux.yml +++ b/.github/workflows/package-tests-linux.yml @@ -22,6 +22,12 @@ jobs: with: node-version: 16 + - name: Install Python setuptools + # This is needed for Python 3.12+, since many versions of node-gyp + # are incompatible with Python 3.12+, which no-longer ships 'distutils' + # out of the box. 'setuptools' package provides 'distutils'. + run: python3 -m pip install setuptools + - name: Install Dependencies run: yarn install diff --git a/.github/workflows/validate-wasm-grammar-prs.yml b/.github/workflows/validate-wasm-grammar-prs.yml new file mode 100644 index 0000000000..ee827ac093 --- /dev/null +++ b/.github/workflows/validate-wasm-grammar-prs.yml @@ -0,0 +1,36 @@ +name: Validate WASM Grammar PR Changes +# Since we now want to enforce the rule that any changes to a WASM grammar binary +# file, is accompanied by a change to the `parserSource` key within the +# `grammar.cson` file. This GHA will preform this check for us. + +on: + pull_request: + paths: + - '**.wasm' + +jobs: + validate: + runs-on: ubuntu-latest + steps: + - name: Checkout the Latest Code + uses: actions/checkout@v3 + with: + fetch-depth: 0 + # Make sure we get all commits, so that we can compare to early commits + + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version: 16 + + - name: Install Python setuptools + # This is needed for Python 3.12+, since many versions of node-gyp + # are incompatible with Python 3.12+, which no-longer ships 'distutils' + # out of the box. 'setuptools' package provides 'distutils'. + run: python3 -m pip install setuptools + + - name: Install dependencies + run: yarn install + + - name: Run Validation Script + run: node ./script/validate-wasm-grammar-prs.js diff --git a/CHANGELOG.md b/CHANGELOG.md index f6654dacd8..23ae71c2e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,8 +5,59 @@ - Project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html) ## [Unreleased] + +## 1.110.0 + +- Made the modification of `editor.preferredLineLength` configurable within `wrap-guide` when changing `wrap-guide.columns` +- Fixed Snippets from `language-php` that would lose the `$` character +- Fixed a condition where an invalid config may crash Pulsar before fully starting up, but not registering that it's crashed +- Reduced error notifications that may appear from `autocomplete-html` when handling EJS files +- Fixed macOS binary signing after moving over to GitHub Actions for CI +- Updated PPM to a newer `node-gyp`, allowing newer versions of C/C++ compiler toolchains and Python to be used (also dropped support for Python 2.x!) +- Fully decaffed the entire PPM codebase - Added a new autocomplete API that does not uses prefixes and instead declares the range it'll replace (better LSP support) +### Pulsar +- Added: [wrap-guide] Make the automatic modification of `editor.preferredLineLength` configurable [@confused-Techie](https://github.com/pulsar-edit/pulsar/pull/754) +- Fixed: Fixed filtering of suggestions with ranges [@mauricioszabo](https://github.com/pulsar-edit/pulsar/pull/762) +- Added: Tree-sitter running fixes for September [@savetheclocktower](https://github.com/pulsar-edit/pulsar/pull/735) +- Added: Add escapement to variable literals within php snippets [@Spiker985](https://github.com/pulsar-edit/pulsar/pull/758) +- Added: [core] Handle invalid config on load [@confused-Techie](https://github.com/pulsar-edit/pulsar/pull/750) +- Added: [autocomplete-html] Wrap completions in `try/catch` handler [@confused-Techie](https://github.com/pulsar-edit/pulsar/pull/753) +- Bumped: Update dependency postcss to v8.4.31 [SECURITY] [@renovate](https://github.com/pulsar-edit/pulsar/pull/752) +- Fixed: CI: Sign macOS binaries for branch pushes, not PRs [@DeeDeeG](https://github.com/pulsar-edit/pulsar/pull/745) +- Fixed: CI: Use Python 3.11 to fix macOS signing [@DeeDeeG](https://github.com/pulsar-edit/pulsar/pull/743) +- Fixed: [meta] Fix Windows Builds in CI [@confused-Techie](https://github.com/pulsar-edit/pulsar/pull/738) +- Bumped: ppm: Update ppm submodule to commit a2ade745bfbc5f [@DeeDeeG](https://github.com/pulsar-edit/pulsar/pull/725) +- Added: Making autocomplete-plus work to replace ranges [@mauricioszabo](https://github.com/pulsar-edit/pulsar/pull/479) + +### ppm +- Bumped: Update npm and node-gyp, for macOS signing fix [@DeeDeeG](https://github.com/pulsar-edit/ppm/pull/94) +- Removed: Remove remnants of Coffeescript building [@2colours](https://github.com/pulsar-edit/ppm/pull/92) +- Added: Update unpublishing wording [@Daeraxa](https://github.com/pulsar-edit/ppm/pull/90) +- Added: Migrate to `second-mate` and remove `first-mate` [@confused-Techie](https://github.com/pulsar-edit/ppm/pull/86) +- Added: Cleanup `visualStudioIsInstalled()` [@confused-Techie](https://github.com/pulsar-edit/ppm/pull/85) +- Decafed: Decaf Source [@confused-Techie](https://github.com/pulsar-edit/ppm/pull/84) +- Fixed: Make `postinstall` scripts work on Windows with spaces in cwd path [@confused-Techie](https://github.com/pulsar-edit/ppm/pull/83) +- Added: Move Spec Decaf PRs into `master` [@confused-Techie](https://github.com/pulsar-edit/ppm/pull/81) +- Bumped: Switch to our npm fork, to get newer node-gyp (node-gyp 9.x) [@DeeDeeG](https://github.com/pulsar-edit/ppm/pull/79) +- Decafed: Decaffeinate remaining spec files from list-spec on [@GuilleW and @2colours](https://github.com/pulsar-edit/ppm/pull/78) +- Decafed: Decaffeinate link spec [@GuilleW and @2colours](https://github.com/pulsar-edit/ppm/pull/77) +- Decafed: Decaffeinate install spec [@GuilleW and @2colours](https://github.com/pulsar-edit/ppm/pull/76) +- Decafed: Decaffeinate init spec [@GuilleW and @2colours](https://github.com/pulsar-edit/ppm/pull/75) +- Decafed: Decaffeinate help spec [@GuilleW and @2colours](https://github.com/pulsar-edit/ppm/pull/74) +- Decafed: Decaffeinate featured spec [@GuilleW and @2colours](https://github.com/pulsar-edit/ppm/pull/73) +- Decafed: Decaffeinate enable spec [@GuilleW and @2colours](https://github.com/pulsar-edit/ppm/pull/72) +- Decafed: Decaffeinate docs spec [@GuilleW and @2colours](https://github.com/pulsar-edit/ppm/pull/71) +- Decafed: Decaffeinate disable spec [@GuilleW and @2colours](https://github.com/pulsar-edit/ppm/pull/70) +- Decafed: Decaffeinate develop spec [@GuilleW and @2colours](https://github.com/pulsar-edit/ppm/pull/69) +- Decafed: Decaffeinate config spec [@GuilleW and @2colours](https://github.com/pulsar-edit/ppm/pull/68) +- Decafed: Decaffeinate command spec [@GuilleW and @2colours](https://github.com/pulsar-edit/ppm/pull/67) +- Decafed: Decaffeinate clean spec [@GuilleW and @2colours](https://github.com/pulsar-edit/ppm/pull/66) +- Decafed: Decaffeinate ci spec [@GuilleW and @2colours](https://github.com/pulsar-edit/ppm/pull/65) +- Decafed: Decaffeinate apm cli spec [@GuilleW and @2colours](https://github.com/pulsar-edit/ppm/pull/64) +- Decafed: Decaffeinate spec helper (updated) [@GuilleW and @2colours](https://github.com/pulsar-edit/ppm/pull/63) + ## 1.109.0 - Fixed a race condition that could cause `autocomplete-plus` to ignore user input. diff --git a/package.json b/package.json index ecf0a368fd..bbac58f2a3 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "pulsar", "author": "Pulsar-Edit ", "productName": "Pulsar", - "version": "1.109.0-dev", + "version": "1.110.0-dev", "description": "A Community-led Hyper-Hackable Text Editor", "branding": { "id": "pulsar", @@ -63,6 +63,7 @@ "deprecation-cop": "file:packages/deprecation-cop", "dev-live-reload": "file:packages/dev-live-reload", "document-register-element": "https://github.com/pulsar-edit/document-register-element.git#1f5868f", + "dompurify": "^3.0.6", "encoding-selector": "file:packages/encoding-selector", "etch": "0.14.1", "event-kit": "^2.5.3", @@ -73,12 +74,10 @@ "fs-admin": "0.19.0", "fs-plus": "^3.1.1", "fstream": "1.0.12", - "functional-red-black-tree": "^1.0.1", "fuzzy-finder": "file:packages/fuzzy-finder", "git-diff": "file:packages/git-diff", - "git-utils": "5.7.1", + "git-utils": "^5.7.3", "github": "https://codeload.github.com/pulsar-edit/github/tar.gz/refs/tags/v0.36.17-pretranspiled", - "glob": "^7.1.1", "go-to-line": "file:packages/go-to-line", "grammar-selector": "file:packages/grammar-selector", "grim": "2.0.3", @@ -149,7 +148,6 @@ "pathwatcher": "^8.1.2", "postcss": "8.4.31", "postcss-selector-parser": "6.0.4", - "property-accessors": "^1.1.3", "pulsar-updater": "file:packages/pulsar-updater", "resolve": "1.18.1", "scandal": "^3.2.0", diff --git a/packages/autocomplete-plus/lib/autocomplete-manager.js b/packages/autocomplete-plus/lib/autocomplete-manager.js index c4fc1af190..7467a57ec0 100644 --- a/packages/autocomplete-plus/lib/autocomplete-manager.js +++ b/packages/autocomplete-plus/lib/autocomplete-manager.js @@ -373,14 +373,15 @@ class AutocompleteManager { const text = (suggestion.snippet || suggestion.text) const suggestionPrefix = suggestion.replacementPrefix != null ? suggestion.replacementPrefix : prefix const prefixIsEmpty = !suggestionPrefix || suggestionPrefix === ' ' - const firstCharIsMatch = !prefixIsEmpty && suggestionPrefix[0].toLowerCase() === text[0].toLowerCase() if (prefixIsEmpty) { results.push(suggestion) - } - if (firstCharIsMatch && (score = atom.ui.fuzzyMatcher.score(text, suggestionPrefix)) > 0) { - suggestion.score = score * suggestion.sortScore - results.push(suggestion) + } else { + const keepMatching = suggestion.ranges || suggestionPrefix[0].toLowerCase() === text[0].toLowerCase() + if (keepMatching && (score = atom.ui.fuzzyMatcher.score(text, suggestionPrefix)) > 0) { + suggestion.score = score * suggestion.sortScore + results.push(suggestion) + } } } diff --git a/packages/autocomplete-plus/lib/suggestion-list-element.js b/packages/autocomplete-plus/lib/suggestion-list-element.js index 541ff35568..f8ba267151 100644 --- a/packages/autocomplete-plus/lib/suggestion-list-element.js +++ b/packages/autocomplete-plus/lib/suggestion-list-element.js @@ -1,8 +1,6 @@ const {CompositeDisposable} = require('atom') const SnippetParser = require('./snippet-parser') const {isString} = require('./type-helpers') -const {marked} = require('marked') -const createDOMPurify = require('dompurify') const createSuggestionFrag = () => { const frag = document.createDocumentFragment() @@ -133,15 +131,13 @@ module.exports = class SuggestionListElement { if (item.descriptionMarkdown && item.descriptionMarkdown.length > 0) { this.descriptionContainer.style.display = 'block' - this.descriptionContent.innerHTML = createDOMPurify().sanitize( - marked(item.descriptionMarkdown, { - gfm: true, + this.descriptionContent.innerHTML = atom.ui.markdown.render( + item.descriptionMarkdown, + { breaks: true, - sanitize: false, - mangle: false, - headerIds: false - }) - ) + renderMode: "fragment" + } + ); this.setDescriptionMoreLink(item) } else if (item.description && item.description.length > 0) { this.descriptionContainer.style.display = 'block' diff --git a/packages/autocomplete-plus/package.json b/packages/autocomplete-plus/package.json index 4780b8d511..990c8a4cf1 100644 --- a/packages/autocomplete-plus/package.json +++ b/packages/autocomplete-plus/package.json @@ -10,9 +10,7 @@ }, "dependencies": { "atom-slick": "^2.0.0", - "dompurify": "^3.0.4", "grim": "^2.0.1", - "marked": "^5.1.1", "minimatch": "^3.0.3", "selector-kit": "^0.1.0", "stable": "^0.1.8", diff --git a/packages/autocomplete-plus/spec/provider-api-spec.js b/packages/autocomplete-plus/spec/provider-api-spec.js index f1c04287eb..ff721172f5 100644 --- a/packages/autocomplete-plus/spec/provider-api-spec.js +++ b/packages/autocomplete-plus/spec/provider-api-spec.js @@ -327,5 +327,25 @@ describe('Provider API', () => { expect(editor.getText()).toEqual("ohai, world\n") }) + + it('ignores `prefix` if `range` is present', async () => { + testProvider = { + scopeSelector: '.source.js', + filterSuggestions: true, + getSuggestions (options) { + return [ + {text: 'notmatch/foololohairange', ranges: [[[0, 0], [0, 5]]]}, + {text: 'notmatch/foololohaiprefix'}, + {text: 'foololohaiprefix2'} + ] + } + } + registration = atom.packages.serviceHub.provide('autocomplete.provider', '5.0.0', testProvider) + editor.insertText('foololohai') + await triggerAutocompletion() + expect(document.querySelector('autocomplete-suggestion-list').innerText).toMatch(/notmatch\/foololohairange/) + expect(document.querySelector('autocomplete-suggestion-list').innerText).toMatch(/foololohaiprefix2/) + expect(document.querySelector('autocomplete-suggestion-list').innerText).toNotMatch(/notmatch\/foololohaiprefix/) + }) }) }) diff --git a/packages/base16-tomorrow-dark-theme/styles/syntax-legacy/_base.less b/packages/base16-tomorrow-dark-theme/styles/syntax-legacy/_base.less index d824a41ba1..e7eab57a6f 100644 --- a/packages/base16-tomorrow-dark-theme/styles/syntax-legacy/_base.less +++ b/packages/base16-tomorrow-dark-theme/styles/syntax-legacy/_base.less @@ -186,7 +186,7 @@ } .syntax--meta { - &.syntax--class { + &.syntax--class:not(.syntax--block) { color: @yellow; &.syntax--body { diff --git a/packages/base16-tomorrow-light-theme/styles/syntax-legacy/_base.less b/packages/base16-tomorrow-light-theme/styles/syntax-legacy/_base.less index d824a41ba1..e7eab57a6f 100644 --- a/packages/base16-tomorrow-light-theme/styles/syntax-legacy/_base.less +++ b/packages/base16-tomorrow-light-theme/styles/syntax-legacy/_base.less @@ -186,7 +186,7 @@ } .syntax--meta { - &.syntax--class { + &.syntax--class:not(.syntax--block) { color: @yellow; &.syntax--body { diff --git a/packages/deprecation-cop/lib/deprecation-cop-view.js b/packages/deprecation-cop/lib/deprecation-cop-view.js index c716ff96ac..7523d4a9f6 100644 --- a/packages/deprecation-cop/lib/deprecation-cop-view.js +++ b/packages/deprecation-cop/lib/deprecation-cop-view.js @@ -6,7 +6,6 @@ import { CompositeDisposable } from 'atom'; import etch from 'etch'; import fs from 'fs-plus'; import Grim from 'grim'; -import { marked } from 'marked'; import path from 'path'; import { shell } from 'electron'; @@ -138,7 +137,7 @@ export default class DeprecationCopView {
{this.renderIssueURLIfNeeded( packageName, @@ -218,7 +217,7 @@ export default class DeprecationCopView {
{this.renderSelectorIssueURLIfNeeded( packageName, diff --git a/packages/deprecation-cop/package.json b/packages/deprecation-cop/package.json index 5b80ebef7f..7f10e45cd2 100644 --- a/packages/deprecation-cop/package.json +++ b/packages/deprecation-cop/package.json @@ -12,7 +12,6 @@ "etch": "0.9.0", "fs-plus": "^3.0.0", "grim": "^2.0.1", - "marked": "5.0.3", "underscore-plus": "^1.7.0" }, "consumedServices": { diff --git a/packages/language-c/grammars/tree-sitter-c/highlights.scm b/packages/language-c/grammars/tree-sitter-c/highlights.scm index a85ee59771..96dccf2de6 100644 --- a/packages/language-c/grammars/tree-sitter-c/highlights.scm +++ b/packages/language-c/grammars/tree-sitter-c/highlights.scm @@ -43,18 +43,18 @@ (type_identifier) @_IGNORE_ (#set! capture.final true)) -(primitive_type) @storage.type.builtin.c -(type_identifier) @storage.type.other.c +(primitive_type) @support.type.builtin.c +(type_identifier) @support.type.other.c ; These types are all reserved words; if we see an identifier with this name, ; it must be a type. -((identifier) @storage.type.builtin.c - (#match? @storage.type.builtin.c "^(char|int|float|double|long)$")) +((identifier) @support.type.builtin.c + (#match? @support.type.builtin.c "^(char|int|float|double|long)$")) ; Assume any identifier that ends in `_t` is a type. This convention is not ; always followed, but it's a very strong indicator when it's present. -((identifier) @storage.type.other.c - (#match? @storage.type.other.c "_t$")) +((identifier) @support.type.other.c + (#match? @support.type.other.c "_t$")) [ "enum" diff --git a/packages/language-c/grammars/tree-sitter-cpp/highlights.scm b/packages/language-c/grammars/tree-sitter-cpp/highlights.scm index ed0d2ebc9e..c829a2d2ee 100644 --- a/packages/language-c/grammars/tree-sitter-cpp/highlights.scm +++ b/packages/language-c/grammars/tree-sitter-cpp/highlights.scm @@ -49,24 +49,31 @@ (#set! capture.final true)) -(primitive_type) @storage.type.builtin.cpp +(primitive_type) @support.type.builtin.cpp + +; Type parameters +(template_argument_list + (type_descriptor + type: (type_identifier) @variable.parameter.type.cpp + (#set! capture.final true))) + (class_specifier (type_identifier) @entity.name.class.cpp (#set! capture.final true)) -(type_identifier) @storage.type.other.cpp +(type_identifier) @support.type.other.cpp ; (struct_specifier) @storage.type.cpp ; These types are all reserved words; if we see an identifier with this name, ; it must be a type. -((identifier) @storage.type.builtin.cpp - (#match? @storage.type.builtin.cpp "^(char|int|float|double|long)$")) +((identifier) @support.type.builtin.cpp + (#match? @support.type.builtin.cpp "^(char|int|float|double|long)$")) ; Assume any identifier that ends in `_t` is a type. This convention is not ; always followed, but it's a very strong indicator when it's present. -((identifier) @storage.type.other.cpp - (#match? @storage.type.other.cpp "_t$")) +((identifier) @support.type.other.cpp + (#match? @support.type.other.cpp "_t$")) [ diff --git a/packages/language-shellscript/grammars/modern-tree-sitter-bash.cson b/packages/language-shellscript/grammars/modern-tree-sitter-bash.cson index 4793527f5d..a814a7b1e5 100644 --- a/packages/language-shellscript/grammars/modern-tree-sitter-bash.cson +++ b/packages/language-shellscript/grammars/modern-tree-sitter-bash.cson @@ -21,6 +21,9 @@ firstLineRegex: [ injectionRegex: '(^(bash|BASH)$|sh^|SH^)' treeSitter: + # Grammar generated on 2023-09-22 from commit: + # fd4e40dab883d6456da4d847de8321aee9c80805 + parserSource: 'github:tree-sitter/tree-sitter-bash#fd4e40dab883d6456da4d847de8321aee9c80805' grammar: 'tree-sitter/tree-sitter-bash.wasm' highlightsQuery: 'tree-sitter/highlights.scm' tagsQuery: 'tree-sitter/tags.scm' diff --git a/packages/language-shellscript/grammars/tree-sitter/highlights.scm b/packages/language-shellscript/grammars/tree-sitter/highlights.scm index 2f914eac3c..505d178c86 100644 --- a/packages/language-shellscript/grammars/tree-sitter/highlights.scm +++ b/packages/language-shellscript/grammars/tree-sitter/highlights.scm @@ -68,6 +68,19 @@ (string "\"" @punctuation.definition.string.end.shell (#is? test.last true)) (raw_string) @string.quoted.single.shell +((raw_string) @punctuation.definition.string.begin.shell + (#match? @punctuation.definition.string.begin.shell "^.") + (#set! adjust.startAndEndAroundFirstMatchOf "^.")) +((raw_string) @punctuation.definition.string.end.shell + (#match? @punctuation.definition.string.begin.shell ".$") + (#set! adjust.startAndEndAroundFirstMatchOf ".$")) +(ansi_c_string) @string.quoted.single.dollar.shell +((ansi_c_string) @punctuation.definition.string.begin.shell + (#match? @punctuation.definition.string.begin.shell "^..") + (#set! adjust.startAndEndAroundFirstMatchOf "^..")) +((ansi_c_string) @punctuation.definition.string.end.shell + (#match? @punctuation.definition.string.end.shell ".$") + (#set! adjust.startAndEndAroundFirstMatchOf ".$")) (string (command_substitution) @meta.embedded.line.subshell.shell) diff --git a/packages/language-shellscript/grammars/tree-sitter/tree-sitter-bash.wasm b/packages/language-shellscript/grammars/tree-sitter/tree-sitter-bash.wasm index 00c5404480..769cc61541 100755 Binary files a/packages/language-shellscript/grammars/tree-sitter/tree-sitter-bash.wasm and b/packages/language-shellscript/grammars/tree-sitter/tree-sitter-bash.wasm differ diff --git a/packages/markdown-preview/lib/renderer.js b/packages/markdown-preview/lib/renderer.js index c8a0462835..a0d71420e7 100644 --- a/packages/markdown-preview/lib/renderer.js +++ b/packages/markdown-preview/lib/renderer.js @@ -18,34 +18,85 @@ const emojiFolder = path.join( ) exports.toDOMFragment = async function (text, filePath, grammar, callback) { - if (text == null) { - text = '' - } - const domFragment = render(text, filePath) + text ??= ""; + + if (atom.config.get("markdown-preview.useOriginalParser")) { + const domFragment = render(text, filePath); + + await highlightCodeBlocks(domFragment, grammar, makeAtomEditorNonInteractive); - await highlightCodeBlocks(domFragment, grammar, makeAtomEditorNonInteractive) + return domFragment; - return domFragment + } else { + // We use the new parser! + const domFragment = atom.ui.markdown.render(text, + { + renderMode: "fragment", + filePath: filePath, + breaks: atom.config.get('markdown-preview.breakOnSingleNewline'), + sanitizeAllowUnknownProtocols: atom.config.get('markdown-preview.allowUnsafeProtocols') + } + ); + const domHTMLFragment = atom.ui.markdown.convertToDOM(domFragment); + await atom.ui.markdown.applySyntaxHighlighting(domHTMLFragment, + { + renderMode: "fragment", + syntaxScopeNameFunc: scopeForFenceName, + grammar: grammar + } + ); + + return domHTMLFragment; + } } exports.toHTML = async function (text, filePath, grammar) { - if (text == null) { - text = '' - } - const domFragment = render(text, filePath) - const div = document.createElement('div') + text ??= ""; - div.appendChild(domFragment) - document.body.appendChild(div) + if (atom.config.get("markdown-preview.useOriginalParser")) { + const domFragment = render(text, filePath) + const div = document.createElement('div') - await highlightCodeBlocks(div, grammar, convertAtomEditorToStandardElement) + div.appendChild(domFragment) + document.body.appendChild(div) - const result = div.innerHTML - div.remove() + await highlightCodeBlocks(div, grammar, convertAtomEditorToStandardElement) - return result + const result = div.innerHTML + div.remove() + + return result + } else { + // We use the new parser! + const domFragment = atom.ui.markdown.render(text, + { + renderMode: "full", + filePath: filePath, + breaks: atom.config.get('markdown-preview.breakOnSingleNewline'), + sanitizeAllowUnknownProtocols: atom.config.get('markdown-preview.allowUnsafeProtocols') + } + ); + const domHTMLFragment = atom.ui.markdown.convertToDOM(domFragment); + + const div = document.createElement("div"); + div.appendChild(domHTMLFragment); + document.body.appendChild(div); + + await atom.ui.markdown.applySyntaxHighlighting(div, + { + renderMode: "full", + syntaxScopeNameFunc: scopeForFenceName, + grammar: grammar + } + ); + + const result = div.innerHTML; + div.remove(); + + return result; + } } var render = function (text, filePath) { diff --git a/packages/markdown-preview/package.json b/packages/markdown-preview/package.json index 0767540d13..67134120c8 100644 --- a/packages/markdown-preview/package.json +++ b/packages/markdown-preview/package.json @@ -89,6 +89,11 @@ "description": "Custom comma seperated list of Syntax Language Identifiers to map to any language. See [the README](https://github.com/pulsar-edit/pulsar/tree/master/packages/markdown-preview#readme) for usage.", "type": "string", "default": "" + }, + "useOriginalParser": { + "description": "Wether to use the original Markdown Parser, or the new Pulsar one.", + "type": "boolean", + "default": "true" } } } diff --git a/packages/notifications/lib/notification-element.js b/packages/notifications/lib/notification-element.js index 660ee6e7e8..4d3ef9be49 100644 --- a/packages/notifications/lib/notification-element.js +++ b/packages/notifications/lib/notification-element.js @@ -8,18 +8,14 @@ * Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md */ let NotificationElement; -const createDOMPurify = require('dompurify'); const fs = require('fs-plus'); const path = require('path'); -const marked = require('marked'); const {shell} = require('electron'); const NotificationIssue = require('./notification-issue'); const TemplateHelper = require('./template-helper'); const UserUtilities = require('./user-utilities'); -let DOMPurify = null; - const NotificationTemplate = `\
@@ -110,12 +106,7 @@ module.exports = const notificationContainer = this.element.querySelector('.message'); - if (DOMPurify === null) { - DOMPurify = createDOMPurify(); - } - notificationContainer.innerHTML = DOMPurify.sanitize( - marked.parse(this.model.getMessage()) - ); + notificationContainer.innerHTML = atom.ui.markdown.render(this.model.getMessage()); if (detail = this.model.getDetail()) { let stack; @@ -137,7 +128,7 @@ module.exports = metaContainer = this.element.querySelector('.meta'); metaContainer.appendChild(TemplateHelper.render(this.metaTemplate)); const description = this.element.querySelector('.description'); - description.innerHTML = marked.parse(metaContent); + description.innerHTML = atom.ui.markdown.render(metaContent); } if (options.buttons && (options.buttons.length > 0)) { diff --git a/packages/notifications/package.json b/packages/notifications/package.json index 0b85bdb405..84e9387612 100644 --- a/packages/notifications/package.json +++ b/packages/notifications/package.json @@ -9,9 +9,7 @@ "atom": ">0.50.0" }, "dependencies": { - "dompurify": "3.0.3", "fs-plus": "^3.0.0", - "marked": "5.0.3", "moment": "^2.19.3", "semver": "^7.0.0", "stacktrace-parser": "^0.1.3", diff --git a/packages/one-dark-syntax/styles/syntax-legacy/_base.less b/packages/one-dark-syntax/styles/syntax-legacy/_base.less index cd11d14ad9..c21e13c5bd 100644 --- a/packages/one-dark-syntax/styles/syntax-legacy/_base.less +++ b/packages/one-dark-syntax/styles/syntax-legacy/_base.less @@ -210,7 +210,7 @@ } .syntax--meta { - &.syntax--class { + &.syntax--class:not(.syntax--block) { color: @hue-6-2; &.syntax--body { diff --git a/packages/one-light-syntax/styles/syntax-legacy/_base.less b/packages/one-light-syntax/styles/syntax-legacy/_base.less index 423fad74ce..ac2a34a90a 100644 --- a/packages/one-light-syntax/styles/syntax-legacy/_base.less +++ b/packages/one-light-syntax/styles/syntax-legacy/_base.less @@ -210,7 +210,7 @@ } .syntax--meta { - &.syntax--class { + &.syntax--class:not(.syntax--block) { color: @hue-6-2; &.syntax--body { diff --git a/packages/pulsar-updater/spec/cache-spec.js b/packages/pulsar-updater/spec/cache-spec.js index 19baf8ed41..e5e42eb130 100644 --- a/packages/pulsar-updater/spec/cache-spec.js +++ b/packages/pulsar-updater/spec/cache-spec.js @@ -1,20 +1,41 @@ const cache = require("../src/cache.js"); describe("pulsar-updater cache", () => { + beforeEach(() => { + jasmine.useRealClock(); + }); + it("returns key for path", () => { let key = cache.cacheKeyForPath("test"); expect(key).toBe("pulsar-updater:test"); }); - it("returns expired properly according to date", () => { - let expiry = cache.isItemExpired({ createdOn: Date.now() }); + it("returns not expired properly according to date", () => { + let expiry = cache.isItemExpired({ createdOn: Date.now() }, 'some-key'); expect(expiry).toBe(false); }); - it("returns not expired if offline", () => { - spyOn(cache, "online").andReturn(true); + it("returns expired properly according to date", () => { + let expiry = cache.isItemExpired({ createdOn: 0 }, 'some-key'); + expect(expiry).toBe(true); + }); - let expiry = cache.isItemExpired({ createdOn: 0 }); + it("returns not expired properly for last-update-check", () => { + let expiry = cache.isItemExpired({ createdOn: 0 }, 'last-update-check'); expect(expiry).toBe(false); - }) + }); + + if(jasmine.version_.major > 1) { + // TODO: The current version right now is 1.3.1 of jasmine-node + // https://github.com/kevinsawicki/jasmine-node + // + // This is an unmaintained package that tried to implement jasmine for node, + // however we have an official jasmine implementation since then + it("returns not expired if offline", () => { + spyOnProperty(window.navigator, 'onLine').and.returnValue(false); + + let expiry = cache.isItemExpired({ createdOn: 0 }, 'some-key'); + expect(expiry).toBe(false); + }); + } }); diff --git a/packages/pulsar-updater/src/cache.js b/packages/pulsar-updater/src/cache.js index 02520d6db6..6f80c051ee 100644 --- a/packages/pulsar-updater/src/cache.js +++ b/packages/pulsar-updater/src/cache.js @@ -23,7 +23,7 @@ function getCacheItem(key) { let cached = JSON.parse(obj); - if (typeof cached === "object" && !isItemExpired(cached)) { + if (typeof cached === "object" && !isItemExpired(cached, key)) { return JSON.parse(cached.data); } diff --git a/packages/settings-view/lib/package-detail-view.js b/packages/settings-view/lib/package-detail-view.js index eb98538f81..cb7be2b07f 100644 --- a/packages/settings-view/lib/package-detail-view.js +++ b/packages/settings-view/lib/package-detail-view.js @@ -385,22 +385,24 @@ export default class PackageDetailView { readme = fs.readFileSync(this.readmePath, {encoding: 'utf8'}) } - let readmeSrc + let readmeSrc, readmeIsLocal; if (this.pack.path) { // If package is installed, use installed path readmeSrc = this.pack.path + readmeIsLocal = true; } else { // If package isn't installed, use url path let repoUrl = this.packageManager.getRepositoryUrl(this.pack) + readmeIsLocal = false; // Check if URL is undefined (i.e. package is unpublished) if (repoUrl) { - readmeSrc = repoUrl + `/blob/master/` + readmeSrc = repoUrl; } } - const readmeView = new PackageReadmeView(readme, readmeSrc) + const readmeView = new PackageReadmeView(readme, readmeSrc, readmeIsLocal) if (this.readmeView) { this.readmeView.element.parentElement.replaceChild(readmeView.element, this.readmeView.element) this.readmeView.destroy() diff --git a/packages/settings-view/lib/package-readme-view.js b/packages/settings-view/lib/package-readme-view.js index c05592173b..1c47bec8ca 100644 --- a/packages/settings-view/lib/package-readme-view.js +++ b/packages/settings-view/lib/package-readme-view.js @@ -1,57 +1,9 @@ /** @babel */ -import {marked} from 'marked' -import createDOMPurify from 'dompurify' - -function sanitize (html, readmeSrc) { - const temporaryContainer = document.createElement('div') - temporaryContainer.innerHTML = html - - for (const checkbox of temporaryContainer.querySelectorAll('input[type="checkbox"]')) { - checkbox.setAttribute('disabled', '') - } - - let path = require('path') - - for (const image of temporaryContainer.querySelectorAll('img')) { - let imageSrc = image.getAttribute('src') - - let changeImageSrc = true - - // If src contains a protocol then it must be absolute - if (/^(?:[a-z]+:)?\/\//i.test(imageSrc)) { - changeImageSrc = false - } - - // If src contains a base64 encoded image it must be left unchanged - if (/^data:image\/.*;base64/i.test(imageSrc)) { - changeImageSrc = false - } - - // If path is absolute on file system it must be a local file, e.g. emoji - if (path.isAbsolute(imageSrc)) { - changeImageSrc = false - } - - // If imageSrc needs changing and readmeSrc isn't undefined (i.e. if package was unpublished) - if (changeImageSrc && readmeSrc) { - if (path.isAbsolute(readmeSrc)) { - // If repoUrl is a local path (i.e. package is installed) - image.setAttribute('src', path.join(readmeSrc, imageSrc)) - } else { - // If repoUrl is a URL (i.e. package isn't installed) - image.setAttribute('src', new URL(imageSrc, readmeSrc)) - } - } - } - - return createDOMPurify().sanitize(temporaryContainer.innerHTML) -} - // Displays the readme for a package, if it has one // TODO Decide to keep this or current button-to-new-tab view export default class PackageReadmeView { - constructor (readme, readmeSrc) { + constructor (readme, readmeSrc, readmeIsLocal) { this.element = document.createElement('section') this.element.classList.add('section') @@ -69,13 +21,25 @@ export default class PackageReadmeView { container.appendChild(this.packageReadme) this.element.appendChild(container) - marked(readme || '### No README.', {breaks: false}, (err, content) => { - if (err) { - this.packageReadme.innerHTML = '

Error parsing README

' - } else { - this.packageReadme.innerHTML = sanitize(content, readmeSrc) - } - }) + readme ||= "### No README."; + + const markdownOpts = { + breaks: false, + taskCheckboxDisabled: true, + useGitHubHeadings: true + }; + + if (readmeIsLocal) { + markdownOpts.filePath = readmeSrc; + } else { + markdownOpts.rootDomain = readmeSrc; + } + + try { + this.packageReadme.innerHTML = atom.ui.markdown.render(readme, markdownOpts); + } catch(err) { + this.packageReadme.innerHTML = "

Error parsing README

"; + } } destroy () { diff --git a/packages/settings-view/lib/rich-description.js b/packages/settings-view/lib/rich-description.js index f246fbd1b9..a71f43cb63 100644 --- a/packages/settings-view/lib/rich-description.js +++ b/packages/settings-view/lib/rich-description.js @@ -1,20 +1,3 @@ -const {marked} = require('marked') - -const renderer = new marked.Renderer() -renderer.code = () => '' -renderer.blockquote = () => '' -renderer.heading = () => '' -renderer.html = (src) => { - const match = src.match(//) - if (match) { - return `
` - } - return '' -} -renderer.image = () => '' -renderer.list = () => '' - -const markdown = text => marked(text, {renderer, breaks: true}).replace(/

(.*)<\/p>/, '$1').trim() module.exports = { getSettingDescription (keyPath) { @@ -23,6 +6,12 @@ module.exports = { if (schema && schema.description) { description = schema.description } - return markdown(description) + return atom.ui.markdown.render( + description, + { + useTaskCheckbox: false, + disableMode: "strict", + } + ).replace(/

(.*)<\/p>/, "$1").trim(); } } diff --git a/packages/settings-view/package.json b/packages/settings-view/package.json index 843cbaf973..6826a02fc3 100644 --- a/packages/settings-view/package.json +++ b/packages/settings-view/package.json @@ -42,12 +42,10 @@ }, "dependencies": { "async": "^3.2.0", - "dompurify": "^2.0.17", "etch": "0.9.0", "fs-plus": "^3.0.0", "glob": "5.0.15", "hosted-git-info": "^2.8.9", - "marked": "5.0.3", "request": "^2.83.0", "season": "^6.0.2", "semver": "^5.3.0", diff --git a/packages/settings-view/spec/package-detail-view-spec.js b/packages/settings-view/spec/package-detail-view-spec.js index c0314c7128..9caa9bb291 100644 --- a/packages/settings-view/spec/package-detail-view-spec.js +++ b/packages/settings-view/spec/package-detail-view-spec.js @@ -112,7 +112,7 @@ describe("PackageDetailView", function() { expect(view.element.querySelectorAll('.package-readme iframe').length).toBe(0); expect(view.element.querySelectorAll('.package-readme input[type="checkbox"][disabled]').length).toBe(2); expect(view.element.querySelector('img[alt="AbsoluteImage"]').getAttribute('src')).toBe('https://example.com/static/image.jpg'); - expect(view.element.querySelector('img[alt="RelativeImage"]').getAttribute('src')).toBe('https://github.com/example/package-with-readme/blob/master/static/image.jpg'); + expect(view.element.querySelector('img[alt="RelativeImage"]').getAttribute('src')).toBe('https://github.com/example/package-with-readme/raw/HEAD/static/image.jpg'); expect(view.element.querySelector('img[alt="Base64Image"]').getAttribute('src')).toBe('data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=='); }); diff --git a/packages/settings-view/spec/rich-description-spec.js b/packages/settings-view/spec/rich-description-spec.js index 7445a08c7a..d79f4b5669 100644 --- a/packages/settings-view/spec/rich-description-spec.js +++ b/packages/settings-view/spec/rich-description-spec.js @@ -139,9 +139,9 @@ Description without table it('handles inline code', () => expect(getSettingDescription('foo.inlineCode')).toEqual('Description with inline code')); - it('handles line breaks', () => expect(getSettingDescription('foo.lineBreak')).toEqual('Description with
line break')); + it('handles line breaks', () => expect(getSettingDescription('foo.lineBreak')).toEqual('Description with
line break')); - it('handles strikethrough', () => expect(getSettingDescription('foo.strikethrough')).toEqual('Description with strikethrough')); + it('handles strikethrough', () => expect(getSettingDescription('foo.strikethrough')).toEqual('Description with strikethrough')); }); describe('unsupported Markdown', () => { diff --git a/packages/welcome/lib/changelog-view.js b/packages/welcome/lib/changelog-view.js index ca37df4c75..e6983c4038 100644 --- a/packages/welcome/lib/changelog-view.js +++ b/packages/welcome/lib/changelog-view.js @@ -50,31 +50,28 @@ export default class ChangeLogView {

Feel free to read our Full Change Log.

  • - Fixed a race condition that could cause `autocomplete-plus` to ignore user input. + Made the modification of `editor.preferredLineLength` configurable within `wrap-guide` when changing `wrap-guide.columns`
  • - Fixed the `about` package linking to release notes for Pulsar. + Fixed Snippets from `language-php` that would lose the `$` character
  • - Reduced the amount of network requests that `settings-view` creates. + Fixed a condition where an invalid config may crash Pulsar before fully starting up, but not registering that it's crashed
  • - Fixed the icon used when registering Pulsar as a file handler on Windows. + Reduced error notifications that may appear from `autocomplete-html` when handling EJS files
  • - Removed the non-functional `autoUpdate` API from Pulsar, instead relying on the `pulsar-updater` package. + Fixed macOS binary signing after moving over to GitHub Actions for CI
  • - Ensure that project-specific setting overrides don't leak to the user's config file when the settings UI is visited. + Updated PPM to a newer `node-gyp`, allowing newer versions of C/C++ compiler toolchains and Python to be used (also dropped support for Python 2.x!)
  • - Prevented warnings in the developer console from appearing when autocomplete suggestions are shown. + Fully decaffed the entire PPM codebase
  • - Removed the last CoffeeScript code from Pulsar and core packages. -
  • -
  • - Migrated the majority of our CI to GitHub Actions. + Added a new autocomplete API that does not uses prefixes and instead declares the range it'll replace (better LSP support)
diff --git a/packages/wrap-guide/lib/wrap-guide-element.js b/packages/wrap-guide/lib/wrap-guide-element.js index afb4f21435..ab4b6e3e04 100644 --- a/packages/wrap-guide/lib/wrap-guide-element.js +++ b/packages/wrap-guide/lib/wrap-guide-element.js @@ -90,8 +90,10 @@ module.exports = class WrapGuideElement { const columns = uniqueAscending(args.newValue); if (columns != null ? columns.length : undefined) { atom.config.set('wrap-guide.columns', columns); - atom.config.set('editor.preferredLineLength', columns[columns.length - 1], - {scopeSelector: `.${this.editor.getGrammar().scopeName}`}); + if (atom.config.get('wrap-guide.modifyPreferredLineLength')) { + atom.config.set('editor.preferredLineLength', columns[columns.length - 1], + {scopeSelector: `.${this.editor.getGrammar().scopeName}`}); + } return this.updateGuide(); } }; diff --git a/packages/wrap-guide/package.json b/packages/wrap-guide/package.json index 642a205c7c..5deece076b 100644 --- a/packages/wrap-guide/package.json +++ b/packages/wrap-guide/package.json @@ -17,6 +17,11 @@ }, "description": "Display guides at each of the listed character widths. Leave blank for one guide at your `editor.preferredLineLength`." }, + "modifyPreferredLineLength": { + "default": true, + "type": "boolean", + "description": "Modify the Editor's Preferred Line Length when changing Wrap Guide's Columns setting." + }, "enabled": { "default": true, "type": "boolean" diff --git a/packages/wrap-guide/spec/wrap-guide-element-spec.js b/packages/wrap-guide/spec/wrap-guide-element-spec.js index 053c690d17..ce8d342a34 100644 --- a/packages/wrap-guide/spec/wrap-guide-element-spec.js +++ b/packages/wrap-guide/spec/wrap-guide-element-spec.js @@ -105,7 +105,7 @@ describe("WrapGuideElement", function() { for (let i = 0; i < columnCount; i++) { columns.push(i * 10); } - + atom.config.set("wrap-guide.columns", columns); waitsForPromise(() => editorElement.getComponent().getNextUpdatePromise()); @@ -245,6 +245,19 @@ describe("WrapGuideElement", function() { expect(wrapGuide).toBeVisible(); }); }); + + it("leaves alone preferredLineLength if modifyPreferredLineLength is false", () => { + const initial = atom.config.get("editor.preferredLineLength", { scope: editor.getRootScopeDescriptor() }); + atom.config.set("wrap-guide.modifyPreferredLineLength", false); + + atom.config.set("wrap-guide.columns", [ initial, initial + 10]); + waitsForPromise(() => editorElement.getComponent().getNextUpdatePromise()); + + runs(() => { + const length = atom.config.get("editor.preferredLineLength", { scope: editor.getRootScopeDescriptor() }); + expect(length).toBe(initial); + }); + }); }); describe("when the editor's scroll left changes", () => it("updates the wrap guide position to a relative position on screen", function() { diff --git a/script/validate-wasm-grammar-prs.js b/script/validate-wasm-grammar-prs.js new file mode 100644 index 0000000000..5035475302 --- /dev/null +++ b/script/validate-wasm-grammar-prs.js @@ -0,0 +1,148 @@ +/* + * This script is called via `validate-wasm-grammar-prs.yml` + * It's purpose is to ensure that everytime a `.wasm` file is changed in a PR + * That the `parserSource` key of the grammar that uses that specific `.wasm` + * file is also updated. + * This way we can ensure that the `parserSource` is always accurate, and is + * never forgotten about. + */ + +const cp = require("node:child_process"); +const path = require("node:path"); +const fs = require("node:fs"); +const CSON = require("season"); + +// Change this if you want more logs +let verbose = true; + +// Lets first find our common ancestor commit +// This lets us determine the commit where the branch or fork departed from +const commonAncestorCmd = cp.spawnSync("git", [ "merge-base", "origin/master", "HEAD^" ]); + +if (commonAncestorCmd.status !== 0 || commonAncestorCmd.stderr.toString().length > 0) { + console.error("Git Command has failed!"); + console.error("'git merge-base origin/master HEAD^'"); + console.error(commonAncestorCmd.stderr.toString()); + process.exit(1); +} + +const commit = commonAncestorCmd.stdout.toString().trim(); + +if (verbose) { + console.log(`Common Ancestor Commit: '${commit}'`); +} + +const cmd = cp.spawnSync("git", [ "diff", "--name-only", "-r", "HEAD", commit]) + +if (cmd.status !== 0 || cmd.stderr.toString().length > 0) { + console.error("Git Command has failed!"); + console.error(`'git diff --name-only -r HEAD ${commit}'`); + console.error(cmd.stderr.toString()); + process.exit(1); +} + +const changedFiles = cmd.stdout.toString().split("\n"); +// This gives us an array of the name and path of every single changed file from the last two commits +// Now to check if there's any changes we care about. + +if (verbose) { + console.log("Array of changed files between commits:"); + console.log(changedFiles); +} + +const wasmFilesChanged = changedFiles.filter(element => element.endsWith(".wasm")); + +if (wasmFilesChanged.length === 0) { + // No WASM files have been modified. Return success + console.log("No WASM files have been changed."); + process.exit(0); +} + +// Now for every single wasm file that's been changed, we must validate those changes +// are also accompanied by a change in the `parserSource` key + +for (const wasmFile of wasmFilesChanged) { + const wasmPath = path.dirname(wasmFile); + + const files = fs.readdirSync(path.join(wasmPath, "..")); + console.log(`Detected changes to: ${wasmFile}`); + + if (verbose) { + console.log("Verbose file check details:"); + console.log(wasmFile); + console.log(wasmPath); + console.log(files); + console.log("\n"); + } + + for (const file of files) { + const filePath = path.join(wasmPath, "..", file); + console.log(`Checking: ${filePath}`); + + if (fs.lstatSync(filePath).isFile()) { + const contents = CSON.readFileSync(filePath); + + // We now have the contents of one of the grammar files for this specific grammar. + // Since each grammar may contain multiple grammar files, we need to ensure + // that this particular one is using the tree-sitter wasm file that was + // actually changed. + const grammarFile = contents.treeSitter?.grammar ?? ""; + + if (path.basename(grammarFile) === path.basename(wasmFile)) { + // This grammar uses the WASM file that's changed. So we must ensure our key has also changed + // Sidenote we use `basename` here, since the `wasmFile` will be + // a path relative from the root of the repo, meanwhile `grammarFile` + // will be relative from the file itself + + // In order to check the previous state of what the key is, we first must retreive the file prior to this PR + const getPrevFile = cp.spawnSync("git", [ "show", `${commit}:./${filePath}` ]); + + if (getPrevFile.status !== 0 || getPrevFile.stderr.toString().length > 0) { + // This can fail for two major reasons + // 1. The `git show` command has returned an error code other than `0`, failing. + // 2. This is a new file, and it failed to find an earlier copy (which didn't exist) + // So that we don't fail brand new TreeSitter grammars, we manually check for number 2 + + if (getPrevFile.stderr.toString().includes("exists on disk, but not in")) { + // Looks like this file is new. Skip this check + if (verbose) { + console.log("Looks like this file is new. Skipping..."); + } + continue; + } + + console.error("Git command failed!"); + console.error(`'git show ${commit}:./${filePath}'`); + console.error(getPrevFile.stderr.toString()); + process.exit(1); + } + + fs.writeFileSync(path.join(wasmPath, "..", `OLD-${file}`), getPrevFile.stdout.toString()); + + const oldContents = CSON.readFileSync(path.join(wasmPath, "..", `OLD-${file}`)); + const oldParserSource = oldContents.treeSitter?.parserSource ?? ""; + const newParserSource = contents.treeSitter?.parserSource ?? ""; + + if (newParserSource.length === 0) { + console.error(`Failed to find the new \`parserSource\` within: '${filePath}'`); + console.error(contents.treeSitter); + process.exit(1); + } + + if (oldParserSource == newParserSource) { + // The repo and commit is identical! This means it hasn't been updated + console.error(`The \`parserSource\` key of '${filePath}' has not been updated!`); + console.error(`Current key: ${newParserSource} - Old key: ${oldParserSource}`); + process.exit(1); + } + + // Else it looks like it has been updated properly + console.log(`Validated \`parserSource\` has been updated within '${filePath}' properly.`); + } else { + if (verbose) { + console.log("This grammar file doesn't use a WASM file that's changed (On the current iteration)"); + } + } + } + } +} diff --git a/spec/ui-spec.js b/spec/ui-spec.js new file mode 100644 index 0000000000..e36d468d3e --- /dev/null +++ b/spec/ui-spec.js @@ -0,0 +1,37 @@ + +describe("Renders Markdown", () => { + describe("properly when given no opts", () => { + it("handles bold", () => { + expect(atom.ui.markdown.render("**Hello World**")) + .toBe("

Hello World

\n"); + }); + }); + + describe("transforms links correctly", () => { + it("makes no changes to a fqdn link", () => { + expect(atom.ui.markdown.render("[Hello World](https://github.com)")) + .toBe('

Hello World

\n'); + }); + it("resolves package links to pulsar", () => { + expect(atom.ui.markdown.render("[Hello](https://atom.io/packages/hey-pane)")) + .toBe('

Hello

\n'); + }); + it("resolves atom links to web archive", () => { + expect(atom.ui.markdown.render("[Hello](https://flight-manual.atom.io/some-docs)")) + .toBe('

Hello

\n'); + }); + it("resolves incomplete local links", () => { + expect(atom.ui.markdown.render( + "[Hello](./readme.md)", + { rootDomain: "https://github.com/pulsar-edit/pulsar" } + )).toBe('

Hello

\n'); + }); + it("resolves incomplete root links", () => { + expect(atom.ui.markdown.render( + "[Hello](/readme.md)", + { rootDomain: "https://github.com/pulsar-edit/pulsar" } + )).toBe('

Hello

\n'); + }); + }); + +}); diff --git a/src/ui.js b/src/ui.js index 3092ad5984..d1a22bcaec 100644 --- a/src/ui.js +++ b/src/ui.js @@ -1,30 +1,91 @@ +const path = require("path"); +const fs = require("fs"); const MarkdownIt = require("markdown-it"); const { TextEditor } = require("atom"); const { Matcher } = require("@pulsar-edit/fuzzy-native"); let yamlFrontMatter, markdownItEmoji, markdownItGitHubHeadings, markdownItTaskCheckbox; -// Regex Declarations -const reg = { - localLinks: { - currentDir: new RegExp(/^\.\//), - rootDir: new RegExp(/^\//) +// Helper Markdown Components +const mdComponents = { + deps: { + domPurify: null, + yamlFrontMatter: null, + markdownItEmoji: null, + markdownItGitHubHeadings: null, + markdownItTaskCheckbox: null + }, + // Regex Declarations + reg: { + localLinks: { + currentDir: new RegExp(/^\.\//), + rootDir: new RegExp(/^\//) + }, + globalLinks: { + base64: new RegExp(/^data:image\/.*;base64/, "i") + }, + atomLinks: { + package: new RegExp(/^https:\/\/atom\.io\/packages\/(.*)$/), + flightManual: new RegExp(/^https:\/\/flight-manual\.atom\.io\//) + } }, - atomLinks: { - package: new RegExp(/^https:\/\/atom\.io\/packages\/(.*)$/), - flightManual: new RegExp(/^https:\/\/flight-manual\.atom\.io\//) - } }; +/** + * @function renderMarkdown + * @memberof markdown + * @alias render + * @desc Takes a Markdown document and renders it as HTML. + * @param {string} content - The Markdown source material. + * @param {object} givenOpts - The optional arguments: + * @param {string} givenOpts.renderMode - Determines how the page is rendered. + * Valid values "full" or "fragment". + * @param {boolean} givenOpts.html - Whether HTML tags should be allowed. + * @param {boolean} givenOpts.sanitize - If the page content should be saniized via DOMPurify. + * @param {boolean} givenOpts.sanitizeAllowUnknownProtocols - Controls DOMPurify's + * own option of 'ALLOW_UNKNOWN_PROTOCOLS'. + * @param {boolean} givenOpts.sanitizeAllowSelfClose - Controls DOMPurify's + * own option of 'ALLOW_SELF_CLOSE' + * @param {boolean} givenOpts.breaks - If newlines should always be converted + * into breaklines. + * @param {boolean} givenOpts.handleFrontMatter - Whether frontmatter data should + * processed and displayed. + * @param {boolean} givenOpts.useDefaultEmoji - Whether `markdown-it-emoji` should be enabled. + * @param {boolean} givenOpts.useGitHubHeadings - Whether `markdown-it-github-headings` + * should be enabled. False by default. + * @param {boolean} givenOpts.useTaskCheckbox - Whether `markdown-it-task-checkbox` + * should be enabled. True by default. + * @param {boolean} givenOpts.taskCheckboxDisabled - Controls `markdown-it-task-checkbox` + * `disabled` option. True by default. + * @param {boolean} givenOpts.taskCheckboxDivWrap - Controls `markdown-it-task-checkboc` + * `divWrap` option. False by default. + * @param {boolean} givenOpts.transformImageLinks - Attempt to resolve image URLs. + * True by default. + * @param {boolean} givenOpts.transformAtomLinks - Attempt to resolve links + * pointing to Atom. True by Default. + * @param {boolean} givenOpts.transformNonFqdnLinks - Attempt to resolve links + * that are not fully qualified domain names. True by Default. + * @param {string} givenOpts.rootDomain - The root URL of the online resource. + * Useful when attempting to resolve any links on the page. Only works for online + * resources. + * @param {string} givenOpts.filePath - The local alternative to `rootDomain`. + * Used to resolve incomplete paths, but locally on the file system. + * @param {string} givenOpts.disabledMode - The level of disabling of markdown features. + * `none` by default. But supports: "none", "strict" + * @returns {string} Parsed HTML content. + */ function renderMarkdown(content, givenOpts = {}) { // First we will setup our markdown renderer instance according to the opts provided const defaultOpts = { renderMode: "full", // Determines if we are rendering a fragment or full page. // Valid values: 'full', 'fragment' html: true, // Enable HTML tags in source - breaks: true, // Convert `\n` in paragraphs into `
` + sanitize: true, // Enable or disable sanitization + sanitizeAllowUnknownProtocols: true, + sanitizeAllowSelfClose: true, + breaks: false, // Convert `\n` in paragraphs into `
` handleFrontMatter: true, // Determines if Front Matter content should be parsed useDefaultEmoji: true, // Use `markdown-it-emoji` - useGitHubHeadings: true, // Use `markdown-it-github-headings` + useGitHubHeadings: false, // Use `markdown-it-github-headings` useTaskCheckbox: true, // Use `markdown-it-task-checkbox` taskCheckboxDisabled: true, // `markdown-it-task-checkbox`: Disable checkbox interactivity taskCheckboxDivWrap: false, // `markdown-it-task-checkbox`: Wrap div arround checkboc @@ -32,6 +93,11 @@ function renderMarkdown(content, givenOpts = {}) { transformAtomLinks: true, // Attempt to rewrite links to Atom pages, changing them to Pulsar transformNonFqdnLinks: true, // Attempt to resolve non-FQDN links rootDomain: "", // The root URL that should be used for the above 'transform' options + filePath: "", // The path to the file where this markdown is generated from, + disableMode: "none", // The level of disabling that should be done on the output. + // Provides helpful defaults to control how much or how little is disabled: + // - none: Nothing is disabled + // - strict: Everything possible is disabled, except what is otherwise needed }; let opts = { ...defaultOpts, ...givenOpts }; @@ -41,7 +107,8 @@ function renderMarkdown(content, givenOpts = {}) { }; const cleanRootDomain = () => { - return opts.rootDomain.replace(".git", ""); + // We will also remove any trailing `/` as link resolvers down the line add them in + return opts.rootDomain.replace(".git", "").replace(/\/$/, ""); }; const markdownItOpts = { @@ -52,16 +119,16 @@ function renderMarkdown(content, givenOpts = {}) { let md = new MarkdownIt(markdownItOpts); if (opts.useDefaultEmoji) { - markdownItEmoji = require("markdown-it-emoji"); - md.use(markdownItEmoji, {}); + mdComponents.deps.markdownItEmoji ??= require("markdown-it-emoji"); + md.use(mdComponents.deps.markdownItEmoji, {}); } if (opts.useGitHubHeadings) { - markdownItGitHubHeadings = require("markdown-it-github-headings"); - md.use(markdownItGitHubHeadings, {}); + mdComponents.deps.markdownItGitHubHeadings ??= require("markdown-it-github-headings"); + md.use(mdComponents.deps.markdownItGitHubHeadings, {}); } if (opts.useTaskCheckbox) { - markdownItTaskCheckbox = require("markdown-it-task-checkbox"); - md.use(markdownItTaskCheckbox, { + mdComponents.deps.markdownItTaskCheckbox ??= require("markdown-it-task-checkbox"); + md.use(mdComponents.deps.markdownItTaskCheckbox, { disabled: opts.taskCheckboxDisabled, divWrap: opts.taskCheckboxDivWrap }); @@ -71,6 +138,14 @@ function renderMarkdown(content, givenOpts = {}) { // our best to ensure they can accurately resolve. const defaultImageRenderer = md.renderer.rules.image; // We want to keep access to this + // Determines when we handle links if the item could be a local file or not + let couldBeLocalItem; + if (typeof opts.filePath != "string" || opts.filePath.length < 1) { + couldBeLocalItem = false; + } else { + couldBeLocalItem = true; + } + md.renderer.rules.image = (tokens, idx, options, env, self) => { let token = tokens[idx]; let aIndex = token.attrIndex("src"); @@ -78,15 +153,37 @@ function renderMarkdown(content, givenOpts = {}) { // Lets say content contains './my-cool-image.png' // We need to turn it into something like this: // https://github.com/USER/REPO/raw/HEAD/my-cool-image.png - if (reg.localLinks.currentDir.test(token.attrGet("src"))) { + if (mdComponents.reg.localLinks.currentDir.test(token.attrGet("src"))) { let rawLink = token.attrGet("src"); - rawLink = rawLink.replace(reg.localLinks.currentDir, ""); - token.attrSet("src", `${cleanRootDomain()}/raw/HEAD/${rawLink}`); - } else if (reg.localLinks.rootDir.test(token.attrGet("src"))) { + rawLink = rawLink.replace(mdComponents.reg.localLinks.currentDir, ""); + // Now we need to handle links for both the web and locally + // We can do this by first checking if the link resolves locally + if (couldBeLocalItem) { + let newSrc = path.resolve(path.dirname(opts.filePath, rawLink)); + if (!fs.lstatSync(newSrc).isFile()) { + token.attrSet("src", newSrc); + } else { + token.attrSet("src", `${cleanRootDomain()}/raw/HEAD/${rawLink}`); + } + } else { + token.attrSet("src", `${cleanRootDomain()}/raw/HEAD/${rawLink}`); + } + } else if (mdComponents.reg.localLinks.rootDir.test(token.attrGet("src"))) { let rawLink = token.attrGet("src"); - rawLink = rawLink.replace(reg.localLinks.rootDir, ""); - token.attrSet("src", `${cleanRootDomain()}/raw/HEAD/${rawLink}`); - } else if (!token.attrGet("src").startsWith("http")) { + rawLink = rawLink.replace(mdComponents.reg.localLinks.rootDir, ""); + // Now to handle the possible web or local link + if (couldBeLocalItem) { + const [rootDirectory] = atom.project.relativePath(opts.filePath); + if (!fs.lstatSync(src).isFile() && rootDirectory) { + let newSrc = path.join(rootDirectory, rawLink); + token.attrSet("src", newSrc); + } else { + token.attrSet("src", `${cleanRootDomain()}/raw/HEAD/${rawLink}`); + } + } else { + token.attrSet("src", `${cleanRootDomain()}/raw/HEAD/${rawLink}`); + } + } else if (!token.attrGet("src").startsWith("http") && !mdComponents.reg.globalLinks.base64.test(token.attrGet("src"))) { // Check for implicit relative urls let rawLink = token.attrGet("src"); token.attrSet("src", `${cleanRootDomain()}/raw/HEAD/${rawLink}`); @@ -100,7 +197,32 @@ function renderMarkdown(content, givenOpts = {}) { return defaultImageRenderer(tokens, idx, options, env, self); }; } - if (validateRootDomain() && (opts.transformNonFqdnLinks || opts.transformAtomLinks)) { + if (validateRootDomain() && opts.transformNonFqdnLinks) { + md.core.ruler.after("inline", "fix-links", (state) => { + state.tokens.forEach((blockToken) => { + if (blockToken.type === "inline" && blockToken.children) { + blockToken.children.forEach((token) => { + if (token.type === "link_open") { + token.attrs.forEach((attr) => { + if (attr[0] === "href") { + let link = attr[1]; + + if (opts.transformNonFqdnLinks && mdComponents.reg.localLinks.currentDir.test(link)) { + attr[1] = `${cleanRootDomain()}/blob/HEAD/${link.replace(mdComponents.reg.localLinks.currentDir, "")}`; + } else if (opts.transformNonFqdnLinks && mdComponents.reg.localLinks.rootDir.test(link)) { + attr[1] = `${cleanRootDomain()}/blob/HEAD/${link.replace(mdComponents.reg.localLinks.rootDir, "")}`; + } else if (opts.transformNonFqdnLinks && !link.startsWith("http")) { + attr[1] = `${cleanRootDomain()}/blob/HEAD/${link.replace(".git", "")}`; + } + } + }); + } + }); + } + }); + }); + } else if (opts.transformAtomLinks) { + // This is a separate if since transforming Atom links does not need a valid root domain provided md.core.ruler.after("inline", "fix-atom-links", (state) => { state.tokens.forEach((blockToken) => { if (blockToken.type === "inline" && blockToken.children) { @@ -110,18 +232,12 @@ function renderMarkdown(content, givenOpts = {}) { if (attr[0] === "href") { let link = attr[1]; - if (opts.transformAtomLinks && reg.atomLinks.package.test(link)) { + if (mdComponents.reg.atomLinks.package.test(link)) { // Fix any links that attempt to point to packages on `https://atom.io/packages/...` - attr[1] = `https://web.pulsar-edit.dev/packages/${link.match(reg.atomLinks.package)[1]}`; - } else if (opts.transformNonFqdnLinks && reg.localLinks.currentDir.test(link)) { - attr[1] = `${cleanRootDomain()}/raw/HEAD/${link.replace(reg.localLinks.currentDir, "")}`; - } else if (opts.transformNonFqdnLinks && reg.localLinks.rootDir.test(link)) { - attr[1] = `${cleanRootDomain()}/raw/HEAD/${link.replace(reg.localLinks.rootDir, "")}`; - } else if (opts.transformNonFqdnLinks && !link.startsWith("http")) { - attr[1] = `${cleanRootDomain()}/raw/HEAD/${link.replace(".git", "")}`; - } else if (opts.transformAtomLinks && reg.atomLinks.flightManual.test(link)) { + attr[1] = `https://web.pulsar-edit.dev/packages/${link.match(mdComponents.reg.atomLinks.package)[1]}`; + } else if (mdComponents.reg.atomLinks.flightManual.test(link)) { // Resolve any links to the flight manual to web archive - attr[1] = link.replace(reg.atomLinks.flightManual, "https://web.archive.org/web/20221215003438/https://flight-manual.atom.io/"); + attr[1] = link.replace(mdComponents.reg.atomLinks.flightManual, "https://web.archive.org/web/20221215003438/https://flight-manual.atom.io/"); } } }); @@ -132,11 +248,156 @@ function renderMarkdown(content, givenOpts = {}) { }); } + // Here we can add some simple additions that make code highlighting possible later on, + // but doesn't actually preform any code highlighting. + md.options.highlight = function(str, lang) { + return `
${str}
`; + }; + + // Process disables + if (opts.disableMode === "strict") { + + // Easy Disable + md.disable("lheading"); + + // Disable Code Blocks + md.renderer.rules.code_block = (tokens, idx, _options, _env, _self) => { + if (tokens[idx].type === "code_block") { + return ""; + } + }; + + // Disable Code Fences + md.renderer.rules.fence = (tokens, idx, _options, _env, _self) => { + if (tokens[idx].type === "fence") { + return ""; + } + }; + + // Disable Images + md.renderer.rules.image = (tokens, idx, _options, _env, _self) => { + // Double check this is an image + if (tokens[idx].type === "image") { + return ""; + } + }; + + // Only support line breaks in HTML that's inline + md.inline.ruler.before("html_inline", "only_allow_line_breaks", (state) => { + // Determine how to best handle this to only allow line breaks. Research needed + if (state.src.charAt(state.pos) === "<") { + // We only want to act once on the beginning of the inline element + // Then confirm if it's the item we expect + const textAfterPending = state.src.replace(state.pending, ""); + const match = textAfterPending.match(/^/); + if (match) { + // We define breakline as a custom Token Type + let token = state.push("html_inline", "breakline", 0); + token.content = "
"; + state.pos += "
".length; + return true; + } + } + }); + + // Disable Heading + md.block.ruler.before("heading", "strip_heading", (state, startLine, endLine) => { + let pos = state.bMarks[startLine] + state.tShift[startLine]; + + if (state.src.charAt(pos) === "#") { + let max = state.eMarks[startLine]; + + const isSpace = () => { + let code = state.src.charCodeAt(pos); + switch(code) { + case 0x09: + case 0x20: + return true; + } + return false; + }; + + let level = 1; + + let ch = state.src.charAt(++pos); + while (ch === "#" && pos < max && level <= 6) { + level++; + ch = state.src.charAt(++pos); + } + + if (level > 6 || (pos < max && !isSpace())) { return false; } + // Now that we are confident we are within a heading, lets strip it + state.pos += level; + state.line = startLine + 1; + return true; + } + }); + + const stripAllTokensTill = (tokens, initIdx, endType) => { + // This function will loop a given set of tokens, stripping them of all data + // (converting them to empty text tokens) + // until the specified token is reached. Which it will also strip to text, + // then return + let idx = initIdx; + while(idx < tokens.length) { + tokens[idx].type = "text"; + tokens[idx].content = ""; + + if (tokens[idx].type == endType) { + break; + } + + idx++; + } + return; + }; + + // Disable blockquotes + md.renderer.rules.blockquote_open = (tokens, idx, _options, _env, _self) => { + stripAllTokensTill(tokens, idx, "blockquote_close"); + return ""; + }; + + // Disable Bullet lists + md.renderer.rules.bullet_list_open = (tokens, idx, _options, _env, _self) => { + stripAllTokensTill(tokens, idx, "bullet_list_close"); + return ""; + }; + + // Disable Ordered lists + md.renderer.rules.ordered_list_open = (tokens, idx, _options, _env, _self) => { + stripAllTokensTill(tokens, idx, "ordered_list_close"); + return ""; + }; + + // Ensure that only breaklines are supported as inline raw HTML + md.renderer.rules.html_inline = (tokens, idx, _options, _env, _self) => { + if (tokens[idx].type === "html_inline") { + // Here we can build an allow list of inline HTML elements to keep. + if ( + tokens[idx].tag !== "breakline" + ) { + return ""; + } else { + return tokens[idx].content; + } + } + }; + + // Ensure nothing is supported as block HTML + md.renderer.rules.html_block = (tokens, idx, _options, _env, _self) => { + if (tokens[idx].type === "html_block") { + return ""; + } + }; + + } + let textContent; if (opts.handleFrontMatter) { - yamlFrontMatter = require("yaml-front-matter"); - const { __content, vars } = yamlFrontMatter.loadFront(content); + mdComponents.deps.yamlFrontMatter ??= require("yaml-front-matter"); + const { __content, vars } = mdComponents.deps.yamlFrontMatter.loadFront(content); const renderYamlTable = (variables) => { if (typeof variables === "undefined") { @@ -172,18 +433,39 @@ function renderMarkdown(content, givenOpts = {}) { textContent = content; } - let rendered; + let rendered = md.render(textContent); - if (opts.renderMode === "fragment") { - rendered = md.renderInline(textContent); - } else { - // Captures "full" and anything else - rendered = md.render(textContent); + if (opts.sanitize) { + mdComponents.deps.domPurify ??= require("dompurify"); + + let domPurifyOpts = { + ALLOW_UNKNOWN_PROTOCOLS: opts.sanitizeAllowUnknownProtocols, + ALLOW_SELF_CLOSE_IN_ATTR: opts.sanitizeAllowSelfClose + }; + + rendered = mdComponents.deps.domPurify.sanitize(rendered, opts); } return rendered; } +/** + * @function applySyntaxHighlighting + * @memberof markdown + * @async + * @desc Uses Pulsar's built-in Syntax Highlighting system to apply the same syntax + * highlighting to code blocks within markdown. Modifies the existing object passed. + * @param {HTMLFragment} content - The HTML Node/Fragment to apply syntax highlighting on. + * Will modifyn the original object. + * @param {object} givenOpts - Optional Arguments: + * @param {function} givenOpts.syntaxScopeNameFunc - A function that can be called with + * any given language ID from a code block scope, and returns the grammar source id + * that should be used to preform syntax highlighting. + * @param {string} givenOpts.renderMode - Whether we are rdnering a document fragment + * or a full document. Valid values: "full", "fragment". + * @param {object} givenOpts.grammar - The grammar of the source file. Carryover from + * original `markdown-preview` functionality. + */ function applySyntaxHighlighting(content, givenOpts = {}) { const defaultOpts = { syntaxScopeNameFunc: null, // Function used to resolve codeblock fences language id @@ -220,74 +502,54 @@ function applySyntaxHighlighting(content, givenOpts = {}) { } } + let editorCallback; + + if (opts.renderMode === "fragment") { + editorCallback = makeAtomEditorNonInteractive; + } else { + // Captures full and defaults + editorCallback = convertAtomEditorToStandardElement; + } + const promises = []; for (const preElement of content.querySelectorAll("pre")) { - const codeBlock = preElement.firstElementChild != null ? preElement.firstElementChild : preElement; + const codeBlock = preElement.firstElementChild ?? preElement; const className = codeBlock.getAttribute("class"); - const fenceName = className != null ? className.replace(/^language-/, "") : defaultLanguage; + const fenceName = + className != null ? className.replace(/^language-/, "") : defaultLanguage; const editor = new TextEditor({ readonly: true, keyboardInputEnabled: false }); - const editorElement = editor.getElement(); preElement.classList.add("editor-colors", `lang-${fenceName}`); editorElement.setUpdatedSynchronously(true); preElement.innerHTML = ""; preElement.parentNode.insertBefore(editorElement, preElement); - editor.setText(codeBlock.textContent.replace(/\r?\n%/, "")); + editor.setText(codeBlock.textContent.replace(/\r?\n$/, "")); atom.grammars.assignLanguageMode(editor, scopeForFenceName(fenceName)); editor.setVisible(true); - let editorCallback; - - if (opts.renderMode === "fragment") { - editorCallback = (editorElementToModify, preElementToModify) => { - return new Promise((resolve) => { - const editorModel = editorElementToModify.getModel(); - const done = () => { - editorModel.component.getNextUpdatePromise().then(() => { - for (const line of editorElementToModify.querySelectorAll(".line:not(.dummy)")) { - const line2 = document.createElement("div"); - line2.className = "line"; - line2.innerHTML = line.firstChild.innerHTML; - preElementToModify.appendChild(line2); - } - editorElementToModify.remove(); - resolve(); - }); - }; - const languageMode = editorModel.getBuffer().getLanguageMode(); - if (languageMode.fullyTokenized || languageMode.tree) { - done(); - } else { - editorModel.onDidTokenize(done); - } - }); - }; - } else { - // Captures full and defaults - editorCallback = (editorElementToModify, preElementToModify) => { - preElementToModify.remove(); - editorElementToModify.setAttributeNode(document.createAttribute("gutter-hidden")); // Hide gutter - editorElementToModify.removeAttribute("tabindex"); // Make read-only - - // Remove line decorations from code blocks - for (const cursorLineDecoration of editorElementToModify.getModel().cursorLineDecorations) { - cursorLineDecoration.destroy(); - } - }; - } promises.push(editorCallback(editorElement, preElement)); } return Promise.all(promises); } +/** + * @function convertToDOM + * @memberof markdown + * @desc Takes a raw HTML string of data and returns a proper HTMLFragment. + * This should be done if you need access to APIs available on the DOM itself. + * @param {string} content - The HTML String. + * @returns {HTMLFragment} + */ function convertToDOM(content) { - const template = new DOMParser().parseFromString(content, "text/html"); - return template.body; + const template = document.createElement("template"); + template.innerHTML = content; + const fragment = template.content.cloneNode(true); + return fragment; } function setCandidates(matcherOrCandidates, candidates) { @@ -304,6 +566,7 @@ function setCandidates(matcherOrCandidates, candidates) { ); } } + const fuzzyMatcher = { setCandidates: setCandidates, @@ -317,9 +580,56 @@ const fuzzyMatcher = { } } +function makeAtomEditorNonInteractive(editorElement, preElement) { + preElement.remove(); + editorElement.setAttributeNode(document.createAttribute("gutter-hidden")); // Hide gutter + editorElement.removeAttribute("tabindex"); // Make read-only + + // Remove line decorations from code blocks. + for (const cursorLineDecoration of editorElement.getModel().cursorLineDecorations) { + cursorLineDecoration.destroy(); + } +} + +function convertAtomEditorToStandardElement(editorElement, preElement) { + return new Promise(function (resolve) { + const editor = editorElement.getModel(); + const done = () => + editor.component.getNextUpdatePromise().then(function () { + for (const line of editorElement.querySelectorAll( + ".line:not(.dummy)" + )) { + const line2 = document.createElement("div"); + line2.className = "line"; + line2.innerHTML = line.firstChild.innerHTML; + preElement.appendChild(line2); + } + editorElement.remove(); + resolve(); + }) + const languageMode = editor.getBuffer().getLanguageMode(); + if (languageMode.fullyTokenized || languageMode.tree) { + done(); + } else { + editor.onDidTokenize(done); + } + }); +} + +// Markdown Exported Object +/** + * @member markdown + * @memberof ui + * @desc The Markdown object exported from the UI API. + * Provides access to: ".render", ".applySyntaxHighlighting", ".convertToDOM" + */ +const markdown = { + render: renderMarkdown, + applySyntaxHighlighting: applySyntaxHighlighting, + convertToDOM: convertToDOM +}; + module.exports = { - renderMarkdown, - applySyntaxHighlighting, - convertToDOM, + markdown, fuzzyMatcher }; diff --git a/src/wasm-tree-sitter-language-mode.js b/src/wasm-tree-sitter-language-mode.js index 559274b4de..d9c7a31df5 100644 --- a/src/wasm-tree-sitter-language-mode.js +++ b/src/wasm-tree-sitter-language-mode.js @@ -3838,12 +3838,18 @@ class LanguageLayer { if (existingInjectionMarkers.length > 0) { // Enlarge our range to contain all of the injection zones in the // affected buffer range. - range = range.union( - new Range( - existingInjectionMarkers[0].getRange().start, - last(existingInjectionMarkers).getRange().end - ) - ); + let earliest, latest; + for (let marker of existingInjectionMarkers) { + range = marker.getRange(); + if (!earliest || range.start.compare(earliest) === -1) { + earliest = range.start; + } + if (!latest || range.end.compare(latest) === 1) { + latest = range.end; + } + } + + range = range.union(new Range(earliest, latest)); } // Now that we've enlarged the range, we might have more existing injection diff --git a/vendor/web-tree-sitter/tree-sitter.js b/vendor/web-tree-sitter/tree-sitter.js index 3eee68bfff..07c5c36f02 100644 --- a/vendor/web-tree-sitter/tree-sitter.js +++ b/vendor/web-tree-sitter/tree-sitter.js @@ -1,3011 +1,3014 @@ var Module = typeof Module !== "undefined" ? Module : {}; var TreeSitter = function() { - function checkForAsmVersion(prop) { - if (!(prop in Module['asm'])) { - console.warn(`Warning: parser wants to call function ${prop}, but it is not defined. If parsing fails, this is probably the reason why. Please report this to the Pulsar team so that this parser can be supported properly.`); + function checkForAsmVersion(prop) { + if (!(prop in Module['asm'])) { + console.warn(`Warning: parser wants to call function ${prop}, but it is not defined. If parsing fails, this is probably the reason why. Please report this to the Pulsar team so that this parser can be supported properly.`); + } } - } - - var initPromise; - var document = typeof window == "object" ? { - currentScript: window.document.currentScript - } : null; - class Parser { - constructor() { - this.initialize() - } - initialize() { - throw new Error("cannot construct a Parser before calling `init()`") - } - static init(moduleOptions) { - if (initPromise) return initPromise; - Module = Object.assign({}, Module, moduleOptions); - return initPromise = new Promise(resolveInitPromise => { - var moduleOverrides = {}; - var key; - for (key in Module) { - if (Module.hasOwnProperty(key)) { - moduleOverrides[key] = Module[key] - } - } - var arguments_ = []; - var thisProgram = "./this.program"; - var quit_ = function(status, toThrow) { - throw toThrow - }; - var ENVIRONMENT_IS_WEB = false; - var ENVIRONMENT_IS_WORKER = false; - var ENVIRONMENT_IS_NODE = false; - var ENVIRONMENT_IS_SHELL = false; - ENVIRONMENT_IS_WEB = typeof window === "object"; - ENVIRONMENT_IS_WORKER = typeof importScripts === "function"; - ENVIRONMENT_IS_NODE = typeof process === "object" && typeof process.versions === "object" && typeof process.versions.node === "string"; - ENVIRONMENT_IS_SHELL = !ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_NODE && !ENVIRONMENT_IS_WORKER; - var scriptDirectory = ""; - - function locateFile(path) { - if (Module["locateFile"]) { - return Module["locateFile"](path, scriptDirectory) - } - return scriptDirectory + path - } - var read_, readAsync, readBinary, setWindowTitle; - var nodeFS; - var nodePath; - if (ENVIRONMENT_IS_NODE) { - if (ENVIRONMENT_IS_WORKER) { - scriptDirectory = require("path").dirname(scriptDirectory) + "/" - } else { - scriptDirectory = __dirname + "/" - } - read_ = function shell_read(filename, binary) { - if (!nodeFS) nodeFS = require("fs"); - if (!nodePath) nodePath = require("path"); - filename = nodePath["normalize"](filename); - return nodeFS["readFileSync"](filename, binary ? null : "utf8") - }; - readBinary = function readBinary(filename) { - var ret = read_(filename, true); - if (!ret.buffer) { - ret = new Uint8Array(ret) - } - assert(ret.buffer); - return ret - }; - if (process["argv"].length > 1) { - thisProgram = process["argv"][1].replace(/\\/g, "/") - } - arguments_ = process["argv"].slice(2); - if (typeof module !== "undefined") { - module["exports"] = Module - } - quit_ = function(status) { - process["exit"](status) - }; - Module["inspect"] = function() { - return "[Emscripten Module object]" - } - } else if (ENVIRONMENT_IS_SHELL) { - if (typeof read != "undefined") { - read_ = function shell_read(f) { - return read(f) - } - } - readBinary = function readBinary(f) { - var data; - if (typeof readbuffer === "function") { - return new Uint8Array(readbuffer(f)) - } - data = read(f, "binary"); - assert(typeof data === "object"); - return data - }; - if (typeof scriptArgs != "undefined") { - arguments_ = scriptArgs - } else if (typeof arguments != "undefined") { - arguments_ = arguments - } - if (typeof quit === "function") { - quit_ = function(status) { - quit(status) - } - } - if (typeof print !== "undefined") { - if (typeof console === "undefined") console = {}; - console.log = print; - console.warn = console.error = typeof printErr !== "undefined" ? printErr : print - } - } else if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) { - if (ENVIRONMENT_IS_WORKER) { - scriptDirectory = self.location.href - } else if (typeof document !== "undefined" && document.currentScript) { - scriptDirectory = document.currentScript.src - } - if (scriptDirectory.indexOf("blob:") !== 0) { - scriptDirectory = scriptDirectory.substr(0, scriptDirectory.lastIndexOf("/") + 1) - } else { - scriptDirectory = "" - } { - read_ = function(url) { - var xhr = new XMLHttpRequest; - xhr.open("GET", url, false); - xhr.send(null); - return xhr.responseText - }; - if (ENVIRONMENT_IS_WORKER) { - readBinary = function(url) { - var xhr = new XMLHttpRequest; - xhr.open("GET", url, false); - xhr.responseType = "arraybuffer"; - xhr.send(null); - return new Uint8Array(xhr.response) - } - } - readAsync = function(url, onload, onerror) { - var xhr = new XMLHttpRequest; - xhr.open("GET", url, true); - xhr.responseType = "arraybuffer"; - xhr.onload = function() { - if (xhr.status == 200 || xhr.status == 0 && xhr.response) { - onload(xhr.response); - return - } - onerror() - }; - xhr.onerror = onerror; - xhr.send(null) - } - } - setWindowTitle = function(title) { - document.title = title - } - } else {} - var out = Module["print"] || console.log.bind(console); - var err = Module["printErr"] || console.warn.bind(console); - for (key in moduleOverrides) { - if (moduleOverrides.hasOwnProperty(key)) { - Module[key] = moduleOverrides[key] - } - } - moduleOverrides = null; - if (Module["arguments"]) arguments_ = Module["arguments"]; - if (Module["thisProgram"]) thisProgram = Module["thisProgram"]; - if (Module["quit"]) quit_ = Module["quit"]; - var STACK_ALIGN = 16; - - function alignMemory(size, factor) { - if (!factor) factor = STACK_ALIGN; - return Math.ceil(size / factor) * factor - } - function convertJsFunctionToWasm(func, sig) { - if (typeof WebAssembly.Function === "function") { - var typeNames = { - "i": "i32", - "j": "i64", - "f": "f32", - "d": "f64" - }; - var type = { - parameters: [], - results: sig[0] == "v" ? [] : [typeNames[sig[0]]] - }; - for (var i = 1; i < sig.length; - ++i) { - type.parameters.push(typeNames[sig[i]]) - } - return new WebAssembly.Function(type, func) - } - var typeSection = [1, 0, 1, 96]; - var sigRet = sig.slice(0, 1); - var sigParam = sig.slice(1); - var typeCodes = { - "i": 127, - "j": 126, - "f": 125, - "d": 124 - }; - typeSection.push(sigParam.length); - for (var i = 0; i < sigParam.length; - ++i) { - typeSection.push(typeCodes[sigParam[i]]) - } - if (sigRet == "v") { - typeSection.push(0) - } else { - typeSection = typeSection.concat([1, typeCodes[sigRet]]) - } - typeSection[1] = typeSection.length - 2; - var bytes = new Uint8Array([0, 97, 115, 109, 1, 0, 0, 0].concat(typeSection, [2, 7, 1, 1, 101, 1, 102, 0, 0, 7, 5, 1, 1, 102, 0, 0])); - var module = new WebAssembly.Module(bytes); - var instance = new WebAssembly.Instance(module, { - "e": { - "f": func - } - }); - var wrappedFunc = instance.exports["f"]; - return wrappedFunc - } - var freeTableIndexes = []; - var functionsInTableMap; - - function getEmptyTableSlot() { - if (freeTableIndexes.length) { - return freeTableIndexes.pop() - } - try { - wasmTable.grow(1) - } catch (err) { - if (!(err instanceof RangeError)) { - throw err - } - throw "Unable to grow wasm table. Set ALLOW_TABLE_GROWTH." - } - return wasmTable.length - 1 - } + var initPromise; + var document = typeof window == "object" ? { + currentScript: window.document.currentScript + } : null; + class Parser { + constructor() { + this.initialize() + } + initialize() { + throw new Error("cannot construct a Parser before calling `init()`") + } + static init(moduleOptions) { + if (initPromise) return initPromise; + Module = Object.assign({}, Module, moduleOptions); + return initPromise = new Promise(resolveInitPromise => { + var moduleOverrides = {}; + var key; + for (key in Module) { + if (Module.hasOwnProperty(key)) { + moduleOverrides[key] = Module[key] + } + } + var arguments_ = []; + var thisProgram = "./this.program"; + var quit_ = function(status, toThrow) { + throw toThrow + }; + var ENVIRONMENT_IS_WEB = false; + var ENVIRONMENT_IS_WORKER = false; + var ENVIRONMENT_IS_NODE = false; + var ENVIRONMENT_IS_SHELL = false; + ENVIRONMENT_IS_WEB = typeof window === "object"; + ENVIRONMENT_IS_WORKER = typeof importScripts === "function"; + ENVIRONMENT_IS_NODE = typeof process === "object" && typeof process.versions === "object" && typeof process.versions.node === "string"; + ENVIRONMENT_IS_SHELL = !ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_NODE && !ENVIRONMENT_IS_WORKER; + var scriptDirectory = ""; + + function locateFile(path) { + if (Module["locateFile"]) { + return Module["locateFile"](path, scriptDirectory) + } + return scriptDirectory + path + } + var read_, readAsync, readBinary, setWindowTitle; + var nodeFS; + var nodePath; + if (ENVIRONMENT_IS_NODE) { + if (ENVIRONMENT_IS_WORKER) { + scriptDirectory = require("path").dirname(scriptDirectory) + "/" + } else { + scriptDirectory = __dirname + "/" + } + read_ = function shell_read(filename, binary) { + if (!nodeFS) nodeFS = require("fs"); + if (!nodePath) nodePath = require("path"); + filename = nodePath["normalize"](filename); + return nodeFS["readFileSync"](filename, binary ? null : "utf8") + }; + readBinary = function readBinary(filename) { + var ret = read_(filename, true); + if (!ret.buffer) { + ret = new Uint8Array(ret) + } + assert(ret.buffer); + return ret + }; + if (process["argv"].length > 1) { + thisProgram = process["argv"][1].replace(/\\/g, "/") + } + arguments_ = process["argv"].slice(2); + if (typeof module !== "undefined") { + module["exports"] = Module + } + quit_ = function(status) { + process["exit"](status) + }; + Module["inspect"] = function() { + return "[Emscripten Module object]" + } + } else if (ENVIRONMENT_IS_SHELL) { + if (typeof read != "undefined") { + read_ = function shell_read(f) { + return read(f) + } + } + readBinary = function readBinary(f) { + var data; + if (typeof readbuffer === "function") { + return new Uint8Array(readbuffer(f)) + } + data = read(f, "binary"); + assert(typeof data === "object"); + return data + }; + if (typeof scriptArgs != "undefined") { + arguments_ = scriptArgs + } else if (typeof arguments != "undefined") { + arguments_ = arguments + } + if (typeof quit === "function") { + quit_ = function(status) { + quit(status) + } + } + if (typeof print !== "undefined") { + if (typeof console === "undefined") console = {}; + console.log = print; + console.warn = console.error = typeof printErr !== "undefined" ? printErr : print + } + } else if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) { + if (ENVIRONMENT_IS_WORKER) { + scriptDirectory = self.location.href + } else if (typeof document !== "undefined" && document.currentScript) { + scriptDirectory = document.currentScript.src + } + if (scriptDirectory.indexOf("blob:") !== 0) { + scriptDirectory = scriptDirectory.substr(0, scriptDirectory.lastIndexOf("/") + 1) + } else { + scriptDirectory = "" + } { + read_ = function(url) { + var xhr = new XMLHttpRequest; + xhr.open("GET", url, false); + xhr.send(null); + return xhr.responseText + }; + if (ENVIRONMENT_IS_WORKER) { + readBinary = function(url) { + var xhr = new XMLHttpRequest; + xhr.open("GET", url, false); + xhr.responseType = "arraybuffer"; + xhr.send(null); + return new Uint8Array(xhr.response) + } + } + readAsync = function(url, onload, onerror) { + var xhr = new XMLHttpRequest; + xhr.open("GET", url, true); + xhr.responseType = "arraybuffer"; + xhr.onload = function() { + if (xhr.status == 200 || xhr.status == 0 && xhr.response) { + onload(xhr.response); + return + } + onerror() + }; + xhr.onerror = onerror; + xhr.send(null) + } + } + setWindowTitle = function(title) { + document.title = title + } + } else {} + var out = Module["print"] || console.log.bind(console); + var err = Module["printErr"] || console.warn.bind(console); + for (key in moduleOverrides) { + if (moduleOverrides.hasOwnProperty(key)) { + Module[key] = moduleOverrides[key] + } + } + moduleOverrides = null; + if (Module["arguments"]) arguments_ = Module["arguments"]; + if (Module["thisProgram"]) thisProgram = Module["thisProgram"]; + if (Module["quit"]) quit_ = Module["quit"]; + var STACK_ALIGN = 16; + + function alignMemory(size, factor) { + if (!factor) factor = STACK_ALIGN; + return Math.ceil(size / factor) * factor + } - function addFunctionWasm(func, sig) { - if (!functionsInTableMap) { - functionsInTableMap = new WeakMap; - for (var i = 0; i < wasmTable.length; i++) { - var item = wasmTable.get(i); - if (item) { - functionsInTableMap.set(item, i) - } - } - } - if (functionsInTableMap.has(func)) { - return functionsInTableMap.get(func) - } - var ret = getEmptyTableSlot(); - try { - wasmTable.set(ret, func) - } catch (err) { - if (!(err instanceof TypeError)) { - throw err - } - var wrapped = convertJsFunctionToWasm(func, sig); - wasmTable.set(ret, wrapped) - } - functionsInTableMap.set(func, ret); - return ret - } - var tempRet0 = 0; - var setTempRet0 = function(value) { - tempRet0 = value - }; - var dynamicLibraries = Module["dynamicLibraries"] || []; - var wasmBinary; - if (Module["wasmBinary"]) wasmBinary = Module["wasmBinary"]; - var noExitRuntime = Module["noExitRuntime"] || true; - if (typeof WebAssembly !== "object") { - abort("no native wasm support detected") - } + function convertJsFunctionToWasm(func, sig) { + if (typeof WebAssembly.Function === "function") { + var typeNames = { + "i": "i32", + "j": "i64", + "f": "f32", + "d": "f64" + }; + var type = { + parameters: [], + results: sig[0] == "v" ? [] : [typeNames[sig[0]]] + }; + for (var i = 1; i < sig.length; ++i) { + type.parameters.push(typeNames[sig[i]]) + } + return new WebAssembly.Function(type, func) + } + var typeSection = [1, 0, 1, 96]; + var sigRet = sig.slice(0, 1); + var sigParam = sig.slice(1); + var typeCodes = { + "i": 127, + "j": 126, + "f": 125, + "d": 124 + }; + typeSection.push(sigParam.length); + for (var i = 0; i < sigParam.length; ++i) { + typeSection.push(typeCodes[sigParam[i]]) + } + if (sigRet == "v") { + typeSection.push(0) + } else { + typeSection = typeSection.concat([1, typeCodes[sigRet]]) + } + typeSection[1] = typeSection.length - 2; + var bytes = new Uint8Array([0, 97, 115, 109, 1, 0, 0, 0].concat(typeSection, [2, 7, 1, 1, 101, 1, 102, 0, 0, 7, 5, 1, 1, 102, 0, 0])); + var module = new WebAssembly.Module(bytes); + var instance = new WebAssembly.Instance(module, { + "e": { + "f": func + } + }); + var wrappedFunc = instance.exports["f"]; + return wrappedFunc + } + var freeTableIndexes = []; + var functionsInTableMap; + + function getEmptyTableSlot() { + if (freeTableIndexes.length) { + return freeTableIndexes.pop() + } + try { + wasmTable.grow(1) + } catch (err) { + if (!(err instanceof RangeError)) { + throw err + } + throw "Unable to grow wasm table. Set ALLOW_TABLE_GROWTH." + } + return wasmTable.length - 1 + } - function setValue(ptr, value, type, noSafe) { - type = type || "i8"; - if (type.charAt(type.length - 1) === "*") type = "i32"; - switch (type) { - case "i1": - HEAP8[ptr >> 0] = value; - break; - case "i8": - HEAP8[ptr >> 0] = value; - break; - case "i16": - HEAP16[ptr >> 1] = value; - break; - case "i32": - HEAP32[ptr >> 2] = value; - break; - case "i64": - tempI64 = [value >>> 0, (tempDouble = value, +Math.abs(tempDouble) >= 1 ? tempDouble > 0 ? (Math.min(+Math.floor(tempDouble / 4294967296), 4294967295) | 0) >>> 0 : ~~+Math.ceil((tempDouble - +(~~tempDouble >>> 0)) / 4294967296) >>> 0 : 0)], HEAP32[ptr >> 2] = tempI64[0], HEAP32[ptr + 4 >> 2] = tempI64[1]; - break; - case "float": - HEAPF32[ptr >> 2] = value; - break; - case "double": - HEAPF64[ptr >> 3] = value; - break; - default: - abort("invalid type for setValue: " + type) - } - } + function addFunctionWasm(func, sig) { + if (!functionsInTableMap) { + functionsInTableMap = new WeakMap; + for (var i = 0; i < wasmTable.length; i++) { + var item = wasmTable.get(i); + if (item) { + functionsInTableMap.set(item, i) + } + } + } + if (functionsInTableMap.has(func)) { + return functionsInTableMap.get(func) + } + var ret = getEmptyTableSlot(); + try { + wasmTable.set(ret, func) + } catch (err) { + if (!(err instanceof TypeError)) { + throw err + } + var wrapped = convertJsFunctionToWasm(func, sig); + wasmTable.set(ret, wrapped) + } + functionsInTableMap.set(func, ret); + return ret + } + var tempRet0 = 0; + var setTempRet0 = function(value) { + tempRet0 = value + }; + var dynamicLibraries = Module["dynamicLibraries"] || []; + var wasmBinary; + if (Module["wasmBinary"]) wasmBinary = Module["wasmBinary"]; + var noExitRuntime = Module["noExitRuntime"] || true; + if (typeof WebAssembly !== "object") { + abort("no native wasm support detected") + } - function getValue(ptr, type, noSafe) { - type = type || "i8"; - if (type.charAt(type.length - 1) === "*") type = "i32"; - switch (type) { - case "i1": - return HEAP8[ptr >> 0]; - case "i8": - return HEAP8[ptr >> 0]; - case "i16": - return HEAP16[ptr >> 1]; - case "i32": - return HEAP32[ptr >> 2]; - case "i64": - return HEAP32[ptr >> 2]; - case "float": - return HEAPF32[ptr >> 2]; - case "double": - return HEAPF64[ptr >> 3]; - default: - abort("invalid type for getValue: " + type) - } - return null - } - var wasmMemory; - var ABORT = false; - var EXITSTATUS; - - function assert(condition, text) { - if (!condition) { - abort("Assertion failed: " + text) - } - } - var ALLOC_STACK = 1; - - function allocate(slab, allocator) { - var ret; - if (allocator == ALLOC_STACK) { - ret = stackAlloc(slab.length) - } else { - ret = _malloc(slab.length) - } - if (slab.subarray || slab.slice) { - HEAPU8.set(slab, ret) - } else { - HEAPU8.set(new Uint8Array(slab), ret) - } - return ret - } - var UTF8Decoder = typeof TextDecoder !== "undefined" ? new TextDecoder("utf8") : undefined; - - function UTF8ArrayToString(heap, idx, maxBytesToRead) { - var endIdx = idx + maxBytesToRead; - var endPtr = idx; - while (heap[endPtr] && !(endPtr >= endIdx)) ++endPtr; - if (endPtr - idx > 16 && heap.subarray && UTF8Decoder) { - return UTF8Decoder.decode(heap.subarray(idx, endPtr)) - } else { - var str = ""; - while (idx < endPtr) { - var u0 = heap[idx++]; - if (!(u0 & 128)) { - str += String.fromCharCode(u0); - continue - } - var u1 = heap[idx++] & 63; - if ((u0 & 224) == 192) { - str += String.fromCharCode((u0 & 31) << 6 | u1); - continue - } - var u2 = heap[idx++] & 63; - if ((u0 & 240) == 224) { - u0 = (u0 & 15) << 12 | u1 << 6 | u2 - } else { - u0 = (u0 & 7) << 18 | u1 << 12 | u2 << 6 | heap[idx++] & 63 - } - if (u0 < 65536) { - str += String.fromCharCode(u0) - } else { - var ch = u0 - 65536; - str += String.fromCharCode(55296 | ch >> 10, 56320 | ch & 1023) - } - } - } - return str - } + function setValue(ptr, value, type, noSafe) { + type = type || "i8"; + if (type.charAt(type.length - 1) === "*") type = "i32"; + switch (type) { + case "i1": + HEAP8[ptr >> 0] = value; + break; + case "i8": + HEAP8[ptr >> 0] = value; + break; + case "i16": + HEAP16[ptr >> 1] = value; + break; + case "i32": + HEAP32[ptr >> 2] = value; + break; + case "i64": + tempI64 = [value >>> 0, (tempDouble = value, +Math.abs(tempDouble) >= 1 ? tempDouble > 0 ? (Math.min(+Math.floor(tempDouble / 4294967296), 4294967295) | 0) >>> 0 : ~~+Math.ceil((tempDouble - +(~~tempDouble >>> 0)) / 4294967296) >>> 0 : 0)], HEAP32[ptr >> 2] = tempI64[0], HEAP32[ptr + 4 >> 2] = tempI64[1]; + break; + case "float": + HEAPF32[ptr >> 2] = value; + break; + case "double": + HEAPF64[ptr >> 3] = value; + break; + default: + abort("invalid type for setValue: " + type) + } + } - function UTF8ToString(ptr, maxBytesToRead) { - return ptr ? UTF8ArrayToString(HEAPU8, ptr, maxBytesToRead) : "" - } + function getValue(ptr, type, noSafe) { + type = type || "i8"; + if (type.charAt(type.length - 1) === "*") type = "i32"; + switch (type) { + case "i1": + return HEAP8[ptr >> 0]; + case "i8": + return HEAP8[ptr >> 0]; + case "i16": + return HEAP16[ptr >> 1]; + case "i32": + return HEAP32[ptr >> 2]; + case "i64": + return HEAP32[ptr >> 2]; + case "float": + return HEAPF32[ptr >> 2]; + case "double": + return HEAPF64[ptr >> 3]; + default: + abort("invalid type for getValue: " + type) + } + return null + } + var wasmMemory; + var ABORT = false; + var EXITSTATUS; + + function assert(condition, text) { + if (!condition) { + abort("Assertion failed: " + text) + } + } + var ALLOC_STACK = 1; + + function allocate(slab, allocator) { + var ret; + if (allocator == ALLOC_STACK) { + ret = stackAlloc(slab.length) + } else { + ret = _malloc(slab.length) + } + if (slab.subarray || slab.slice) { + HEAPU8.set(slab, ret) + } else { + HEAPU8.set(new Uint8Array(slab), ret) + } + return ret + } + var UTF8Decoder = typeof TextDecoder !== "undefined" ? new TextDecoder("utf8") : undefined; + + function UTF8ArrayToString(heap, idx, maxBytesToRead) { + var endIdx = idx + maxBytesToRead; + var endPtr = idx; + while (heap[endPtr] && !(endPtr >= endIdx)) ++endPtr; + if (endPtr - idx > 16 && heap.subarray && UTF8Decoder) { + return UTF8Decoder.decode(heap.subarray(idx, endPtr)) + } else { + var str = ""; + while (idx < endPtr) { + var u0 = heap[idx++]; + if (!(u0 & 128)) { + str += String.fromCharCode(u0); + continue + } + var u1 = heap[idx++] & 63; + if ((u0 & 224) == 192) { + str += String.fromCharCode((u0 & 31) << 6 | u1); + continue + } + var u2 = heap[idx++] & 63; + if ((u0 & 240) == 224) { + u0 = (u0 & 15) << 12 | u1 << 6 | u2 + } else { + u0 = (u0 & 7) << 18 | u1 << 12 | u2 << 6 | heap[idx++] & 63 + } + if (u0 < 65536) { + str += String.fromCharCode(u0) + } else { + var ch = u0 - 65536; + str += String.fromCharCode(55296 | ch >> 10, 56320 | ch & 1023) + } + } + } + return str + } - function stringToUTF8Array(str, heap, outIdx, maxBytesToWrite) { - if (!(maxBytesToWrite > 0)) return 0; - var startIdx = outIdx; - var endIdx = outIdx + maxBytesToWrite - 1; - for (var i = 0; i < str.length; - ++i) { - var u = str.charCodeAt(i); - if (u >= 55296 && u <= 57343) { - var u1 = str.charCodeAt(++i); - u = 65536 + ((u & 1023) << 10) | u1 & 1023 - } - if (u <= 127) { - if (outIdx >= endIdx) break; - heap[outIdx++] = u - } else if (u <= 2047) { - if (outIdx + 1 >= endIdx) break; - heap[outIdx++] = 192 | u >> 6; - heap[outIdx++] = 128 | u & 63 - } else if (u <= 65535) { - if (outIdx + 2 >= endIdx) break; - heap[outIdx++] = 224 | u >> 12; - heap[outIdx++] = 128 | u >> 6 & 63; - heap[outIdx++] = 128 | u & 63 - } else { - if (outIdx + 3 >= endIdx) break; - heap[outIdx++] = 240 | u >> 18; - heap[outIdx++] = 128 | u >> 12 & 63; - heap[outIdx++] = 128 | u >> 6 & 63; - heap[outIdx++] = 128 | u & 63 - } - } - heap[outIdx] = 0; - return outIdx - startIdx - } + function UTF8ToString(ptr, maxBytesToRead) { + return ptr ? UTF8ArrayToString(HEAPU8, ptr, maxBytesToRead) : "" + } - function stringToUTF8(str, outPtr, maxBytesToWrite) { - return stringToUTF8Array(str, HEAPU8, outPtr, maxBytesToWrite) - } + function stringToUTF8Array(str, heap, outIdx, maxBytesToWrite) { + if (!(maxBytesToWrite > 0)) return 0; + var startIdx = outIdx; + var endIdx = outIdx + maxBytesToWrite - 1; + for (var i = 0; i < str.length; ++i) { + var u = str.charCodeAt(i); + if (u >= 55296 && u <= 57343) { + var u1 = str.charCodeAt(++i); + u = 65536 + ((u & 1023) << 10) | u1 & 1023 + } + if (u <= 127) { + if (outIdx >= endIdx) break; + heap[outIdx++] = u + } else if (u <= 2047) { + if (outIdx + 1 >= endIdx) break; + heap[outIdx++] = 192 | u >> 6; + heap[outIdx++] = 128 | u & 63 + } else if (u <= 65535) { + if (outIdx + 2 >= endIdx) break; + heap[outIdx++] = 224 | u >> 12; + heap[outIdx++] = 128 | u >> 6 & 63; + heap[outIdx++] = 128 | u & 63 + } else { + if (outIdx + 3 >= endIdx) break; + heap[outIdx++] = 240 | u >> 18; + heap[outIdx++] = 128 | u >> 12 & 63; + heap[outIdx++] = 128 | u >> 6 & 63; + heap[outIdx++] = 128 | u & 63 + } + } + heap[outIdx] = 0; + return outIdx - startIdx + } - function lengthBytesUTF8(str) { - var len = 0; - for (var i = 0; i < str.length; - ++i) { - var u = str.charCodeAt(i); - if (u >= 55296 && u <= 57343) u = 65536 + ((u & 1023) << 10) | str.charCodeAt(++i) & 1023; - if (u <= 127) ++len; - else if (u <= 2047) len += 2; - else if (u <= 65535) len += 3; - else len += 4 - } - return len - } + function stringToUTF8(str, outPtr, maxBytesToWrite) { + return stringToUTF8Array(str, HEAPU8, outPtr, maxBytesToWrite) + } - function AsciiToString(ptr) { - var str = ""; - while (1) { - var ch = HEAPU8[ptr++ >> 0]; - if (!ch) return str; - str += String.fromCharCode(ch) - } - } + function lengthBytesUTF8(str) { + var len = 0; + for (var i = 0; i < str.length; ++i) { + var u = str.charCodeAt(i); + if (u >= 55296 && u <= 57343) u = 65536 + ((u & 1023) << 10) | str.charCodeAt(++i) & 1023; + if (u <= 127) ++len; + else if (u <= 2047) len += 2; + else if (u <= 65535) len += 3; + else len += 4 + } + return len + } - function stringToUTF16(str, outPtr, maxBytesToWrite) { - if (maxBytesToWrite === undefined) { - maxBytesToWrite = 2147483647 - } - if (maxBytesToWrite < 2) return 0; - maxBytesToWrite -= 2; - var startPtr = outPtr; - var numCharsToWrite = maxBytesToWrite < str.length * 2 ? maxBytesToWrite / 2 : str.length; - for (var i = 0; i < numCharsToWrite; - ++i) { - var codeUnit = str.charCodeAt(i); - HEAP16[outPtr >> 1] = codeUnit; - outPtr += 2 - } - HEAP16[outPtr >> 1] = 0; - return outPtr - startPtr - } + function AsciiToString(ptr) { + var str = ""; + while (1) { + var ch = HEAPU8[ptr++ >> 0]; + if (!ch) return str; + str += String.fromCharCode(ch) + } + } - function allocateUTF8OnStack(str) { - var size = lengthBytesUTF8(str) + 1; - var ret = stackAlloc(size); - stringToUTF8Array(str, HEAP8, ret, size); - return ret - } + function stringToUTF16(str, outPtr, maxBytesToWrite) { + if (maxBytesToWrite === undefined) { + maxBytesToWrite = 2147483647 + } + if (maxBytesToWrite < 2) return 0; + maxBytesToWrite -= 2; + var startPtr = outPtr; + var numCharsToWrite = maxBytesToWrite < str.length * 2 ? maxBytesToWrite / 2 : str.length; + for (var i = 0; i < numCharsToWrite; ++i) { + var codeUnit = str.charCodeAt(i); + HEAP16[outPtr >> 1] = codeUnit; + outPtr += 2 + } + HEAP16[outPtr >> 1] = 0; + return outPtr - startPtr + } - function alignUp(x, multiple) { - if (x % multiple > 0) { - x += multiple - x % multiple - } - return x - } - var buffer, HEAP8, HEAPU8, HEAP16, HEAPU16, HEAP32, HEAPU32, HEAPF32, HEAPF64; - - function updateGlobalBufferAndViews(buf) { - buffer = buf; - Module["HEAP8"] = HEAP8 = new Int8Array(buf); - Module["HEAP16"] = HEAP16 = new Int16Array(buf); - Module["HEAP32"] = HEAP32 = new Int32Array(buf); - Module["HEAPU8"] = HEAPU8 = new Uint8Array(buf); - Module["HEAPU16"] = HEAPU16 = new Uint16Array(buf); - Module["HEAPU32"] = HEAPU32 = new Uint32Array(buf); - Module["HEAPF32"] = HEAPF32 = new Float32Array(buf); - Module["HEAPF64"] = HEAPF64 = new Float64Array(buf) - } - var INITIAL_MEMORY = Module["INITIAL_MEMORY"] || 33554432; - if (Module["wasmMemory"]) { - wasmMemory = Module["wasmMemory"] - } else { - wasmMemory = new WebAssembly.Memory({ - "initial": INITIAL_MEMORY / 65536, - "maximum": 2147483648 / 65536 - }) - } - if (wasmMemory) { - buffer = wasmMemory.buffer - } - INITIAL_MEMORY = buffer.byteLength; - updateGlobalBufferAndViews(buffer); - var wasmTable = new WebAssembly.Table({ - "initial": 20, - "element": "anyfunc" - }); - var __ATPRERUN__ = []; - var __ATINIT__ = []; - var __ATMAIN__ = []; - var __ATPOSTRUN__ = []; - var runtimeInitialized = false; - var runtimeExited = false; - - function preRun() { - if (Module["preRun"]) { - if (typeof Module["preRun"] == "function") Module["preRun"] = [Module["preRun"]]; - while (Module["preRun"].length) { - addOnPreRun(Module["preRun"].shift()) - } - } - callRuntimeCallbacks(__ATPRERUN__) - } + function allocateUTF8OnStack(str) { + var size = lengthBytesUTF8(str) + 1; + var ret = stackAlloc(size); + stringToUTF8Array(str, HEAP8, ret, size); + return ret + } - function initRuntime() { - runtimeInitialized = true; - callRuntimeCallbacks(__ATINIT__) - } + function alignUp(x, multiple) { + if (x % multiple > 0) { + x += multiple - x % multiple + } + return x + } + var buffer, HEAP8, HEAPU8, HEAP16, HEAPU16, HEAP32, HEAPU32, HEAPF32, HEAPF64; + + function updateGlobalBufferAndViews(buf) { + buffer = buf; + Module["HEAP8"] = HEAP8 = new Int8Array(buf); + Module["HEAP16"] = HEAP16 = new Int16Array(buf); + Module["HEAP32"] = HEAP32 = new Int32Array(buf); + Module["HEAPU8"] = HEAPU8 = new Uint8Array(buf); + Module["HEAPU16"] = HEAPU16 = new Uint16Array(buf); + Module["HEAPU32"] = HEAPU32 = new Uint32Array(buf); + Module["HEAPF32"] = HEAPF32 = new Float32Array(buf); + Module["HEAPF64"] = HEAPF64 = new Float64Array(buf) + } + var INITIAL_MEMORY = Module["INITIAL_MEMORY"] || 33554432; + if (Module["wasmMemory"]) { + wasmMemory = Module["wasmMemory"] + } else { + wasmMemory = new WebAssembly.Memory({ + "initial": INITIAL_MEMORY / 65536, + "maximum": 2147483648 / 65536 + }) + } + if (wasmMemory) { + buffer = wasmMemory.buffer + } + INITIAL_MEMORY = buffer.byteLength; + updateGlobalBufferAndViews(buffer); + var wasmTable = new WebAssembly.Table({ + "initial": 20, + "element": "anyfunc" + }); + var __ATPRERUN__ = []; + var __ATINIT__ = []; + var __ATMAIN__ = []; + var __ATPOSTRUN__ = []; + var runtimeInitialized = false; + var runtimeExited = false; + + function preRun() { + if (Module["preRun"]) { + if (typeof Module["preRun"] == "function") Module["preRun"] = [Module["preRun"]]; + while (Module["preRun"].length) { + addOnPreRun(Module["preRun"].shift()) + } + } + callRuntimeCallbacks(__ATPRERUN__) + } - function preMain() { - callRuntimeCallbacks(__ATMAIN__) - } + function initRuntime() { + runtimeInitialized = true; + callRuntimeCallbacks(__ATINIT__) + } - function exitRuntime() { - runtimeExited = true - } + function preMain() { + callRuntimeCallbacks(__ATMAIN__) + } - function postRun() { - if (Module["postRun"]) { - if (typeof Module["postRun"] == "function") Module["postRun"] = [Module["postRun"]]; - while (Module["postRun"].length) { - addOnPostRun(Module["postRun"].shift()) - } - } - callRuntimeCallbacks(__ATPOSTRUN__) - } + function exitRuntime() { + runtimeExited = true + } - function addOnPreRun(cb) { - __ATPRERUN__.unshift(cb) - } + function postRun() { + if (Module["postRun"]) { + if (typeof Module["postRun"] == "function") Module["postRun"] = [Module["postRun"]]; + while (Module["postRun"].length) { + addOnPostRun(Module["postRun"].shift()) + } + } + callRuntimeCallbacks(__ATPOSTRUN__) + } - function addOnInit(cb) { - __ATINIT__.unshift(cb) - } + function addOnPreRun(cb) { + __ATPRERUN__.unshift(cb) + } - function addOnPostRun(cb) { - __ATPOSTRUN__.unshift(cb) - } - var runDependencies = 0; - var runDependencyWatcher = null; - var dependenciesFulfilled = null; - - function addRunDependency(id) { - runDependencies++; - if (Module["monitorRunDependencies"]) { - Module["monitorRunDependencies"](runDependencies) - } - } + function addOnInit(cb) { + __ATINIT__.unshift(cb) + } - function removeRunDependency(id) { - runDependencies--; - if (Module["monitorRunDependencies"]) { - Module["monitorRunDependencies"](runDependencies) - } - if (runDependencies == 0) { - if (runDependencyWatcher !== null) { - clearInterval(runDependencyWatcher); - runDependencyWatcher = null - } - if (dependenciesFulfilled) { - var callback = dependenciesFulfilled; - dependenciesFulfilled = null; - callback() - } - } - } - Module["preloadedImages"] = {}; - Module["preloadedAudios"] = {}; - Module["preloadedWasm"] = {}; - - function abort(what) { - if (Module["onAbort"]) { - Module["onAbort"](what) - } - what += ""; - err(what); - ABORT = true; - EXITSTATUS = 1; - what = "abort(" + what + "). Build with -s ASSERTIONS=1 for more info."; - var e = new WebAssembly.RuntimeError(what); - throw e - } - var dataURIPrefix = "data:application/octet-stream;base64,"; + function addOnPostRun(cb) { + __ATPOSTRUN__.unshift(cb) + } + var runDependencies = 0; + var runDependencyWatcher = null; + var dependenciesFulfilled = null; + + function addRunDependency(id) { + runDependencies++; + if (Module["monitorRunDependencies"]) { + Module["monitorRunDependencies"](runDependencies) + } + } - function isDataURI(filename) { - return filename.startsWith(dataURIPrefix) - } + function removeRunDependency(id) { + runDependencies--; + if (Module["monitorRunDependencies"]) { + Module["monitorRunDependencies"](runDependencies) + } + if (runDependencies == 0) { + if (runDependencyWatcher !== null) { + clearInterval(runDependencyWatcher); + runDependencyWatcher = null + } + if (dependenciesFulfilled) { + var callback = dependenciesFulfilled; + dependenciesFulfilled = null; + callback() + } + } + } + Module["preloadedImages"] = {}; + Module["preloadedAudios"] = {}; + Module["preloadedWasm"] = {}; + + function abort(what) { + if (Module["onAbort"]) { + Module["onAbort"](what) + } + what += ""; + err(what); + ABORT = true; + EXITSTATUS = 1; + what = "abort(" + what + "). Build with -s ASSERTIONS=1 for more info."; + var e = new WebAssembly.RuntimeError(what); + throw e + } + var dataURIPrefix = "data:application/octet-stream;base64,"; - function isFileURI(filename) { - return filename.startsWith("file://") - } - var wasmBinaryFile; - wasmBinaryFile = "tree-sitter.wasm"; - if (!isDataURI(wasmBinaryFile)) { - wasmBinaryFile = locateFile(wasmBinaryFile) - } + function isDataURI(filename) { + return filename.startsWith(dataURIPrefix) + } - function getBinary(file) { - try { - if (file == wasmBinaryFile && wasmBinary) { - return new Uint8Array(wasmBinary) - } - if (readBinary) { - return readBinary(file) - } else { - throw "both async and sync fetching of the wasm failed" - } - } catch (err) { - abort(err) - } - } + function isFileURI(filename) { + return filename.startsWith("file://") + } + var wasmBinaryFile; + wasmBinaryFile = "tree-sitter.wasm"; + if (!isDataURI(wasmBinaryFile)) { + wasmBinaryFile = locateFile(wasmBinaryFile) + } - function getBinaryPromise() { - if (!wasmBinary && (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER)) { - if (typeof fetch === "function" && !isFileURI(wasmBinaryFile)) { - return fetch(wasmBinaryFile, { - credentials: "same-origin" - }).then(function(response) { - if (!response["ok"]) { - throw "failed to load wasm binary file at '" + wasmBinaryFile + "'" - } - return response["arrayBuffer"]() - }).catch(function() { - return getBinary(wasmBinaryFile) - }) - } else { - if (readAsync) { - return new Promise(function(resolve, reject) { - readAsync(wasmBinaryFile, function(response) { - resolve(new Uint8Array(response)) - }, reject) - }) - } - } - } - return Promise.resolve().then(function() { - return getBinary(wasmBinaryFile) - }) - } + function getBinary(file) { + try { + if (file == wasmBinaryFile && wasmBinary) { + return new Uint8Array(wasmBinary) + } + if (readBinary) { + return readBinary(file) + } else { + throw "both async and sync fetching of the wasm failed" + } + } catch (err) { + abort(err) + } + } - function createWasm() { - var info = { - "env": asmLibraryArg, - "wasi_snapshot_preview1": asmLibraryArg, - "GOT.mem": new Proxy(asmLibraryArg, GOTHandler), - "GOT.func": new Proxy(asmLibraryArg, GOTHandler) - }; - - function receiveInstance(instance, module) { - var exports = instance.exports; - exports = relocateExports(exports, 1024); - Module["asm"] = exports; - var metadata = getDylinkMetadata(module); - if (metadata.neededDynlibs) { - dynamicLibraries = metadata.neededDynlibs.concat(dynamicLibraries) - } - mergeLibSymbols(exports, "main"); - addOnInit(Module["asm"]["__wasm_call_ctors"]); - removeRunDependency("wasm-instantiate") - } - addRunDependency("wasm-instantiate"); - - function receiveInstantiationResult(result) { - receiveInstance(result["instance"], result["module"]) - } - - function instantiateArrayBuffer(receiver) { - return getBinaryPromise().then(function(binary) { - var result = WebAssembly.instantiate(binary, info); - return result - }).then(receiver, function(reason) { - err("failed to asynchronously prepare wasm: " + reason); - abort(reason) - }) - } - - function instantiateAsync() { - if (!wasmBinary && typeof WebAssembly.instantiateStreaming === "function" && !isDataURI(wasmBinaryFile) && !isFileURI(wasmBinaryFile) && typeof fetch === "function") { - return fetch(wasmBinaryFile, { - credentials: "same-origin" - }).then(function(response) { - var result = WebAssembly.instantiateStreaming(response, info); - return result.then(receiveInstantiationResult, function(reason) { - err("wasm streaming compile failed: " + reason); - err("falling back to ArrayBuffer instantiation"); - return instantiateArrayBuffer(receiveInstantiationResult) - }) - }) - } else { - return instantiateArrayBuffer(receiveInstantiationResult) - } - } - if (Module["instantiateWasm"]) { - try { - var exports = Module["instantiateWasm"](info, receiveInstance); - return exports - } catch (e) { - err("Module.instantiateWasm callback failed with error: " + e); - return false - } - } - instantiateAsync(); - return {} - } - var tempDouble; - var tempI64; - var GOT = {}; - var GOTHandler = { - get: function(obj, symName) { - if (!GOT[symName]) { - GOT[symName] = new WebAssembly.Global({ - "value": "i32", - "mutable": true - }) - } - return GOT[symName] - } - }; - - function callRuntimeCallbacks(callbacks) { - while (callbacks.length > 0) { - var callback = callbacks.shift(); - if (typeof callback == "function") { - callback(Module); - continue - } - var func = callback.func; - if (typeof func === "number") { - if (callback.arg === undefined) { - wasmTable.get(func)() - } else { - wasmTable.get(func)(callback.arg) - } - } else { - func(callback.arg === undefined ? null : callback.arg) - } - } - } + function getBinaryPromise() { + if (!wasmBinary && (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER)) { + if (typeof fetch === "function" && !isFileURI(wasmBinaryFile)) { + return fetch(wasmBinaryFile, { + credentials: "same-origin" + }).then(function(response) { + if (!response["ok"]) { + throw "failed to load wasm binary file at '" + wasmBinaryFile + "'" + } + return response["arrayBuffer"]() + }).catch(function() { + return getBinary(wasmBinaryFile) + }) + } else { + if (readAsync) { + return new Promise(function(resolve, reject) { + readAsync(wasmBinaryFile, function(response) { + resolve(new Uint8Array(response)) + }, reject) + }) + } + } + } + return Promise.resolve().then(function() { + return getBinary(wasmBinaryFile) + }) + } - function getDylinkMetadata(binary) { - var next = 0; - - function getLEB() { - var ret = 0; - var mul = 1; - while (1) { - var byte = binary[next++]; - ret += (byte & 127) * mul; - mul *= 128; - if (!(byte & 128)) break - } - return ret - } - if (binary instanceof WebAssembly.Module) { - var dylinkSection = WebAssembly.Module.customSections(binary, "dylink"); - assert(dylinkSection.length != 0, "need dylink section"); - binary = new Int8Array(dylinkSection[0]) - } else { - var int32View = new Uint32Array(new Uint8Array(binary.subarray(0, 24)).buffer); - assert(int32View[0] == 1836278016, "need to see wasm magic number"); - assert(binary[8] === 0, "need the dylink section to be first"); - next = 9; - getLEB(); - assert(binary[next] === 6); - next++; - assert(binary[next] === "d".charCodeAt(0)); - next++; - assert(binary[next] === "y".charCodeAt(0)); - next++; - assert(binary[next] === "l".charCodeAt(0)); - next++; - assert(binary[next] === "i".charCodeAt(0)); - next++; - assert(binary[next] === "n".charCodeAt(0)); - next++; - assert(binary[next] === "k".charCodeAt(0)); - next++ - } - var customSection = {}; - customSection.memorySize = getLEB(); - customSection.memoryAlign = getLEB(); - customSection.tableSize = getLEB(); - customSection.tableAlign = getLEB(); - var neededDynlibsCount = getLEB(); - customSection.neededDynlibs = []; - for (var i = 0; i < neededDynlibsCount; - ++i) { - var nameLen = getLEB(); - var nameUTF8 = binary.subarray(next, next + nameLen); - next += nameLen; - var name = UTF8ArrayToString(nameUTF8, 0); - customSection.neededDynlibs.push(name) - } - return customSection - } - var runtimeKeepaliveCounter = 0; + function createWasm() { + var info = { + "env": asmLibraryArg, + "wasi_snapshot_preview1": asmLibraryArg, + "GOT.mem": new Proxy(asmLibraryArg, GOTHandler), + "GOT.func": new Proxy(asmLibraryArg, GOTHandler) + }; + + function receiveInstance(instance, module) { + var exports = instance.exports; + exports = relocateExports(exports, 1024); + Module["asm"] = exports; + var metadata = getDylinkMetadata(module); + if (metadata.neededDynlibs) { + dynamicLibraries = metadata.neededDynlibs.concat(dynamicLibraries) + } + mergeLibSymbols(exports, "main"); + addOnInit(Module["asm"]["__wasm_call_ctors"]); + removeRunDependency("wasm-instantiate") + } + addRunDependency("wasm-instantiate"); + + function receiveInstantiationResult(result) { + receiveInstance(result["instance"], result["module"]) + } + + function instantiateArrayBuffer(receiver) { + return getBinaryPromise().then(function(binary) { + var result = WebAssembly.instantiate(binary, info); + return result + }).then(receiver, function(reason) { + err("failed to asynchronously prepare wasm: " + reason); + abort(reason) + }) + } + + function instantiateAsync() { + if (!wasmBinary && typeof WebAssembly.instantiateStreaming === "function" && !isDataURI(wasmBinaryFile) && !isFileURI(wasmBinaryFile) && typeof fetch === "function") { + return fetch(wasmBinaryFile, { + credentials: "same-origin" + }).then(function(response) { + var result = WebAssembly.instantiateStreaming(response, info); + return result.then(receiveInstantiationResult, function(reason) { + err("wasm streaming compile failed: " + reason); + err("falling back to ArrayBuffer instantiation"); + return instantiateArrayBuffer(receiveInstantiationResult) + }) + }) + } else { + return instantiateArrayBuffer(receiveInstantiationResult) + } + } + if (Module["instantiateWasm"]) { + try { + var exports = Module["instantiateWasm"](info, receiveInstance); + return exports + } catch (e) { + err("Module.instantiateWasm callback failed with error: " + e); + return false + } + } + instantiateAsync(); + return {} + } + var tempDouble; + var tempI64; + var GOT = {}; + var GOTHandler = { + get: function(obj, symName) { + if (!GOT[symName]) { + GOT[symName] = new WebAssembly.Global({ + "value": "i32", + "mutable": true + }) + } + return GOT[symName] + } + }; - function keepRuntimeAlive() { - return noExitRuntime || runtimeKeepaliveCounter > 0 - } + function callRuntimeCallbacks(callbacks) { + while (callbacks.length > 0) { + var callback = callbacks.shift(); + if (typeof callback == "function") { + callback(Module); + continue + } + var func = callback.func; + if (typeof func === "number") { + if (callback.arg === undefined) { + wasmTable.get(func)() + } else { + wasmTable.get(func)(callback.arg) + } + } else { + func(callback.arg === undefined ? null : callback.arg) + } + } + } - function asmjsMangle(x) { - var unmangledSymbols = ["stackAlloc", "stackSave", "stackRestore"]; - return x.indexOf("dynCall_") == 0 || unmangledSymbols.includes(x) ? x : "_" + x - } + function getDylinkMetadata(binary) { + var next = 0; + + function getLEB() { + var ret = 0; + var mul = 1; + while (1) { + var byte = binary[next++]; + ret += (byte & 127) * mul; + mul *= 128; + if (!(byte & 128)) break + } + return ret + } + if (binary instanceof WebAssembly.Module) { + var dylinkSection = WebAssembly.Module.customSections(binary, "dylink"); + assert(dylinkSection.length != 0, "need dylink section"); + binary = new Int8Array(dylinkSection[0]) + } else { + var int32View = new Uint32Array(new Uint8Array(binary.subarray(0, 24)).buffer); + assert(int32View[0] == 1836278016, "need to see wasm magic number"); + assert(binary[8] === 0, "need the dylink section to be first"); + next = 9; + getLEB(); + assert(binary[next] === 6); + next++; + assert(binary[next] === "d".charCodeAt(0)); + next++; + assert(binary[next] === "y".charCodeAt(0)); + next++; + assert(binary[next] === "l".charCodeAt(0)); + next++; + assert(binary[next] === "i".charCodeAt(0)); + next++; + assert(binary[next] === "n".charCodeAt(0)); + next++; + assert(binary[next] === "k".charCodeAt(0)); + next++ + } + var customSection = {}; + customSection.memorySize = getLEB(); + customSection.memoryAlign = getLEB(); + customSection.tableSize = getLEB(); + customSection.tableAlign = getLEB(); + var neededDynlibsCount = getLEB(); + customSection.neededDynlibs = []; + for (var i = 0; i < neededDynlibsCount; ++i) { + var nameLen = getLEB(); + var nameUTF8 = binary.subarray(next, next + nameLen); + next += nameLen; + var name = UTF8ArrayToString(nameUTF8, 0); + customSection.neededDynlibs.push(name) + } + return customSection + } + var runtimeKeepaliveCounter = 0; - function mergeLibSymbols(exports, libName) { - for (var sym in exports) { - if (!exports.hasOwnProperty(sym)) { - continue - } - if (!asmLibraryArg.hasOwnProperty(sym)) { - asmLibraryArg[sym] = exports[sym] - } - var module_sym = asmjsMangle(sym); - if (!Module.hasOwnProperty(module_sym)) { - Module[module_sym] = exports[sym] - } - } - } - var LDSO = { - nextHandle: 1, - loadedLibs: {}, - loadedLibNames: {} - }; - - function dynCallLegacy(sig, ptr, args) { - var f = Module["dynCall_" + sig]; - return args && args.length ? f.apply(null, [ptr].concat(args)) : f.call(null, ptr) - } + function keepRuntimeAlive() { + return noExitRuntime || runtimeKeepaliveCounter > 0 + } - function dynCall(sig, ptr, args) { - if (sig.includes("j")) { - return dynCallLegacy(sig, ptr, args) - } - return wasmTable.get(ptr).apply(null, args) - } + function asmjsMangle(x) { + var unmangledSymbols = ["stackAlloc", "stackSave", "stackRestore"]; + return x.indexOf("dynCall_") == 0 || unmangledSymbols.includes(x) ? x : "_" + x + } - function createInvokeFunction(sig) { - return function() { - var sp = stackSave(); - try { - return dynCall(sig, arguments[0], Array.prototype.slice.call(arguments, 1)) - } catch (e) { - stackRestore(sp); - if (e !== e + 0 && e !== "longjmp") throw e; - _setThrew(1, 0) - } - } - } - var ___heap_base = 5251072; - Module["___heap_base"] = ___heap_base; - - function getMemory(size) { - if (runtimeInitialized) return _malloc(size); - var ret = ___heap_base; - var end = ret + size + 15 & -16; - ___heap_base = end; - GOT["__heap_base"].value = end; - return ret - } + function mergeLibSymbols(exports, libName) { + for (var sym in exports) { + if (!exports.hasOwnProperty(sym)) { + continue + } + if (!asmLibraryArg.hasOwnProperty(sym)) { + asmLibraryArg[sym] = exports[sym] + } + var module_sym = asmjsMangle(sym); + if (!Module.hasOwnProperty(module_sym)) { + Module[module_sym] = exports[sym] + } + } + } + var LDSO = { + nextHandle: 1, + loadedLibs: {}, + loadedLibNames: {} + }; - function isInternalSym(symName) { - return ["__cpp_exception", "__wasm_apply_data_relocs", "__dso_handle", "__set_stack_limits"].includes(symName) - } + function dynCallLegacy(sig, ptr, args) { + var f = Module["dynCall_" + sig]; + return args && args.length ? f.apply(null, [ptr].concat(args)) : f.call(null, ptr) + } - function updateGOT(exports) { - for (var symName in exports) { - if (isInternalSym(symName)) { - continue - } - var replace = false; - var value = exports[symName]; - if (symName.startsWith("orig$")) { - symName = symName.split("$")[1]; - replace = true - } - if (!GOT[symName]) { - GOT[symName] = new WebAssembly.Global({ - "value": "i32", - "mutable": true - }) - } - if (replace || GOT[symName].value == 0) { - if (typeof value === "function") { - GOT[symName].value = addFunctionWasm(value) - } else if (typeof value === "number") { - GOT[symName].value = value - } else { - err("unhandled export type for `" + symName + "`: " + typeof value) - } - } - } - } + function dynCall(sig, ptr, args) { + if (sig.includes("j")) { + return dynCallLegacy(sig, ptr, args) + } + return wasmTable.get(ptr).apply(null, args) + } - function relocateExports(exports, memoryBase) { - var relocated = {}; - for (var e in exports) { - var value = exports[e]; - if (typeof value === "object") { - value = value.value - } - if (typeof value === "number") { - value += memoryBase - } - relocated[e] = value - } - updateGOT(relocated); - return relocated - } + function createInvokeFunction(sig) { + return function() { + var sp = stackSave(); + try { + return dynCall(sig, arguments[0], Array.prototype.slice.call(arguments, 1)) + } catch (e) { + stackRestore(sp); + if (e !== e + 0 && e !== "longjmp") throw e; + _setThrew(1, 0) + } + } + } + var ___heap_base = 5251072; + Module["___heap_base"] = ___heap_base; + + function getMemory(size) { + if (runtimeInitialized) return _malloc(size); + var ret = ___heap_base; + var end = ret + size + 15 & -16; + ___heap_base = end; + GOT["__heap_base"].value = end; + return ret + } - function resolveGlobalSymbol(symName, direct) { - var sym; - if (direct) { - sym = asmLibraryArg["orig$" + symName] - } - if (!sym) { - sym = asmLibraryArg[symName] - } - if (!sym) { - sym = Module[asmjsMangle(symName)] - } - if (!sym && symName.startsWith("invoke_")) { - sym = createInvokeFunction(symName.split("_")[1]) - } - return sym - } + function isInternalSym(symName) { + return ["__cpp_exception", "__wasm_apply_data_relocs", "__dso_handle", "__set_stack_limits"].includes(symName) + } - function loadWebAssemblyModule(binary, flags) { - var metadata = getDylinkMetadata(binary); - - function loadModule() { - var memAlign = Math.pow(2, metadata.memoryAlign); - memAlign = Math.max(memAlign, STACK_ALIGN); - var memoryBase = alignMemory(getMemory(metadata.memorySize + memAlign), memAlign); - var tableBase = wasmTable.length; - wasmTable.grow(metadata.tableSize); - for (var i = memoryBase; i < memoryBase + metadata.memorySize; i++) { - HEAP8[i] = 0 - } - for (var i = tableBase; i < tableBase + metadata.tableSize; i++) { - wasmTable.set(i, null) - } - var moduleExports; - - function resolveSymbol(sym) { - var resolved = resolveGlobalSymbol(sym, false); - if (!resolved) { - resolved = moduleExports[sym] - } - return resolved - } - var proxyHandler = { - "get": function(stubs, prop) { - switch (prop) { - case "__memory_base": - return memoryBase; - case "__table_base": - return tableBase - } - if (prop in asmLibraryArg) { - return asmLibraryArg[prop] - } - if (!(prop in stubs)) { - var resolved; - stubs[prop] = function() { - if (!resolved) resolved = resolveSymbol(prop, true); - checkForAsmVersion(prop); - return resolved.apply(null, arguments) - } - } - return stubs[prop] - } - }; - var proxy = new Proxy({}, proxyHandler); - var info = { - "GOT.mem": new Proxy({}, GOTHandler), - "GOT.func": new Proxy({}, GOTHandler), - "env": proxy, - wasi_snapshot_preview1: proxy - }; - - function postInstantiation(instance) { - for (var i = 0; i < metadata.tableSize; i++) { - var item = wasmTable.get(tableBase + i); - if (item) { - functionsInTableMap.set(item, tableBase + i) - } - } - moduleExports = relocateExports(instance.exports, memoryBase); - if (!flags.allowUndefined) { - reportUndefinedSymbols() - } - var init = moduleExports["__wasm_call_ctors"]; - if (!init) { - init = moduleExports["__post_instantiate"] - } - if (init) { - if (runtimeInitialized) { - init() - } else { - __ATINIT__.push(init) - } - } - return moduleExports - } - if (flags.loadAsync) { - if (binary instanceof WebAssembly.Module) { - var instance = new WebAssembly.Instance(binary, info); - return Promise.resolve(postInstantiation(instance)) - } - return WebAssembly.instantiate(binary, info).then(function(result) { - return postInstantiation(result.instance) - }) - } - var module = binary instanceof WebAssembly.Module ? binary : new WebAssembly.Module(binary); - var instance = new WebAssembly.Instance(module, info); - return postInstantiation(instance) - } - if (flags.loadAsync) { - return metadata.neededDynlibs.reduce(function(chain, dynNeeded) { - return chain.then(function() { - return loadDynamicLibrary(dynNeeded, flags) - }) - }, Promise.resolve()).then(function() { - return loadModule() - }) - } - metadata.neededDynlibs.forEach(function(dynNeeded) { - loadDynamicLibrary(dynNeeded, flags) - }); - return loadModule() - } + function updateGOT(exports) { + for (var symName in exports) { + if (isInternalSym(symName)) { + continue + } + var replace = false; + var value = exports[symName]; + if (symName.startsWith("orig$")) { + symName = symName.split("$")[1]; + replace = true + } + if (!GOT[symName]) { + GOT[symName] = new WebAssembly.Global({ + "value": "i32", + "mutable": true + }) + } + if (replace || GOT[symName].value == 0) { + if (typeof value === "function") { + GOT[symName].value = addFunctionWasm(value) + } else if (typeof value === "number") { + GOT[symName].value = value + } else { + err("unhandled export type for `" + symName + "`: " + typeof value) + } + } + } + } - function fetchBinary(url) { - return fetch(url, { - credentials: "same-origin" - }).then(function(response) { - if (!response["ok"]) { - throw "failed to load binary file at '" + url + "'" - } - return response["arrayBuffer"]() - }).then(function(buffer) { - return new Uint8Array(buffer) - }) - } + function relocateExports(exports, memoryBase) { + var relocated = {}; + for (var e in exports) { + var value = exports[e]; + if (typeof value === "object") { + value = value.value + } + if (typeof value === "number") { + value += memoryBase + } + relocated[e] = value + } + updateGOT(relocated); + return relocated + } - function loadDynamicLibrary(lib, flags) { - if (lib == "__main__" && !LDSO.loadedLibNames[lib]) { - LDSO.loadedLibs[-1] = { - refcount: Infinity, - name: "__main__", - module: Module["asm"], - global: true - }; - LDSO.loadedLibNames["__main__"] = -1 - } - flags = flags || { - global: true, - nodelete: true - }; - var handle = LDSO.loadedLibNames[lib]; - var dso; - if (handle) { - dso = LDSO.loadedLibs[handle]; - if (flags.global && !dso.global) { - dso.global = true; - if (dso.module !== "loading") { - mergeLibSymbols(dso.module, lib) - } - } - if (flags.nodelete && dso.refcount !== Infinity) { - dso.refcount = Infinity - } - dso.refcount++; - return flags.loadAsync ? Promise.resolve(handle) : handle - } - handle = LDSO.nextHandle++; - dso = { - refcount: flags.nodelete ? Infinity : 1, - name: lib, - module: "loading", - global: flags.global - }; - LDSO.loadedLibNames[lib] = handle; - LDSO.loadedLibs[handle] = dso; - - function loadLibData(libFile) { - if (flags.fs) { - var libData = flags.fs.readFile(libFile, { - encoding: "binary" - }); - if (!(libData instanceof Uint8Array)) { - libData = new Uint8Array(libData) - } - return flags.loadAsync ? Promise.resolve(libData) : libData - } - if (flags.loadAsync) { - return fetchBinary(libFile) - } - return readBinary(libFile) - } - - function getLibModule() { - if (Module["preloadedWasm"] !== undefined && Module["preloadedWasm"][lib] !== undefined) { - var libModule = Module["preloadedWasm"][lib]; - return flags.loadAsync ? Promise.resolve(libModule) : libModule - } - if (flags.loadAsync) { - return loadLibData(lib).then(function(libData) { - return loadWebAssemblyModule(libData, flags) - }) - } - return loadWebAssemblyModule(loadLibData(lib), flags) - } - - function moduleLoaded(libModule) { - if (dso.global) { - mergeLibSymbols(libModule, lib) - } - dso.module = libModule - } - if (flags.loadAsync) { - return getLibModule().then(function(libModule) { - moduleLoaded(libModule); - return handle - }) - } - moduleLoaded(getLibModule()); - return handle - } + function resolveGlobalSymbol(symName, direct) { + var sym; + if (direct) { + sym = asmLibraryArg["orig$" + symName] + } + if (!sym) { + sym = asmLibraryArg[symName] + } + if (!sym) { + sym = Module[asmjsMangle(symName)] + } + if (!sym && symName.startsWith("invoke_")) { + sym = createInvokeFunction(symName.split("_")[1]) + } + return sym + } - function reportUndefinedSymbols() { - for (var symName in GOT) { - if (GOT[symName].value == 0) { - var value = resolveGlobalSymbol(symName, true); - if (typeof value === "function") { - GOT[symName].value = addFunctionWasm(value, value.sig) - } else if (typeof value === "number") { - GOT[symName].value = value - } else { - assert(false, "bad export type for `" + symName + "`: " + typeof value) - } - } - } - } + function loadWebAssemblyModule(binary, flags) { + var metadata = getDylinkMetadata(binary); + + function loadModule() { + var memAlign = Math.pow(2, metadata.memoryAlign); + memAlign = Math.max(memAlign, STACK_ALIGN); + var memoryBase = alignMemory(getMemory(metadata.memorySize + memAlign), memAlign); + var tableBase = wasmTable.length; + wasmTable.grow(metadata.tableSize); + for (var i = memoryBase; i < memoryBase + metadata.memorySize; i++) { + HEAP8[i] = 0 + } + for (var i = tableBase; i < tableBase + metadata.tableSize; i++) { + wasmTable.set(i, null) + } + var moduleExports; - function preloadDylibs() { - if (!dynamicLibraries.length) { - reportUndefinedSymbols(); - return - } - if (!readBinary) { - addRunDependency("preloadDylibs"); - dynamicLibraries.reduce(function(chain, lib) { - return chain.then(function() { - return loadDynamicLibrary(lib, { - loadAsync: true, - global: true, - nodelete: true, - allowUndefined: true - }) - }) - }, Promise.resolve()).then(function() { - removeRunDependency("preloadDylibs"); - reportUndefinedSymbols() - }); - return - } - dynamicLibraries.forEach(function(lib) { - loadDynamicLibrary(lib, { - global: true, - nodelete: true, - allowUndefined: true - }) - }); - reportUndefinedSymbols() - } - var ___stack_pointer = new WebAssembly.Global({ - "value": "i32", - "mutable": true - }, 5251072); + function resolveSymbol(sym) { + var resolved = resolveGlobalSymbol(sym, false); + if (!resolved) { + resolved = moduleExports[sym] + } + return resolved + } + var proxyHandler = { + "get": function(stubs, prop) { + switch (prop) { + case "__memory_base": + return memoryBase; + case "__table_base": + return tableBase + } + if (prop in asmLibraryArg) { + return asmLibraryArg[prop] + } + if (!(prop in stubs)) { + var resolved; + stubs[prop] = function() { + if (!resolved) resolved = resolveSymbol(prop, true); + checkForAsmVersion(prop); + return resolved.apply(null, arguments) + } + } + return stubs[prop] + } + }; + var proxy = new Proxy({}, proxyHandler); + var info = { + "GOT.mem": new Proxy({}, GOTHandler), + "GOT.func": new Proxy({}, GOTHandler), + "env": proxy, + wasi_snapshot_preview1: proxy + }; + + function postInstantiation(instance) { + for (var i = 0; i < metadata.tableSize; i++) { + var item = wasmTable.get(tableBase + i); + if (item) { + functionsInTableMap.set(item, tableBase + i) + } + } + moduleExports = relocateExports(instance.exports, memoryBase); + if (!flags.allowUndefined) { + reportUndefinedSymbols() + } + var init = moduleExports["__wasm_call_ctors"]; + if (!init) { + init = moduleExports["__post_instantiate"] + } + if (init) { + if (runtimeInitialized) { + init() + } else { + __ATINIT__.push(init) + } + } + return moduleExports + } + if (flags.loadAsync) { + if (binary instanceof WebAssembly.Module) { + var instance = new WebAssembly.Instance(binary, info); + return Promise.resolve(postInstantiation(instance)) + } + return WebAssembly.instantiate(binary, info).then(function(result) { + return postInstantiation(result.instance) + }) + } + var module = binary instanceof WebAssembly.Module ? binary : new WebAssembly.Module(binary); + var instance = new WebAssembly.Instance(module, info); + return postInstantiation(instance) + } + if (flags.loadAsync) { + return metadata.neededDynlibs.reduce(function(chain, dynNeeded) { + return chain.then(function() { + return loadDynamicLibrary(dynNeeded, flags) + }) + }, Promise.resolve()).then(function() { + return loadModule() + }) + } + metadata.neededDynlibs.forEach(function(dynNeeded) { + loadDynamicLibrary(dynNeeded, flags) + }); + return loadModule() + } - function _abort() { - abort() - } - Module["_abort"] = _abort; - _abort.sig = "v"; - var _emscripten_get_now; - if (ENVIRONMENT_IS_NODE) { - _emscripten_get_now = function() { - var t = process["hrtime"](); - return t[0] * 1e3 + t[1] / 1e6 - } - } else if (typeof dateNow !== "undefined") { - _emscripten_get_now = dateNow - } else _emscripten_get_now = function() { - return performance.now() - }; - var _emscripten_get_now_is_monotonic = true; - - function setErrNo(value) { - HEAP32[___errno_location() >> 2] = value; - return value - } + function fetchBinary(url) { + return fetch(url, { + credentials: "same-origin" + }).then(function(response) { + if (!response["ok"]) { + throw "failed to load binary file at '" + url + "'" + } + return response["arrayBuffer"]() + }).then(function(buffer) { + return new Uint8Array(buffer) + }) + } - function _clock_gettime(clk_id, tp) { - var now; - if (clk_id === 0) { - now = Date.now() - } else if ((clk_id === 1 || clk_id === 4) && _emscripten_get_now_is_monotonic) { - now = _emscripten_get_now() - } else { - setErrNo(28); - return -1 - } - HEAP32[tp >> 2] = now / 1e3 | 0; - HEAP32[tp + 4 >> 2] = now % 1e3 * 1e3 * 1e3 | 0; - return 0 - } - _clock_gettime.sig = "iii"; + function loadDynamicLibrary(lib, flags) { + if (lib == "__main__" && !LDSO.loadedLibNames[lib]) { + LDSO.loadedLibs[-1] = { + refcount: Infinity, + name: "__main__", + module: Module["asm"], + global: true + }; + LDSO.loadedLibNames["__main__"] = -1 + } + flags = flags || { + global: true, + nodelete: true + }; + var handle = LDSO.loadedLibNames[lib]; + var dso; + if (handle) { + dso = LDSO.loadedLibs[handle]; + if (flags.global && !dso.global) { + dso.global = true; + if (dso.module !== "loading") { + mergeLibSymbols(dso.module, lib) + } + } + if (flags.nodelete && dso.refcount !== Infinity) { + dso.refcount = Infinity + } + dso.refcount++; + return flags.loadAsync ? Promise.resolve(handle) : handle + } + handle = LDSO.nextHandle++; + dso = { + refcount: flags.nodelete ? Infinity : 1, + name: lib, + module: "loading", + global: flags.global + }; + LDSO.loadedLibNames[lib] = handle; + LDSO.loadedLibs[handle] = dso; + + function loadLibData(libFile) { + if (flags.fs) { + var libData = flags.fs.readFile(libFile, { + encoding: "binary" + }); + if (!(libData instanceof Uint8Array)) { + libData = new Uint8Array(libData) + } + return flags.loadAsync ? Promise.resolve(libData) : libData + } + if (flags.loadAsync) { + return fetchBinary(libFile) + } + return readBinary(libFile) + } - function _emscripten_memcpy_big(dest, src, num) { - HEAPU8.copyWithin(dest, src, src + num) - } + function getLibModule() { + if (Module["preloadedWasm"] !== undefined && Module["preloadedWasm"][lib] !== undefined) { + var libModule = Module["preloadedWasm"][lib]; + return flags.loadAsync ? Promise.resolve(libModule) : libModule + } + if (flags.loadAsync) { + return loadLibData(lib).then(function(libData) { + return loadWebAssemblyModule(libData, flags) + }) + } + return loadWebAssemblyModule(loadLibData(lib), flags) + } - function emscripten_realloc_buffer(size) { - try { - wasmMemory.grow(size - buffer.byteLength + 65535 >>> 16); - updateGlobalBufferAndViews(wasmMemory.buffer); - return 1 - } catch (e) {} - } + function moduleLoaded(libModule) { + if (dso.global) { + mergeLibSymbols(libModule, lib) + } + dso.module = libModule + } + if (flags.loadAsync) { + return getLibModule().then(function(libModule) { + moduleLoaded(libModule); + return handle + }) + } + moduleLoaded(getLibModule()); + return handle + } - function _emscripten_resize_heap(requestedSize) { - var oldSize = HEAPU8.length; - requestedSize = requestedSize >>> 0; - var maxHeapSize = 2147483648; - if (requestedSize > maxHeapSize) { - return false - } - for (var cutDown = 1; cutDown <= 4; cutDown *= 2) { - var overGrownHeapSize = oldSize * (1 + .2 / cutDown); - overGrownHeapSize = Math.min(overGrownHeapSize, requestedSize + 100663296); - var newSize = Math.min(maxHeapSize, alignUp(Math.max(requestedSize, overGrownHeapSize), 65536)); - var replacement = emscripten_realloc_buffer(newSize); - if (replacement) { - return true - } - } - return false - } + function reportUndefinedSymbols() { + for (var symName in GOT) { + if (GOT[symName].value == 0) { + var value = resolveGlobalSymbol(symName, true); + if (typeof value === "function") { + GOT[symName].value = addFunctionWasm(value, value.sig) + } else if (typeof value === "number") { + GOT[symName].value = value + } else { + assert(false, "bad export type for `" + symName + "`: " + typeof value) + } + } + } + } - function _exit(status) { - exit(status) - } - _exit.sig = "vi"; - var SYSCALLS = { - mappings: {}, - DEFAULT_POLLMASK: 5, - umask: 511, - calculateAt: function(dirfd, path, allowEmpty) { - if (path[0] === "/") { - return path - } - var dir; - if (dirfd === -100) { - dir = FS.cwd() - } else { - var dirstream = FS.getStream(dirfd); - if (!dirstream) throw new FS.ErrnoError(8); - dir = dirstream.path - } - if (path.length == 0) { - if (!allowEmpty) { - throw new FS.ErrnoError(44) - } - return dir - } - return PATH.join2(dir, path) - }, - doStat: function(func, path, buf) { - try { - var stat = func(path) - } catch (e) { - if (e && e.node && PATH.normalize(path) !== PATH.normalize(FS.getPath(e.node))) { - return -54 - } - throw e - } - HEAP32[buf >> 2] = stat.dev; - HEAP32[buf + 4 >> 2] = 0; - HEAP32[buf + 8 >> 2] = stat.ino; - HEAP32[buf + 12 >> 2] = stat.mode; - HEAP32[buf + 16 >> 2] = stat.nlink; - HEAP32[buf + 20 >> 2] = stat.uid; - HEAP32[buf + 24 >> 2] = stat.gid; - HEAP32[buf + 28 >> 2] = stat.rdev; - HEAP32[buf + 32 >> 2] = 0; - tempI64 = [stat.size >>> 0, (tempDouble = stat.size, +Math.abs(tempDouble) >= 1 ? tempDouble > 0 ? (Math.min(+Math.floor(tempDouble / 4294967296), 4294967295) | 0) >>> 0 : ~~+Math.ceil((tempDouble - +(~~tempDouble >>> 0)) / 4294967296) >>> 0 : 0)], HEAP32[buf + 40 >> 2] = tempI64[0], HEAP32[buf + 44 >> 2] = tempI64[1]; - HEAP32[buf + 48 >> 2] = 4096; - HEAP32[buf + 52 >> 2] = stat.blocks; - HEAP32[buf + 56 >> 2] = stat.atime.getTime() / 1e3 | 0; - HEAP32[buf + 60 >> 2] = 0; - HEAP32[buf + 64 >> 2] = stat.mtime.getTime() / 1e3 | 0; - HEAP32[buf + 68 >> 2] = 0; - HEAP32[buf + 72 >> 2] = stat.ctime.getTime() / 1e3 | 0; - HEAP32[buf + 76 >> 2] = 0; - tempI64 = [stat.ino >>> 0, (tempDouble = stat.ino, +Math.abs(tempDouble) >= 1 ? tempDouble > 0 ? (Math.min(+Math.floor(tempDouble / 4294967296), 4294967295) | 0) >>> 0 : ~~+Math.ceil((tempDouble - +(~~tempDouble >>> 0)) / 4294967296) >>> 0 : 0)], HEAP32[buf + 80 >> 2] = tempI64[0], HEAP32[buf + 84 >> 2] = tempI64[1]; - return 0 - }, - doMsync: function(addr, stream, len, flags, offset) { - var buffer = HEAPU8.slice(addr, addr + len); - FS.msync(stream, buffer, offset, len, flags) - }, - doMkdir: function(path, mode) { - path = PATH.normalize(path); - if (path[path.length - 1] === "/") path = path.substr(0, path.length - 1); - FS.mkdir(path, mode, 0); - return 0 - }, - doMknod: function(path, mode, dev) { - switch (mode & 61440) { - case 32768: - case 8192: - case 24576: - case 4096: - case 49152: - break; - default: - return -28 - } - FS.mknod(path, mode, dev); - return 0 - }, - doReadlink: function(path, buf, bufsize) { - if (bufsize <= 0) return -28; - var ret = FS.readlink(path); - var len = Math.min(bufsize, lengthBytesUTF8(ret)); - var endChar = HEAP8[buf + len]; - stringToUTF8(ret, buf, bufsize + 1); - HEAP8[buf + len] = endChar; - return len - }, - doAccess: function(path, amode) { - if (amode & ~7) { - return -28 - } - var node; - var lookup = FS.lookupPath(path, { - follow: true - }); - node = lookup.node; - if (!node) { - return -44 - } - var perms = ""; - if (amode & 4) perms += "r"; - if (amode & 2) perms += "w"; - if (amode & 1) perms += "x"; - if (perms && FS.nodePermissions(node, perms)) { - return -2 - } - return 0 - }, - doDup: function(path, flags, suggestFD) { - var suggest = FS.getStream(suggestFD); - if (suggest) FS.close(suggest); - return FS.open(path, flags, 0, suggestFD, suggestFD).fd - }, - doReadv: function(stream, iov, iovcnt, offset) { - var ret = 0; - for (var i = 0; i < iovcnt; i++) { - var ptr = HEAP32[iov + i * 8 >> 2]; - var len = HEAP32[iov + (i * 8 + 4) >> 2]; - var curr = FS.read(stream, HEAP8, ptr, len, offset); - if (curr < 0) return -1; - ret += curr; - if (curr < len) break - } - return ret - }, - doWritev: function(stream, iov, iovcnt, offset) { - var ret = 0; - for (var i = 0; i < iovcnt; i++) { - var ptr = HEAP32[iov + i * 8 >> 2]; - var len = HEAP32[iov + (i * 8 + 4) >> 2]; - var curr = FS.write(stream, HEAP8, ptr, len, offset); - if (curr < 0) return -1; - ret += curr - } - return ret - }, - varargs: undefined, - get: function() { - SYSCALLS.varargs += 4; - var ret = HEAP32[SYSCALLS.varargs - 4 >> 2]; - return ret - }, - getStr: function(ptr) { - var ret = UTF8ToString(ptr); - return ret - }, - getStreamFromFD: function(fd) { - var stream = FS.getStream(fd); - if (!stream) throw new FS.ErrnoError(8); - return stream - }, - get64: function(low, high) { - return low - } - }; - - function _fd_close(fd) { - try { - var stream = SYSCALLS.getStreamFromFD(fd); - FS.close(stream); - return 0 - } catch (e) { - if (typeof FS === "undefined" || !(e instanceof FS.ErrnoError)) abort(e); - return e.errno - } - } - _fd_close.sig = "ii"; - - function _fd_seek(fd, offset_low, offset_high, whence, newOffset) { - try { - var stream = SYSCALLS.getStreamFromFD(fd); - var HIGH_OFFSET = 4294967296; - var offset = offset_high * HIGH_OFFSET + (offset_low >>> 0); - var DOUBLE_LIMIT = 9007199254740992; - if (offset <= -DOUBLE_LIMIT || offset >= DOUBLE_LIMIT) { - return -61 - } - FS.llseek(stream, offset, whence); - tempI64 = [stream.position >>> 0, (tempDouble = stream.position, +Math.abs(tempDouble) >= 1 ? tempDouble > 0 ? (Math.min(+Math.floor(tempDouble / 4294967296), 4294967295) | 0) >>> 0 : ~~+Math.ceil((tempDouble - +(~~tempDouble >>> 0)) / 4294967296) >>> 0 : 0)], HEAP32[newOffset >> 2] = tempI64[0], HEAP32[newOffset + 4 >> 2] = tempI64[1]; - if (stream.getdents && offset === 0 && whence === 0) stream.getdents = null; - return 0 - } catch (e) { - if (typeof FS === "undefined" || !(e instanceof FS.ErrnoError)) abort(e); - return e.errno - } - } + function preloadDylibs() { + if (!dynamicLibraries.length) { + reportUndefinedSymbols(); + return + } + if (!readBinary) { + addRunDependency("preloadDylibs"); + dynamicLibraries.reduce(function(chain, lib) { + return chain.then(function() { + return loadDynamicLibrary(lib, { + loadAsync: true, + global: true, + nodelete: true, + allowUndefined: true + }) + }) + }, Promise.resolve()).then(function() { + removeRunDependency("preloadDylibs"); + reportUndefinedSymbols() + }); + return + } + dynamicLibraries.forEach(function(lib) { + loadDynamicLibrary(lib, { + global: true, + nodelete: true, + allowUndefined: true + }) + }); + reportUndefinedSymbols() + } + var ___stack_pointer = new WebAssembly.Global({ + "value": "i32", + "mutable": true + }, 5251072); - function _fd_write(fd, iov, iovcnt, pnum) { - try { - var stream = SYSCALLS.getStreamFromFD(fd); - var num = SYSCALLS.doWritev(stream, iov, iovcnt); - HEAP32[pnum >> 2] = num; - return 0 - } catch (e) { - if (typeof FS === "undefined" || !(e instanceof FS.ErrnoError)) abort(e); - return e.errno - } - } - _fd_write.sig = "iiiii"; + function _abort() { + abort() + } + Module["_abort"] = _abort; + _abort.sig = "v"; + var _emscripten_get_now; + if (ENVIRONMENT_IS_NODE) { + _emscripten_get_now = function() { + var t = process["hrtime"](); + return t[0] * 1e3 + t[1] / 1e6 + } + } else if (typeof dateNow !== "undefined") { + _emscripten_get_now = dateNow + } else _emscripten_get_now = function() { + return performance.now() + }; + var _emscripten_get_now_is_monotonic = true; - function _setTempRet0(val) { - setTempRet0(val) - } - _setTempRet0.sig = "vi"; + function setErrNo(value) { + HEAP32[___errno_location() >> 2] = value; + return value + } - function _tree_sitter_log_callback(isLexMessage, messageAddress) { - if (currentLogCallback) { - const message = UTF8ToString(messageAddress); - currentLogCallback(message, isLexMessage !== 0) - } - } + function _clock_gettime(clk_id, tp) { + var now; + if (clk_id === 0) { + now = Date.now() + } else if ((clk_id === 1 || clk_id === 4) && _emscripten_get_now_is_monotonic) { + now = _emscripten_get_now() + } else { + setErrNo(28); + return -1 + } + HEAP32[tp >> 2] = now / 1e3 | 0; + HEAP32[tp + 4 >> 2] = now % 1e3 * 1e3 * 1e3 | 0; + return 0 + } + _clock_gettime.sig = "iii"; - function _tree_sitter_parse_callback(inputBufferAddress, index, row, column, lengthAddress) { - var INPUT_BUFFER_SIZE = 10 * 1024; - var string = currentParseCallback(index, { - row: row, - column: column - }); - if (typeof string === "string") { - setValue(lengthAddress, string.length, "i32"); - stringToUTF16(string, inputBufferAddress, INPUT_BUFFER_SIZE) - } else { - setValue(lengthAddress, 0, "i32") - } - } - var ___memory_base = 1024; - var ___table_base = 1; - var asmLibraryArg = { - "__heap_base": ___heap_base, - "__indirect_function_table": wasmTable, - "__memory_base": ___memory_base, - "__stack_pointer": ___stack_pointer, - "__table_base": ___table_base, - "abort": _abort, - "clock_gettime": _clock_gettime, - "emscripten_memcpy_big": _emscripten_memcpy_big, - "emscripten_resize_heap": _emscripten_resize_heap, - "exit": _exit, - "fd_close": _fd_close, - "fd_seek": _fd_seek, - "fd_write": _fd_write, - "memory": wasmMemory, - "setTempRet0": _setTempRet0, - "tree_sitter_log_callback": _tree_sitter_log_callback, - "tree_sitter_parse_callback": _tree_sitter_parse_callback - }; - var asm = createWasm(); - var ___wasm_call_ctors = Module["___wasm_call_ctors"] = function() { - return (___wasm_call_ctors = Module["___wasm_call_ctors"] = Module["asm"]["__wasm_call_ctors"]).apply(null, arguments) - }; - var _malloc = Module["_malloc"] = function() { - return (_malloc = Module["_malloc"] = Module["asm"]["malloc"]).apply(null, arguments) - }; - var _calloc = Module["_calloc"] = function() { - return (_calloc = Module["_calloc"] = Module["asm"]["calloc"]).apply(null, arguments) - }; - var _realloc = Module["_realloc"] = function() { - return (_realloc = Module["_realloc"] = Module["asm"]["realloc"]).apply(null, arguments) - }; - var _free = Module["_free"] = function() { - return (_free = Module["_free"] = Module["asm"]["free"]).apply(null, arguments) - }; - var _ts_language_symbol_count = Module["_ts_language_symbol_count"] = function() { - return (_ts_language_symbol_count = Module["_ts_language_symbol_count"] = Module["asm"]["ts_language_symbol_count"]).apply(null, arguments) - }; - var _ts_language_version = Module["_ts_language_version"] = function() { - return (_ts_language_version = Module["_ts_language_version"] = Module["asm"]["ts_language_version"]).apply(null, arguments) - }; - var _ts_language_field_count = Module["_ts_language_field_count"] = function() { - return (_ts_language_field_count = Module["_ts_language_field_count"] = Module["asm"]["ts_language_field_count"]).apply(null, arguments) - }; - var _ts_language_symbol_name = Module["_ts_language_symbol_name"] = function() { - return (_ts_language_symbol_name = Module["_ts_language_symbol_name"] = Module["asm"]["ts_language_symbol_name"]).apply(null, arguments) - }; - var _ts_language_symbol_for_name = Module["_ts_language_symbol_for_name"] = function() { - return (_ts_language_symbol_for_name = Module["_ts_language_symbol_for_name"] = Module["asm"]["ts_language_symbol_for_name"]).apply(null, arguments) - }; - var _strncmp = Module["_strncmp"] = function() { - return (_strncmp = Module["_strncmp"] = Module["asm"]["strncmp"]).apply(null, arguments) - }; - var _ts_language_symbol_type = Module["_ts_language_symbol_type"] = function() { - return (_ts_language_symbol_type = Module["_ts_language_symbol_type"] = Module["asm"]["ts_language_symbol_type"]).apply(null, arguments) - }; - var _ts_language_field_name_for_id = Module["_ts_language_field_name_for_id"] = function() { - return (_ts_language_field_name_for_id = Module["_ts_language_field_name_for_id"] = Module["asm"]["ts_language_field_name_for_id"]).apply(null, arguments) - }; - var _memset = Module["_memset"] = function() { - return (_memset = Module["_memset"] = Module["asm"]["memset"]).apply(null, arguments) - }; - var _memcpy = Module["_memcpy"] = function() { - return (_memcpy = Module["_memcpy"] = Module["asm"]["memcpy"]).apply(null, arguments) - }; - var _ts_parser_delete = Module["_ts_parser_delete"] = function() { - return (_ts_parser_delete = Module["_ts_parser_delete"] = Module["asm"]["ts_parser_delete"]).apply(null, arguments) - }; - var _ts_parser_reset = Module["_ts_parser_reset"] = function() { - return (_ts_parser_reset = Module["_ts_parser_reset"] = Module["asm"]["ts_parser_reset"]).apply(null, arguments) - }; - var _ts_parser_set_language = Module["_ts_parser_set_language"] = function() { - return (_ts_parser_set_language = Module["_ts_parser_set_language"] = Module["asm"]["ts_parser_set_language"]).apply(null, arguments) - }; - var _ts_parser_timeout_micros = Module["_ts_parser_timeout_micros"] = function() { - return (_ts_parser_timeout_micros = Module["_ts_parser_timeout_micros"] = Module["asm"]["ts_parser_timeout_micros"]).apply(null, arguments) - }; - var _ts_parser_set_timeout_micros = Module["_ts_parser_set_timeout_micros"] = function() { - return (_ts_parser_set_timeout_micros = Module["_ts_parser_set_timeout_micros"] = Module["asm"]["ts_parser_set_timeout_micros"]).apply(null, arguments) - }; - var _memmove = Module["_memmove"] = function() { - return (_memmove = Module["_memmove"] = Module["asm"]["memmove"]).apply(null, arguments) - }; - var _memcmp = Module["_memcmp"] = function() { - return (_memcmp = Module["_memcmp"] = Module["asm"]["memcmp"]).apply(null, arguments) - }; - var _ts_query_new = Module["_ts_query_new"] = function() { - return (_ts_query_new = Module["_ts_query_new"] = Module["asm"]["ts_query_new"]).apply(null, arguments) - }; - var _ts_query_delete = Module["_ts_query_delete"] = function() { - return (_ts_query_delete = Module["_ts_query_delete"] = Module["asm"]["ts_query_delete"]).apply(null, arguments) - }; - var _iswspace = Module["_iswspace"] = function() { - return (_iswspace = Module["_iswspace"] = Module["asm"]["iswspace"]).apply(null, arguments) - }; - var _iswalnum = Module["_iswalnum"] = function() { - return (_iswalnum = Module["_iswalnum"] = Module["asm"]["iswalnum"]).apply(null, arguments) - }; - var _ts_query_pattern_count = Module["_ts_query_pattern_count"] = function() { - return (_ts_query_pattern_count = Module["_ts_query_pattern_count"] = Module["asm"]["ts_query_pattern_count"]).apply(null, arguments) - }; - var _ts_query_capture_count = Module["_ts_query_capture_count"] = function() { - return (_ts_query_capture_count = Module["_ts_query_capture_count"] = Module["asm"]["ts_query_capture_count"]).apply(null, arguments) - }; - var _ts_query_string_count = Module["_ts_query_string_count"] = function() { - return (_ts_query_string_count = Module["_ts_query_string_count"] = Module["asm"]["ts_query_string_count"]).apply(null, arguments) - }; - var _ts_query_capture_name_for_id = Module["_ts_query_capture_name_for_id"] = function() { - return (_ts_query_capture_name_for_id = Module["_ts_query_capture_name_for_id"] = Module["asm"]["ts_query_capture_name_for_id"]).apply(null, arguments) - }; - var _ts_query_string_value_for_id = Module["_ts_query_string_value_for_id"] = function() { - return (_ts_query_string_value_for_id = Module["_ts_query_string_value_for_id"] = Module["asm"]["ts_query_string_value_for_id"]).apply(null, arguments) - }; - var _ts_query_predicates_for_pattern = Module["_ts_query_predicates_for_pattern"] = function() { - return (_ts_query_predicates_for_pattern = Module["_ts_query_predicates_for_pattern"] = Module["asm"]["ts_query_predicates_for_pattern"]).apply(null, arguments) - }; - var _ts_tree_copy = Module["_ts_tree_copy"] = function() { - return (_ts_tree_copy = Module["_ts_tree_copy"] = Module["asm"]["ts_tree_copy"]).apply(null, arguments) - }; - var _ts_tree_delete = Module["_ts_tree_delete"] = function() { - return (_ts_tree_delete = Module["_ts_tree_delete"] = Module["asm"]["ts_tree_delete"]).apply(null, arguments) - }; - var _ts_init = Module["_ts_init"] = function() { - return (_ts_init = Module["_ts_init"] = Module["asm"]["ts_init"]).apply(null, arguments) - }; - var _ts_parser_new_wasm = Module["_ts_parser_new_wasm"] = function() { - return (_ts_parser_new_wasm = Module["_ts_parser_new_wasm"] = Module["asm"]["ts_parser_new_wasm"]).apply(null, arguments) - }; - var _ts_parser_enable_logger_wasm = Module["_ts_parser_enable_logger_wasm"] = function() { - return (_ts_parser_enable_logger_wasm = Module["_ts_parser_enable_logger_wasm"] = Module["asm"]["ts_parser_enable_logger_wasm"]).apply(null, arguments) - }; - var _ts_parser_parse_wasm = Module["_ts_parser_parse_wasm"] = function() { - return (_ts_parser_parse_wasm = Module["_ts_parser_parse_wasm"] = Module["asm"]["ts_parser_parse_wasm"]).apply(null, arguments) - }; - var _ts_language_type_is_named_wasm = Module["_ts_language_type_is_named_wasm"] = function() { - return (_ts_language_type_is_named_wasm = Module["_ts_language_type_is_named_wasm"] = Module["asm"]["ts_language_type_is_named_wasm"]).apply(null, arguments) - }; - var _ts_language_type_is_visible_wasm = Module["_ts_language_type_is_visible_wasm"] = function() { - return (_ts_language_type_is_visible_wasm = Module["_ts_language_type_is_visible_wasm"] = Module["asm"]["ts_language_type_is_visible_wasm"]).apply(null, arguments) - }; - var _ts_tree_root_node_wasm = Module["_ts_tree_root_node_wasm"] = function() { - return (_ts_tree_root_node_wasm = Module["_ts_tree_root_node_wasm"] = Module["asm"]["ts_tree_root_node_wasm"]).apply(null, arguments) - }; - var _ts_tree_edit_wasm = Module["_ts_tree_edit_wasm"] = function() { - return (_ts_tree_edit_wasm = Module["_ts_tree_edit_wasm"] = Module["asm"]["ts_tree_edit_wasm"]).apply(null, arguments) - }; - var _ts_tree_get_changed_ranges_wasm = Module["_ts_tree_get_changed_ranges_wasm"] = function() { - return (_ts_tree_get_changed_ranges_wasm = Module["_ts_tree_get_changed_ranges_wasm"] = Module["asm"]["ts_tree_get_changed_ranges_wasm"]).apply(null, arguments) - }; - var _ts_tree_cursor_new_wasm = Module["_ts_tree_cursor_new_wasm"] = function() { - return (_ts_tree_cursor_new_wasm = Module["_ts_tree_cursor_new_wasm"] = Module["asm"]["ts_tree_cursor_new_wasm"]).apply(null, arguments) - }; - var _ts_tree_cursor_delete_wasm = Module["_ts_tree_cursor_delete_wasm"] = function() { - return (_ts_tree_cursor_delete_wasm = Module["_ts_tree_cursor_delete_wasm"] = Module["asm"]["ts_tree_cursor_delete_wasm"]).apply(null, arguments) - }; - var _ts_tree_cursor_reset_wasm = Module["_ts_tree_cursor_reset_wasm"] = function() { - return (_ts_tree_cursor_reset_wasm = Module["_ts_tree_cursor_reset_wasm"] = Module["asm"]["ts_tree_cursor_reset_wasm"]).apply(null, arguments) - }; - var _ts_tree_cursor_goto_first_child_wasm = Module["_ts_tree_cursor_goto_first_child_wasm"] = function() { - return (_ts_tree_cursor_goto_first_child_wasm = Module["_ts_tree_cursor_goto_first_child_wasm"] = Module["asm"]["ts_tree_cursor_goto_first_child_wasm"]).apply(null, arguments) - }; - var _ts_tree_cursor_goto_next_sibling_wasm = Module["_ts_tree_cursor_goto_next_sibling_wasm"] = function() { - return (_ts_tree_cursor_goto_next_sibling_wasm = Module["_ts_tree_cursor_goto_next_sibling_wasm"] = Module["asm"]["ts_tree_cursor_goto_next_sibling_wasm"]).apply(null, arguments) - }; - var _ts_tree_cursor_goto_parent_wasm = Module["_ts_tree_cursor_goto_parent_wasm"] = function() { - return (_ts_tree_cursor_goto_parent_wasm = Module["_ts_tree_cursor_goto_parent_wasm"] = Module["asm"]["ts_tree_cursor_goto_parent_wasm"]).apply(null, arguments) - }; - var _ts_tree_cursor_current_node_type_id_wasm = Module["_ts_tree_cursor_current_node_type_id_wasm"] = function() { - return (_ts_tree_cursor_current_node_type_id_wasm = Module["_ts_tree_cursor_current_node_type_id_wasm"] = Module["asm"]["ts_tree_cursor_current_node_type_id_wasm"]).apply(null, arguments) - }; - var _ts_tree_cursor_current_node_is_named_wasm = Module["_ts_tree_cursor_current_node_is_named_wasm"] = function() { - return (_ts_tree_cursor_current_node_is_named_wasm = Module["_ts_tree_cursor_current_node_is_named_wasm"] = Module["asm"]["ts_tree_cursor_current_node_is_named_wasm"]).apply(null, arguments) - }; - var _ts_tree_cursor_current_node_is_missing_wasm = Module["_ts_tree_cursor_current_node_is_missing_wasm"] = function() { - return (_ts_tree_cursor_current_node_is_missing_wasm = Module["_ts_tree_cursor_current_node_is_missing_wasm"] = Module["asm"]["ts_tree_cursor_current_node_is_missing_wasm"]).apply(null, arguments) - }; - var _ts_tree_cursor_current_node_id_wasm = Module["_ts_tree_cursor_current_node_id_wasm"] = function() { - return (_ts_tree_cursor_current_node_id_wasm = Module["_ts_tree_cursor_current_node_id_wasm"] = Module["asm"]["ts_tree_cursor_current_node_id_wasm"]).apply(null, arguments) - }; - var _ts_tree_cursor_start_position_wasm = Module["_ts_tree_cursor_start_position_wasm"] = function() { - return (_ts_tree_cursor_start_position_wasm = Module["_ts_tree_cursor_start_position_wasm"] = Module["asm"]["ts_tree_cursor_start_position_wasm"]).apply(null, arguments) - }; - var _ts_tree_cursor_end_position_wasm = Module["_ts_tree_cursor_end_position_wasm"] = function() { - return (_ts_tree_cursor_end_position_wasm = Module["_ts_tree_cursor_end_position_wasm"] = Module["asm"]["ts_tree_cursor_end_position_wasm"]).apply(null, arguments) - }; - var _ts_tree_cursor_start_index_wasm = Module["_ts_tree_cursor_start_index_wasm"] = function() { - return (_ts_tree_cursor_start_index_wasm = Module["_ts_tree_cursor_start_index_wasm"] = Module["asm"]["ts_tree_cursor_start_index_wasm"]).apply(null, arguments) - }; - var _ts_tree_cursor_end_index_wasm = Module["_ts_tree_cursor_end_index_wasm"] = function() { - return (_ts_tree_cursor_end_index_wasm = Module["_ts_tree_cursor_end_index_wasm"] = Module["asm"]["ts_tree_cursor_end_index_wasm"]).apply(null, arguments) - }; - var _ts_tree_cursor_current_field_id_wasm = Module["_ts_tree_cursor_current_field_id_wasm"] = function() { - return (_ts_tree_cursor_current_field_id_wasm = Module["_ts_tree_cursor_current_field_id_wasm"] = Module["asm"]["ts_tree_cursor_current_field_id_wasm"]).apply(null, arguments) - }; - var _ts_tree_cursor_current_node_wasm = Module["_ts_tree_cursor_current_node_wasm"] = function() { - return (_ts_tree_cursor_current_node_wasm = Module["_ts_tree_cursor_current_node_wasm"] = Module["asm"]["ts_tree_cursor_current_node_wasm"]).apply(null, arguments) - }; - var _ts_node_symbol_wasm = Module["_ts_node_symbol_wasm"] = function() { - return (_ts_node_symbol_wasm = Module["_ts_node_symbol_wasm"] = Module["asm"]["ts_node_symbol_wasm"]).apply(null, arguments) - }; - var _ts_node_child_count_wasm = Module["_ts_node_child_count_wasm"] = function() { - return (_ts_node_child_count_wasm = Module["_ts_node_child_count_wasm"] = Module["asm"]["ts_node_child_count_wasm"]).apply(null, arguments) - }; - var _ts_node_named_child_count_wasm = Module["_ts_node_named_child_count_wasm"] = function() { - return (_ts_node_named_child_count_wasm = Module["_ts_node_named_child_count_wasm"] = Module["asm"]["ts_node_named_child_count_wasm"]).apply(null, arguments) - }; - var _ts_node_child_wasm = Module["_ts_node_child_wasm"] = function() { - return (_ts_node_child_wasm = Module["_ts_node_child_wasm"] = Module["asm"]["ts_node_child_wasm"]).apply(null, arguments) - }; - var _ts_node_named_child_wasm = Module["_ts_node_named_child_wasm"] = function() { - return (_ts_node_named_child_wasm = Module["_ts_node_named_child_wasm"] = Module["asm"]["ts_node_named_child_wasm"]).apply(null, arguments) - }; - var _ts_node_child_by_field_id_wasm = Module["_ts_node_child_by_field_id_wasm"] = function() { - return (_ts_node_child_by_field_id_wasm = Module["_ts_node_child_by_field_id_wasm"] = Module["asm"]["ts_node_child_by_field_id_wasm"]).apply(null, arguments) - }; - var _ts_node_next_sibling_wasm = Module["_ts_node_next_sibling_wasm"] = function() { - return (_ts_node_next_sibling_wasm = Module["_ts_node_next_sibling_wasm"] = Module["asm"]["ts_node_next_sibling_wasm"]).apply(null, arguments) - }; - var _ts_node_prev_sibling_wasm = Module["_ts_node_prev_sibling_wasm"] = function() { - return (_ts_node_prev_sibling_wasm = Module["_ts_node_prev_sibling_wasm"] = Module["asm"]["ts_node_prev_sibling_wasm"]).apply(null, arguments) - }; - var _ts_node_next_named_sibling_wasm = Module["_ts_node_next_named_sibling_wasm"] = function() { - return (_ts_node_next_named_sibling_wasm = Module["_ts_node_next_named_sibling_wasm"] = Module["asm"]["ts_node_next_named_sibling_wasm"]).apply(null, arguments) - }; - var _ts_node_prev_named_sibling_wasm = Module["_ts_node_prev_named_sibling_wasm"] = function() { - return (_ts_node_prev_named_sibling_wasm = Module["_ts_node_prev_named_sibling_wasm"] = Module["asm"]["ts_node_prev_named_sibling_wasm"]).apply(null, arguments) - }; - var _ts_node_parent_wasm = Module["_ts_node_parent_wasm"] = function() { - return (_ts_node_parent_wasm = Module["_ts_node_parent_wasm"] = Module["asm"]["ts_node_parent_wasm"]).apply(null, arguments) - }; - var _ts_node_descendant_for_index_wasm = Module["_ts_node_descendant_for_index_wasm"] = function() { - return (_ts_node_descendant_for_index_wasm = Module["_ts_node_descendant_for_index_wasm"] = Module["asm"]["ts_node_descendant_for_index_wasm"]).apply(null, arguments) - }; - var _ts_node_named_descendant_for_index_wasm = Module["_ts_node_named_descendant_for_index_wasm"] = function() { - return (_ts_node_named_descendant_for_index_wasm = Module["_ts_node_named_descendant_for_index_wasm"] = Module["asm"]["ts_node_named_descendant_for_index_wasm"]).apply(null, arguments) - }; - var _ts_node_descendant_for_position_wasm = Module["_ts_node_descendant_for_position_wasm"] = function() { - return (_ts_node_descendant_for_position_wasm = Module["_ts_node_descendant_for_position_wasm"] = Module["asm"]["ts_node_descendant_for_position_wasm"]).apply(null, arguments) - }; - var _ts_node_named_descendant_for_position_wasm = Module["_ts_node_named_descendant_for_position_wasm"] = function() { - return (_ts_node_named_descendant_for_position_wasm = Module["_ts_node_named_descendant_for_position_wasm"] = Module["asm"]["ts_node_named_descendant_for_position_wasm"]).apply(null, arguments) - }; - var _ts_node_start_point_wasm = Module["_ts_node_start_point_wasm"] = function() { - return (_ts_node_start_point_wasm = Module["_ts_node_start_point_wasm"] = Module["asm"]["ts_node_start_point_wasm"]).apply(null, arguments) - }; - var _ts_node_end_point_wasm = Module["_ts_node_end_point_wasm"] = function() { - return (_ts_node_end_point_wasm = Module["_ts_node_end_point_wasm"] = Module["asm"]["ts_node_end_point_wasm"]).apply(null, arguments) - }; - var _ts_node_start_index_wasm = Module["_ts_node_start_index_wasm"] = function() { - return (_ts_node_start_index_wasm = Module["_ts_node_start_index_wasm"] = Module["asm"]["ts_node_start_index_wasm"]).apply(null, arguments) - }; - var _ts_node_end_index_wasm = Module["_ts_node_end_index_wasm"] = function() { - return (_ts_node_end_index_wasm = Module["_ts_node_end_index_wasm"] = Module["asm"]["ts_node_end_index_wasm"]).apply(null, arguments) - }; - var _ts_node_to_string_wasm = Module["_ts_node_to_string_wasm"] = function() { - return (_ts_node_to_string_wasm = Module["_ts_node_to_string_wasm"] = Module["asm"]["ts_node_to_string_wasm"]).apply(null, arguments) - }; - var _ts_node_children_wasm = Module["_ts_node_children_wasm"] = function() { - return (_ts_node_children_wasm = Module["_ts_node_children_wasm"] = Module["asm"]["ts_node_children_wasm"]).apply(null, arguments) - }; - var _ts_node_named_children_wasm = Module["_ts_node_named_children_wasm"] = function() { - return (_ts_node_named_children_wasm = Module["_ts_node_named_children_wasm"] = Module["asm"]["ts_node_named_children_wasm"]).apply(null, arguments) - }; - var _ts_node_descendants_of_type_wasm = Module["_ts_node_descendants_of_type_wasm"] = function() { - return (_ts_node_descendants_of_type_wasm = Module["_ts_node_descendants_of_type_wasm"] = Module["asm"]["ts_node_descendants_of_type_wasm"]).apply(null, arguments) - }; - var _ts_node_is_named_wasm = Module["_ts_node_is_named_wasm"] = function() { - return (_ts_node_is_named_wasm = Module["_ts_node_is_named_wasm"] = Module["asm"]["ts_node_is_named_wasm"]).apply(null, arguments) - }; - var _ts_node_has_changes_wasm = Module["_ts_node_has_changes_wasm"] = function() { - return (_ts_node_has_changes_wasm = Module["_ts_node_has_changes_wasm"] = Module["asm"]["ts_node_has_changes_wasm"]).apply(null, arguments) - }; - var _ts_node_has_error_wasm = Module["_ts_node_has_error_wasm"] = function() { - return (_ts_node_has_error_wasm = Module["_ts_node_has_error_wasm"] = Module["asm"]["ts_node_has_error_wasm"]).apply(null, arguments) - }; - var _ts_node_is_missing_wasm = Module["_ts_node_is_missing_wasm"] = function() { - return (_ts_node_is_missing_wasm = Module["_ts_node_is_missing_wasm"] = Module["asm"]["ts_node_is_missing_wasm"]).apply(null, arguments) - }; - var _ts_query_matches_wasm = Module["_ts_query_matches_wasm"] = function() { - return (_ts_query_matches_wasm = Module["_ts_query_matches_wasm"] = Module["asm"]["ts_query_matches_wasm"]).apply(null, arguments) - }; - var _ts_query_captures_wasm = Module["_ts_query_captures_wasm"] = function() { - return (_ts_query_captures_wasm = Module["_ts_query_captures_wasm"] = Module["asm"]["ts_query_captures_wasm"]).apply(null, arguments) - }; - var _iswdigit = Module["_iswdigit"] = function() { - return (_iswdigit = Module["_iswdigit"] = Module["asm"]["iswdigit"]).apply(null, arguments) - }; - var _iswalpha = Module["_iswalpha"] = function() { - return (_iswalpha = Module["_iswalpha"] = Module["asm"]["iswalpha"]).apply(null, arguments) - }; - var _iswupper = Module["_iswupper"] = function() { - return (_iswupper = Module["_iswupper"] = Module["asm"]["iswupper"]).apply(null, arguments) - }; - var _iswlower = Module["_iswlower"] = function() { - return (_iswlower = Module["_iswlower"] = Module["asm"]["iswlower"]).apply(null, arguments) - }; - var _iswxdigit = Module["_iswxdigit"] = function() { - return (_iswxdigit = Module["_iswxdigit"] = Module["asm"]["iswxdigit"]).apply(null, arguments) - }; - var _towupper = Module["_towupper"] = function() { - return (_towupper = Module["_towupper"] = Module["asm"]["towupper"]).apply(null, arguments) - }; - var _towlower = Module["_towlower"] = function() { - return (_towlower = Module["_towlower"] = Module["asm"]["towlower"]).apply(null, arguments) - }; - var ___errno_location = Module["___errno_location"] = function() { - return (___errno_location = Module["___errno_location"] = Module["asm"]["__errno_location"]).apply(null, arguments) - }; - var _memchr = Module["_memchr"] = function() { - return (_memchr = Module["_memchr"] = Module["asm"]["memchr"]).apply(null, arguments) - }; - var _strlen = Module["_strlen"] = function() { - return (_strlen = Module["_strlen"] = Module["asm"]["strlen"]).apply(null, arguments) - }; - var _strcmp = Module["_strcmp"] = function() { - return (_strcmp = Module["_strcmp"] = Module["asm"]["strcmp"]).apply(null, arguments) - }; - var _strncpy = Module["_strncpy"] = function() { - return (_strncpy = Module["_strncpy"] = Module["asm"]["strncpy"]).apply(null, arguments) - }; - var stackSave = Module["stackSave"] = function() { - return (stackSave = Module["stackSave"] = Module["asm"]["stackSave"]).apply(null, arguments) - }; - var stackRestore = Module["stackRestore"] = function() { - return (stackRestore = Module["stackRestore"] = Module["asm"]["stackRestore"]).apply(null, arguments) - }; - var stackAlloc = Module["stackAlloc"] = function() { - return (stackAlloc = Module["stackAlloc"] = Module["asm"]["stackAlloc"]).apply(null, arguments) - }; - var _setThrew = Module["_setThrew"] = function() { - return (_setThrew = Module["_setThrew"] = Module["asm"]["setThrew"]).apply(null, arguments) - }; - var __ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEED2Ev = Module["__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEED2Ev"] = function() { - return (__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEED2Ev = Module["__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEED2Ev"] = Module["asm"]["_ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEED2Ev"]).apply(null, arguments) - }; - var __ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE9__grow_byEmmmmmm = Module["__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE9__grow_byEmmmmmm"] = function() { - return (__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE9__grow_byEmmmmmm = Module["__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE9__grow_byEmmmmmm"] = Module["asm"]["_ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE9__grow_byEmmmmmm"]).apply(null, arguments) - }; - var __ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initEPKcm = Module["__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initEPKcm"] = function() { - return (__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initEPKcm = Module["__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initEPKcm"] = Module["asm"]["_ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initEPKcm"]).apply(null, arguments) - }; - var __ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE25__init_copy_ctor_externalEPKcm = Module["__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE25__init_copy_ctor_externalEPKcm"] = function() { - return (__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE25__init_copy_ctor_externalEPKcm = Module["__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE25__init_copy_ctor_externalEPKcm"] = Module["asm"]["_ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE25__init_copy_ctor_externalEPKcm"]).apply(null, arguments) - }; - var __ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE7reserveEm = Module["__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE7reserveEm"] = function() { - return (__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE7reserveEm = Module["__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE7reserveEm"] = Module["asm"]["_ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE7reserveEm"]).apply(null, arguments) - }; - var __ZNKSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE4copyEPcmm = Module["__ZNKSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE4copyEPcmm"] = function() { - return (__ZNKSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE4copyEPcmm = Module["__ZNKSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE4copyEPcmm"] = Module["asm"]["_ZNKSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE4copyEPcmm"]).apply(null, arguments) - }; - var __ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE9push_backEc = Module["__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE9push_backEc"] = function() { - return (__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE9push_backEc = Module["__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE9push_backEc"] = Module["asm"]["_ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE9push_backEc"]).apply(null, arguments) - }; - var __ZNSt3__212basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEED2Ev = Module["__ZNSt3__212basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEED2Ev"] = function() { - return (__ZNSt3__212basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEED2Ev = Module["__ZNSt3__212basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEED2Ev"] = Module["asm"]["_ZNSt3__212basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEED2Ev"]).apply(null, arguments) - }; - var __ZNSt3__212basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE9push_backEw = Module["__ZNSt3__212basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE9push_backEw"] = function() { - return (__ZNSt3__212basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE9push_backEw = Module["__ZNSt3__212basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE9push_backEw"] = Module["asm"]["_ZNSt3__212basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE9push_backEw"]).apply(null, arguments) - }; - var __Znwm = Module["__Znwm"] = function() { - return (__Znwm = Module["__Znwm"] = Module["asm"]["_Znwm"]).apply(null, arguments) - }; - var __ZdlPv = Module["__ZdlPv"] = function() { - return (__ZdlPv = Module["__ZdlPv"] = Module["asm"]["_ZdlPv"]).apply(null, arguments) - }; - var dynCall_jiji = Module["dynCall_jiji"] = function() { - return (dynCall_jiji = Module["dynCall_jiji"] = Module["asm"]["dynCall_jiji"]).apply(null, arguments) - }; - var _orig$ts_parser_timeout_micros = Module["_orig$ts_parser_timeout_micros"] = function() { - return (_orig$ts_parser_timeout_micros = Module["_orig$ts_parser_timeout_micros"] = Module["asm"]["orig$ts_parser_timeout_micros"]).apply(null, arguments) - }; - var _orig$ts_parser_set_timeout_micros = Module["_orig$ts_parser_set_timeout_micros"] = function() { - return (_orig$ts_parser_set_timeout_micros = Module["_orig$ts_parser_set_timeout_micros"] = Module["asm"]["orig$ts_parser_set_timeout_micros"]).apply(null, arguments) - }; - Module["allocate"] = allocate; - var calledRun; - - function ExitStatus(status) { - this.name = "ExitStatus"; - this.message = "Program terminated with exit(" + status + ")"; - this.status = status - } - var calledMain = false; - dependenciesFulfilled = function runCaller() { - if (!calledRun) run(); - if (!calledRun) dependenciesFulfilled = runCaller - }; - - function callMain(args) { - var entryFunction = Module["_main"]; - if (!entryFunction) return; - args = args || []; - var argc = args.length + 1; - var argv = stackAlloc((argc + 1) * 4); - HEAP32[argv >> 2] = allocateUTF8OnStack(thisProgram); - for (var i = 1; i < argc; i++) { - HEAP32[(argv >> 2) + i] = allocateUTF8OnStack(args[i - 1]) - } - HEAP32[(argv >> 2) + argc] = 0; - try { - var ret = entryFunction(argc, argv); - exit(ret, true) - } catch (e) { - if (e instanceof ExitStatus) { - return - } else if (e == "unwind") { - return - } else { - var toLog = e; - if (e && typeof e === "object" && e.stack) { - toLog = [e, e.stack] - } - err("exception thrown: " + toLog); - quit_(1, e) - } - } finally { - calledMain = true - } - } - var dylibsLoaded = false; - - function run(args) { - args = args || arguments_; - if (runDependencies > 0) { - return - } - if (!dylibsLoaded) { - preloadDylibs(); - dylibsLoaded = true; - if (runDependencies > 0) { - return - } - } - preRun(); - if (runDependencies > 0) { - return - } - - function doRun() { - if (calledRun) return; - calledRun = true; - Module["calledRun"] = true; - if (ABORT) return; - initRuntime(); - preMain(); - if (Module["onRuntimeInitialized"]) Module["onRuntimeInitialized"](); - if (shouldRunNow) callMain(args); - postRun() - } - if (Module["setStatus"]) { - Module["setStatus"]("Running..."); - setTimeout(function() { - setTimeout(function() { - Module["setStatus"]("") - }, 1); - doRun() - }, 1) - } else { - doRun() - } - } - Module["run"] = run; - - function exit(status, implicit) { - EXITSTATUS = status; - if (implicit && keepRuntimeAlive() && status === 0) { - return - } - if (keepRuntimeAlive()) {} else { - exitRuntime(); - if (Module["onExit"]) Module["onExit"](status); - ABORT = true - } - quit_(status, new ExitStatus(status)) - } - if (Module["preInit"]) { - if (typeof Module["preInit"] == "function") Module["preInit"] = [Module["preInit"]]; - while (Module["preInit"].length > 0) { - Module["preInit"].pop()() - } - } - var shouldRunNow = true; - if (Module["noInitialRun"]) shouldRunNow = false; - run(); - const C = Module; - const INTERNAL = {}; - const SIZE_OF_INT = 4; - const SIZE_OF_NODE = 5 * SIZE_OF_INT; - const SIZE_OF_POINT = 2 * SIZE_OF_INT; - const SIZE_OF_RANGE = 2 * SIZE_OF_INT + 2 * SIZE_OF_POINT; - const ZERO_POINT = { - row: 0, - column: 0 - }; - const QUERY_WORD_REGEX = /[\w-.]*/g; - const PREDICATE_STEP_TYPE_CAPTURE = 1; - const PREDICATE_STEP_TYPE_STRING = 2; - const LANGUAGE_FUNCTION_REGEX = /^_?tree_sitter_\w+/; - var VERSION; - var MIN_COMPATIBLE_VERSION; - var TRANSFER_BUFFER; - var currentParseCallback; - var currentLogCallback; - class ParserImpl { - static init() { - TRANSFER_BUFFER = C._ts_init(); - VERSION = getValue(TRANSFER_BUFFER, "i32"); - MIN_COMPATIBLE_VERSION = getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32") - } - initialize() { - C._ts_parser_new_wasm(); - this[0] = getValue(TRANSFER_BUFFER, "i32"); - this[1] = getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32") - } - delete() { - C._ts_parser_delete(this[0]); - C._free(this[1]); - this[0] = 0; - this[1] = 0 - } - setLanguage(language) { - let address; - if (!language) { - address = 0; - language = null - } else if (language.constructor === Language) { - address = language[0]; - const version = C._ts_language_version(address); - if (version < MIN_COMPATIBLE_VERSION || VERSION < version) { - throw new Error(`Incompatible language version ${version}. ` + `Compatibility range ${MIN_COMPATIBLE_VERSION} through ${VERSION}.`) - } - } else { - throw new Error("Argument must be a Language") - } - this.language = language; - C._ts_parser_set_language(this[0], address); - return this - } - getLanguage() { - return this.language - } - parse(callback, oldTree, options) { - if (typeof callback === "string") { - currentParseCallback = ((index, _, endIndex) => callback.slice(index, endIndex)) - } else if (typeof callback === "function") { - currentParseCallback = callback - } else { - throw new Error("Argument must be a string or a function") - } - if (this.logCallback) { - currentLogCallback = this.logCallback; - C._ts_parser_enable_logger_wasm(this[0], 1) - } else { - currentLogCallback = null; - C._ts_parser_enable_logger_wasm(this[0], 0) - } - let rangeCount = 0; - let rangeAddress = 0; - if (options && options.includedRanges) { - rangeCount = options.includedRanges.length; - rangeAddress = C._calloc(rangeCount, SIZE_OF_RANGE); - let address = rangeAddress; - for (let i = 0; i < rangeCount; i++) { - marshalRange(address, options.includedRanges[i]); - address += SIZE_OF_RANGE - } - } - const treeAddress = C._ts_parser_parse_wasm(this[0], this[1], oldTree ? oldTree[0] : 0, rangeAddress, rangeCount); - if (!treeAddress) { - currentParseCallback = null; - currentLogCallback = null; - throw new Error("Parsing failed") - } - const result = new Tree(INTERNAL, treeAddress, this.language, currentParseCallback); - currentParseCallback = null; - currentLogCallback = null; - return result - } - reset() { - C._ts_parser_reset(this[0]) - } - setTimeoutMicros(timeout) { - C._ts_parser_set_timeout_micros(this[0], timeout) - } - getTimeoutMicros() { - return C._ts_parser_timeout_micros(this[0]) - } - setLogger(callback) { - if (!callback) { - callback = null - } else if (typeof callback !== "function") { - throw new Error("Logger callback must be a function") - } - this.logCallback = callback; - return this - } - getLogger() { - return this.logCallback - } - } - class Tree { - constructor(internal, address, language, textCallback) { - assertInternal(internal); - this[0] = address; - this.language = language; - this.textCallback = textCallback - } - copy() { - const address = C._ts_tree_copy(this[0]); - return new Tree(INTERNAL, address, this.language, this.textCallback) - } - delete() { - C._ts_tree_delete(this[0]); - this[0] = 0 - } - edit(edit) { - marshalEdit(edit); - C._ts_tree_edit_wasm(this[0]) - } - get rootNode() { - C._ts_tree_root_node_wasm(this[0]); - return unmarshalNode(this) - } - getLanguage() { - return this.language - } - walk() { - return this.rootNode.walk() - } - getChangedRanges(other) { - if (other.constructor !== Tree) { - throw new TypeError("Argument must be a Tree") - } - C._ts_tree_get_changed_ranges_wasm(this[0], other[0]); - const count = getValue(TRANSFER_BUFFER, "i32"); - const buffer = getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32"); - const result = new Array(count); - if (count > 0) { - let address = buffer; - for (let i = 0; i < count; i++) { - result[i] = unmarshalRange(address); - address += SIZE_OF_RANGE - } - C._free(buffer) - } - return result - } - } - class Node { - constructor(internal, tree) { - assertInternal(internal); - this.tree = tree - } - get typeId() { - marshalNode(this); - return C._ts_node_symbol_wasm(this.tree[0]) - } - get type() { - return this.tree.language.types[this.typeId] || "ERROR" - } - get endPosition() { - marshalNode(this); - C._ts_node_end_point_wasm(this.tree[0]); - return unmarshalPoint(TRANSFER_BUFFER) - } - get endIndex() { - marshalNode(this); - return C._ts_node_end_index_wasm(this.tree[0]) - } - get text() { - return getText(this.tree, this.startIndex, this.endIndex) - } - isNamed() { - marshalNode(this); - return C._ts_node_is_named_wasm(this.tree[0]) === 1 - } - hasError() { - marshalNode(this); - return C._ts_node_has_error_wasm(this.tree[0]) === 1 - } - hasChanges() { - marshalNode(this); - return C._ts_node_has_changes_wasm(this.tree[0]) === 1 - } - isMissing() { - marshalNode(this); - return C._ts_node_is_missing_wasm(this.tree[0]) === 1 - } - equals(other) { - return this.id === other.id - } - child(index) { - marshalNode(this); - C._ts_node_child_wasm(this.tree[0], index); - return unmarshalNode(this.tree) - } - namedChild(index) { - marshalNode(this); - C._ts_node_named_child_wasm(this.tree[0], index); - return unmarshalNode(this.tree) - } - childForFieldId(fieldId) { - marshalNode(this); - C._ts_node_child_by_field_id_wasm(this.tree[0], fieldId); - return unmarshalNode(this.tree) - } - childForFieldName(fieldName) { - const fieldId = this.tree.language.fields.indexOf(fieldName); - if (fieldId !== -1) return this.childForFieldId(fieldId) - } - get childCount() { - marshalNode(this); - return C._ts_node_child_count_wasm(this.tree[0]) - } - get namedChildCount() { - marshalNode(this); - return C._ts_node_named_child_count_wasm(this.tree[0]) - } - get firstChild() { - return this.child(0) - } - get firstNamedChild() { - return this.namedChild(0) - } - get lastChild() { - return this.child(this.childCount - 1) - } - get lastNamedChild() { - return this.namedChild(this.namedChildCount - 1) - } - get children() { - if (!this._children) { - marshalNode(this); - C._ts_node_children_wasm(this.tree[0]); - const count = getValue(TRANSFER_BUFFER, "i32"); - const buffer = getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32"); - this._children = new Array(count); - if (count > 0) { - let address = buffer; - for (let i = 0; i < count; i++) { - this._children[i] = unmarshalNode(this.tree, address); - address += SIZE_OF_NODE - } - C._free(buffer) - } - } - return this._children - } - get namedChildren() { - if (!this._namedChildren) { - marshalNode(this); - C._ts_node_named_children_wasm(this.tree[0]); - const count = getValue(TRANSFER_BUFFER, "i32"); - const buffer = getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32"); - this._namedChildren = new Array(count); - if (count > 0) { - let address = buffer; - for (let i = 0; i < count; i++) { - this._namedChildren[i] = unmarshalNode(this.tree, address); - address += SIZE_OF_NODE - } - C._free(buffer) - } - } - return this._namedChildren - } - descendantsOfType(types, startPosition, endPosition) { - if (!Array.isArray(types)) types = [types]; - if (!startPosition) startPosition = ZERO_POINT; - if (!endPosition) endPosition = ZERO_POINT; - const symbols = []; - const typesBySymbol = this.tree.language.types; - for (let i = 0, n = typesBySymbol.length; i < n; i++) { - if (types.includes(typesBySymbol[i])) { - symbols.push(i) - } - } - const symbolsAddress = C._malloc(SIZE_OF_INT * symbols.length); - for (let i = 0, n = symbols.length; i < n; i++) { - setValue(symbolsAddress + i * SIZE_OF_INT, symbols[i], "i32") - } - marshalNode(this); - C._ts_node_descendants_of_type_wasm(this.tree[0], symbolsAddress, symbols.length, startPosition.row, startPosition.column, endPosition.row, endPosition.column); - const descendantCount = getValue(TRANSFER_BUFFER, "i32"); - const descendantAddress = getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32"); - const result = new Array(descendantCount); - if (descendantCount > 0) { - let address = descendantAddress; - for (let i = 0; i < descendantCount; i++) { - result[i] = unmarshalNode(this.tree, address); - address += SIZE_OF_NODE - } - } - C._free(descendantAddress); - C._free(symbolsAddress); - return result - } - get nextSibling() { - marshalNode(this); - C._ts_node_next_sibling_wasm(this.tree[0]); - return unmarshalNode(this.tree) - } - get previousSibling() { - marshalNode(this); - C._ts_node_prev_sibling_wasm(this.tree[0]); - return unmarshalNode(this.tree) - } - get nextNamedSibling() { - marshalNode(this); - C._ts_node_next_named_sibling_wasm(this.tree[0]); - return unmarshalNode(this.tree) - } - get previousNamedSibling() { - marshalNode(this); - C._ts_node_prev_named_sibling_wasm(this.tree[0]); - return unmarshalNode(this.tree) - } - get parent() { - marshalNode(this); - C._ts_node_parent_wasm(this.tree[0]); - return unmarshalNode(this.tree) - } - descendantForIndex(start, end = start) { - if (typeof start !== "number" || typeof end !== "number") { - throw new Error("Arguments must be numbers") - } - marshalNode(this); - let address = TRANSFER_BUFFER + SIZE_OF_NODE; - setValue(address, start, "i32"); - setValue(address + SIZE_OF_INT, end, "i32"); - C._ts_node_descendant_for_index_wasm(this.tree[0]); - return unmarshalNode(this.tree) - } - namedDescendantForIndex(start, end = start) { - if (typeof start !== "number" || typeof end !== "number") { - throw new Error("Arguments must be numbers") - } - marshalNode(this); - let address = TRANSFER_BUFFER + SIZE_OF_NODE; - setValue(address, start, "i32"); - setValue(address + SIZE_OF_INT, end, "i32"); - C._ts_node_named_descendant_for_index_wasm(this.tree[0]); - return unmarshalNode(this.tree) - } - descendantForPosition(start, end = start) { - if (!isPoint(start) || !isPoint(end)) { - throw new Error("Arguments must be {row, column} objects") - } - marshalNode(this); - let address = TRANSFER_BUFFER + SIZE_OF_NODE; - marshalPoint(address, start); - marshalPoint(address + SIZE_OF_POINT, end); - C._ts_node_descendant_for_position_wasm(this.tree[0]); - return unmarshalNode(this.tree) - } - namedDescendantForPosition(start, end = start) { - if (!isPoint(start) || !isPoint(end)) { - throw new Error("Arguments must be {row, column} objects") - } - marshalNode(this); - let address = TRANSFER_BUFFER + SIZE_OF_NODE; - marshalPoint(address, start); - marshalPoint(address + SIZE_OF_POINT, end); - C._ts_node_named_descendant_for_position_wasm(this.tree[0]); - return unmarshalNode(this.tree) - } - walk() { - marshalNode(this); - C._ts_tree_cursor_new_wasm(this.tree[0]); - return new TreeCursor(INTERNAL, this.tree) - } - toString() { - marshalNode(this); - const address = C._ts_node_to_string_wasm(this.tree[0]); - const result = AsciiToString(address); - C._free(address); - return result - } - } - class TreeCursor { - constructor(internal, tree) { - assertInternal(internal); - this.tree = tree; - unmarshalTreeCursor(this) - } - delete() { - marshalTreeCursor(this); - C._ts_tree_cursor_delete_wasm(this.tree[0]); - this[0] = this[1] = this[2] = 0 - } - reset(node) { - marshalNode(node); - marshalTreeCursor(this, TRANSFER_BUFFER + SIZE_OF_NODE); - C._ts_tree_cursor_reset_wasm(this.tree[0]); - unmarshalTreeCursor(this) - } - get nodeType() { - return this.tree.language.types[this.nodeTypeId] || "ERROR" - } - get nodeTypeId() { - marshalTreeCursor(this); - return C._ts_tree_cursor_current_node_type_id_wasm(this.tree[0]) - } - get nodeId() { - marshalTreeCursor(this); - return C._ts_tree_cursor_current_node_id_wasm(this.tree[0]) - } - get nodeIsNamed() { - marshalTreeCursor(this); - return C._ts_tree_cursor_current_node_is_named_wasm(this.tree[0]) === 1 - } - get nodeIsMissing() { - marshalTreeCursor(this); - return C._ts_tree_cursor_current_node_is_missing_wasm(this.tree[0]) === 1 - } - get nodeText() { - marshalTreeCursor(this); - const startIndex = C._ts_tree_cursor_start_index_wasm(this.tree[0]); - const endIndex = C._ts_tree_cursor_end_index_wasm(this.tree[0]); - return getText(this.tree, startIndex, endIndex) - } - get startPosition() { - marshalTreeCursor(this); - C._ts_tree_cursor_start_position_wasm(this.tree[0]); - return unmarshalPoint(TRANSFER_BUFFER) - } - get endPosition() { - marshalTreeCursor(this); - C._ts_tree_cursor_end_position_wasm(this.tree[0]); - return unmarshalPoint(TRANSFER_BUFFER) - } - get startIndex() { - marshalTreeCursor(this); - return C._ts_tree_cursor_start_index_wasm(this.tree[0]) - } - get endIndex() { - marshalTreeCursor(this); - return C._ts_tree_cursor_end_index_wasm(this.tree[0]) - } - currentNode() { - marshalTreeCursor(this); - C._ts_tree_cursor_current_node_wasm(this.tree[0]); - return unmarshalNode(this.tree) - } - currentFieldId() { - marshalTreeCursor(this); - return C._ts_tree_cursor_current_field_id_wasm(this.tree[0]) - } - currentFieldName() { - return this.tree.language.fields[this.currentFieldId()] - } - gotoFirstChild() { - marshalTreeCursor(this); - const result = C._ts_tree_cursor_goto_first_child_wasm(this.tree[0]); - unmarshalTreeCursor(this); - return result === 1 - } - gotoNextSibling() { - marshalTreeCursor(this); - const result = C._ts_tree_cursor_goto_next_sibling_wasm(this.tree[0]); - unmarshalTreeCursor(this); - return result === 1 - } - gotoParent() { - marshalTreeCursor(this); - const result = C._ts_tree_cursor_goto_parent_wasm(this.tree[0]); - unmarshalTreeCursor(this); - return result === 1 - } - } - class Language { - constructor(internal, address) { - assertInternal(internal); - this[0] = address; - this.types = new Array(C._ts_language_symbol_count(this[0])); - for (let i = 0, n = this.types.length; i < n; i++) { - if (C._ts_language_symbol_type(this[0], i) < 2) { - this.types[i] = UTF8ToString(C._ts_language_symbol_name(this[0], i)) - } - } - this.fields = new Array(C._ts_language_field_count(this[0]) + 1); - for (let i = 0, n = this.fields.length; i < n; i++) { - const fieldName = C._ts_language_field_name_for_id(this[0], i); - if (fieldName !== 0) { - this.fields[i] = UTF8ToString(fieldName) - } else { - this.fields[i] = null - } - } - } - get version() { - return C._ts_language_version(this[0]) - } - get fieldCount() { - return this.fields.length - 1 - } - fieldIdForName(fieldName) { - const result = this.fields.indexOf(fieldName); - if (result !== -1) { - return result - } else { - return null - } - } - fieldNameForId(fieldId) { - return this.fields[fieldId] || null - } - idForNodeType(type, named) { - const typeLength = lengthBytesUTF8(type); - const typeAddress = C._malloc(typeLength + 1); - stringToUTF8(type, typeAddress, typeLength + 1); - const result = C._ts_language_symbol_for_name(this[0], typeAddress, typeLength, named); - C._free(typeAddress); - return result || null - } - get nodeTypeCount() { - return C._ts_language_symbol_count(this[0]) - } - nodeTypeForId(typeId) { - const name = C._ts_language_symbol_name(this[0], typeId); - return name ? UTF8ToString(name) : null - } - nodeTypeIsNamed(typeId) { - return C._ts_language_type_is_named_wasm(this[0], typeId) ? true : false - } - nodeTypeIsVisible(typeId) { - return C._ts_language_type_is_visible_wasm(this[0], typeId) ? true : false - } - query(source) { - const sourceLength = lengthBytesUTF8(source); - const sourceAddress = C._malloc(sourceLength + 1); - stringToUTF8(source, sourceAddress, sourceLength + 1); - const address = C._ts_query_new(this[0], sourceAddress, sourceLength, TRANSFER_BUFFER, TRANSFER_BUFFER + SIZE_OF_INT); - if (!address) { - const errorId = getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32"); - const errorByte = getValue(TRANSFER_BUFFER, "i32"); - const errorIndex = UTF8ToString(sourceAddress, errorByte).length; - const suffix = source.substr(errorIndex, 100).split("\n")[0]; - let word = suffix.match(QUERY_WORD_REGEX)[0]; - let error; - switch (errorId) { - case 2: - error = new RangeError(`Bad node name '${word}'`); - break; - case 3: - error = new RangeError(`Bad field name '${word}'`); - break; - case 4: - error = new RangeError(`Bad capture name @${word}`); - break; - case 5: - error = new TypeError(`Bad pattern structure at offset ${errorIndex}: '${suffix}'...`); - word = ""; - break; - default: - error = new SyntaxError(`Bad syntax at offset ${errorIndex}: '${suffix}'...`); - word = ""; - break - } - error.index = errorIndex; - error.length = word.length; - C._free(sourceAddress); - throw error - } - const stringCount = C._ts_query_string_count(address); - const captureCount = C._ts_query_capture_count(address); - const patternCount = C._ts_query_pattern_count(address); - const captureNames = new Array(captureCount); - const stringValues = new Array(stringCount); - for (let i = 0; i < captureCount; i++) { - const nameAddress = C._ts_query_capture_name_for_id(address, i, TRANSFER_BUFFER); - const nameLength = getValue(TRANSFER_BUFFER, "i32"); - captureNames[i] = UTF8ToString(nameAddress, nameLength) - } - for (let i = 0; i < stringCount; i++) { - const valueAddress = C._ts_query_string_value_for_id(address, i, TRANSFER_BUFFER); - const nameLength = getValue(TRANSFER_BUFFER, "i32"); - stringValues[i] = UTF8ToString(valueAddress, nameLength) - } - const setProperties = new Array(patternCount); - const assertedProperties = new Array(patternCount); - const refutedProperties = new Array(patternCount); - const predicates = new Array(patternCount); - const textPredicates = new Array(patternCount); - for (let i = 0; i < patternCount; i++) { - const predicatesAddress = C._ts_query_predicates_for_pattern(address, i, TRANSFER_BUFFER); - const stepCount = getValue(TRANSFER_BUFFER, "i32"); - predicates[i] = []; - textPredicates[i] = []; - const steps = []; - let stepAddress = predicatesAddress; - for (let j = 0; j < stepCount; j++) { - const stepType = getValue(stepAddress, "i32"); - stepAddress += SIZE_OF_INT; - const stepValueId = getValue(stepAddress, "i32"); - stepAddress += SIZE_OF_INT; - if (stepType === PREDICATE_STEP_TYPE_CAPTURE) { - steps.push({ - type: "capture", - name: captureNames[stepValueId] - }) - } else if (stepType === PREDICATE_STEP_TYPE_STRING) { - steps.push({ - type: "string", - value: stringValues[stepValueId] - }) - } else if (steps.length > 0) { - if (steps[0].type !== "string") { - throw new Error("Predicates must begin with a literal value") - } - const operator = steps[0].value; - let isPositive = true; - switch (operator) { - case "not-eq?": - isPositive = false; - case "eq?": - if (steps.length !== 3) throw new Error(`Wrong number of arguments to \`#eq?\` predicate. Expected 2, got ${steps.length-1}`); - if (steps[1].type !== "capture") throw new Error(`First argument of \`#eq?\` predicate must be a capture. Got "${steps[1].value}"`); - if (steps[2].type === "capture") { - const captureName1 = steps[1].name; - const captureName2 = steps[2].name; - textPredicates[i].push(function(captures) { - let node1, node2; - for (const c of captures) { - if (c.name === captureName1) node1 = c.node; - if (c.name === captureName2) node2 = c.node - } - if (node1 === undefined || node2 === undefined) return true; - return node1.text === node2.text === isPositive - }) - } else { - const captureName = steps[1].name; - const stringValue = steps[2].value; - textPredicates[i].push(function(captures) { - for (const c of captures) { - if (c.name === captureName) { - return c.node.text === stringValue === isPositive + function _emscripten_memcpy_big(dest, src, num) { + HEAPU8.copyWithin(dest, src, src + num) + } + + function emscripten_realloc_buffer(size) { + try { + wasmMemory.grow(size - buffer.byteLength + 65535 >>> 16); + updateGlobalBufferAndViews(wasmMemory.buffer); + return 1 + } catch (e) {} + } + + function _emscripten_resize_heap(requestedSize) { + var oldSize = HEAPU8.length; + requestedSize = requestedSize >>> 0; + var maxHeapSize = 2147483648; + if (requestedSize > maxHeapSize) { + return false + } + for (var cutDown = 1; cutDown <= 4; cutDown *= 2) { + var overGrownHeapSize = oldSize * (1 + .2 / cutDown); + overGrownHeapSize = Math.min(overGrownHeapSize, requestedSize + 100663296); + var newSize = Math.min(maxHeapSize, alignUp(Math.max(requestedSize, overGrownHeapSize), 65536)); + var replacement = emscripten_realloc_buffer(newSize); + if (replacement) { + return true + } + } + return false + } + + function _exit(status) { + exit(status) + } + _exit.sig = "vi"; + var SYSCALLS = { + mappings: {}, + DEFAULT_POLLMASK: 5, + umask: 511, + calculateAt: function(dirfd, path, allowEmpty) { + if (path[0] === "/") { + return path + } + var dir; + if (dirfd === -100) { + dir = FS.cwd() + } else { + var dirstream = FS.getStream(dirfd); + if (!dirstream) throw new FS.ErrnoError(8); + dir = dirstream.path + } + if (path.length == 0) { + if (!allowEmpty) { + throw new FS.ErrnoError(44) + } + return dir + } + return PATH.join2(dir, path) + }, + doStat: function(func, path, buf) { + try { + var stat = func(path) + } catch (e) { + if (e && e.node && PATH.normalize(path) !== PATH.normalize(FS.getPath(e.node))) { + return -54 + } + throw e + } + HEAP32[buf >> 2] = stat.dev; + HEAP32[buf + 4 >> 2] = 0; + HEAP32[buf + 8 >> 2] = stat.ino; + HEAP32[buf + 12 >> 2] = stat.mode; + HEAP32[buf + 16 >> 2] = stat.nlink; + HEAP32[buf + 20 >> 2] = stat.uid; + HEAP32[buf + 24 >> 2] = stat.gid; + HEAP32[buf + 28 >> 2] = stat.rdev; + HEAP32[buf + 32 >> 2] = 0; + tempI64 = [stat.size >>> 0, (tempDouble = stat.size, +Math.abs(tempDouble) >= 1 ? tempDouble > 0 ? (Math.min(+Math.floor(tempDouble / 4294967296), 4294967295) | 0) >>> 0 : ~~+Math.ceil((tempDouble - +(~~tempDouble >>> 0)) / 4294967296) >>> 0 : 0)], HEAP32[buf + 40 >> 2] = tempI64[0], HEAP32[buf + 44 >> 2] = tempI64[1]; + HEAP32[buf + 48 >> 2] = 4096; + HEAP32[buf + 52 >> 2] = stat.blocks; + HEAP32[buf + 56 >> 2] = stat.atime.getTime() / 1e3 | 0; + HEAP32[buf + 60 >> 2] = 0; + HEAP32[buf + 64 >> 2] = stat.mtime.getTime() / 1e3 | 0; + HEAP32[buf + 68 >> 2] = 0; + HEAP32[buf + 72 >> 2] = stat.ctime.getTime() / 1e3 | 0; + HEAP32[buf + 76 >> 2] = 0; + tempI64 = [stat.ino >>> 0, (tempDouble = stat.ino, +Math.abs(tempDouble) >= 1 ? tempDouble > 0 ? (Math.min(+Math.floor(tempDouble / 4294967296), 4294967295) | 0) >>> 0 : ~~+Math.ceil((tempDouble - +(~~tempDouble >>> 0)) / 4294967296) >>> 0 : 0)], HEAP32[buf + 80 >> 2] = tempI64[0], HEAP32[buf + 84 >> 2] = tempI64[1]; + return 0 + }, + doMsync: function(addr, stream, len, flags, offset) { + var buffer = HEAPU8.slice(addr, addr + len); + FS.msync(stream, buffer, offset, len, flags) + }, + doMkdir: function(path, mode) { + path = PATH.normalize(path); + if (path[path.length - 1] === "/") path = path.substr(0, path.length - 1); + FS.mkdir(path, mode, 0); + return 0 + }, + doMknod: function(path, mode, dev) { + switch (mode & 61440) { + case 32768: + case 8192: + case 24576: + case 4096: + case 49152: + break; + default: + return -28 + } + FS.mknod(path, mode, dev); + return 0 + }, + doReadlink: function(path, buf, bufsize) { + if (bufsize <= 0) return -28; + var ret = FS.readlink(path); + var len = Math.min(bufsize, lengthBytesUTF8(ret)); + var endChar = HEAP8[buf + len]; + stringToUTF8(ret, buf, bufsize + 1); + HEAP8[buf + len] = endChar; + return len + }, + doAccess: function(path, amode) { + if (amode & ~7) { + return -28 + } + var node; + var lookup = FS.lookupPath(path, { + follow: true + }); + node = lookup.node; + if (!node) { + return -44 + } + var perms = ""; + if (amode & 4) perms += "r"; + if (amode & 2) perms += "w"; + if (amode & 1) perms += "x"; + if (perms && FS.nodePermissions(node, perms)) { + return -2 + } + return 0 + }, + doDup: function(path, flags, suggestFD) { + var suggest = FS.getStream(suggestFD); + if (suggest) FS.close(suggest); + return FS.open(path, flags, 0, suggestFD, suggestFD).fd + }, + doReadv: function(stream, iov, iovcnt, offset) { + var ret = 0; + for (var i = 0; i < iovcnt; i++) { + var ptr = HEAP32[iov + i * 8 >> 2]; + var len = HEAP32[iov + (i * 8 + 4) >> 2]; + var curr = FS.read(stream, HEAP8, ptr, len, offset); + if (curr < 0) return -1; + ret += curr; + if (curr < len) break + } + return ret + }, + doWritev: function(stream, iov, iovcnt, offset) { + var ret = 0; + for (var i = 0; i < iovcnt; i++) { + var ptr = HEAP32[iov + i * 8 >> 2]; + var len = HEAP32[iov + (i * 8 + 4) >> 2]; + var curr = FS.write(stream, HEAP8, ptr, len, offset); + if (curr < 0) return -1; + ret += curr + } + return ret + }, + varargs: undefined, + get: function() { + SYSCALLS.varargs += 4; + var ret = HEAP32[SYSCALLS.varargs - 4 >> 2]; + return ret + }, + getStr: function(ptr) { + var ret = UTF8ToString(ptr); + return ret + }, + getStreamFromFD: function(fd) { + var stream = FS.getStream(fd); + if (!stream) throw new FS.ErrnoError(8); + return stream + }, + get64: function(low, high) { + return low + } + }; + + function _fd_close(fd) { + try { + var stream = SYSCALLS.getStreamFromFD(fd); + FS.close(stream); + return 0 + } catch (e) { + if (typeof FS === "undefined" || !(e instanceof FS.ErrnoError)) abort(e); + return e.errno + } + } + _fd_close.sig = "ii"; + + function _fd_seek(fd, offset_low, offset_high, whence, newOffset) { + try { + var stream = SYSCALLS.getStreamFromFD(fd); + var HIGH_OFFSET = 4294967296; + var offset = offset_high * HIGH_OFFSET + (offset_low >>> 0); + var DOUBLE_LIMIT = 9007199254740992; + if (offset <= -DOUBLE_LIMIT || offset >= DOUBLE_LIMIT) { + return -61 + } + FS.llseek(stream, offset, whence); + tempI64 = [stream.position >>> 0, (tempDouble = stream.position, +Math.abs(tempDouble) >= 1 ? tempDouble > 0 ? (Math.min(+Math.floor(tempDouble / 4294967296), 4294967295) | 0) >>> 0 : ~~+Math.ceil((tempDouble - +(~~tempDouble >>> 0)) / 4294967296) >>> 0 : 0)], HEAP32[newOffset >> 2] = tempI64[0], HEAP32[newOffset + 4 >> 2] = tempI64[1]; + if (stream.getdents && offset === 0 && whence === 0) stream.getdents = null; + return 0 + } catch (e) { + if (typeof FS === "undefined" || !(e instanceof FS.ErrnoError)) abort(e); + return e.errno + } + } + + function _fd_write(fd, iov, iovcnt, pnum) { + try { + var stream = SYSCALLS.getStreamFromFD(fd); + var num = SYSCALLS.doWritev(stream, iov, iovcnt); + HEAP32[pnum >> 2] = num; + return 0 + } catch (e) { + if (typeof FS === "undefined" || !(e instanceof FS.ErrnoError)) abort(e); + return e.errno + } + } + _fd_write.sig = "iiiii"; + + function _setTempRet0(val) { + setTempRet0(val) + } + _setTempRet0.sig = "vi"; + + function _tree_sitter_log_callback(isLexMessage, messageAddress) { + if (currentLogCallback) { + const message = UTF8ToString(messageAddress); + currentLogCallback(message, isLexMessage !== 0) + } + } + + function _tree_sitter_parse_callback(inputBufferAddress, index, row, column, lengthAddress) { + var INPUT_BUFFER_SIZE = 10 * 1024; + var string = currentParseCallback(index, { + row: row, + column: column + }); + if (typeof string === "string") { + setValue(lengthAddress, string.length, "i32"); + stringToUTF16(string, inputBufferAddress, INPUT_BUFFER_SIZE) + } else { + setValue(lengthAddress, 0, "i32") + } + } + var ___memory_base = 1024; + var ___table_base = 1; + var asmLibraryArg = { + "__heap_base": ___heap_base, + "__indirect_function_table": wasmTable, + "__memory_base": ___memory_base, + "__stack_pointer": ___stack_pointer, + "__table_base": ___table_base, + "abort": _abort, + "clock_gettime": _clock_gettime, + "emscripten_memcpy_big": _emscripten_memcpy_big, + "emscripten_resize_heap": _emscripten_resize_heap, + "exit": _exit, + "fd_close": _fd_close, + "fd_seek": _fd_seek, + "fd_write": _fd_write, + "memory": wasmMemory, + "setTempRet0": _setTempRet0, + "tree_sitter_log_callback": _tree_sitter_log_callback, + "tree_sitter_parse_callback": _tree_sitter_parse_callback + }; + var asm = createWasm(); + var ___wasm_call_ctors = Module["___wasm_call_ctors"] = function() { + return (___wasm_call_ctors = Module["___wasm_call_ctors"] = Module["asm"]["__wasm_call_ctors"]).apply(null, arguments) + }; + var _malloc = Module["_malloc"] = function() { + return (_malloc = Module["_malloc"] = Module["asm"]["malloc"]).apply(null, arguments) + }; + var _calloc = Module["_calloc"] = function() { + return (_calloc = Module["_calloc"] = Module["asm"]["calloc"]).apply(null, arguments) + }; + var _realloc = Module["_realloc"] = function() { + return (_realloc = Module["_realloc"] = Module["asm"]["realloc"]).apply(null, arguments) + }; + var _free = Module["_free"] = function() { + return (_free = Module["_free"] = Module["asm"]["free"]).apply(null, arguments) + }; + var _ts_language_symbol_count = Module["_ts_language_symbol_count"] = function() { + return (_ts_language_symbol_count = Module["_ts_language_symbol_count"] = Module["asm"]["ts_language_symbol_count"]).apply(null, arguments) + }; + var _ts_language_version = Module["_ts_language_version"] = function() { + return (_ts_language_version = Module["_ts_language_version"] = Module["asm"]["ts_language_version"]).apply(null, arguments) + }; + var _ts_language_field_count = Module["_ts_language_field_count"] = function() { + return (_ts_language_field_count = Module["_ts_language_field_count"] = Module["asm"]["ts_language_field_count"]).apply(null, arguments) + }; + var _ts_language_symbol_name = Module["_ts_language_symbol_name"] = function() { + return (_ts_language_symbol_name = Module["_ts_language_symbol_name"] = Module["asm"]["ts_language_symbol_name"]).apply(null, arguments) + }; + var _ts_language_symbol_for_name = Module["_ts_language_symbol_for_name"] = function() { + return (_ts_language_symbol_for_name = Module["_ts_language_symbol_for_name"] = Module["asm"]["ts_language_symbol_for_name"]).apply(null, arguments) + }; + var _strncmp = Module["_strncmp"] = function() { + return (_strncmp = Module["_strncmp"] = Module["asm"]["strncmp"]).apply(null, arguments) + }; + var _ts_language_symbol_type = Module["_ts_language_symbol_type"] = function() { + return (_ts_language_symbol_type = Module["_ts_language_symbol_type"] = Module["asm"]["ts_language_symbol_type"]).apply(null, arguments) + }; + var _ts_language_field_name_for_id = Module["_ts_language_field_name_for_id"] = function() { + return (_ts_language_field_name_for_id = Module["_ts_language_field_name_for_id"] = Module["asm"]["ts_language_field_name_for_id"]).apply(null, arguments) + }; + var _memset = Module["_memset"] = function() { + return (_memset = Module["_memset"] = Module["asm"]["memset"]).apply(null, arguments) + }; + var _memcpy = Module["_memcpy"] = function() { + return (_memcpy = Module["_memcpy"] = Module["asm"]["memcpy"]).apply(null, arguments) + }; + var _ts_parser_delete = Module["_ts_parser_delete"] = function() { + return (_ts_parser_delete = Module["_ts_parser_delete"] = Module["asm"]["ts_parser_delete"]).apply(null, arguments) + }; + var _ts_parser_reset = Module["_ts_parser_reset"] = function() { + return (_ts_parser_reset = Module["_ts_parser_reset"] = Module["asm"]["ts_parser_reset"]).apply(null, arguments) + }; + var _ts_parser_set_language = Module["_ts_parser_set_language"] = function() { + return (_ts_parser_set_language = Module["_ts_parser_set_language"] = Module["asm"]["ts_parser_set_language"]).apply(null, arguments) + }; + var _ts_parser_timeout_micros = Module["_ts_parser_timeout_micros"] = function() { + return (_ts_parser_timeout_micros = Module["_ts_parser_timeout_micros"] = Module["asm"]["ts_parser_timeout_micros"]).apply(null, arguments) + }; + var _ts_parser_set_timeout_micros = Module["_ts_parser_set_timeout_micros"] = function() { + return (_ts_parser_set_timeout_micros = Module["_ts_parser_set_timeout_micros"] = Module["asm"]["ts_parser_set_timeout_micros"]).apply(null, arguments) + }; + var _memmove = Module["_memmove"] = function() { + return (_memmove = Module["_memmove"] = Module["asm"]["memmove"]).apply(null, arguments) + }; + var _memcmp = Module["_memcmp"] = function() { + return (_memcmp = Module["_memcmp"] = Module["asm"]["memcmp"]).apply(null, arguments) + }; + var _ts_query_new = Module["_ts_query_new"] = function() { + return (_ts_query_new = Module["_ts_query_new"] = Module["asm"]["ts_query_new"]).apply(null, arguments) + }; + var _ts_query_delete = Module["_ts_query_delete"] = function() { + return (_ts_query_delete = Module["_ts_query_delete"] = Module["asm"]["ts_query_delete"]).apply(null, arguments) + }; + var _iswspace = Module["_iswspace"] = function() { + return (_iswspace = Module["_iswspace"] = Module["asm"]["iswspace"]).apply(null, arguments) + }; + var _iswalnum = Module["_iswalnum"] = function() { + return (_iswalnum = Module["_iswalnum"] = Module["asm"]["iswalnum"]).apply(null, arguments) + }; + var _ts_query_pattern_count = Module["_ts_query_pattern_count"] = function() { + return (_ts_query_pattern_count = Module["_ts_query_pattern_count"] = Module["asm"]["ts_query_pattern_count"]).apply(null, arguments) + }; + var _ts_query_capture_count = Module["_ts_query_capture_count"] = function() { + return (_ts_query_capture_count = Module["_ts_query_capture_count"] = Module["asm"]["ts_query_capture_count"]).apply(null, arguments) + }; + var _ts_query_string_count = Module["_ts_query_string_count"] = function() { + return (_ts_query_string_count = Module["_ts_query_string_count"] = Module["asm"]["ts_query_string_count"]).apply(null, arguments) + }; + var _ts_query_capture_name_for_id = Module["_ts_query_capture_name_for_id"] = function() { + return (_ts_query_capture_name_for_id = Module["_ts_query_capture_name_for_id"] = Module["asm"]["ts_query_capture_name_for_id"]).apply(null, arguments) + }; + var _ts_query_string_value_for_id = Module["_ts_query_string_value_for_id"] = function() { + return (_ts_query_string_value_for_id = Module["_ts_query_string_value_for_id"] = Module["asm"]["ts_query_string_value_for_id"]).apply(null, arguments) + }; + var _ts_query_predicates_for_pattern = Module["_ts_query_predicates_for_pattern"] = function() { + return (_ts_query_predicates_for_pattern = Module["_ts_query_predicates_for_pattern"] = Module["asm"]["ts_query_predicates_for_pattern"]).apply(null, arguments) + }; + var _ts_tree_copy = Module["_ts_tree_copy"] = function() { + return (_ts_tree_copy = Module["_ts_tree_copy"] = Module["asm"]["ts_tree_copy"]).apply(null, arguments) + }; + var _ts_tree_delete = Module["_ts_tree_delete"] = function() { + return (_ts_tree_delete = Module["_ts_tree_delete"] = Module["asm"]["ts_tree_delete"]).apply(null, arguments) + }; + var _ts_init = Module["_ts_init"] = function() { + return (_ts_init = Module["_ts_init"] = Module["asm"]["ts_init"]).apply(null, arguments) + }; + var _ts_parser_new_wasm = Module["_ts_parser_new_wasm"] = function() { + return (_ts_parser_new_wasm = Module["_ts_parser_new_wasm"] = Module["asm"]["ts_parser_new_wasm"]).apply(null, arguments) + }; + var _ts_parser_enable_logger_wasm = Module["_ts_parser_enable_logger_wasm"] = function() { + return (_ts_parser_enable_logger_wasm = Module["_ts_parser_enable_logger_wasm"] = Module["asm"]["ts_parser_enable_logger_wasm"]).apply(null, arguments) + }; + var _ts_parser_parse_wasm = Module["_ts_parser_parse_wasm"] = function() { + return (_ts_parser_parse_wasm = Module["_ts_parser_parse_wasm"] = Module["asm"]["ts_parser_parse_wasm"]).apply(null, arguments) + }; + var _ts_language_type_is_named_wasm = Module["_ts_language_type_is_named_wasm"] = function() { + return (_ts_language_type_is_named_wasm = Module["_ts_language_type_is_named_wasm"] = Module["asm"]["ts_language_type_is_named_wasm"]).apply(null, arguments) + }; + var _ts_language_type_is_visible_wasm = Module["_ts_language_type_is_visible_wasm"] = function() { + return (_ts_language_type_is_visible_wasm = Module["_ts_language_type_is_visible_wasm"] = Module["asm"]["ts_language_type_is_visible_wasm"]).apply(null, arguments) + }; + var _ts_tree_root_node_wasm = Module["_ts_tree_root_node_wasm"] = function() { + return (_ts_tree_root_node_wasm = Module["_ts_tree_root_node_wasm"] = Module["asm"]["ts_tree_root_node_wasm"]).apply(null, arguments) + }; + var _ts_tree_edit_wasm = Module["_ts_tree_edit_wasm"] = function() { + return (_ts_tree_edit_wasm = Module["_ts_tree_edit_wasm"] = Module["asm"]["ts_tree_edit_wasm"]).apply(null, arguments) + }; + var _ts_tree_get_changed_ranges_wasm = Module["_ts_tree_get_changed_ranges_wasm"] = function() { + return (_ts_tree_get_changed_ranges_wasm = Module["_ts_tree_get_changed_ranges_wasm"] = Module["asm"]["ts_tree_get_changed_ranges_wasm"]).apply(null, arguments) + }; + var _ts_tree_cursor_new_wasm = Module["_ts_tree_cursor_new_wasm"] = function() { + return (_ts_tree_cursor_new_wasm = Module["_ts_tree_cursor_new_wasm"] = Module["asm"]["ts_tree_cursor_new_wasm"]).apply(null, arguments) + }; + var _ts_tree_cursor_delete_wasm = Module["_ts_tree_cursor_delete_wasm"] = function() { + return (_ts_tree_cursor_delete_wasm = Module["_ts_tree_cursor_delete_wasm"] = Module["asm"]["ts_tree_cursor_delete_wasm"]).apply(null, arguments) + }; + var _ts_tree_cursor_reset_wasm = Module["_ts_tree_cursor_reset_wasm"] = function() { + return (_ts_tree_cursor_reset_wasm = Module["_ts_tree_cursor_reset_wasm"] = Module["asm"]["ts_tree_cursor_reset_wasm"]).apply(null, arguments) + }; + var _ts_tree_cursor_goto_first_child_wasm = Module["_ts_tree_cursor_goto_first_child_wasm"] = function() { + return (_ts_tree_cursor_goto_first_child_wasm = Module["_ts_tree_cursor_goto_first_child_wasm"] = Module["asm"]["ts_tree_cursor_goto_first_child_wasm"]).apply(null, arguments) + }; + var _ts_tree_cursor_goto_next_sibling_wasm = Module["_ts_tree_cursor_goto_next_sibling_wasm"] = function() { + return (_ts_tree_cursor_goto_next_sibling_wasm = Module["_ts_tree_cursor_goto_next_sibling_wasm"] = Module["asm"]["ts_tree_cursor_goto_next_sibling_wasm"]).apply(null, arguments) + }; + var _ts_tree_cursor_goto_parent_wasm = Module["_ts_tree_cursor_goto_parent_wasm"] = function() { + return (_ts_tree_cursor_goto_parent_wasm = Module["_ts_tree_cursor_goto_parent_wasm"] = Module["asm"]["ts_tree_cursor_goto_parent_wasm"]).apply(null, arguments) + }; + var _ts_tree_cursor_current_node_type_id_wasm = Module["_ts_tree_cursor_current_node_type_id_wasm"] = function() { + return (_ts_tree_cursor_current_node_type_id_wasm = Module["_ts_tree_cursor_current_node_type_id_wasm"] = Module["asm"]["ts_tree_cursor_current_node_type_id_wasm"]).apply(null, arguments) + }; + var _ts_tree_cursor_current_node_is_named_wasm = Module["_ts_tree_cursor_current_node_is_named_wasm"] = function() { + return (_ts_tree_cursor_current_node_is_named_wasm = Module["_ts_tree_cursor_current_node_is_named_wasm"] = Module["asm"]["ts_tree_cursor_current_node_is_named_wasm"]).apply(null, arguments) + }; + var _ts_tree_cursor_current_node_is_missing_wasm = Module["_ts_tree_cursor_current_node_is_missing_wasm"] = function() { + return (_ts_tree_cursor_current_node_is_missing_wasm = Module["_ts_tree_cursor_current_node_is_missing_wasm"] = Module["asm"]["ts_tree_cursor_current_node_is_missing_wasm"]).apply(null, arguments) + }; + var _ts_tree_cursor_current_node_id_wasm = Module["_ts_tree_cursor_current_node_id_wasm"] = function() { + return (_ts_tree_cursor_current_node_id_wasm = Module["_ts_tree_cursor_current_node_id_wasm"] = Module["asm"]["ts_tree_cursor_current_node_id_wasm"]).apply(null, arguments) + }; + var _ts_tree_cursor_start_position_wasm = Module["_ts_tree_cursor_start_position_wasm"] = function() { + return (_ts_tree_cursor_start_position_wasm = Module["_ts_tree_cursor_start_position_wasm"] = Module["asm"]["ts_tree_cursor_start_position_wasm"]).apply(null, arguments) + }; + var _ts_tree_cursor_end_position_wasm = Module["_ts_tree_cursor_end_position_wasm"] = function() { + return (_ts_tree_cursor_end_position_wasm = Module["_ts_tree_cursor_end_position_wasm"] = Module["asm"]["ts_tree_cursor_end_position_wasm"]).apply(null, arguments) + }; + var _ts_tree_cursor_start_index_wasm = Module["_ts_tree_cursor_start_index_wasm"] = function() { + return (_ts_tree_cursor_start_index_wasm = Module["_ts_tree_cursor_start_index_wasm"] = Module["asm"]["ts_tree_cursor_start_index_wasm"]).apply(null, arguments) + }; + var _ts_tree_cursor_end_index_wasm = Module["_ts_tree_cursor_end_index_wasm"] = function() { + return (_ts_tree_cursor_end_index_wasm = Module["_ts_tree_cursor_end_index_wasm"] = Module["asm"]["ts_tree_cursor_end_index_wasm"]).apply(null, arguments) + }; + var _ts_tree_cursor_current_field_id_wasm = Module["_ts_tree_cursor_current_field_id_wasm"] = function() { + return (_ts_tree_cursor_current_field_id_wasm = Module["_ts_tree_cursor_current_field_id_wasm"] = Module["asm"]["ts_tree_cursor_current_field_id_wasm"]).apply(null, arguments) + }; + var _ts_tree_cursor_current_node_wasm = Module["_ts_tree_cursor_current_node_wasm"] = function() { + return (_ts_tree_cursor_current_node_wasm = Module["_ts_tree_cursor_current_node_wasm"] = Module["asm"]["ts_tree_cursor_current_node_wasm"]).apply(null, arguments) + }; + var _ts_node_symbol_wasm = Module["_ts_node_symbol_wasm"] = function() { + return (_ts_node_symbol_wasm = Module["_ts_node_symbol_wasm"] = Module["asm"]["ts_node_symbol_wasm"]).apply(null, arguments) + }; + var _ts_node_child_count_wasm = Module["_ts_node_child_count_wasm"] = function() { + return (_ts_node_child_count_wasm = Module["_ts_node_child_count_wasm"] = Module["asm"]["ts_node_child_count_wasm"]).apply(null, arguments) + }; + var _ts_node_named_child_count_wasm = Module["_ts_node_named_child_count_wasm"] = function() { + return (_ts_node_named_child_count_wasm = Module["_ts_node_named_child_count_wasm"] = Module["asm"]["ts_node_named_child_count_wasm"]).apply(null, arguments) + }; + var _ts_node_child_wasm = Module["_ts_node_child_wasm"] = function() { + return (_ts_node_child_wasm = Module["_ts_node_child_wasm"] = Module["asm"]["ts_node_child_wasm"]).apply(null, arguments) + }; + var _ts_node_named_child_wasm = Module["_ts_node_named_child_wasm"] = function() { + return (_ts_node_named_child_wasm = Module["_ts_node_named_child_wasm"] = Module["asm"]["ts_node_named_child_wasm"]).apply(null, arguments) + }; + var _ts_node_child_by_field_id_wasm = Module["_ts_node_child_by_field_id_wasm"] = function() { + return (_ts_node_child_by_field_id_wasm = Module["_ts_node_child_by_field_id_wasm"] = Module["asm"]["ts_node_child_by_field_id_wasm"]).apply(null, arguments) + }; + var _ts_node_next_sibling_wasm = Module["_ts_node_next_sibling_wasm"] = function() { + return (_ts_node_next_sibling_wasm = Module["_ts_node_next_sibling_wasm"] = Module["asm"]["ts_node_next_sibling_wasm"]).apply(null, arguments) + }; + var _ts_node_prev_sibling_wasm = Module["_ts_node_prev_sibling_wasm"] = function() { + return (_ts_node_prev_sibling_wasm = Module["_ts_node_prev_sibling_wasm"] = Module["asm"]["ts_node_prev_sibling_wasm"]).apply(null, arguments) + }; + var _ts_node_next_named_sibling_wasm = Module["_ts_node_next_named_sibling_wasm"] = function() { + return (_ts_node_next_named_sibling_wasm = Module["_ts_node_next_named_sibling_wasm"] = Module["asm"]["ts_node_next_named_sibling_wasm"]).apply(null, arguments) + }; + var _ts_node_prev_named_sibling_wasm = Module["_ts_node_prev_named_sibling_wasm"] = function() { + return (_ts_node_prev_named_sibling_wasm = Module["_ts_node_prev_named_sibling_wasm"] = Module["asm"]["ts_node_prev_named_sibling_wasm"]).apply(null, arguments) + }; + var _ts_node_parent_wasm = Module["_ts_node_parent_wasm"] = function() { + return (_ts_node_parent_wasm = Module["_ts_node_parent_wasm"] = Module["asm"]["ts_node_parent_wasm"]).apply(null, arguments) + }; + var _ts_node_descendant_for_index_wasm = Module["_ts_node_descendant_for_index_wasm"] = function() { + return (_ts_node_descendant_for_index_wasm = Module["_ts_node_descendant_for_index_wasm"] = Module["asm"]["ts_node_descendant_for_index_wasm"]).apply(null, arguments) + }; + var _ts_node_named_descendant_for_index_wasm = Module["_ts_node_named_descendant_for_index_wasm"] = function() { + return (_ts_node_named_descendant_for_index_wasm = Module["_ts_node_named_descendant_for_index_wasm"] = Module["asm"]["ts_node_named_descendant_for_index_wasm"]).apply(null, arguments) + }; + var _ts_node_descendant_for_position_wasm = Module["_ts_node_descendant_for_position_wasm"] = function() { + return (_ts_node_descendant_for_position_wasm = Module["_ts_node_descendant_for_position_wasm"] = Module["asm"]["ts_node_descendant_for_position_wasm"]).apply(null, arguments) + }; + var _ts_node_named_descendant_for_position_wasm = Module["_ts_node_named_descendant_for_position_wasm"] = function() { + return (_ts_node_named_descendant_for_position_wasm = Module["_ts_node_named_descendant_for_position_wasm"] = Module["asm"]["ts_node_named_descendant_for_position_wasm"]).apply(null, arguments) + }; + var _ts_node_start_point_wasm = Module["_ts_node_start_point_wasm"] = function() { + return (_ts_node_start_point_wasm = Module["_ts_node_start_point_wasm"] = Module["asm"]["ts_node_start_point_wasm"]).apply(null, arguments) + }; + var _ts_node_end_point_wasm = Module["_ts_node_end_point_wasm"] = function() { + return (_ts_node_end_point_wasm = Module["_ts_node_end_point_wasm"] = Module["asm"]["ts_node_end_point_wasm"]).apply(null, arguments) + }; + var _ts_node_start_index_wasm = Module["_ts_node_start_index_wasm"] = function() { + return (_ts_node_start_index_wasm = Module["_ts_node_start_index_wasm"] = Module["asm"]["ts_node_start_index_wasm"]).apply(null, arguments) + }; + var _ts_node_end_index_wasm = Module["_ts_node_end_index_wasm"] = function() { + return (_ts_node_end_index_wasm = Module["_ts_node_end_index_wasm"] = Module["asm"]["ts_node_end_index_wasm"]).apply(null, arguments) + }; + var _ts_node_to_string_wasm = Module["_ts_node_to_string_wasm"] = function() { + return (_ts_node_to_string_wasm = Module["_ts_node_to_string_wasm"] = Module["asm"]["ts_node_to_string_wasm"]).apply(null, arguments) + }; + var _ts_node_children_wasm = Module["_ts_node_children_wasm"] = function() { + return (_ts_node_children_wasm = Module["_ts_node_children_wasm"] = Module["asm"]["ts_node_children_wasm"]).apply(null, arguments) + }; + var _ts_node_named_children_wasm = Module["_ts_node_named_children_wasm"] = function() { + return (_ts_node_named_children_wasm = Module["_ts_node_named_children_wasm"] = Module["asm"]["ts_node_named_children_wasm"]).apply(null, arguments) + }; + var _ts_node_descendants_of_type_wasm = Module["_ts_node_descendants_of_type_wasm"] = function() { + return (_ts_node_descendants_of_type_wasm = Module["_ts_node_descendants_of_type_wasm"] = Module["asm"]["ts_node_descendants_of_type_wasm"]).apply(null, arguments) + }; + var _ts_node_is_named_wasm = Module["_ts_node_is_named_wasm"] = function() { + return (_ts_node_is_named_wasm = Module["_ts_node_is_named_wasm"] = Module["asm"]["ts_node_is_named_wasm"]).apply(null, arguments) + }; + var _ts_node_has_changes_wasm = Module["_ts_node_has_changes_wasm"] = function() { + return (_ts_node_has_changes_wasm = Module["_ts_node_has_changes_wasm"] = Module["asm"]["ts_node_has_changes_wasm"]).apply(null, arguments) + }; + var _ts_node_has_error_wasm = Module["_ts_node_has_error_wasm"] = function() { + return (_ts_node_has_error_wasm = Module["_ts_node_has_error_wasm"] = Module["asm"]["ts_node_has_error_wasm"]).apply(null, arguments) + }; + var _ts_node_is_missing_wasm = Module["_ts_node_is_missing_wasm"] = function() { + return (_ts_node_is_missing_wasm = Module["_ts_node_is_missing_wasm"] = Module["asm"]["ts_node_is_missing_wasm"]).apply(null, arguments) + }; + var _ts_query_matches_wasm = Module["_ts_query_matches_wasm"] = function() { + return (_ts_query_matches_wasm = Module["_ts_query_matches_wasm"] = Module["asm"]["ts_query_matches_wasm"]).apply(null, arguments) + }; + var _ts_query_captures_wasm = Module["_ts_query_captures_wasm"] = function() { + return (_ts_query_captures_wasm = Module["_ts_query_captures_wasm"] = Module["asm"]["ts_query_captures_wasm"]).apply(null, arguments) + }; + var _iswdigit = Module["_iswdigit"] = function() { + return (_iswdigit = Module["_iswdigit"] = Module["asm"]["iswdigit"]).apply(null, arguments) + }; + var _iswalpha = Module["_iswalpha"] = function() { + return (_iswalpha = Module["_iswalpha"] = Module["asm"]["iswalpha"]).apply(null, arguments) + }; + var _iswupper = Module["_iswupper"] = function() { + return (_iswupper = Module["_iswupper"] = Module["asm"]["iswupper"]).apply(null, arguments) + }; + var _iswlower = Module["_iswlower"] = function() { + return (_iswlower = Module["_iswlower"] = Module["asm"]["iswlower"]).apply(null, arguments) + }; + var _iswxdigit = Module["_iswxdigit"] = function() { + return (_iswxdigit = Module["_iswxdigit"] = Module["asm"]["iswxdigit"]).apply(null, arguments) + }; + var _towupper = Module["_towupper"] = function() { + return (_towupper = Module["_towupper"] = Module["asm"]["towupper"]).apply(null, arguments) + }; + var _towlower = Module["_towlower"] = function() { + return (_towlower = Module["_towlower"] = Module["asm"]["towlower"]).apply(null, arguments) + }; + var _isalpha = Module["_isalpha"] = function() { + return (_isalpha = Module["_isalpha"] = Module["asm"]["isalpha"]).apply(null, arguments) + }; + var _isalnum = Module["_isalnum"] = function() { + return (_isalnum = Module["_isalnum"] = Module["asm"]["isalnum"]).apply(null, arguments) + }; + var ___errno_location = Module["___errno_location"] = function() { + return (___errno_location = Module["___errno_location"] = Module["asm"]["__errno_location"]).apply(null, arguments) + }; + var _memchr = Module["_memchr"] = function() { + return (_memchr = Module["_memchr"] = Module["asm"]["memchr"]).apply(null, arguments) + }; + var _strlen = Module["_strlen"] = function() { + return (_strlen = Module["_strlen"] = Module["asm"]["strlen"]).apply(null, arguments) + }; + var _strcmp = Module["_strcmp"] = function() { + return (_strcmp = Module["_strcmp"] = Module["asm"]["strcmp"]).apply(null, arguments) + }; + var _strncpy = Module["_strncpy"] = function() { + return (_strncpy = Module["_strncpy"] = Module["asm"]["strncpy"]).apply(null, arguments) + }; + var stackSave = Module["stackSave"] = function() { + return (stackSave = Module["stackSave"] = Module["asm"]["stackSave"]).apply(null, arguments) + }; + var stackRestore = Module["stackRestore"] = function() { + return (stackRestore = Module["stackRestore"] = Module["asm"]["stackRestore"]).apply(null, arguments) + }; + var stackAlloc = Module["stackAlloc"] = function() { + return (stackAlloc = Module["stackAlloc"] = Module["asm"]["stackAlloc"]).apply(null, arguments) + }; + var _setThrew = Module["_setThrew"] = function() { + return (_setThrew = Module["_setThrew"] = Module["asm"]["setThrew"]).apply(null, arguments) + }; + var __ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEED2Ev = Module["__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEED2Ev"] = function() { + return (__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEED2Ev = Module["__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEED2Ev"] = Module["asm"]["_ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEED2Ev"]).apply(null, arguments) + }; + var __ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE9__grow_byEmmmmmm = Module["__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE9__grow_byEmmmmmm"] = function() { + return (__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE9__grow_byEmmmmmm = Module["__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE9__grow_byEmmmmmm"] = Module["asm"]["_ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE9__grow_byEmmmmmm"]).apply(null, arguments) + }; + var __ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initEPKcm = Module["__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initEPKcm"] = function() { + return (__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initEPKcm = Module["__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initEPKcm"] = Module["asm"]["_ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initEPKcm"]).apply(null, arguments) + }; + var __ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE25__init_copy_ctor_externalEPKcm = Module["__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE25__init_copy_ctor_externalEPKcm"] = function() { + return (__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE25__init_copy_ctor_externalEPKcm = Module["__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE25__init_copy_ctor_externalEPKcm"] = Module["asm"]["_ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE25__init_copy_ctor_externalEPKcm"]).apply(null, arguments) + }; + var __ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE7reserveEm = Module["__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE7reserveEm"] = function() { + return (__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE7reserveEm = Module["__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE7reserveEm"] = Module["asm"]["_ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE7reserveEm"]).apply(null, arguments) + }; + var __ZNKSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE4copyEPcmm = Module["__ZNKSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE4copyEPcmm"] = function() { + return (__ZNKSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE4copyEPcmm = Module["__ZNKSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE4copyEPcmm"] = Module["asm"]["_ZNKSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE4copyEPcmm"]).apply(null, arguments) + }; + var __ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE17__assign_no_aliasILb1EEERS5_PKcm = Module["__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE17__assign_no_aliasILb1EEERS5_PKcm"] = function() { + return (__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE17__assign_no_aliasILb1EEERS5_PKcm = Module["__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE17__assign_no_aliasILb1EEERS5_PKcm"] = Module["asm"]["_ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE17__assign_no_aliasILb1EEERS5_PKcm"]).apply(null, arguments) + }; + var __ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE9push_backEc = Module["__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE9push_backEc"] = function() { + return (__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE9push_backEc = Module["__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE9push_backEc"] = Module["asm"]["_ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE9push_backEc"]).apply(null, arguments) + }; + var __ZNSt3__212basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEED2Ev = Module["__ZNSt3__212basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEED2Ev"] = function() { + return (__ZNSt3__212basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEED2Ev = Module["__ZNSt3__212basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEED2Ev"] = Module["asm"]["_ZNSt3__212basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEED2Ev"]).apply(null, arguments) + }; + var __ZNSt3__212basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE9push_backEw = Module["__ZNSt3__212basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE9push_backEw"] = function() { + return (__ZNSt3__212basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE9push_backEw = Module["__ZNSt3__212basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE9push_backEw"] = Module["asm"]["_ZNSt3__212basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE9push_backEw"]).apply(null, arguments) + }; + var __Znwm = Module["__Znwm"] = function() { + return (__Znwm = Module["__Znwm"] = Module["asm"]["_Znwm"]).apply(null, arguments) + }; + var __ZdlPv = Module["__ZdlPv"] = function() { + return (__ZdlPv = Module["__ZdlPv"] = Module["asm"]["_ZdlPv"]).apply(null, arguments) + }; + var dynCall_jiji = Module["dynCall_jiji"] = function() { + return (dynCall_jiji = Module["dynCall_jiji"] = Module["asm"]["dynCall_jiji"]).apply(null, arguments) + }; + var _orig$ts_parser_timeout_micros = Module["_orig$ts_parser_timeout_micros"] = function() { + return (_orig$ts_parser_timeout_micros = Module["_orig$ts_parser_timeout_micros"] = Module["asm"]["orig$ts_parser_timeout_micros"]).apply(null, arguments) + }; + var _orig$ts_parser_set_timeout_micros = Module["_orig$ts_parser_set_timeout_micros"] = function() { + return (_orig$ts_parser_set_timeout_micros = Module["_orig$ts_parser_set_timeout_micros"] = Module["asm"]["orig$ts_parser_set_timeout_micros"]).apply(null, arguments) + }; + Module["allocate"] = allocate; + var calledRun; + + function ExitStatus(status) { + this.name = "ExitStatus"; + this.message = "Program terminated with exit(" + status + ")"; + this.status = status + } + var calledMain = false; + dependenciesFulfilled = function runCaller() { + if (!calledRun) run(); + if (!calledRun) dependenciesFulfilled = runCaller + }; + + function callMain(args) { + var entryFunction = Module["_main"]; + if (!entryFunction) return; + args = args || []; + var argc = args.length + 1; + var argv = stackAlloc((argc + 1) * 4); + HEAP32[argv >> 2] = allocateUTF8OnStack(thisProgram); + for (var i = 1; i < argc; i++) { + HEAP32[(argv >> 2) + i] = allocateUTF8OnStack(args[i - 1]) + } + HEAP32[(argv >> 2) + argc] = 0; + try { + var ret = entryFunction(argc, argv); + exit(ret, true) + } catch (e) { + if (e instanceof ExitStatus) { + return + } else if (e == "unwind") { + return + } else { + var toLog = e; + if (e && typeof e === "object" && e.stack) { + toLog = [e, e.stack] } - } - return true + err("exception thrown: " + toLog); + quit_(1, e) + } + } finally { + calledMain = true + } + } + var dylibsLoaded = false; + + function run(args) { + args = args || arguments_; + if (runDependencies > 0) { + return + } + if (!dylibsLoaded) { + preloadDylibs(); + dylibsLoaded = true; + if (runDependencies > 0) { + return + } + } + preRun(); + if (runDependencies > 0) { + return + } + + function doRun() { + if (calledRun) return; + calledRun = true; + Module["calledRun"] = true; + if (ABORT) return; + initRuntime(); + preMain(); + if (Module["onRuntimeInitialized"]) Module["onRuntimeInitialized"](); + if (shouldRunNow) callMain(args); + postRun() + } + if (Module["setStatus"]) { + Module["setStatus"]("Running..."); + setTimeout(function() { + setTimeout(function() { + Module["setStatus"]("") + }, 1); + doRun() + }, 1) + } else { + doRun() + } + } + Module["run"] = run; + + function exit(status, implicit) { + EXITSTATUS = status; + if (implicit && keepRuntimeAlive() && status === 0) { + return + } + if (keepRuntimeAlive()) {} else { + exitRuntime(); + if (Module["onExit"]) Module["onExit"](status); + ABORT = true + } + quit_(status, new ExitStatus(status)) + } + if (Module["preInit"]) { + if (typeof Module["preInit"] == "function") Module["preInit"] = [Module["preInit"]]; + while (Module["preInit"].length > 0) { + Module["preInit"].pop()() + } + } + var shouldRunNow = true; + if (Module["noInitialRun"]) shouldRunNow = false; + run(); + const C = Module; + const INTERNAL = {}; + const SIZE_OF_INT = 4; + const SIZE_OF_NODE = 5 * SIZE_OF_INT; + const SIZE_OF_POINT = 2 * SIZE_OF_INT; + const SIZE_OF_RANGE = 2 * SIZE_OF_INT + 2 * SIZE_OF_POINT; + const ZERO_POINT = { + row: 0, + column: 0 + }; + const QUERY_WORD_REGEX = /[\w-.]*/g; + const PREDICATE_STEP_TYPE_CAPTURE = 1; + const PREDICATE_STEP_TYPE_STRING = 2; + const LANGUAGE_FUNCTION_REGEX = /^_?tree_sitter_\w+/; + var VERSION; + var MIN_COMPATIBLE_VERSION; + var TRANSFER_BUFFER; + var currentParseCallback; + var currentLogCallback; + class ParserImpl { + static init() { + TRANSFER_BUFFER = C._ts_init(); + VERSION = getValue(TRANSFER_BUFFER, "i32"); + MIN_COMPATIBLE_VERSION = getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32") + } + initialize() { + C._ts_parser_new_wasm(); + this[0] = getValue(TRANSFER_BUFFER, "i32"); + this[1] = getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32") + } + delete() { + C._ts_parser_delete(this[0]); + C._free(this[1]); + this[0] = 0; + this[1] = 0 + } + setLanguage(language) { + let address; + if (!language) { + address = 0; + language = null + } else if (language.constructor === Language) { + address = language[0]; + const version = C._ts_language_version(address); + if (version < MIN_COMPATIBLE_VERSION || VERSION < version) { + throw new Error(`Incompatible language version ${version}. ` + `Compatibility range ${MIN_COMPATIBLE_VERSION} through ${VERSION}.`) + } + } else { + throw new Error("Argument must be a Language") + } + this.language = language; + C._ts_parser_set_language(this[0], address); + return this + } + getLanguage() { + return this.language + } + parse(callback, oldTree, options) { + if (typeof callback === "string") { + currentParseCallback = ((index, _, endIndex) => callback.slice(index, endIndex)) + } else if (typeof callback === "function") { + currentParseCallback = callback + } else { + throw new Error("Argument must be a string or a function") + } + if (this.logCallback) { + currentLogCallback = this.logCallback; + C._ts_parser_enable_logger_wasm(this[0], 1) + } else { + currentLogCallback = null; + C._ts_parser_enable_logger_wasm(this[0], 0) + } + let rangeCount = 0; + let rangeAddress = 0; + if (options && options.includedRanges) { + rangeCount = options.includedRanges.length; + rangeAddress = C._calloc(rangeCount, SIZE_OF_RANGE); + let address = rangeAddress; + for (let i = 0; i < rangeCount; i++) { + marshalRange(address, options.includedRanges[i]); + address += SIZE_OF_RANGE + } + } + const treeAddress = C._ts_parser_parse_wasm(this[0], this[1], oldTree ? oldTree[0] : 0, rangeAddress, rangeCount); + if (!treeAddress) { + currentParseCallback = null; + currentLogCallback = null; + throw new Error("Parsing failed") + } + const result = new Tree(INTERNAL, treeAddress, this.language, currentParseCallback); + currentParseCallback = null; + currentLogCallback = null; + return result + } + reset() { + C._ts_parser_reset(this[0]) + } + setTimeoutMicros(timeout) { + C._ts_parser_set_timeout_micros(this[0], timeout) + } + getTimeoutMicros() { + return C._ts_parser_timeout_micros(this[0]) + } + setLogger(callback) { + if (!callback) { + callback = null + } else if (typeof callback !== "function") { + throw new Error("Logger callback must be a function") + } + this.logCallback = callback; + return this + } + getLogger() { + return this.logCallback + } + } + class Tree { + constructor(internal, address, language, textCallback) { + assertInternal(internal); + this[0] = address; + this.language = language; + this.textCallback = textCallback + } + copy() { + const address = C._ts_tree_copy(this[0]); + return new Tree(INTERNAL, address, this.language, this.textCallback) + } + delete() { + C._ts_tree_delete(this[0]); + this[0] = 0 + } + edit(edit) { + marshalEdit(edit); + C._ts_tree_edit_wasm(this[0]) + } + get rootNode() { + C._ts_tree_root_node_wasm(this[0]); + return unmarshalNode(this) + } + getLanguage() { + return this.language + } + walk() { + return this.rootNode.walk() + } + getChangedRanges(other) { + if (other.constructor !== Tree) { + throw new TypeError("Argument must be a Tree") + } + C._ts_tree_get_changed_ranges_wasm(this[0], other[0]); + const count = getValue(TRANSFER_BUFFER, "i32"); + const buffer = getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32"); + const result = new Array(count); + if (count > 0) { + let address = buffer; + for (let i = 0; i < count; i++) { + result[i] = unmarshalRange(address); + address += SIZE_OF_RANGE + } + C._free(buffer) + } + return result + } + } + class Node { + constructor(internal, tree) { + assertInternal(internal); + this.tree = tree + } + get typeId() { + marshalNode(this); + return C._ts_node_symbol_wasm(this.tree[0]) + } + get type() { + return this.tree.language.types[this.typeId] || "ERROR" + } + get endPosition() { + marshalNode(this); + C._ts_node_end_point_wasm(this.tree[0]); + return unmarshalPoint(TRANSFER_BUFFER) + } + get endIndex() { + marshalNode(this); + return C._ts_node_end_index_wasm(this.tree[0]) + } + get text() { + return getText(this.tree, this.startIndex, this.endIndex) + } + isNamed() { + marshalNode(this); + return C._ts_node_is_named_wasm(this.tree[0]) === 1 + } + hasError() { + marshalNode(this); + return C._ts_node_has_error_wasm(this.tree[0]) === 1 + } + hasChanges() { + marshalNode(this); + return C._ts_node_has_changes_wasm(this.tree[0]) === 1 + } + isMissing() { + marshalNode(this); + return C._ts_node_is_missing_wasm(this.tree[0]) === 1 + } + equals(other) { + return this.id === other.id + } + child(index) { + marshalNode(this); + C._ts_node_child_wasm(this.tree[0], index); + return unmarshalNode(this.tree) + } + namedChild(index) { + marshalNode(this); + C._ts_node_named_child_wasm(this.tree[0], index); + return unmarshalNode(this.tree) + } + childForFieldId(fieldId) { + marshalNode(this); + C._ts_node_child_by_field_id_wasm(this.tree[0], fieldId); + return unmarshalNode(this.tree) + } + childForFieldName(fieldName) { + const fieldId = this.tree.language.fields.indexOf(fieldName); + if (fieldId !== -1) return this.childForFieldId(fieldId) + } + get childCount() { + marshalNode(this); + return C._ts_node_child_count_wasm(this.tree[0]) + } + get namedChildCount() { + marshalNode(this); + return C._ts_node_named_child_count_wasm(this.tree[0]) + } + get firstChild() { + return this.child(0) + } + get firstNamedChild() { + return this.namedChild(0) + } + get lastChild() { + return this.child(this.childCount - 1) + } + get lastNamedChild() { + return this.namedChild(this.namedChildCount - 1) + } + get children() { + if (!this._children) { + marshalNode(this); + C._ts_node_children_wasm(this.tree[0]); + const count = getValue(TRANSFER_BUFFER, "i32"); + const buffer = getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32"); + this._children = new Array(count); + if (count > 0) { + let address = buffer; + for (let i = 0; i < count; i++) { + this._children[i] = unmarshalNode(this.tree, address); + address += SIZE_OF_NODE + } + C._free(buffer) + } + } + return this._children + } + get namedChildren() { + if (!this._namedChildren) { + marshalNode(this); + C._ts_node_named_children_wasm(this.tree[0]); + const count = getValue(TRANSFER_BUFFER, "i32"); + const buffer = getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32"); + this._namedChildren = new Array(count); + if (count > 0) { + let address = buffer; + for (let i = 0; i < count; i++) { + this._namedChildren[i] = unmarshalNode(this.tree, address); + address += SIZE_OF_NODE + } + C._free(buffer) + } + } + return this._namedChildren + } + descendantsOfType(types, startPosition, endPosition) { + if (!Array.isArray(types)) types = [types]; + if (!startPosition) startPosition = ZERO_POINT; + if (!endPosition) endPosition = ZERO_POINT; + const symbols = []; + const typesBySymbol = this.tree.language.types; + for (let i = 0, n = typesBySymbol.length; i < n; i++) { + if (types.includes(typesBySymbol[i])) { + symbols.push(i) + } + } + const symbolsAddress = C._malloc(SIZE_OF_INT * symbols.length); + for (let i = 0, n = symbols.length; i < n; i++) { + setValue(symbolsAddress + i * SIZE_OF_INT, symbols[i], "i32") + } + marshalNode(this); + C._ts_node_descendants_of_type_wasm(this.tree[0], symbolsAddress, symbols.length, startPosition.row, startPosition.column, endPosition.row, endPosition.column); + const descendantCount = getValue(TRANSFER_BUFFER, "i32"); + const descendantAddress = getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32"); + const result = new Array(descendantCount); + if (descendantCount > 0) { + let address = descendantAddress; + for (let i = 0; i < descendantCount; i++) { + result[i] = unmarshalNode(this.tree, address); + address += SIZE_OF_NODE + } + } + C._free(descendantAddress); + C._free(symbolsAddress); + return result + } + get nextSibling() { + marshalNode(this); + C._ts_node_next_sibling_wasm(this.tree[0]); + return unmarshalNode(this.tree) + } + get previousSibling() { + marshalNode(this); + C._ts_node_prev_sibling_wasm(this.tree[0]); + return unmarshalNode(this.tree) + } + get nextNamedSibling() { + marshalNode(this); + C._ts_node_next_named_sibling_wasm(this.tree[0]); + return unmarshalNode(this.tree) + } + get previousNamedSibling() { + marshalNode(this); + C._ts_node_prev_named_sibling_wasm(this.tree[0]); + return unmarshalNode(this.tree) + } + get parent() { + marshalNode(this); + C._ts_node_parent_wasm(this.tree[0]); + return unmarshalNode(this.tree) + } + descendantForIndex(start, end = start) { + if (typeof start !== "number" || typeof end !== "number") { + throw new Error("Arguments must be numbers") + } + marshalNode(this); + let address = TRANSFER_BUFFER + SIZE_OF_NODE; + setValue(address, start, "i32"); + setValue(address + SIZE_OF_INT, end, "i32"); + C._ts_node_descendant_for_index_wasm(this.tree[0]); + return unmarshalNode(this.tree) + } + namedDescendantForIndex(start, end = start) { + if (typeof start !== "number" || typeof end !== "number") { + throw new Error("Arguments must be numbers") + } + marshalNode(this); + let address = TRANSFER_BUFFER + SIZE_OF_NODE; + setValue(address, start, "i32"); + setValue(address + SIZE_OF_INT, end, "i32"); + C._ts_node_named_descendant_for_index_wasm(this.tree[0]); + return unmarshalNode(this.tree) + } + descendantForPosition(start, end = start) { + if (!isPoint(start) || !isPoint(end)) { + throw new Error("Arguments must be {row, column} objects") + } + marshalNode(this); + let address = TRANSFER_BUFFER + SIZE_OF_NODE; + marshalPoint(address, start); + marshalPoint(address + SIZE_OF_POINT, end); + C._ts_node_descendant_for_position_wasm(this.tree[0]); + return unmarshalNode(this.tree) + } + namedDescendantForPosition(start, end = start) { + if (!isPoint(start) || !isPoint(end)) { + throw new Error("Arguments must be {row, column} objects") + } + marshalNode(this); + let address = TRANSFER_BUFFER + SIZE_OF_NODE; + marshalPoint(address, start); + marshalPoint(address + SIZE_OF_POINT, end); + C._ts_node_named_descendant_for_position_wasm(this.tree[0]); + return unmarshalNode(this.tree) + } + walk() { + marshalNode(this); + C._ts_tree_cursor_new_wasm(this.tree[0]); + return new TreeCursor(INTERNAL, this.tree) + } + toString() { + marshalNode(this); + const address = C._ts_node_to_string_wasm(this.tree[0]); + const result = AsciiToString(address); + C._free(address); + return result + } + } + class TreeCursor { + constructor(internal, tree) { + assertInternal(internal); + this.tree = tree; + unmarshalTreeCursor(this) + } + delete() { + marshalTreeCursor(this); + C._ts_tree_cursor_delete_wasm(this.tree[0]); + this[0] = this[1] = this[2] = 0 + } + reset(node) { + marshalNode(node); + marshalTreeCursor(this, TRANSFER_BUFFER + SIZE_OF_NODE); + C._ts_tree_cursor_reset_wasm(this.tree[0]); + unmarshalTreeCursor(this) + } + get nodeType() { + return this.tree.language.types[this.nodeTypeId] || "ERROR" + } + get nodeTypeId() { + marshalTreeCursor(this); + return C._ts_tree_cursor_current_node_type_id_wasm(this.tree[0]) + } + get nodeId() { + marshalTreeCursor(this); + return C._ts_tree_cursor_current_node_id_wasm(this.tree[0]) + } + get nodeIsNamed() { + marshalTreeCursor(this); + return C._ts_tree_cursor_current_node_is_named_wasm(this.tree[0]) === 1 + } + get nodeIsMissing() { + marshalTreeCursor(this); + return C._ts_tree_cursor_current_node_is_missing_wasm(this.tree[0]) === 1 + } + get nodeText() { + marshalTreeCursor(this); + const startIndex = C._ts_tree_cursor_start_index_wasm(this.tree[0]); + const endIndex = C._ts_tree_cursor_end_index_wasm(this.tree[0]); + return getText(this.tree, startIndex, endIndex) + } + get startPosition() { + marshalTreeCursor(this); + C._ts_tree_cursor_start_position_wasm(this.tree[0]); + return unmarshalPoint(TRANSFER_BUFFER) + } + get endPosition() { + marshalTreeCursor(this); + C._ts_tree_cursor_end_position_wasm(this.tree[0]); + return unmarshalPoint(TRANSFER_BUFFER) + } + get startIndex() { + marshalTreeCursor(this); + return C._ts_tree_cursor_start_index_wasm(this.tree[0]) + } + get endIndex() { + marshalTreeCursor(this); + return C._ts_tree_cursor_end_index_wasm(this.tree[0]) + } + currentNode() { + marshalTreeCursor(this); + C._ts_tree_cursor_current_node_wasm(this.tree[0]); + return unmarshalNode(this.tree) + } + currentFieldId() { + marshalTreeCursor(this); + return C._ts_tree_cursor_current_field_id_wasm(this.tree[0]) + } + currentFieldName() { + return this.tree.language.fields[this.currentFieldId()] + } + gotoFirstChild() { + marshalTreeCursor(this); + const result = C._ts_tree_cursor_goto_first_child_wasm(this.tree[0]); + unmarshalTreeCursor(this); + return result === 1 + } + gotoNextSibling() { + marshalTreeCursor(this); + const result = C._ts_tree_cursor_goto_next_sibling_wasm(this.tree[0]); + unmarshalTreeCursor(this); + return result === 1 + } + gotoParent() { + marshalTreeCursor(this); + const result = C._ts_tree_cursor_goto_parent_wasm(this.tree[0]); + unmarshalTreeCursor(this); + return result === 1 + } + } + class Language { + constructor(internal, address) { + assertInternal(internal); + this[0] = address; + this.types = new Array(C._ts_language_symbol_count(this[0])); + for (let i = 0, n = this.types.length; i < n; i++) { + if (C._ts_language_symbol_type(this[0], i) < 2) { + this.types[i] = UTF8ToString(C._ts_language_symbol_name(this[0], i)) + } + } + this.fields = new Array(C._ts_language_field_count(this[0]) + 1); + for (let i = 0, n = this.fields.length; i < n; i++) { + const fieldName = C._ts_language_field_name_for_id(this[0], i); + if (fieldName !== 0) { + this.fields[i] = UTF8ToString(fieldName) + } else { + this.fields[i] = null + } + } + } + get version() { + return C._ts_language_version(this[0]) + } + get fieldCount() { + return this.fields.length - 1 + } + fieldIdForName(fieldName) { + const result = this.fields.indexOf(fieldName); + if (result !== -1) { + return result + } else { + return null + } + } + fieldNameForId(fieldId) { + return this.fields[fieldId] || null + } + idForNodeType(type, named) { + const typeLength = lengthBytesUTF8(type); + const typeAddress = C._malloc(typeLength + 1); + stringToUTF8(type, typeAddress, typeLength + 1); + const result = C._ts_language_symbol_for_name(this[0], typeAddress, typeLength, named); + C._free(typeAddress); + return result || null + } + get nodeTypeCount() { + return C._ts_language_symbol_count(this[0]) + } + nodeTypeForId(typeId) { + const name = C._ts_language_symbol_name(this[0], typeId); + return name ? UTF8ToString(name) : null + } + nodeTypeIsNamed(typeId) { + return C._ts_language_type_is_named_wasm(this[0], typeId) ? true : false + } + nodeTypeIsVisible(typeId) { + return C._ts_language_type_is_visible_wasm(this[0], typeId) ? true : false + } + query(source) { + const sourceLength = lengthBytesUTF8(source); + const sourceAddress = C._malloc(sourceLength + 1); + stringToUTF8(source, sourceAddress, sourceLength + 1); + const address = C._ts_query_new(this[0], sourceAddress, sourceLength, TRANSFER_BUFFER, TRANSFER_BUFFER + SIZE_OF_INT); + if (!address) { + const errorId = getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32"); + const errorByte = getValue(TRANSFER_BUFFER, "i32"); + const errorIndex = UTF8ToString(sourceAddress, errorByte).length; + const suffix = source.substr(errorIndex, 100).split("\n")[0]; + let word = suffix.match(QUERY_WORD_REGEX)[0]; + let error; + switch (errorId) { + case 2: + error = new RangeError(`Bad node name '${word}'`); + break; + case 3: + error = new RangeError(`Bad field name '${word}'`); + break; + case 4: + error = new RangeError(`Bad capture name @${word}`); + break; + case 5: + error = new TypeError(`Bad pattern structure at offset ${errorIndex}: '${suffix}'...`); + word = ""; + break; + default: + error = new SyntaxError(`Bad syntax at offset ${errorIndex}: '${suffix}'...`); + word = ""; + break + } + error.index = errorIndex; + error.length = word.length; + C._free(sourceAddress); + throw error + } + const stringCount = C._ts_query_string_count(address); + const captureCount = C._ts_query_capture_count(address); + const patternCount = C._ts_query_pattern_count(address); + const captureNames = new Array(captureCount); + const stringValues = new Array(stringCount); + for (let i = 0; i < captureCount; i++) { + const nameAddress = C._ts_query_capture_name_for_id(address, i, TRANSFER_BUFFER); + const nameLength = getValue(TRANSFER_BUFFER, "i32"); + captureNames[i] = UTF8ToString(nameAddress, nameLength) + } + for (let i = 0; i < stringCount; i++) { + const valueAddress = C._ts_query_string_value_for_id(address, i, TRANSFER_BUFFER); + const nameLength = getValue(TRANSFER_BUFFER, "i32"); + stringValues[i] = UTF8ToString(valueAddress, nameLength) + } + const setProperties = new Array(patternCount); + const assertedProperties = new Array(patternCount); + const refutedProperties = new Array(patternCount); + const predicates = new Array(patternCount); + const textPredicates = new Array(patternCount); + for (let i = 0; i < patternCount; i++) { + const predicatesAddress = C._ts_query_predicates_for_pattern(address, i, TRANSFER_BUFFER); + const stepCount = getValue(TRANSFER_BUFFER, "i32"); + predicates[i] = []; + textPredicates[i] = []; + const steps = []; + let stepAddress = predicatesAddress; + for (let j = 0; j < stepCount; j++) { + const stepType = getValue(stepAddress, "i32"); + stepAddress += SIZE_OF_INT; + const stepValueId = getValue(stepAddress, "i32"); + stepAddress += SIZE_OF_INT; + if (stepType === PREDICATE_STEP_TYPE_CAPTURE) { + steps.push({ + type: "capture", + name: captureNames[stepValueId] + }) + } else if (stepType === PREDICATE_STEP_TYPE_STRING) { + steps.push({ + type: "string", + value: stringValues[stepValueId] + }) + } else if (steps.length > 0) { + if (steps[0].type !== "string") { + throw new Error("Predicates must begin with a literal value") + } + const operator = steps[0].value; + let isPositive = true; + switch (operator) { + case "not-eq?": + isPositive = false; + case "eq?": + if (steps.length !== 3) throw new Error(`Wrong number of arguments to \`#eq?\` predicate. Expected 2, got ${steps.length-1}`); + if (steps[1].type !== "capture") throw new Error(`First argument of \`#eq?\` predicate must be a capture. Got "${steps[1].value}"`); + if (steps[2].type === "capture") { + const captureName1 = steps[1].name; + const captureName2 = steps[2].name; + textPredicates[i].push(function(captures) { + let node1, node2; + for (const c of captures) { + if (c.name === captureName1) node1 = c.node; + if (c.name === captureName2) node2 = c.node + } + if (node1 === undefined || node2 === undefined) return true; + return node1.text === node2.text === isPositive + }) + } else { + const captureName = steps[1].name; + const stringValue = steps[2].value; + textPredicates[i].push(function(captures) { + for (const c of captures) { + if (c.name === captureName) { + return c.node.text === stringValue === isPositive + } + } + return true + }) + } + break; + case "not-match?": + isPositive = false; + case "match?": + if (steps.length !== 3) throw new Error(`Wrong number of arguments to \`#match?\` predicate. Expected 2, got ${steps.length-1}.`); + if (steps[1].type !== "capture") throw new Error(`First argument of \`#match?\` predicate must be a capture. Got "${steps[1].value}".`); + if (steps[2].type !== "string") throw new Error(`Second argument of \`#match?\` predicate must be a string. Got @${steps[2].value}.`); + const captureName = steps[1].name; + const regex = new RegExp(steps[2].value); + textPredicates[i].push(function(captures) { + for (const c of captures) { + if (c.name === captureName) return regex.test(c.node.text) === isPositive + } + return true + }); + break; + case "set!": + if (steps.length < 2 || steps.length > 3) throw new Error(`Wrong number of arguments to \`#set!\` predicate. Expected 1 or 2. Got ${steps.length-1}.`); + if (steps.some(s => s.type !== "string")) throw new Error(`Arguments to \`#set!\` predicate must be a strings.".`); + if (!setProperties[i]) setProperties[i] = {}; + setProperties[i][steps[1].value] = steps[2] ? steps[2].value : null; + break; + case "is?": + case "is-not?": + if (steps.length < 2 || steps.length > 3) throw new Error(`Wrong number of arguments to \`#${operator}\` predicate. Expected 1 or 2. Got ${steps.length-1}.`); + if (steps.some(s => s.type !== "string")) throw new Error(`Arguments to \`#${operator}\` predicate must be a strings.".`); + const properties = operator === "is?" ? assertedProperties : refutedProperties; + if (!properties[i]) properties[i] = {}; + properties[i][steps[1].value] = steps[2] ? steps[2].value : null; + break; + default: + predicates[i].push({ + operator: operator, + operands: steps.slice(1) + }) + } + steps.length = 0 + } + } + Object.freeze(setProperties[i]); + Object.freeze(assertedProperties[i]); + Object.freeze(refutedProperties[i]) + } + C._free(sourceAddress); + return new Query(INTERNAL, address, captureNames, textPredicates, predicates, Object.freeze(setProperties), Object.freeze(assertedProperties), Object.freeze(refutedProperties)) + } + static load(input) { + let bytes; + if (input instanceof Uint8Array) { + bytes = Promise.resolve(input) + } else { + const url = input; + if (typeof process !== "undefined" && process.versions && process.versions.node) { + const fs = require("fs"); + bytes = Promise.resolve(fs.readFileSync(url)) + } else { + bytes = fetch(url).then(response => response.arrayBuffer().then(buffer => { + if (response.ok) { + return new Uint8Array(buffer) + } else { + const body = new TextDecoder("utf-8").decode(buffer); + throw new Error(`Language.load failed with status ${response.status}.\n\n${body}`) + } + })) + } + } + const loadModule = typeof loadSideModule === "function" ? loadSideModule : loadWebAssemblyModule; + return bytes.then(bytes => loadModule(bytes, { + loadAsync: true + })).then(mod => { + const symbolNames = Object.keys(mod); + const functionName = symbolNames.find(key => LANGUAGE_FUNCTION_REGEX.test(key) && !key.includes("external_scanner_")); + if (!functionName) { + console.log(`Couldn't find language function in WASM file. Symbols:\n${JSON.stringify(symbolNames,null,2)}`) + } + const languageAddress = mod[functionName](); + return new Language(INTERNAL, languageAddress) }) - } - break; - case "not-match?": - isPositive = false; - case "match?": - if (steps.length !== 3) throw new Error(`Wrong number of arguments to \`#match?\` predicate. Expected 2, got ${steps.length-1}.`); - if (steps[1].type !== "capture") throw new Error(`First argument of \`#match?\` predicate must be a capture. Got "${steps[1].value}".`); - if (steps[2].type !== "string") throw new Error(`Second argument of \`#match?\` predicate must be a string. Got @${steps[2].value}.`); - const captureName = steps[1].name; - const regex = new RegExp(steps[2].value); - textPredicates[i].push(function(captures) { - for (const c of captures) { - if (c.name === captureName) return regex.test(c.node.text) === isPositive - } - return true - }); - break; - case "set!": - if (steps.length < 2 || steps.length > 3) throw new Error(`Wrong number of arguments to \`#set!\` predicate. Expected 1 or 2. Got ${steps.length-1}.`); - if (steps.some(s => s.type !== "string")) throw new Error(`Arguments to \`#set!\` predicate must be a strings.".`); - if (!setProperties[i]) setProperties[i] = {}; - setProperties[i][steps[1].value] = steps[2] ? steps[2].value : null; - break; - case "is?": - case "is-not?": - if (steps.length < 2 || steps.length > 3) throw new Error(`Wrong number of arguments to \`#${operator}\` predicate. Expected 1 or 2. Got ${steps.length-1}.`); - if (steps.some(s => s.type !== "string")) throw new Error(`Arguments to \`#${operator}\` predicate must be a strings.".`); - const properties = operator === "is?" ? assertedProperties : refutedProperties; - if (!properties[i]) properties[i] = {}; - properties[i][steps[1].value] = steps[2] ? steps[2].value : null; - break; - default: - predicates[i].push({ - operator: operator, - operands: steps.slice(1) - }) - } - steps.length = 0 - } - } - Object.freeze(setProperties[i]); - Object.freeze(assertedProperties[i]); - Object.freeze(refutedProperties[i]) - } - C._free(sourceAddress); - return new Query(INTERNAL, address, captureNames, textPredicates, predicates, Object.freeze(setProperties), Object.freeze(assertedProperties), Object.freeze(refutedProperties)) - } - static load(input) { - let bytes; - if (input instanceof Uint8Array) { - bytes = Promise.resolve(input) - } else { - const url = input; - if (typeof process !== "undefined" && process.versions && process.versions.node) { - const fs = require("fs"); - bytes = Promise.resolve(fs.readFileSync(url)) - } else { - bytes = fetch(url).then(response => response.arrayBuffer().then(buffer => { - if (response.ok) { - return new Uint8Array(buffer) - } else { - const body = new TextDecoder("utf-8").decode(buffer); - throw new Error(`Language.load failed with status ${response.status}.\n\n${body}`) - } - })) - } - } - const loadModule = typeof loadSideModule === "function" ? loadSideModule : loadWebAssemblyModule; - return bytes.then(bytes => loadModule(bytes, { - loadAsync: true - })).then(mod => { - const symbolNames = Object.keys(mod); - const functionName = symbolNames.find(key => LANGUAGE_FUNCTION_REGEX.test(key) && !key.includes("external_scanner_")); - if (!functionName) { - console.log(`Couldn't find language function in WASM file. Symbols:\n${JSON.stringify(symbolNames,null,2)}`) - } - const languageAddress = mod[functionName](); - return new Language(INTERNAL, languageAddress) - }) - } - } - class Query { - constructor(internal, address, captureNames, textPredicates, predicates, setProperties, assertedProperties, refutedProperties) { - assertInternal(internal); - this[0] = address; - this.captureNames = captureNames; - this.textPredicates = textPredicates; - this.predicates = predicates; - this.setProperties = setProperties; - this.assertedProperties = assertedProperties; - this.refutedProperties = refutedProperties; - this.exceededMatchLimit = false - } - delete() { - C._ts_query_delete(this[0]); - this[0] = 0 - } - matches(node, startPosition, endPosition, options) { - if (!startPosition) startPosition = ZERO_POINT; - if (!endPosition) endPosition = ZERO_POINT; - if (!options) options = {}; - let matchLimit = options.matchLimit; - if (typeof matchLimit === "undefined") { - matchLimit = 0 - } else if (typeof matchLimit !== "number") { - throw new Error("Arguments must be numbers") - } - marshalNode(node); - C._ts_query_matches_wasm(this[0], node.tree[0], startPosition.row, startPosition.column, endPosition.row, endPosition.column, matchLimit); - const rawCount = getValue(TRANSFER_BUFFER, "i32"); - const startAddress = getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32"); - const didExceedMatchLimit = getValue(TRANSFER_BUFFER + 2 * SIZE_OF_INT, "i32"); - const result = new Array(rawCount); - this.exceededMatchLimit = !!didExceedMatchLimit; - let filteredCount = 0; - let address = startAddress; - for (let i = 0; i < rawCount; i++) { - const pattern = getValue(address, "i32"); - address += SIZE_OF_INT; - const captureCount = getValue(address, "i32"); - address += SIZE_OF_INT; - const captures = new Array(captureCount); - address = unmarshalCaptures(this, node.tree, address, captures); - if (this.textPredicates[pattern].every(p => p(captures))) { - result[filteredCount++] = { - pattern: pattern, - captures: captures - }; - const setProperties = this.setProperties[pattern]; - if (setProperties) result[i].setProperties = setProperties; - const assertedProperties = this.assertedProperties[pattern]; - if (assertedProperties) result[i].assertedProperties = assertedProperties; - const refutedProperties = this.refutedProperties[pattern]; - if (refutedProperties) result[i].refutedProperties = refutedProperties - } - } - result.length = filteredCount; - C._free(startAddress); - return result - } - captures(node, startPosition, endPosition, options) { - if (!startPosition) startPosition = ZERO_POINT; - if (!endPosition) endPosition = ZERO_POINT; - if (!options) options = {}; - let matchLimit = options.matchLimit; - if (typeof matchLimit === "undefined") { - matchLimit = 0 - } else if (typeof matchLimit !== "number") { - throw new Error("Arguments must be numbers") - } - marshalNode(node); - C._ts_query_captures_wasm(this[0], node.tree[0], startPosition.row, startPosition.column, endPosition.row, endPosition.column, matchLimit); - const count = getValue(TRANSFER_BUFFER, "i32"); - const startAddress = getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32"); - const didExceedMatchLimit = getValue(TRANSFER_BUFFER + 2 * SIZE_OF_INT, "i32"); - const result = []; - this.exceededMatchLimit = !!didExceedMatchLimit; - const captures = []; - let address = startAddress; - for (let i = 0; i < count; i++) { - const pattern = getValue(address, "i32"); - address += SIZE_OF_INT; - const captureCount = getValue(address, "i32"); - address += SIZE_OF_INT; - const captureIndex = getValue(address, "i32"); - address += SIZE_OF_INT; - captures.length = captureCount; - address = unmarshalCaptures(this, node.tree, address, captures); - if (this.textPredicates[pattern].every(p => p(captures))) { - const capture = captures[captureIndex]; - const setProperties = this.setProperties[pattern]; - if (setProperties) capture.setProperties = setProperties; - const assertedProperties = this.assertedProperties[pattern]; - if (assertedProperties) capture.assertedProperties = assertedProperties; - const refutedProperties = this.refutedProperties[pattern]; - if (refutedProperties) capture.refutedProperties = refutedProperties; - result.push(capture) - } - } - C._free(startAddress); - return result - } - predicatesForPattern(patternIndex) { - return this.predicates[patternIndex] - } - didExceedMatchLimit() { - return this.exceededMatchLimit - } - } + } + } + class Query { + constructor(internal, address, captureNames, textPredicates, predicates, setProperties, assertedProperties, refutedProperties) { + assertInternal(internal); + this[0] = address; + this.captureNames = captureNames; + this.textPredicates = textPredicates; + this.predicates = predicates; + this.setProperties = setProperties; + this.assertedProperties = assertedProperties; + this.refutedProperties = refutedProperties; + this.exceededMatchLimit = false + } + delete() { + C._ts_query_delete(this[0]); + this[0] = 0 + } + matches(node, startPosition, endPosition, options) { + if (!startPosition) startPosition = ZERO_POINT; + if (!endPosition) endPosition = ZERO_POINT; + if (!options) options = {}; + let matchLimit = options.matchLimit; + if (typeof matchLimit === "undefined") { + matchLimit = 0 + } else if (typeof matchLimit !== "number") { + throw new Error("Arguments must be numbers") + } + marshalNode(node); + C._ts_query_matches_wasm(this[0], node.tree[0], startPosition.row, startPosition.column, endPosition.row, endPosition.column, matchLimit); + const rawCount = getValue(TRANSFER_BUFFER, "i32"); + const startAddress = getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32"); + const didExceedMatchLimit = getValue(TRANSFER_BUFFER + 2 * SIZE_OF_INT, "i32"); + const result = new Array(rawCount); + this.exceededMatchLimit = !!didExceedMatchLimit; + let filteredCount = 0; + let address = startAddress; + for (let i = 0; i < rawCount; i++) { + const pattern = getValue(address, "i32"); + address += SIZE_OF_INT; + const captureCount = getValue(address, "i32"); + address += SIZE_OF_INT; + const captures = new Array(captureCount); + address = unmarshalCaptures(this, node.tree, address, captures); + if (this.textPredicates[pattern].every(p => p(captures))) { + result[filteredCount++] = { + pattern: pattern, + captures: captures + }; + const setProperties = this.setProperties[pattern]; + if (setProperties) result[i].setProperties = setProperties; + const assertedProperties = this.assertedProperties[pattern]; + if (assertedProperties) result[i].assertedProperties = assertedProperties; + const refutedProperties = this.refutedProperties[pattern]; + if (refutedProperties) result[i].refutedProperties = refutedProperties + } + } + result.length = filteredCount; + C._free(startAddress); + return result + } + captures(node, startPosition, endPosition, options) { + if (!startPosition) startPosition = ZERO_POINT; + if (!endPosition) endPosition = ZERO_POINT; + if (!options) options = {}; + let matchLimit = options.matchLimit; + if (typeof matchLimit === "undefined") { + matchLimit = 0 + } else if (typeof matchLimit !== "number") { + throw new Error("Arguments must be numbers") + } + marshalNode(node); + C._ts_query_captures_wasm(this[0], node.tree[0], startPosition.row, startPosition.column, endPosition.row, endPosition.column, matchLimit); + const count = getValue(TRANSFER_BUFFER, "i32"); + const startAddress = getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32"); + const didExceedMatchLimit = getValue(TRANSFER_BUFFER + 2 * SIZE_OF_INT, "i32"); + const result = []; + this.exceededMatchLimit = !!didExceedMatchLimit; + const captures = []; + let address = startAddress; + for (let i = 0; i < count; i++) { + const pattern = getValue(address, "i32"); + address += SIZE_OF_INT; + const captureCount = getValue(address, "i32"); + address += SIZE_OF_INT; + const captureIndex = getValue(address, "i32"); + address += SIZE_OF_INT; + captures.length = captureCount; + address = unmarshalCaptures(this, node.tree, address, captures); + if (this.textPredicates[pattern].every(p => p(captures))) { + const capture = captures[captureIndex]; + const setProperties = this.setProperties[pattern]; + if (setProperties) capture.setProperties = setProperties; + const assertedProperties = this.assertedProperties[pattern]; + if (assertedProperties) capture.assertedProperties = assertedProperties; + const refutedProperties = this.refutedProperties[pattern]; + if (refutedProperties) capture.refutedProperties = refutedProperties; + result.push(capture) + } + } + C._free(startAddress); + return result + } + predicatesForPattern(patternIndex) { + return this.predicates[patternIndex] + } + didExceedMatchLimit() { + return this.exceededMatchLimit + } + } - function getText(tree, startIndex, endIndex) { - const length = endIndex - startIndex; - let result = tree.textCallback(startIndex, null, endIndex); - startIndex += result.length; - while (startIndex < endIndex) { - const string = tree.textCallback(startIndex, null, endIndex); - if (string && string.length > 0) { - startIndex += string.length; - result += string - } else { - break - } - } - if (startIndex > endIndex) { - result = result.slice(0, length) - } - return result - } + function getText(tree, startIndex, endIndex) { + const length = endIndex - startIndex; + let result = tree.textCallback(startIndex, null, endIndex); + startIndex += result.length; + while (startIndex < endIndex) { + const string = tree.textCallback(startIndex, null, endIndex); + if (string && string.length > 0) { + startIndex += string.length; + result += string + } else { + break + } + } + if (startIndex > endIndex) { + result = result.slice(0, length) + } + return result + } - function unmarshalCaptures(query, tree, address, result) { - for (let i = 0, n = result.length; i < n; i++) { - const captureIndex = getValue(address, "i32"); - address += SIZE_OF_INT; - const node = unmarshalNode(tree, address); - address += SIZE_OF_NODE; - result[i] = { - name: query.captureNames[captureIndex], - node: node - } - } - return address - } + function unmarshalCaptures(query, tree, address, result) { + for (let i = 0, n = result.length; i < n; i++) { + const captureIndex = getValue(address, "i32"); + address += SIZE_OF_INT; + const node = unmarshalNode(tree, address); + address += SIZE_OF_NODE; + result[i] = { + name: query.captureNames[captureIndex], + node: node + } + } + return address + } - function assertInternal(x) { - if (x !== INTERNAL) throw new Error("Illegal constructor") - } + function assertInternal(x) { + if (x !== INTERNAL) throw new Error("Illegal constructor") + } - function isPoint(point) { - return point && typeof point.row === "number" && typeof point.column === "number" - } + function isPoint(point) { + return point && typeof point.row === "number" && typeof point.column === "number" + } - function marshalNode(node) { - let address = TRANSFER_BUFFER; - setValue(address, node.id, "i32"); - address += SIZE_OF_INT; - setValue(address, node.startIndex, "i32"); - address += SIZE_OF_INT; - setValue(address, node.startPosition.row, "i32"); - address += SIZE_OF_INT; - setValue(address, node.startPosition.column, "i32"); - address += SIZE_OF_INT; - setValue(address, node[0], "i32") - } + function marshalNode(node) { + let address = TRANSFER_BUFFER; + setValue(address, node.id, "i32"); + address += SIZE_OF_INT; + setValue(address, node.startIndex, "i32"); + address += SIZE_OF_INT; + setValue(address, node.startPosition.row, "i32"); + address += SIZE_OF_INT; + setValue(address, node.startPosition.column, "i32"); + address += SIZE_OF_INT; + setValue(address, node[0], "i32") + } - function unmarshalNode(tree, address = TRANSFER_BUFFER) { - const id = getValue(address, "i32"); - address += SIZE_OF_INT; - if (id === 0) return null; - const index = getValue(address, "i32"); - address += SIZE_OF_INT; - const row = getValue(address, "i32"); - address += SIZE_OF_INT; - const column = getValue(address, "i32"); - address += SIZE_OF_INT; - const other = getValue(address, "i32"); - const result = new Node(INTERNAL, tree); - result.id = id; - result.startIndex = index; - result.startPosition = { - row: row, - column: column - }; - result[0] = other; - return result - } + function unmarshalNode(tree, address = TRANSFER_BUFFER) { + const id = getValue(address, "i32"); + address += SIZE_OF_INT; + if (id === 0) return null; + const index = getValue(address, "i32"); + address += SIZE_OF_INT; + const row = getValue(address, "i32"); + address += SIZE_OF_INT; + const column = getValue(address, "i32"); + address += SIZE_OF_INT; + const other = getValue(address, "i32"); + const result = new Node(INTERNAL, tree); + result.id = id; + result.startIndex = index; + result.startPosition = { + row: row, + column: column + }; + result[0] = other; + return result + } - function marshalTreeCursor(cursor, address = TRANSFER_BUFFER) { - setValue(address + 0 * SIZE_OF_INT, cursor[0], "i32"), setValue(address + 1 * SIZE_OF_INT, cursor[1], "i32"), setValue(address + 2 * SIZE_OF_INT, cursor[2], "i32") - } + function marshalTreeCursor(cursor, address = TRANSFER_BUFFER) { + setValue(address + 0 * SIZE_OF_INT, cursor[0], "i32"), setValue(address + 1 * SIZE_OF_INT, cursor[1], "i32"), setValue(address + 2 * SIZE_OF_INT, cursor[2], "i32") + } - function unmarshalTreeCursor(cursor) { - cursor[0] = getValue(TRANSFER_BUFFER + 0 * SIZE_OF_INT, "i32"), cursor[1] = getValue(TRANSFER_BUFFER + 1 * SIZE_OF_INT, "i32"), cursor[2] = getValue(TRANSFER_BUFFER + 2 * SIZE_OF_INT, "i32") - } + function unmarshalTreeCursor(cursor) { + cursor[0] = getValue(TRANSFER_BUFFER + 0 * SIZE_OF_INT, "i32"), cursor[1] = getValue(TRANSFER_BUFFER + 1 * SIZE_OF_INT, "i32"), cursor[2] = getValue(TRANSFER_BUFFER + 2 * SIZE_OF_INT, "i32") + } - function marshalPoint(address, point) { - setValue(address, point.row, "i32"); - setValue(address + SIZE_OF_INT, point.column, "i32") - } + function marshalPoint(address, point) { + setValue(address, point.row, "i32"); + setValue(address + SIZE_OF_INT, point.column, "i32") + } - function unmarshalPoint(address) { - return { - row: getValue(address, "i32"), - column: getValue(address + SIZE_OF_INT, "i32") - } - } + function unmarshalPoint(address) { + return { + row: getValue(address, "i32"), + column: getValue(address + SIZE_OF_INT, "i32") + } + } - function marshalRange(address, range) { - marshalPoint(address, range.startPosition); - address += SIZE_OF_POINT; - marshalPoint(address, range.endPosition); - address += SIZE_OF_POINT; - setValue(address, range.startIndex, "i32"); - address += SIZE_OF_INT; - setValue(address, range.endIndex, "i32"); - address += SIZE_OF_INT - } + function marshalRange(address, range) { + marshalPoint(address, range.startPosition); + address += SIZE_OF_POINT; + marshalPoint(address, range.endPosition); + address += SIZE_OF_POINT; + setValue(address, range.startIndex, "i32"); + address += SIZE_OF_INT; + setValue(address, range.endIndex, "i32"); + address += SIZE_OF_INT + } - function unmarshalRange(address) { - const result = {}; - result.startPosition = unmarshalPoint(address); - address += SIZE_OF_POINT; - result.endPosition = unmarshalPoint(address); - address += SIZE_OF_POINT; - result.startIndex = getValue(address, "i32"); - address += SIZE_OF_INT; - result.endIndex = getValue(address, "i32"); - return result - } + function unmarshalRange(address) { + const result = {}; + result.startPosition = unmarshalPoint(address); + address += SIZE_OF_POINT; + result.endPosition = unmarshalPoint(address); + address += SIZE_OF_POINT; + result.startIndex = getValue(address, "i32"); + address += SIZE_OF_INT; + result.endIndex = getValue(address, "i32"); + return result + } - function marshalEdit(edit) { - let address = TRANSFER_BUFFER; - marshalPoint(address, edit.startPosition); - address += SIZE_OF_POINT; - marshalPoint(address, edit.oldEndPosition); - address += SIZE_OF_POINT; - marshalPoint(address, edit.newEndPosition); - address += SIZE_OF_POINT; - setValue(address, edit.startIndex, "i32"); - address += SIZE_OF_INT; - setValue(address, edit.oldEndIndex, "i32"); - address += SIZE_OF_INT; - setValue(address, edit.newEndIndex, "i32"); - address += SIZE_OF_INT - } - for (const name of Object.getOwnPropertyNames(ParserImpl.prototype)) { - Object.defineProperty(Parser.prototype, name, { - value: ParserImpl.prototype[name], - enumerable: false, - writable: false - }) + function marshalEdit(edit) { + let address = TRANSFER_BUFFER; + marshalPoint(address, edit.startPosition); + address += SIZE_OF_POINT; + marshalPoint(address, edit.oldEndPosition); + address += SIZE_OF_POINT; + marshalPoint(address, edit.newEndPosition); + address += SIZE_OF_POINT; + setValue(address, edit.startIndex, "i32"); + address += SIZE_OF_INT; + setValue(address, edit.oldEndIndex, "i32"); + address += SIZE_OF_INT; + setValue(address, edit.newEndIndex, "i32"); + address += SIZE_OF_INT + } + for (const name of Object.getOwnPropertyNames(ParserImpl.prototype)) { + Object.defineProperty(Parser.prototype, name, { + value: ParserImpl.prototype[name], + enumerable: false, + writable: false + }) + } + Parser.Language = Language; + Module.onRuntimeInitialized = (() => { + ParserImpl.init(); + resolveInitPromise() + }) + }) } - Parser.Language = Language; - Module.onRuntimeInitialized = (() => { - ParserImpl.init(); - resolveInitPromise() - }) - }) } - } - return Parser + return Parser }(); if (typeof exports === "object") { - module.exports = TreeSitter + module.exports = TreeSitter } diff --git a/vendor/web-tree-sitter/tree-sitter.wasm b/vendor/web-tree-sitter/tree-sitter.wasm index 4e61aed825..56e6db9ac9 100755 Binary files a/vendor/web-tree-sitter/tree-sitter.wasm and b/vendor/web-tree-sitter/tree-sitter.wasm differ diff --git a/yarn.lock b/yarn.lock index 61819bb2ae..98cac8e636 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2340,9 +2340,7 @@ atom-slick@^2, atom-slick@^2.0.0: version "2.42.6" dependencies: atom-slick "^2.0.0" - dompurify "^3.0.4" grim "^2.0.1" - marked "^5.1.1" minimatch "^3.0.3" selector-kit "^0.1.0" stable "^0.1.8" @@ -3629,7 +3627,6 @@ depd@^1.1.2: etch "0.9.0" fs-plus "^3.0.0" grim "^2.0.1" - marked "5.0.3" underscore-plus "^1.7.0" detect-libc@^1.0.3: @@ -3792,20 +3789,15 @@ dompurify@2.0.17: resolved "https://registry.yarnpkg.com/dompurify/-/dompurify-2.0.17.tgz#505ffa126a580603df4007e034bdc9b6b738668e" integrity sha512-nNwwJfW55r8akD8MSFz6k75bzyT2y6JEa1O3JrZFBf+Y5R9JXXU4OsRl0B9hKoPgHTw2b7ER5yJ5Md97MMUJPg== -dompurify@3.0.3: - version "3.0.3" - resolved "https://registry.yarnpkg.com/dompurify/-/dompurify-3.0.3.tgz#4b115d15a091ddc96f232bcef668550a2f6f1430" - integrity sha512-axQ9zieHLnAnHh0sfAamKYiqXMJAVwu+LM/alQ7WDagoWessyWvMSFyW65CqF3owufNu8HBcE4cM2Vflu7YWcQ== - dompurify@^2.0.17: version "2.4.1" resolved "https://registry.yarnpkg.com/dompurify/-/dompurify-2.4.1.tgz#f9cb1a275fde9af6f2d0a2644ef648dd6847b631" integrity sha512-ewwFzHzrrneRjxzmK6oVz/rZn9VWspGFRDb4/rRtIsM1n36t9AKma/ye8syCpcw+XJ25kOK/hOG7t1j2I2yBqA== -dompurify@^3.0.4: - version "3.0.4" - resolved "https://registry.yarnpkg.com/dompurify/-/dompurify-3.0.4.tgz#963116d05c94ee42f8353a3690f935475d8cd2f7" - integrity sha512-ae0mA+Qiqp6C29pqZX3fQgK+F91+F7wobM/v8DRzDqJdZJELXiFUx4PP4pK/mzUS0xkiSEx3Ncd9gr69jg3YsQ== +dompurify@^3.0.6: + version "3.0.6" + resolved "https://registry.yarnpkg.com/dompurify/-/dompurify-3.0.6.tgz#925ebd576d54a9531b5d76f0a5bef32548351dae" + integrity sha512-ilkD8YEnnGh1zJ240uJsW7AzE+2qpbOUYjacomn3AvJ6J4JhKGSZ2nh4wUIXPZrEPppaCLx5jFe8T89Rk8tQ7w== domutils@^3.0.1: version "3.0.1" @@ -4785,17 +4777,12 @@ function.prototype.name@^1.1.5: es-abstract "^1.19.0" functions-have-names "^1.2.2" -functional-red-black-tree@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz#1b0ab3bd553b2a0d6399d29c0e3ea0b252078327" - integrity sha512-dsKNQNdj6xA3T+QlADDA7mOSlX0qiMINjn0cgr+eGHGsbSHzTabcIogz2+p/iqP1Xs6EP/sS2SbqH+brGTbq0g== - functions-have-names@^1.2.2: version "1.2.3" resolved "https://registry.yarnpkg.com/functions-have-names/-/functions-have-names-1.2.3.tgz#0404fe4ee2ba2f607f0e0ec3c80bae994133b834" integrity sha512-xckBUXyTIqT97tq2x2AMb+g163b5JFysYk0x4qxNFwbfQkmNZoiRHb6sPzI9/QV33WeuvVYBUIiD4NzNIyqaRQ== -fuzzaldrin@^2.1, fuzzaldrin@^2.1.0: +fuzzaldrin@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/fuzzaldrin/-/fuzzaldrin-2.1.0.tgz#90204c3e2fdaa6941bb28d16645d418063a90e9b" integrity sha512-zgllBYwfHR5P3CncJiGbGVPpa3iFYW1yuPaIv8DiTVRrcg5/6uETNL5zvIoKflG1aifXVUZTlIroDehw4WygGA== @@ -4909,15 +4896,7 @@ getpass@^0.1.1: dependencies: atom-select-list "^0.8.1" -git-utils@5.7.1: - version "5.7.1" - resolved "https://registry.yarnpkg.com/git-utils/-/git-utils-5.7.1.tgz#f26e95f8cc05b475b2b8b09151b68f3788c8a173" - integrity sha512-+mWdJDq9emWoq6GzzrGEB7SIBmAk0lNNv2wgNkgwTVZUkAFkWvgRsJ+Kvs3d1QQD6WG6vczti2WLpjmh2Twtlw== - dependencies: - fs-plus "^3.0.0" - nan "^2.14.0" - -git-utils@^5.6.0: +git-utils@^5.6.0, git-utils@^5.7.3: version "5.7.3" resolved "https://registry.yarnpkg.com/git-utils/-/git-utils-5.7.3.tgz#3b53983204678313b305bbf278c07dc015ba2155" integrity sha512-in1hjFfmzY86gKBt+YMTaVyCGtX2WTnN0uPj37bI5HsrnU2oj8OFcWOEzOI5PxQXPMxFxtvRebOHAOGB8M125w== @@ -5023,7 +5002,7 @@ glob@7.1.3: once "^1.3.0" path-is-absolute "^1.0.0" -glob@^7.0.0, glob@^7.1.1, glob@^7.1.3, glob@^7.1.4, glob@^7.1.6, glob@^7.2.0: +glob@^7.0.0, glob@^7.1.3, glob@^7.1.4, glob@^7.1.6, glob@^7.2.0: version "7.2.3" resolved "https://registry.yarnpkg.com/glob/-/glob-7.2.3.tgz#b8df0fb802bbfa8e89bd1d938b4e16578ed44f2b" integrity sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q== @@ -6717,11 +6696,6 @@ marked@^4.2.3: resolved "https://registry.yarnpkg.com/marked/-/marked-4.2.5.tgz#979813dfc1252cc123a79b71b095759a32f42a5d" integrity sha512-jPueVhumq7idETHkb203WDD4fMA3yV9emQ5vLwop58lu8bTclMghBWcYAavlDqIEMaisADinV1TooIFCfqOsYQ== -marked@^5.1.1: - version "5.1.1" - resolved "https://registry.yarnpkg.com/marked/-/marked-5.1.1.tgz#40b3963bb9da225314f746d5012ba7e34942f636" - integrity sha512-bTmmGdEINWmOMDjnPWDxGPQ4qkDLeYorpYbEtFOXzOruTwUE671q4Guiuchn4N8h/v6NGd7916kXsm3Iz4iUSg== - marky@^1.2.2: version "1.2.5" resolved "https://registry.yarnpkg.com/marky/-/marky-1.2.5.tgz#55796b688cbd72390d2d399eaaf1832c9413e3c0" @@ -7275,9 +7249,7 @@ normalize-url@^6.0.1: "notifications@file:./packages/notifications": version "0.73.0" dependencies: - dompurify "3.0.3" fs-plus "^3.0.0" - marked "5.0.3" moment "^2.19.3" semver "^7.0.0" stacktrace-parser "^0.1.3" @@ -7865,7 +7837,7 @@ prop-types@^15.5.0, prop-types@^15.5.8, prop-types@^15.6.2: object-assign "^4.1.1" react-is "^16.13.1" -property-accessors@^1, property-accessors@^1.1, property-accessors@^1.1.3: +property-accessors@^1, property-accessors@^1.1: version "1.1.3" resolved "https://registry.yarnpkg.com/property-accessors/-/property-accessors-1.1.3.tgz#1dde84024631865909ef30703365680c5f928b15" integrity sha512-WQTVW7rn+k6wq8FyYVM15afyoB2loEdeIzd/o7+HEA5hMZcxvRf4Khie0fBM9wLP3EJotKhiH15kY7Dd4gc57g== @@ -8603,13 +8575,10 @@ setimmediate@^1.0.5: version "0.261.11" dependencies: async "^3.2.0" - dompurify "^2.0.17" etch "0.9.0" fs-plus "^3.0.0" - fuzzaldrin "^2.1" glob "5.0.15" hosted-git-info "^2.8.9" - marked "5.0.3" request "^2.83.0" season "^6.0.2" semver "^5.3.0"