ts-wasms 2.0.0 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (150) hide show
  1. package/README.md +7 -0
  2. package/index.d.ts +107 -94
  3. package/index.js +21 -0
  4. package/manifest.json +620 -0
  5. package/out/ada/folds.scm +15 -0
  6. package/out/ada/highlights.scm +196 -0
  7. package/out/ada/injections.scm +2 -0
  8. package/out/ada/locals.scm +33 -0
  9. package/out/ada/textobjects.scm +23 -0
  10. package/out/ada/tree-sitter-ada.wasm +0 -0
  11. package/out/arduino/folds.scm +1 -0
  12. package/out/arduino/highlights.scm +48 -0
  13. package/out/arduino/indents.scm +1 -0
  14. package/out/arduino/injections.scm +1 -0
  15. package/out/arduino/locals.scm +1 -0
  16. package/out/arduino/tags.scm +5 -0
  17. package/out/arduino/tree-sitter-arduino.wasm +0 -0
  18. package/out/awk/highlights.scm +122 -0
  19. package/out/awk/injections.scm +17 -0
  20. package/out/awk/tree-sitter-awk.wasm +0 -0
  21. package/out/bibtex/folds.scm +1 -0
  22. package/out/bibtex/highlights.scm +47 -0
  23. package/out/bibtex/indents.scm +8 -0
  24. package/out/bibtex/injections.scm +2 -0
  25. package/out/bibtex/locals.scm +0 -0
  26. package/out/bibtex/tags.scm +0 -0
  27. package/out/bibtex/tree-sitter-bibtex.wasm +0 -0
  28. package/out/c_sharp/folds.scm +17 -0
  29. package/out/c_sharp/injections.scm +2 -0
  30. package/out/c_sharp/locals.scm +42 -0
  31. package/out/cairo/folds.scm +26 -0
  32. package/out/cairo/highlights.scm +372 -0
  33. package/out/cairo/indents.scm +134 -0
  34. package/out/cairo/injections.scm +3 -0
  35. package/out/cairo/locals.scm +28 -0
  36. package/out/cairo/textobjects.scm +79 -0
  37. package/out/cairo/tree-sitter-cairo.wasm +0 -0
  38. package/out/cuda/folds.scm +1 -0
  39. package/out/cuda/highlights.scm +17 -0
  40. package/out/cuda/indents.scm +1 -0
  41. package/out/cuda/injections.scm +1 -0
  42. package/out/cuda/locals.scm +1 -0
  43. package/out/cuda/tree-sitter-cuda.wasm +0 -0
  44. package/out/d/folds.scm +4 -0
  45. package/out/d/helix-highlights.scm +241 -0
  46. package/out/d/helix-indents.scm +17 -0
  47. package/out/d/helix-injections.scm +2 -0
  48. package/out/d/helix-textobjects.scm +9 -0
  49. package/out/d/highlights.scm +259 -0
  50. package/out/d/indents.scm +17 -0
  51. package/out/d/injections.scm +2 -0
  52. package/out/d/locals.scm +79 -0
  53. package/out/d/nova-folds.scm +6 -0
  54. package/out/d/nova-highlights.scm +283 -0
  55. package/out/d/nova-symbols.scm +23 -0
  56. package/out/d/tags.scm +28 -0
  57. package/out/d/textobjects.scm +9 -0
  58. package/out/d/tree-sitter-d.wasm +0 -0
  59. package/out/desktop/folds.scm +1 -0
  60. package/out/desktop/highlights.scm +91 -0
  61. package/out/desktop/injections.scm +8 -0
  62. package/out/desktop/tree-sitter-desktop.wasm +0 -0
  63. package/out/devicetree/folds.scm +1 -0
  64. package/out/devicetree/highlights.scm +78 -0
  65. package/out/devicetree/indents.scm +12 -0
  66. package/out/devicetree/injections.scm +2 -0
  67. package/out/devicetree/locals.scm +4 -0
  68. package/out/devicetree/tree-sitter-devicetree.wasm +0 -0
  69. package/out/embedded_template/injections.scm +7 -0
  70. package/out/git_config/folds.scm +2 -0
  71. package/out/git_config/injections.scm +69 -0
  72. package/out/git_rebase/injections.scm +8 -0
  73. package/out/gleam/folds.scm +7 -0
  74. package/out/gleam/highlights.scm +137 -0
  75. package/out/gleam/indents.scm +28 -0
  76. package/out/gleam/injections.scm +3 -0
  77. package/out/gleam/locals.scm +17 -0
  78. package/out/gleam/tags.scm +41 -0
  79. package/out/gleam/tree-sitter-gleam.wasm +0 -0
  80. package/out/glsl/folds.scm +1 -0
  81. package/out/glsl/highlights.scm +115 -0
  82. package/out/glsl/indents.scm +1 -0
  83. package/out/glsl/injections.scm +1 -0
  84. package/out/glsl/locals.scm +1 -0
  85. package/out/glsl/tree-sitter-glsl.wasm +0 -0
  86. package/out/godot_resource/folds.scm +1 -0
  87. package/out/godot_resource/highlights.scm +49 -0
  88. package/out/godot_resource/injections.scm +2 -0
  89. package/out/godot_resource/locals.scm +1 -0
  90. package/out/kdl/folds.scm +8 -0
  91. package/out/kdl/highlights.scm +58 -0
  92. package/out/kdl/indents.scm +7 -0
  93. package/out/kdl/injections.scm +4 -0
  94. package/out/kdl/locals.scm +10 -0
  95. package/out/kdl/tree-sitter-kdl.wasm +0 -0
  96. package/out/liquid/highlights.scm +119 -0
  97. package/out/liquid/injections.scm +22 -0
  98. package/out/liquid/tree-sitter-liquid.wasm +0 -0
  99. package/out/ocaml_interface/folds.scm +1 -0
  100. package/out/ocaml_interface/indents.scm +1 -0
  101. package/out/ocaml_interface/injections.scm +1 -0
  102. package/out/php_only/folds.scm +19 -0
  103. package/out/php_only/indents.scm +68 -0
  104. package/out/php_only/locals.scm +84 -0
  105. package/out/solidity/folds.scm +20 -0
  106. package/out/solidity/highlights-nvim.scm +309 -0
  107. package/out/solidity/highlights.scm +217 -0
  108. package/out/solidity/injections.scm +14 -0
  109. package/out/solidity/locals.scm +9 -0
  110. package/out/solidity/tags.scm +43 -0
  111. package/out/solidity/tree-sitter-solidity.wasm +0 -0
  112. package/package.json +18 -2
  113. package/out/vim/folds.scm +0 -4
  114. package/out/vim/highlights.scm +0 -362
  115. package/out/vim/injections.scm +0 -44
  116. package/out/vim/locals.scm +0 -19
  117. package/out/vim/tree-sitter-vim.wasm +0 -0
  118. /package/out/{c-sharp → c_sharp}/highlights.scm +0 -0
  119. /package/out/{c-sharp → c_sharp}/tags.scm +0 -0
  120. /package/out/{c-sharp/tree-sitter-c-sharp.wasm → c_sharp/tree-sitter-c_sharp.wasm} +0 -0
  121. /package/out/{embedded-template → embedded_template}/highlights.scm +0 -0
  122. /package/out/{embedded-template → embedded_template}/injections-ejs.scm +0 -0
  123. /package/out/{embedded-template → embedded_template}/injections-erb.scm +0 -0
  124. /package/out/{embedded-template → embedded_template}/injections-etlua.scm +0 -0
  125. /package/out/{embedded-template/tree-sitter-embedded-template.wasm → embedded_template/tree-sitter-embedded_template.wasm} +0 -0
  126. /package/out/{git-config → git_config}/highlights.scm +0 -0
  127. /package/out/{git-config/tree-sitter-git-config.wasm → git_config/tree-sitter-git_config.wasm} +0 -0
  128. /package/out/{git-rebase → git_rebase}/highlights.scm +0 -0
  129. /package/out/{git-rebase/tree-sitter-git-rebase.wasm → git_rebase/tree-sitter-git_rebase.wasm} +0 -0
  130. /package/out/{godot-resource/tree-sitter-godot-resource.wasm → godot_resource/tree-sitter-godot_resource.wasm} +0 -0
  131. /package/out/{markdown-inline → markdown_inline}/highlights.scm +0 -0
  132. /package/out/{markdown-inline → markdown_inline}/injections.scm +0 -0
  133. /package/out/{markdown-inline/tree-sitter-markdown-inline.wasm → markdown_inline/tree-sitter-markdown_inline.wasm} +0 -0
  134. /package/out/{ocaml-interface → ocaml_interface}/highlights.scm +0 -0
  135. /package/out/{ocaml-interface → ocaml_interface}/locals.scm +0 -0
  136. /package/out/{ocaml-interface → ocaml_interface}/tags.scm +0 -0
  137. /package/out/{ocaml-interface/tree-sitter-ocaml-interface.wasm → ocaml_interface/tree-sitter-ocaml_interface.wasm} +0 -0
  138. /package/out/{ocaml-type → ocaml_type}/highlights.scm +0 -0
  139. /package/out/{ocaml-type → ocaml_type}/locals.scm +0 -0
  140. /package/out/{ocaml-type → ocaml_type}/tags.scm +0 -0
  141. /package/out/{ocaml-type/tree-sitter-ocaml-type.wasm → ocaml_type/tree-sitter-ocaml_type.wasm} +0 -0
  142. /package/out/{php-only → php_only}/highlights.scm +0 -0
  143. /package/out/{php-only → php_only}/injections-text.scm +0 -0
  144. /package/out/{php-only → php_only}/injections.scm +0 -0
  145. /package/out/{php-only → php_only}/tags.scm +0 -0
  146. /package/out/{php-only/tree-sitter-php-only.wasm → php_only/tree-sitter-php_only.wasm} +0 -0
  147. /package/out/{csv-psv → psv}/highlights.scm +0 -0
  148. /package/out/{csv-psv/tree-sitter-csv-psv.wasm → psv/tree-sitter-psv.wasm} +0 -0
  149. /package/out/{csv-tsv → tsv}/highlights.scm +0 -0
  150. /package/out/{csv-tsv/tree-sitter-csv-tsv.wasm → tsv/tree-sitter-tsv.wasm} +0 -0
package/README.md CHANGED
@@ -20,12 +20,17 @@ import { getWasmPath, getQueryPath } from "ts-wasms";
20
20
 
21
21
  const wasmPath = getWasmPath("python");
22
22
  const queryPath = getQueryPath("python", "highlights");
23
+ const pythonQueries = getAvailableQueries("python");
23
24
  ```
24
25
 
25
26
  You can also import the assets directly via your bundler
26
27
  ```typescript
27
28
  import wasmUrl from "ts-wasms/python/tree-sitter-python.wasm?url";
28
29
  import wasmHighlights from "ts-wasms/python/highlights.scm?raw";
30
+
31
+ // This JSON object acts as table of content for all available languages
32
+ // and their queries.
33
+ import manifest from "ts-wasms/manifest.json"
29
34
  ```
30
35
 
31
36
  Each language directory includes a `tree-sitter-<lang>.wasm` file but may also include:
@@ -35,6 +40,7 @@ Each language directory includes a `tree-sitter-<lang>.wasm` file but may also i
35
40
  - `tags.scm`
36
41
  - `folds.scm`
37
42
  - `indents.scm`
43
+ Certain languages also contain special queries like: `nova-symbols`, please refer to the manifest.json or to the out dir in unpkg.
38
44
 
39
45
  ```txt
40
46
  python/
@@ -43,6 +49,7 @@ python/
43
49
  └── tags.scm
44
50
  ```
45
51
 
52
+
46
53
  ## Licenses
47
54
  The licenses for the generated .wasm and .scm files belong to their respective upstream grammar authors and can be found on their github repos.
48
55
 
package/index.d.ts CHANGED
@@ -1,102 +1,115 @@
1
- /** Standard Tree-sitter query categories */
2
- export type TreeSitterQuery =
3
-     | "highlights"
4
-     | "injections"
5
-     | "locals"
6
-     | "tags"
7
-     | "folds"
8
-     | "indents";
1
+ /** Standard Tree-sitter query categories mapped per language */
2
+ export type QueryMap = {
3
+ "ada": "folds" | "highlights" | "injections" | "locals" | "textobjects";
4
+ "angular": "folds" | "highlights" | "indents" | "injections" | "locals";
5
+ "arduino": "folds" | "highlights" | "indents" | "injections" | "locals" | "tags";
6
+ "asm": "highlights" | "injections";
7
+ "astro": "folds" | "highlights" | "indents" | "injections" | "locals";
8
+ "awk": "highlights" | "injections";
9
+ "bash": "folds" | "highlights" | "indents" | "injections" | "locals";
10
+ "bibtex": "folds" | "highlights" | "indents" | "injections" | "locals" | "tags";
11
+ "c": "folds" | "highlights" | "indents" | "injections" | "locals" | "tags";
12
+ "c_sharp": "folds" | "highlights" | "injections" | "locals" | "tags";
13
+ "cairo": "folds" | "highlights" | "indents" | "injections" | "locals" | "textobjects";
14
+ "clojure": "folds" | "highlights" | "injections" | "locals";
15
+ "cmake": "folds" | "highlights" | "indents" | "injections";
16
+ "comment": "highlights";
17
+ "commonlisp": "folds" | "highlights" | "injections" | "locals" | "tags";
18
+ "cpp": "folds" | "highlights" | "indents" | "injections" | "locals" | "tags";
19
+ "css": "folds" | "highlights" | "indents" | "injections";
20
+ "csv": "highlights";
21
+ "cuda": "folds" | "highlights" | "indents" | "injections" | "locals";
22
+ "d": "folds" | "helix-highlights" | "helix-indents" | "helix-injections" | "helix-textobjects" | "highlights" | "indents" | "injections" | "locals" | "nova-folds" | "nova-highlights" | "nova-symbols" | "tags" | "textobjects";
23
+ "dart": "folds" | "highlights" | "indents" | "injections" | "locals";
24
+ "desktop": "folds" | "highlights" | "injections";
25
+ "devicetree": "folds" | "highlights" | "indents" | "injections" | "locals";
26
+ "diff": "folds" | "highlights" | "injections";
27
+ "dockerfile": "highlights" | "injections";
28
+ "dtd": "folds" | "highlights" | "injections" | "locals";
29
+ "editorconfig": "folds" | "highlights" | "injections";
30
+ "elisp": "highlights" | "tags";
31
+ "elixir": "folds" | "highlights" | "indents" | "injections" | "locals" | "tags";
32
+ "elm": "folds" | "highlights" | "injections" | "locals" | "tags";
33
+ "embedded_template": "highlights" | "injections" | "injections-ejs" | "injections-erb" | "injections-etlua";
34
+ "erlang": "folds" | "highlights" | "injections";
35
+ "fish": "folds" | "highlights" | "indents" | "injections" | "locals";
36
+ "gdscript": "folds" | "highlights" | "indents" | "injections" | "locals";
37
+ "gdshader": "highlights" | "injections" | "locals" | "tags";
38
+ "git_config": "folds" | "highlights" | "injections";
39
+ "git_rebase": "highlights" | "injections";
40
+ "gitattributes": "highlights" | "injections" | "locals";
41
+ "gitignore": "highlights" | "injections";
42
+ "gleam": "folds" | "highlights" | "indents" | "injections" | "locals" | "tags";
43
+ "glsl": "folds" | "highlights" | "indents" | "injections" | "locals";
44
+ "go": "folds" | "highlights" | "indents" | "injections" | "locals" | "tags";
45
+ "godot_resource": "folds" | "highlights" | "injections" | "locals";
46
+ "graphql": "highlights" | "indents" | "injections";
47
+ "groovy": "folds" | "highlights" | "indents" | "injections" | "locals";
48
+ "haskell": "folds" | "highlights" | "injections" | "locals";
49
+ "hcl": "folds" | "highlights" | "indents" | "injections";
50
+ "html": "folds" | "highlights" | "indents" | "injections" | "locals";
51
+ "ini": "folds" | "highlights" | "injections";
52
+ "java": "folds" | "highlights" | "indents" | "injections" | "locals" | "tags";
53
+ "javascript": "folds" | "highlights" | "highlights-jsx" | "highlights-params" | "indents" | "injections" | "locals" | "tags";
54
+ "json": "folds" | "highlights" | "indents" | "injections" | "locals";
55
+ "julia": "folds" | "highlights" | "indents" | "injections" | "locals";
56
+ "kdl": "folds" | "highlights" | "indents" | "injections" | "locals";
57
+ "kotlin": "folds" | "highlights" | "injections" | "locals";
58
+ "liquid": "highlights" | "injections";
59
+ "lua": "folds" | "highlights" | "indents" | "injections" | "locals" | "tags";
60
+ "markdown": "folds" | "highlights" | "indents" | "injections";
61
+ "markdown_inline": "highlights" | "injections";
62
+ "matlab": "folds" | "highlights" | "indents" | "injections" | "locals";
63
+ "nim": "folds" | "highlights" | "injections" | "locals";
64
+ "nix": "folds" | "highlights" | "indents" | "injections" | "locals" | "tags";
65
+ "objc": "folds" | "highlights" | "indents" | "injections" | "locals";
66
+ "ocaml": "folds" | "highlights" | "indents" | "injections" | "locals" | "tags";
67
+ "ocaml_interface": "folds" | "highlights" | "indents" | "injections" | "locals" | "tags";
68
+ "ocaml_type": "highlights" | "locals" | "tags";
69
+ "perl": "folds" | "highlights" | "injections" | "matchup";
70
+ "php": "folds" | "highlights" | "indents" | "injections" | "injections-text" | "locals" | "tags";
71
+ "php_only": "folds" | "highlights" | "indents" | "injections" | "injections-text" | "locals" | "tags";
72
+ "prisma": "folds" | "highlights" | "injections";
73
+ "psv": "highlights";
74
+ "python": "folds" | "highlights" | "indents" | "injections" | "locals" | "tags";
75
+ "qmljs": "folds" | "highlights" | "injections" | "locals";
76
+ "query": "folds" | "highlights" | "indents" | "injections" | "locals";
77
+ "r": "highlights" | "indents" | "injections" | "locals" | "tags";
78
+ "racket": "folds" | "highlights" | "injections" | "locals" | "tags";
79
+ "regex": "highlights";
80
+ "ruby": "folds" | "highlights" | "indents" | "injections" | "locals" | "tags";
81
+ "rust": "folds" | "highlights" | "indents" | "injections" | "locals" | "tags";
82
+ "scala": "folds" | "highlights" | "indents" | "injections" | "locals" | "tags";
83
+ "scheme": "folds" | "highlights" | "injections";
84
+ "scss": "folds" | "highlights" | "indents" | "injections";
85
+ "solidity": "folds" | "highlights" | "highlights-nvim" | "injections" | "locals" | "tags";
86
+ "sql": "folds" | "highlights" | "indents" | "injections";
87
+ "swift": "folds" | "highlights" | "indents" | "injections" | "locals" | "outline" | "tags" | "textobjects";
88
+ "terraform": "folds" | "highlights" | "indents" | "injections";
89
+ "toml": "folds" | "highlights" | "indents" | "injections" | "locals";
90
+ "tsv": "highlights";
91
+ "tsx": "folds" | "highlights" | "indents" | "injections" | "locals" | "tags";
92
+ "typescript": "folds" | "highlights" | "indents" | "injections" | "locals" | "tags";
93
+ "vimdoc": "highlights" | "injections";
94
+ "vue": "folds" | "highlights" | "indents" | "injections";
95
+ "xml": "folds" | "highlights" | "indents" | "injections" | "locals";
96
+ "yaml": "folds" | "highlights" | "indents" | "injections" | "locals";
97
+ "zig": "folds" | "highlights" | "indents" | "injections" | "locals";
98
+ };
9
99
 
10
100
  /** Supported language identifiers compiled during build step */
11
- export type SupportedLanguage =
12
-     | "angular"
13
-     | "asm"
14
-     | "astro"
15
-     | "bash"
16
-     | "c"
17
-     | "c-sharp"
18
-     | "clojure"
19
-     | "cmake"
20
-     | "comment"
21
-     | "commonlisp"
22
-     | "cpp"
23
-     | "css"
24
-     | "csv"
25
-     | "csv-psv"
26
-     | "csv-tsv"
27
-     | "dart"
28
-     | "diff"
29
-     | "dockerfile"
30
-     | "dtd"
31
-     | "editorconfig"
32
-     | "elisp"
33
-     | "elixir"
34
-     | "elm"
35
-     | "embedded-template"
36
-     | "erlang"
37
-     | "fish"
38
-     | "gdscript"
39
-     | "gdshader"
40
-     | "git-config"
41
-     | "git-rebase"
42
-     | "gitattributes"
43
-     | "gitignore"
44
-     | "go"
45
-     | "godot-resource"
46
-     | "graphql"
47
-     | "groovy"
48
-     | "haskell"
49
-     | "hcl"
50
-     | "html"
51
-     | "ini"
52
-     | "java"
53
-     | "javascript"
54
-     | "json"
55
-     | "julia"
56
-     | "kotlin"
57
-     | "lua"
58
-     | "markdown"
59
-     | "markdown-inline"
60
-     | "matlab"
61
-     | "nim"
62
-     | "nix"
63
-     | "objc"
64
-     | "ocaml"
65
-     | "ocaml-interface"
66
-     | "ocaml-type"
67
-     | "perl"
68
-     | "php"
69
-     | "php-only"
70
-     | "prisma"
71
-     | "python"
72
-     | "qmljs"
73
-     | "query"
74
-     | "r"
75
-     | "racket"
76
-     | "regex"
77
-     | "ruby"
78
-     | "rust"
79
-     | "scala"
80
-     | "scheme"
81
-     | "scss"
82
-     | "sql"
83
-     | "swift"
84
-     | "terraform"
85
-     | "toml"
86
-     | "tsx"
87
-     | "typescript"
88
-     | "vim"
89
-     | "vimdoc"
90
-     | "vue"
91
-     | "xml"
92
-     | "yaml"
93
-     | "zig";
101
+ export type SupportedLanguage = keyof QueryMap;
94
102
 
95
103
  /** Resolves the absolute path to a specific language's WASM file. */
96
104
  export declare function getWasmPath(lang: SupportedLanguage): string;
97
105
 
98
106
  /** Resolves the absolute path to a specific language's query file. */
99
- export declare function getQueryPath(
100
-     lang: SupportedLanguage,
101
-     query: TreeSitterQuery,
107
+ export declare function getQueryPath<L extends SupportedLanguage>(
108
+ lang: L,
109
+ query: QueryMap[L],
102
110
  ): string;
111
+
112
+ /** Returns an object mapping available query types to their absolute file paths. */
113
+ export declare function getAvailableQueries<L extends SupportedLanguage>(
114
+ lang: L,
115
+ ): Record<QueryMap[L], string>;
package/index.js CHANGED
@@ -1,5 +1,11 @@
1
+ import fs from "node:fs";
1
2
  import { fileURLToPath } from "node:url";
2
3
 
4
+ const manifestUrl = new URL("./manifest.json", import.meta.url);
5
+ const manifest = JSON.parse(
6
+ fs.readFileSync(fileURLToPath(manifestUrl), "utf8"),
7
+ );
8
+
3
9
  /**
4
10
  * Resolves the absolute path to a specific language's WASM file.
5
11
  *
@@ -25,3 +31,18 @@ export function getQueryPath(lang, query) {
25
31
  const url = new URL(`./out/${lang}/${query}.scm`, import.meta.url);
26
32
  return fileURLToPath(url);
27
33
  }
34
+
35
+ /**
36
+ * Returns an object mapping available query types to their absolute file paths.
37
+ *
38
+ * @param {string} lang
39
+ * @returns {Record<string, string>}
40
+ */
41
+ export function getAvailableQueries(lang) {
42
+ const queries = manifest[lang] || [];
43
+ const result = {};
44
+ for (const query of queries) {
45
+ result[query] = getQueryPath(lang, query);
46
+ }
47
+ return result;
48
+ }