0sec-cli 0.18.0 → 0.22.0

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 (329) hide show
  1. package/{0sec.js → 0.js} +90 -82
  2. package/LICENSE +1 -1
  3. package/README.md +62 -46
  4. package/chunks/adapt-loop-7I57LXXR.js +18 -0
  5. package/chunks/{adgraph-JLGA6RYI.js → adgraph-AUDQTBYA.js} +5 -5
  6. package/chunks/agent/skills/frameworks/entra-id.yaml +2 -2
  7. package/chunks/agent/skills/techniques/assumption-mining.yaml +2 -2
  8. package/chunks/agent/skills/techniques/cve-poc-adaptation.yaml +2 -2
  9. package/chunks/agent/skills/techniques/entra-attack-paths.yaml +1 -1
  10. package/chunks/agent/skills/techniques/kernel-weaponization.yaml +1 -1
  11. package/chunks/agent/skills/techniques/llm-prompt-injection.yaml +2 -2
  12. package/chunks/agent/skills/techniques/npm-ecosystem.yaml +1 -1
  13. package/chunks/agent/skills/techniques/poc-verification.yaml +1 -1
  14. package/chunks/agent/skills/techniques/seedless-depth-review.yaml +20 -38
  15. package/chunks/{artifact-scraper-HQ7HLP6V.js → artifact-scraper-PYZ3RU3O.js} +6 -6
  16. package/chunks/{assumption-mining-5SNIVVDN.js → assumption-mining-MFLF43IR.js} +24 -26
  17. package/chunks/{chunk-7DQEV5QI.js → chunk-23DG5YKS.js} +4 -4
  18. package/chunks/{chunk-UR4ELX2Y.js → chunk-2GV4HQKE.js} +340 -703
  19. package/chunks/{chunk-P6WKNFWX.js → chunk-2OQOQ2FZ.js} +8 -8
  20. package/chunks/{chunk-5G3ZXFBW.js → chunk-2WNCI664.js} +3 -3
  21. package/chunks/{chunk-DW5UWPFY.js → chunk-4VGLO2YS.js} +6 -5
  22. package/chunks/{chunk-KLTNTE2Z.js → chunk-5IBCBQEH.js} +13 -14
  23. package/chunks/{chunk-N7BOUYEV.js → chunk-5MWAG3FT.js} +14 -14
  24. package/chunks/{chunk-OEFNRYI2.js → chunk-6GHSR47F.js} +3 -6
  25. package/chunks/chunk-6YNKRUMC.js +4474 -0
  26. package/chunks/{chunk-6L26OBWI.js → chunk-76KSBWOQ.js} +255 -35
  27. package/chunks/chunk-7DEHG7YT.js +2143 -0
  28. package/chunks/{chunk-AD7WXDH6.js → chunk-7UFUALR2.js} +288 -22
  29. package/chunks/{chunk-53G27VPS.js → chunk-AZ7L3HFD.js} +7 -2
  30. package/chunks/{chunk-TSK2AG6J.js → chunk-CAYANSH6.js} +173 -1757
  31. package/chunks/{chunk-SAFFWQW4.js → chunk-DKSCN2AB.js} +7 -7
  32. package/chunks/{chunk-2JCCA2JL.js → chunk-DM5C5L5D.js} +3 -3
  33. package/chunks/{chunk-RWONANDA.js → chunk-DQTNI3KY.js} +5 -5
  34. package/chunks/{chunk-5JI7L7KV.js → chunk-EGZGZFAH.js} +10036 -12938
  35. package/chunks/{chunk-6LKRLK2R.js → chunk-FHC2B7LN.js} +3 -3
  36. package/chunks/{chunk-MYVT64FN.js → chunk-GHWODZMR.js} +2 -2
  37. package/chunks/{chunk-2RMLOJVB.js → chunk-GVD6SJGH.js} +2 -2
  38. package/chunks/{chunk-SF4KZ4O3.js → chunk-HLFS6WV2.js} +2 -2
  39. package/chunks/chunk-HR2TU42B.js +1228 -0
  40. package/chunks/{chunk-BFRB6HB2.js → chunk-HUNAPTKV.js} +3 -3
  41. package/chunks/chunk-IO7R7WBM.js +114 -0
  42. package/chunks/{chunk-WEBMRWEG.js → chunk-IXT64DV5.js} +656 -1868
  43. package/chunks/{chunk-3MOLBTLS.js → chunk-K2PWUPUI.js} +2 -2
  44. package/chunks/{chunk-WXQ6BJ6A.js → chunk-LCRTAQN2.js} +7 -7
  45. package/chunks/{chunk-SVJEDVYK.js → chunk-LPTRPRZR.js} +5 -5
  46. package/chunks/{chunk-CMKXP5RR.js → chunk-LYUAM3TG.js} +3 -3
  47. package/chunks/{chunk-BVAZO4WA.js → chunk-MICHDTBK.js} +3 -3
  48. package/chunks/{chunk-UCYRA73C.js → chunk-OAYUPGF6.js} +4 -4
  49. package/chunks/{chunk-XM5NLHYU.js → chunk-OWLJYJ5O.js} +14 -14
  50. package/chunks/{chunk-BKZFDZ23.js → chunk-QCUFBVIZ.js} +3 -3
  51. package/chunks/chunk-RE5EZDG2.js +5523 -0
  52. package/chunks/{chunk-ASUR522M.js → chunk-RRD4XXPU.js} +9 -9
  53. package/chunks/{chunk-AHTBZC3E.js → chunk-RSIUX3RW.js} +4 -4
  54. package/chunks/{chunk-BZNEY2ZS.js → chunk-SJBCK2EI.js} +15268 -16053
  55. package/chunks/{chunk-IOL7D5YV.js → chunk-SQCBHFWN.js} +3 -3
  56. package/chunks/chunk-TH2LW437.js +7829 -0
  57. package/chunks/{chunk-WVTBZEQO.js → chunk-TM74SSHC.js} +8 -8
  58. package/chunks/{chunk-U5FLXGHT.js → chunk-TO35Y326.js} +13 -729
  59. package/chunks/chunk-TRH2PJSN.js +547 -0
  60. package/chunks/{chunk-YYRBQVFE.js → chunk-TZFIAMWZ.js} +70 -16
  61. package/chunks/chunk-UELXHK2Y.js +1950 -0
  62. package/chunks/{chunk-RJWOYEOG.js → chunk-UEX7PFSE.js} +5 -5
  63. package/chunks/{chunk-VQG4FT5D.js → chunk-UFHN6RIU.js} +2 -2
  64. package/chunks/{chunk-JQHOLLTD.js → chunk-UU7PQP6N.js} +9 -9
  65. package/chunks/{chunk-BFR2CDV5.js → chunk-UV5QWZGE.js} +283 -153
  66. package/chunks/{chunk-WU6AFRAZ.js → chunk-V36HVTUL.js} +12 -12
  67. package/chunks/{chunk-IR537GON.js → chunk-VCSFCHAJ.js} +2 -2
  68. package/chunks/{chunk-YLMN3N25.js → chunk-VIT5ALXF.js} +3 -3
  69. package/chunks/{chunk-BATRQBOR.js → chunk-VMRRNRMR.js} +41 -41
  70. package/chunks/{chunk-72CISA2D.js → chunk-VNRY6AWF.js} +89 -41
  71. package/chunks/chunk-W6UWZFKL.js +298 -0
  72. package/chunks/{chunk-3KPWWJCI.js → chunk-XFCTUKXR.js} +88 -88
  73. package/chunks/{chunk-GMT2AZKM.js → chunk-YIQSGNAA.js} +897 -130
  74. package/chunks/codex-models-7TLJSY3L.js +17 -0
  75. package/chunks/{commands-TBC2F5CE.js → commands-NEI7L3QA.js} +2836 -1424
  76. package/chunks/corpus-v1.json +2 -2
  77. package/chunks/data/appsec-archetypes.json +2 -2
  78. package/chunks/data/chromium-archetypes.json +1 -1
  79. package/chunks/data/freebsd-archetypes.json +1 -1
  80. package/chunks/data/kernel-archetypes.json +2 -2
  81. package/chunks/db-5AP3JB4W.js +16 -0
  82. package/chunks/{disclose-EKTWSCGW.js → disclose-LDNKAVRH.js} +13 -11
  83. package/chunks/{dist-4YICS2J2.js → dist-3FNZIBB4.js} +394 -404
  84. package/chunks/{dist-4MAW5X6L.js → dist-5YHYNLI3.js} +6 -6
  85. package/chunks/{dist-FMGSR3DW.js → dist-DD4H6HMQ.js} +13 -5
  86. package/chunks/dist-KEULE5IQ.js +21914 -0
  87. package/chunks/dist-XZB53PS5.js +53 -0
  88. package/chunks/eval-runner-43BO2C4T.js +26 -0
  89. package/chunks/example-manifest.json +2 -2
  90. package/chunks/{exploit-agent-45YQOHPJ.js → exploit-agent-N4A5ELBK.js} +4 -4
  91. package/chunks/{exploit-autoclimb-UZGEMGYT.js → exploit-autoclimb-N7P6KIF5.js} +6 -6
  92. package/chunks/{exploit-climb-SG23KB2G.js → exploit-climb-WNEJUB5W.js} +12 -12
  93. package/chunks/fix-Z452M4EC.js +26 -0
  94. package/chunks/{github-issues-MJ6OYOOU.js → github-issues-IGTTWM7V.js} +7 -7
  95. package/chunks/harness-QJJJVSG4.js +22 -0
  96. package/chunks/http-conformance-U5F6GKYG.js +11 -0
  97. package/chunks/http-sender-I5XFFY35.js +10 -0
  98. package/chunks/hunt-scan-K6D2V3PX.js +36 -0
  99. package/chunks/{identity-6ZAIIWOR.js → identity-62SVRW4H.js} +5 -5
  100. package/chunks/{kernel-primitive-7U6CWHXD.js → kernel-primitive-TKUACPKD.js} +6 -6
  101. package/chunks/{kernel-vm-runner-3JAU4O6J.js → kernel-vm-runner-RAAO2PGT.js} +6 -6
  102. package/chunks/memsafety-scan-FCPAXIZE.js +16 -0
  103. package/chunks/{native-loop-RJCJPOUS.js → native-loop-2ZRJENZ3.js} +17 -18
  104. package/chunks/{npm-detectors-KB5Y5ZFX.js → npm-detectors-Z2ZIQCN4.js} +6 -6
  105. package/chunks/npm-dynamic-discovery-5J7FT3XM.js +13 -0
  106. package/chunks/orchestrate-2GWGNTBF.js +58 -0
  107. package/chunks/{pre-recon-cve-66EB6G4M.js → pre-recon-cve-X2K2P5YQ.js} +4 -4
  108. package/chunks/prepare-KYHGFWCJ.js +13 -0
  109. package/chunks/process-N245QIQG.js +12 -0
  110. package/chunks/{run-D56MPDKY.js → run-U3XU4CTC.js} +11507 -13632
  111. package/chunks/{runtime-G7YWIO3B.js → runtime-G75TEWQY.js} +10 -11
  112. package/chunks/runtime-XFWJTBUO.js +12 -0
  113. package/chunks/{scan-stream-FHI2FYZE.js → scan-stream-BMOCPKQX.js} +7 -7
  114. package/chunks/scope-WXI46UHJ.js +21 -0
  115. package/chunks/{session-store-GZ4A4KYT.js → session-store-27L3ZU73.js} +6 -6
  116. package/chunks/source-files-REHOM44I.js +12 -0
  117. package/chunks/{specdrift-WCLH6TTQ.js → specdrift-AFS54WEJ.js} +5 -5
  118. package/chunks/token-KRWP5JYA.js +72 -0
  119. package/chunks/token-util-DWTL33S3.js +8 -0
  120. package/chunks/variant-candidates-YWZORZMK.js +13 -0
  121. package/chunks/{web-recon-prepass-JJGPEOLE.js → web-recon-prepass-YVMFXCIK.js} +9 -9
  122. package/cli-path-traversal-fixture.js +352 -0
  123. package/dashboard/assets/bot-Bg1Tp9_d.js +1 -0
  124. package/dashboard/assets/dist-B_dDCPbu.js +1 -0
  125. package/dashboard/assets/findings-page-mayGhNx6.js +5 -0
  126. package/dashboard/assets/format--susmHX7.js +1 -0
  127. package/dashboard/assets/input-TuVPR3Zl.js +1 -0
  128. package/dashboard/assets/jsx-runtime-MGseXjj5.js +3 -0
  129. package/dashboard/assets/live-page-HWWHX99U.js +1 -0
  130. package/dashboard/assets/meta-tile-ckHo-w7k.js +1 -0
  131. package/dashboard/assets/operations-BxZ0OoXO.js +10 -0
  132. package/dashboard/assets/operations-CMFVrXEe.css +2 -0
  133. package/dashboard/assets/operations-app-D3d35rgo.js +46 -0
  134. package/dashboard/assets/overview-page-W_4IteEr.js +1 -0
  135. package/dashboard/assets/page-header-Bw9AJgBV.js +1 -0
  136. package/dashboard/assets/scans-page-CgzVXHnn.js +1 -0
  137. package/dashboard/assets/siren-KQj8QAnJ.js +1 -0
  138. package/dashboard/assets/table-8EDklulN.js +1 -0
  139. package/dashboard/assets/tabs-CFHPOwg8.js +1 -0
  140. package/dashboard/index.html +4 -5
  141. package/node_modules/node-addon-api/LICENSE.md +9 -0
  142. package/node_modules/node-addon-api/README.md +95 -0
  143. package/node_modules/node-addon-api/common.gypi +21 -0
  144. package/node_modules/node-addon-api/except.gypi +25 -0
  145. package/node_modules/node-addon-api/index.js +14 -0
  146. package/node_modules/node-addon-api/napi-inl.deprecated.h +186 -0
  147. package/node_modules/node-addon-api/napi-inl.h +7250 -0
  148. package/node_modules/node-addon-api/napi.h +3463 -0
  149. package/node_modules/node-addon-api/node_addon_api.gyp +42 -0
  150. package/node_modules/node-addon-api/node_api.gyp +9 -0
  151. package/node_modules/node-addon-api/noexcept.gypi +26 -0
  152. package/node_modules/node-addon-api/nothing.c +0 -0
  153. package/node_modules/node-addon-api/package-support.json +21 -0
  154. package/node_modules/node-addon-api/package.json +481 -0
  155. package/node_modules/node-addon-api/tools/README.md +73 -0
  156. package/node_modules/node-addon-api/tools/check-napi.js +99 -0
  157. package/node_modules/node-addon-api/tools/clang-format.js +71 -0
  158. package/node_modules/node-addon-api/tools/conversion.js +301 -0
  159. package/node_modules/node-gyp-build/LICENSE +21 -0
  160. package/node_modules/node-gyp-build/README.md +58 -0
  161. package/node_modules/node-gyp-build/SECURITY.md +5 -0
  162. package/node_modules/node-gyp-build/bin.js +84 -0
  163. package/node_modules/node-gyp-build/build-test.js +19 -0
  164. package/node_modules/node-gyp-build/index.js +6 -0
  165. package/node_modules/node-gyp-build/node-gyp-build.js +207 -0
  166. package/node_modules/node-gyp-build/optional.js +7 -0
  167. package/node_modules/node-gyp-build/package.json +43 -0
  168. package/node_modules/tree-sitter/LICENSE +21 -0
  169. package/node_modules/tree-sitter/README.md +90 -0
  170. package/node_modules/tree-sitter/binding.gyp +76 -0
  171. package/node_modules/tree-sitter/index.js +895 -0
  172. package/node_modules/tree-sitter/package.json +62 -0
  173. package/node_modules/tree-sitter/prebuilds/darwin-arm64/tree-sitter.node +0 -0
  174. package/node_modules/tree-sitter/prebuilds/darwin-x64/tree-sitter.node +0 -0
  175. package/node_modules/tree-sitter/prebuilds/linux-x64/tree-sitter.node +0 -0
  176. package/node_modules/tree-sitter/prebuilds/win32-x64/tree-sitter.node +0 -0
  177. package/node_modules/tree-sitter/src/addon_data.h +47 -0
  178. package/node_modules/tree-sitter/src/binding.cc +35 -0
  179. package/node_modules/tree-sitter/src/conversions.cc +140 -0
  180. package/node_modules/tree-sitter/src/conversions.h +22 -0
  181. package/node_modules/tree-sitter/src/language.cc +106 -0
  182. package/node_modules/tree-sitter/src/language.h +17 -0
  183. package/node_modules/tree-sitter/src/logger.cc +70 -0
  184. package/node_modules/tree-sitter/src/logger.h +19 -0
  185. package/node_modules/tree-sitter/src/lookaheaditerator.cc +122 -0
  186. package/node_modules/tree-sitter/src/lookaheaditerator.h +33 -0
  187. package/node_modules/tree-sitter/src/node.cc +1056 -0
  188. package/node_modules/tree-sitter/src/node.h +30 -0
  189. package/node_modules/tree-sitter/src/parser.cc +298 -0
  190. package/node_modules/tree-sitter/src/parser.h +35 -0
  191. package/node_modules/tree-sitter/src/query.cc +383 -0
  192. package/node_modules/tree-sitter/src/query.h +39 -0
  193. package/node_modules/tree-sitter/src/tree.cc +307 -0
  194. package/node_modules/tree-sitter/src/tree.h +45 -0
  195. package/node_modules/tree-sitter/src/tree_cursor.cc +213 -0
  196. package/node_modules/tree-sitter/src/tree_cursor.h +52 -0
  197. package/node_modules/tree-sitter/tree-sitter.d.ts +211 -0
  198. package/node_modules/tree-sitter/vendor/tree-sitter/LICENSE +21 -0
  199. package/node_modules/tree-sitter/vendor/tree-sitter/README.md +21 -0
  200. package/node_modules/tree-sitter/vendor/tree-sitter/lib/README.md +6 -0
  201. package/node_modules/tree-sitter/vendor/tree-sitter/lib/include/tree_sitter/api.h +1266 -0
  202. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/alloc.c +48 -0
  203. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/alloc.h +41 -0
  204. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/array.h +290 -0
  205. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/atomic.h +68 -0
  206. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/clock.h +146 -0
  207. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/error_costs.h +11 -0
  208. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/get_changed_ranges.c +501 -0
  209. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/get_changed_ranges.h +36 -0
  210. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/host.h +21 -0
  211. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/language.c +221 -0
  212. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/language.h +299 -0
  213. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/length.h +52 -0
  214. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/lexer.c +419 -0
  215. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/lexer.h +49 -0
  216. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/lib.c +14 -0
  217. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/node.c +774 -0
  218. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/parser.c +2151 -0
  219. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/parser.h +230 -0
  220. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/point.h +62 -0
  221. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/query.c +4134 -0
  222. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/reduce_action.h +34 -0
  223. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/reusable_node.h +95 -0
  224. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/stack.c +899 -0
  225. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/stack.h +133 -0
  226. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/subtree.c +1060 -0
  227. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/subtree.h +382 -0
  228. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/tree.c +165 -0
  229. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/tree.h +31 -0
  230. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/tree_cursor.c +714 -0
  231. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/tree_cursor.h +48 -0
  232. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/unicode/ICU_SHA +1 -0
  233. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/unicode/LICENSE +414 -0
  234. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/unicode/README.md +29 -0
  235. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/unicode/ptypes.h +1 -0
  236. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/unicode/umachine.h +448 -0
  237. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/unicode/urename.h +1 -0
  238. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/unicode/utf.h +1 -0
  239. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/unicode/utf16.h +733 -0
  240. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/unicode/utf8.h +881 -0
  241. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/unicode.h +50 -0
  242. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/wasm/stdlib-symbols.txt +23 -0
  243. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/wasm/stdlib.c +109 -0
  244. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/wasm/wasm-stdlib.h +1294 -0
  245. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/wasm_store.c +1823 -0
  246. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/wasm_store.h +31 -0
  247. package/node_modules/tree-sitter/vendor/tree-sitter/test/fixtures/grammars/.gitkeep +0 -0
  248. package/node_modules/tree-sitter-c/LICENSE +21 -0
  249. package/node_modules/tree-sitter-c/README.md +18 -0
  250. package/node_modules/tree-sitter-c/binding.gyp +20 -0
  251. package/node_modules/tree-sitter-c/bindings/node/binding.cc +20 -0
  252. package/node_modules/tree-sitter-c/bindings/node/index.d.ts +28 -0
  253. package/node_modules/tree-sitter-c/bindings/node/index.js +7 -0
  254. package/node_modules/tree-sitter-c/grammar.js +1463 -0
  255. package/node_modules/tree-sitter-c/package.json +108 -0
  256. package/node_modules/tree-sitter-c/prebuilds/darwin-arm64/tree-sitter-c.node +0 -0
  257. package/node_modules/tree-sitter-c/prebuilds/darwin-x64/tree-sitter-c.node +0 -0
  258. package/node_modules/tree-sitter-c/prebuilds/linux-x64/tree-sitter-c.node +0 -0
  259. package/node_modules/tree-sitter-c/prebuilds/win32-x64/tree-sitter-c.node +0 -0
  260. package/node_modules/tree-sitter-c/queries/highlights.scm +81 -0
  261. package/node_modules/tree-sitter-c/queries/tags.scm +9 -0
  262. package/node_modules/tree-sitter-c/src/grammar.json +9682 -0
  263. package/node_modules/tree-sitter-c/src/node-types.json +4556 -0
  264. package/node_modules/tree-sitter-c/src/parser.c +113852 -0
  265. package/node_modules/tree-sitter-c/src/tree_sitter/alloc.h +54 -0
  266. package/node_modules/tree-sitter-c/src/tree_sitter/array.h +290 -0
  267. package/node_modules/tree-sitter-c/src/tree_sitter/parser.h +265 -0
  268. package/package.json +20 -13
  269. package/vendor/tree-sitter-0.21.1-node24.json +16 -0
  270. package/vendor/tree-sitter-0.21.1-node24.tgz +0 -0
  271. package/chunks/adapt-loop-SMH6V4PD.js +0 -18
  272. package/chunks/appsec-catalog-CBWHGTEL.js +0 -24
  273. package/chunks/chunk-242TMK6G.js +0 -110
  274. package/chunks/chunk-57ZENEX2.js +0 -169
  275. package/chunks/chunk-ADOLI6DT.js +0 -102
  276. package/chunks/chunk-ATATQACO.js +0 -471
  277. package/chunks/chunk-C2WXWFBB.js +0 -1070
  278. package/chunks/chunk-F3WBKITT.js +0 -687
  279. package/chunks/chunk-H2FFLZNK.js +0 -3
  280. package/chunks/chunk-LP3HHYQU.js +0 -245
  281. package/chunks/chunk-QI233I24.js +0 -333
  282. package/chunks/chunk-RRMJC3ZE.js +0 -105
  283. package/chunks/chunk-Z5FA2XOX.js +0 -2798
  284. package/chunks/cost-ledger-NU63MYZM.js +0 -13
  285. package/chunks/db-KFWOAUUB.js +0 -16
  286. package/chunks/eval-runner-7ZF472KV.js +0 -27
  287. package/chunks/fix-IG7LYXH3.js +0 -12
  288. package/chunks/harness-7ODOLOWU.js +0 -22
  289. package/chunks/http-conformance-DU66MZIU.js +0 -11
  290. package/chunks/http-sender-GWH2IYEA.js +0 -10
  291. package/chunks/hunt-scan-MMKUOETU.js +0 -38
  292. package/chunks/memsafety-scan-J7SECV5W.js +0 -16
  293. package/chunks/npm-dynamic-discovery-AHROOZDB.js +0 -13
  294. package/chunks/orchestrate-OC2VZN2X.js +0 -62
  295. package/chunks/pipeline-BZK5BLJR.js +0 -14
  296. package/chunks/prepare-MYY743TK.js +0 -13
  297. package/chunks/process-LQRCS5OY.js +0 -13
  298. package/chunks/replay-runner-45G3VU7X.js +0 -39
  299. package/chunks/runtime-J7PLXZNM.js +0 -12
  300. package/chunks/scope-BI7BF4ZY.js +0 -18
  301. package/chunks/source-files-PWRQR6LY.js +0 -12
  302. package/chunks/variant-candidates-YERCYMPD.js +0 -13
  303. package/dashboard/assets/0sec-icon-66SreztZ.gif +0 -0
  304. package/dashboard/assets/bot-yILPnRgD.js +0 -1
  305. package/dashboard/assets/chevron-down-BeDJ-Vka.js +0 -1
  306. package/dashboard/assets/circle-alert-BEnMBMT-.js +0 -1
  307. package/dashboard/assets/client-DRYsuOGl.js +0 -9
  308. package/dashboard/assets/copy-Bi5vzoF9.js +0 -1
  309. package/dashboard/assets/desktop-CXTQonNm.js +0 -32
  310. package/dashboard/assets/desktop-NOekk4QS.css +0 -1
  311. package/dashboard/assets/dist-CmX-h7a4.js +0 -1
  312. package/dashboard/assets/dist-DAwYQmf_.js +0 -45
  313. package/dashboard/assets/findings-page-CACW9nw2.js +0 -5
  314. package/dashboard/assets/format-PoISqsES.js +0 -1
  315. package/dashboard/assets/jsx-runtime-C7oxC63R.js +0 -1
  316. package/dashboard/assets/live-page-DrgQqQK5.js +0 -1
  317. package/dashboard/assets/meta-tile-CcskIV_o.js +0 -1
  318. package/dashboard/assets/operations-BKE8T-vY.css +0 -2
  319. package/dashboard/assets/operations-D8nUP5_m.js +0 -4
  320. package/dashboard/assets/operations-app-CQQhG54n.js +0 -2
  321. package/dashboard/assets/overview-page-DTGS8dPo.js +0 -1
  322. package/dashboard/assets/page-header-MFVvEtZW.js +0 -1
  323. package/dashboard/assets/play-Dwo-9xt6.js +0 -1
  324. package/dashboard/assets/scans-page-ChVtq8Us.js +0 -1
  325. package/dashboard/assets/search-CiooTLck.js +0 -1
  326. package/dashboard/assets/siren-CCBwTSuk.js +0 -1
  327. package/dashboard/assets/table-BYS-nIVA.js +0 -1
  328. package/dashboard/assets/tabs-DivxbhQy.js +0 -1
  329. package/dashboard/desktop.html +0 -21
@@ -0,0 +1,895 @@
1
+ const binding = require('node-gyp-build')(__dirname);
2
+ const {Query, Parser, NodeMethods, Tree, TreeCursor, LookaheadIterator} = binding;
3
+
4
+ const util = require('util');
5
+
6
+ /*
7
+ * Tree
8
+ */
9
+
10
+ const {rootNode, rootNodeWithOffset, edit} = Tree.prototype;
11
+
12
+ Object.defineProperty(Tree.prototype, 'rootNode', {
13
+ get() {
14
+ /*
15
+ Due to a race condition arising from Jest's worker pool, "this"
16
+ has no knowledge of the native extension if the extension has not
17
+ yet loaded when multiple Jest tests are being run simultaneously.
18
+ If the extension has correctly loaded, "this" should be an instance
19
+ of the class whose prototype we are acting on (in this case, Tree).
20
+ Furthermore, the race condition sometimes results in the function in
21
+ question being undefined even when the context is correct, so we also
22
+ perform a null function check.
23
+ */
24
+ if (this instanceof Tree && rootNode) {
25
+ return unmarshalNode(rootNode.call(this), this);
26
+ }
27
+ },
28
+ // Jest worker pool may attempt to override property due to race condition,
29
+ // we don't want to error on this
30
+ configurable: true
31
+ });
32
+
33
+ Tree.prototype.rootNodeWithOffset = function(offset_bytes, offset_extent) {
34
+ return unmarshalNode(rootNodeWithOffset.call(this, offset_bytes, offset_extent.row, offset_extent.column), this);
35
+ }
36
+
37
+ Tree.prototype.edit = function(arg) {
38
+ if (this instanceof Tree && edit) {
39
+ edit.call(
40
+ this,
41
+ arg.startPosition.row, arg.startPosition.column,
42
+ arg.oldEndPosition.row, arg.oldEndPosition.column,
43
+ arg.newEndPosition.row, arg.newEndPosition.column,
44
+ arg.startIndex,
45
+ arg.oldEndIndex,
46
+ arg.newEndIndex
47
+ );
48
+ }
49
+ };
50
+
51
+ Tree.prototype.walk = function() {
52
+ return this.rootNode.walk()
53
+ };
54
+
55
+ /*
56
+ * Node
57
+ */
58
+
59
+ class SyntaxNode {
60
+ constructor(tree) {
61
+ this.tree = tree;
62
+ }
63
+
64
+ [util.inspect.custom]() {
65
+ return this.constructor.name + ' {\n' +
66
+ ' type: ' + this.type + ',\n' +
67
+ ' startPosition: ' + pointToString(this.startPosition) + ',\n' +
68
+ ' endPosition: ' + pointToString(this.endPosition) + ',\n' +
69
+ ' childCount: ' + this.childCount + ',\n' +
70
+ '}'
71
+ }
72
+
73
+ get id() {
74
+ marshalNode(this);
75
+ return NodeMethods.id(this.tree);
76
+ }
77
+
78
+ get typeId() {
79
+ marshalNode(this);
80
+ return NodeMethods.typeId(this.tree);
81
+ }
82
+
83
+ get grammarId() {
84
+ marshalNode(this);
85
+ return NodeMethods.grammarId(this.tree);
86
+ }
87
+
88
+ get type() {
89
+ marshalNode(this);
90
+ return NodeMethods.type(this.tree);
91
+ }
92
+
93
+ get grammarType() {
94
+ marshalNode(this);
95
+ return NodeMethods.grammarType(this.tree);
96
+ }
97
+
98
+ get isExtra() {
99
+ marshalNode(this);
100
+ return NodeMethods.isExtra(this.tree);
101
+ }
102
+
103
+ get isNamed() {
104
+ marshalNode(this);
105
+ return NodeMethods.isNamed(this.tree);
106
+ }
107
+
108
+ get isMissing() {
109
+ marshalNode(this);
110
+ return NodeMethods.isMissing(this.tree);
111
+ }
112
+
113
+ get hasChanges() {
114
+ marshalNode(this);
115
+ return NodeMethods.hasChanges(this.tree);
116
+ }
117
+
118
+ get hasError() {
119
+ marshalNode(this);
120
+ return NodeMethods.hasError(this.tree);
121
+ }
122
+
123
+ get isError() {
124
+ marshalNode(this);
125
+ return NodeMethods.isError(this.tree);
126
+ }
127
+
128
+ get text() {
129
+ return this.tree.getText(this);
130
+ }
131
+
132
+ get startPosition() {
133
+ marshalNode(this);
134
+ NodeMethods.startPosition(this.tree);
135
+ return unmarshalPoint();
136
+ }
137
+
138
+ get endPosition() {
139
+ marshalNode(this);
140
+ NodeMethods.endPosition(this.tree);
141
+ return unmarshalPoint();
142
+ }
143
+
144
+ get startIndex() {
145
+ marshalNode(this);
146
+ return NodeMethods.startIndex(this.tree);
147
+ }
148
+
149
+ get endIndex() {
150
+ marshalNode(this);
151
+ return NodeMethods.endIndex(this.tree);
152
+ }
153
+
154
+ get parent() {
155
+ marshalNode(this);
156
+ return unmarshalNode(NodeMethods.parent(this.tree), this.tree);
157
+ }
158
+
159
+ get children() {
160
+ marshalNode(this);
161
+ return unmarshalNodes(NodeMethods.children(this.tree), this.tree);
162
+ }
163
+
164
+ get namedChildren() {
165
+ marshalNode(this);
166
+ return unmarshalNodes(NodeMethods.namedChildren(this.tree), this.tree);
167
+ }
168
+
169
+ get childCount() {
170
+ marshalNode(this);
171
+ return NodeMethods.childCount(this.tree);
172
+ }
173
+
174
+ get namedChildCount() {
175
+ marshalNode(this);
176
+ return NodeMethods.namedChildCount(this.tree);
177
+ }
178
+
179
+ get firstChild() {
180
+ marshalNode(this);
181
+ return unmarshalNode(NodeMethods.firstChild(this.tree), this.tree);
182
+ }
183
+
184
+ get firstNamedChild() {
185
+ marshalNode(this);
186
+ return unmarshalNode(NodeMethods.firstNamedChild(this.tree), this.tree);
187
+ }
188
+
189
+ get lastChild() {
190
+ marshalNode(this);
191
+ return unmarshalNode(NodeMethods.lastChild(this.tree), this.tree);
192
+ }
193
+
194
+ get lastNamedChild() {
195
+ marshalNode(this);
196
+ return unmarshalNode(NodeMethods.lastNamedChild(this.tree), this.tree);
197
+ }
198
+
199
+ get nextSibling() {
200
+ marshalNode(this);
201
+ return unmarshalNode(NodeMethods.nextSibling(this.tree), this.tree);
202
+ }
203
+
204
+ get nextNamedSibling() {
205
+ marshalNode(this);
206
+ return unmarshalNode(NodeMethods.nextNamedSibling(this.tree), this.tree);
207
+ }
208
+
209
+ get previousSibling() {
210
+ marshalNode(this);
211
+ return unmarshalNode(NodeMethods.previousSibling(this.tree), this.tree);
212
+ }
213
+
214
+ get previousNamedSibling() {
215
+ marshalNode(this);
216
+ return unmarshalNode(NodeMethods.previousNamedSibling(this.tree), this.tree);
217
+ }
218
+
219
+ get parseState() {
220
+ marshalNode(this);
221
+ return NodeMethods.parseState(this.tree);
222
+ }
223
+
224
+ get nextParseState() {
225
+ marshalNode(this);
226
+ return NodeMethods.nextParseState(this.tree);
227
+ }
228
+
229
+ get descendantCount() {
230
+ marshalNode(this);
231
+ return NodeMethods.descendantCount(this.tree);
232
+ }
233
+
234
+ toString() {
235
+ marshalNode(this);
236
+ return NodeMethods.toString(this.tree);
237
+ }
238
+
239
+ child(index) {
240
+ marshalNode(this);
241
+ return unmarshalNode(NodeMethods.child(this.tree, index), this.tree);
242
+ }
243
+
244
+ namedChild(index) {
245
+ marshalNode(this);
246
+ return unmarshalNode(NodeMethods.namedChild(this.tree, index), this.tree);
247
+ }
248
+
249
+ childForFieldName(fieldName) {
250
+ marshalNode(this);
251
+ return unmarshalNode(NodeMethods.childForFieldName(this.tree, fieldName), this.tree);
252
+ }
253
+
254
+ childForFieldId(fieldId) {
255
+ marshalNode(this);
256
+ return unmarshalNode(NodeMethods.childForFieldId(this.tree, fieldId), this.tree);
257
+ }
258
+
259
+ fieldNameForChild(childIndex) {
260
+ marshalNode(this);
261
+ return NodeMethods.fieldNameForChild(this.tree, childIndex);
262
+ }
263
+
264
+ childrenForFieldName(fieldName) {
265
+ marshalNode(this);
266
+ return unmarshalNodes(NodeMethods.childrenForFieldName(this.tree, fieldName), this.tree);
267
+ }
268
+
269
+ childrenForFieldId(fieldId) {
270
+ marshalNode(this);
271
+ return unmarshalNodes(NodeMethods.childrenForFieldId(this.tree, fieldId), this.tree);
272
+ }
273
+
274
+ firstChildForIndex(index) {
275
+ marshalNode(this);
276
+ return unmarshalNode(NodeMethods.firstChildForIndex(this.tree, index), this.tree);
277
+ }
278
+
279
+ firstNamedChildForIndex(index) {
280
+ marshalNode(this);
281
+ return unmarshalNode(NodeMethods.firstNamedChildForIndex(this.tree, index), this.tree);
282
+ }
283
+
284
+ namedDescendantForIndex(start, end) {
285
+ marshalNode(this);
286
+ if (end == null) end = start;
287
+ return unmarshalNode(NodeMethods.namedDescendantForIndex(this.tree, start, end), this.tree);
288
+ }
289
+
290
+ descendantForIndex(start, end) {
291
+ marshalNode(this);
292
+ if (end == null) end = start;
293
+ return unmarshalNode(NodeMethods.descendantForIndex(this.tree, start, end), this.tree);
294
+ }
295
+
296
+ descendantsOfType(types, start, end) {
297
+ marshalNode(this);
298
+ if (typeof types === 'string') types = [types]
299
+ return unmarshalNodes(NodeMethods.descendantsOfType(this.tree, types, start, end), this.tree);
300
+ }
301
+
302
+ namedDescendantForPosition(start, end) {
303
+ marshalNode(this);
304
+ if (end == null) end = start;
305
+ return unmarshalNode(NodeMethods.namedDescendantForPosition(this.tree, start, end), this.tree);
306
+ }
307
+
308
+ descendantForPosition(start, end) {
309
+ marshalNode(this);
310
+ if (end == null) end = start;
311
+ return unmarshalNode(NodeMethods.descendantForPosition(this.tree, start, end), this.tree);
312
+ }
313
+
314
+ closest(types) {
315
+ marshalNode(this);
316
+ if (typeof types === 'string') types = [types]
317
+ return unmarshalNode(NodeMethods.closest(this.tree, types), this.tree);
318
+ }
319
+
320
+ walk () {
321
+ marshalNode(this);
322
+ const cursor = NodeMethods.walk(this.tree);
323
+ cursor.tree = this.tree;
324
+ unmarshalNode(cursor.currentNode, this.tree);
325
+ return cursor;
326
+ }
327
+ }
328
+
329
+ /*
330
+ * Parser
331
+ */
332
+
333
+ const {parse, setLanguage} = Parser.prototype;
334
+ const languageSymbol = Symbol('parser.language');
335
+
336
+ Parser.prototype.setLanguage = function(language) {
337
+ if (this instanceof Parser && setLanguage) {
338
+ setLanguage.call(this, language);
339
+ }
340
+ this[languageSymbol] = language;
341
+ if (!language.nodeSubclasses) {
342
+ initializeLanguageNodeClasses(language)
343
+ }
344
+ return this;
345
+ };
346
+
347
+ Parser.prototype.getLanguage = function(_language) {
348
+ return this[languageSymbol] || null;
349
+ };
350
+
351
+ Parser.prototype.parse = function(input, oldTree, {bufferSize, includedRanges}={}) {
352
+ let getText, treeInput = input
353
+ if (typeof input === 'string') {
354
+ const inputString = input;
355
+ input = (offset, _position) => inputString.slice(offset)
356
+ getText = getTextFromString
357
+ } else {
358
+ getText = getTextFromFunction
359
+ }
360
+ const tree = this instanceof Parser && parse
361
+ ? parse.call(
362
+ this,
363
+ input,
364
+ oldTree,
365
+ bufferSize,
366
+ includedRanges,
367
+ )
368
+ : undefined;
369
+
370
+ if (tree) {
371
+ tree.input = treeInput
372
+ tree.getText = getText
373
+ tree.language = this.getLanguage()
374
+ }
375
+ return tree
376
+ };
377
+
378
+ /*
379
+ * TreeCursor
380
+ */
381
+
382
+ const {startPosition, endPosition, currentNode} = TreeCursor.prototype;
383
+
384
+ Object.defineProperties(TreeCursor.prototype, {
385
+ currentNode: {
386
+ get() {
387
+ if (this instanceof TreeCursor && currentNode) {
388
+ return unmarshalNode(currentNode.call(this), this.tree);
389
+ }
390
+ },
391
+ configurable: true
392
+ },
393
+ startPosition: {
394
+ get() {
395
+ if (this instanceof TreeCursor && startPosition) {
396
+ startPosition.call(this);
397
+ return unmarshalPoint();
398
+ }
399
+ },
400
+ configurable: true
401
+ },
402
+ endPosition: {
403
+ get() {
404
+ if (this instanceof TreeCursor && endPosition) {
405
+ endPosition.call(this);
406
+ return unmarshalPoint();
407
+ }
408
+ },
409
+ configurable: true
410
+ },
411
+ nodeText: {
412
+ get() {
413
+ return this.tree.getText(this)
414
+ },
415
+ configurable: true
416
+ }
417
+ });
418
+
419
+ /*
420
+ * Query
421
+ */
422
+
423
+ const {_matches, _captures} = Query.prototype;
424
+
425
+ const PREDICATE_STEP_TYPE = {
426
+ DONE: 0,
427
+ CAPTURE: 1,
428
+ STRING: 2,
429
+ }
430
+
431
+ const ZERO_POINT = { row: 0, column: 0 };
432
+
433
+ Query.prototype._init = function() {
434
+ /*
435
+ * Initialize predicate functions
436
+ * format: [type1, value1, type2, value2, ...]
437
+ */
438
+ const predicateDescriptions = this._getPredicates();
439
+ const patternCount = predicateDescriptions.length;
440
+
441
+ const setProperties = new Array(patternCount);
442
+ const assertedProperties = new Array(patternCount);
443
+ const refutedProperties = new Array(patternCount);
444
+ const predicates = new Array(patternCount);
445
+
446
+ const FIRST = 0
447
+ const SECOND = 2
448
+ const THIRD = 4
449
+
450
+ for (let i = 0; i < predicateDescriptions.length; i++) {
451
+ predicates[i] = [];
452
+
453
+ for (let j = 0; j < predicateDescriptions[i].length; j++) {
454
+
455
+ const steps = predicateDescriptions[i][j];
456
+ const stepsLength = steps.length / 2;
457
+
458
+ if (steps[FIRST] !== PREDICATE_STEP_TYPE.STRING) {
459
+ throw new Error('Predicates must begin with a literal value');
460
+ }
461
+
462
+ const operator = steps[FIRST + 1];
463
+
464
+ let isPositive = true;
465
+ let matchAll = true;
466
+ let captureName;
467
+ switch (operator) {
468
+ case 'any-not-eq?':
469
+ case 'not-eq?':
470
+ isPositive = false;
471
+ case 'any-eq?':
472
+ case 'eq?':
473
+ if (stepsLength !== 3) throw new Error(
474
+ `Wrong number of arguments to \`#eq?\` predicate. Expected 2, got ${stepsLength - 1}`
475
+ );
476
+ if (steps[SECOND] !== PREDICATE_STEP_TYPE.CAPTURE) throw new Error(
477
+ `First argument of \`#eq?\` predicate must be a capture. Got "${steps[SECOND + 1]}"`
478
+ );
479
+ matchAll = !operator.startsWith('any-');
480
+ if (steps[THIRD] === PREDICATE_STEP_TYPE.CAPTURE) {
481
+ const captureName1 = steps[SECOND + 1];
482
+ const captureName2 = steps[THIRD + 1];
483
+ predicates[i].push(function (captures) {
484
+ let nodes_1 = [];
485
+ let nodes_2 = [];
486
+ for (const c of captures) {
487
+ if (c.name === captureName1) nodes_1.push(c.node);
488
+ if (c.name === captureName2) nodes_2.push(c.node);
489
+ }
490
+ let compare = (n1, n2, positive) => {
491
+ return positive ?
492
+ n1.text === n2.text :
493
+ n1.text !== n2.text;
494
+ };
495
+ return matchAll
496
+ ? nodes_1.every(n1 => nodes_2.some(n2 => compare(n1, n2, isPositive)))
497
+ : nodes_1.some(n1 => nodes_2.some(n2 => compare(n1, n2, isPositive)));
498
+ });
499
+ } else {
500
+ captureName = steps[SECOND + 1];
501
+ const stringValue = steps[THIRD + 1];
502
+ let matches = (n) => n.text === stringValue;
503
+ let doesNotMatch = (n) => n.text !== stringValue;
504
+ predicates[i].push(function (captures) {
505
+ let nodes = [];
506
+ for (const c of captures) {
507
+ if (c.name === captureName) nodes.push(c.node);
508
+ }
509
+ let test = isPositive ? matches : doesNotMatch;
510
+ return matchAll
511
+ ? nodes.every(test)
512
+ : nodes.some(test);
513
+ });
514
+ }
515
+ break;
516
+
517
+ case 'any-not-match?':
518
+ case 'not-match?':
519
+ isPositive = false;
520
+ case 'any-match?':
521
+ case 'match?':
522
+ if (stepsLength !== 3) throw new Error(
523
+ `Wrong number of arguments to \`#match?\` predicate. Expected 2, got ${stepsLength - 1}.`
524
+ );
525
+ if (steps[SECOND] !== PREDICATE_STEP_TYPE.CAPTURE) throw new Error(
526
+ `First argument of \`#match?\` predicate must be a capture. Got "${steps[SECOND + 1]}".`
527
+ );
528
+ if (steps[THIRD] !== PREDICATE_STEP_TYPE.STRING) throw new Error(
529
+ `Second argument of \`#match?\` predicate must be a string. Got @${steps[THIRD + 1]}.`
530
+ );
531
+ captureName = steps[SECOND + 1];
532
+ const regex = new RegExp(steps[THIRD + 1]);
533
+ matchAll = !operator.startsWith('any-');
534
+ predicates[i].push(function (captures) {
535
+ const nodes = [];
536
+ for (const c of captures) {
537
+ if (c.name === captureName) nodes.push(c.node.text);
538
+ }
539
+ let test = (text, positive) => {
540
+ return positive ?
541
+ regex.test(text) :
542
+ !regex.test(text);
543
+ };
544
+ if (nodes.length === 0) return !isPositive;
545
+ return matchAll
546
+ ? nodes.every(text => test(text, isPositive))
547
+ : nodes.some(text => test(text, isPositive))
548
+ });
549
+ break;
550
+
551
+ case 'set!':
552
+ if (stepsLength < 2 || stepsLength > 3) throw new Error(
553
+ `Wrong number of arguments to \`#set!\` predicate. Expected 1 or 2. Got ${stepsLength - 1}.`
554
+ );
555
+ if (steps.some((s, i) => (i % 2 !== 1) && s !== PREDICATE_STEP_TYPE.STRING)) throw new Error(
556
+ `Arguments to \`#set!\` predicate must be a strings.".`
557
+ );
558
+ if (!setProperties[i]) setProperties[i] = {};
559
+ setProperties[i][steps[SECOND + 1]] = steps[THIRD] ? steps[THIRD + 1] : null;
560
+ break;
561
+
562
+ case 'is?':
563
+ case 'is-not?':
564
+ if (stepsLength < 2 || stepsLength > 3) throw new Error(
565
+ `Wrong number of arguments to \`#${operator}\` predicate. Expected 1 or 2. Got ${stepsLength - 1}.`
566
+ );
567
+ if (steps.some((s, i) => (i % 2 !== 1) && s !== PREDICATE_STEP_TYPE.STRING)) throw new Error(
568
+ `Arguments to \`#${operator}\` predicate must be a strings.".`
569
+ );
570
+ const properties = operator === 'is?' ? assertedProperties : refutedProperties;
571
+ if (!properties[i]) properties[i] = {};
572
+ properties[i][steps[SECOND + 1]] = steps[THIRD] ? steps[THIRD + 1] : null;
573
+ break;
574
+
575
+ case 'not-any-of?':
576
+ isPositive = false;
577
+ case 'any-of?':
578
+ if (stepsLength < 2) throw new Error(
579
+ `Wrong number of arguments to \`#${operator}\` predicate. Expected at least 1. Got ${stepsLength - 1}.`
580
+ );
581
+ if (steps[SECOND] !== PREDICATE_STEP_TYPE.CAPTURE) throw new Error(
582
+ `First argument of \`#${operator}\` predicate must be a capture. Got "${steps[1].value}".`
583
+ );
584
+ stringValues = [];
585
+ for (let k = THIRD; k < 2 * stepsLength; k += 2) {
586
+ if (steps[k] !== PREDICATE_STEP_TYPE.STRING) throw new Error(
587
+ `Arguments to \`#${operator}\` predicate must be a strings.".`
588
+ );
589
+ stringValues.push(steps[k + 1]);
590
+ }
591
+ captureName = steps[SECOND + 1];
592
+ predicates[i].push(function (captures) {
593
+ const nodes = [];
594
+ for (const c of captures) {
595
+ if (c.name === captureName) nodes.push(c.node.text);
596
+ }
597
+ if (nodes.length === 0) return !isPositive;
598
+ return nodes.every(text => stringValues.includes(text)) === isPositive;
599
+ });
600
+ break;
601
+
602
+ default:
603
+ throw new Error(`Unknown query predicate \`#${steps[FIRST + 1]}\``);
604
+ }
605
+ }
606
+ }
607
+
608
+ this.predicates = Object.freeze(predicates);
609
+ this.setProperties = Object.freeze(setProperties);
610
+ this.assertedProperties = Object.freeze(assertedProperties);
611
+ this.refutedProperties = Object.freeze(refutedProperties);
612
+ }
613
+
614
+ Query.prototype.matches = function(
615
+ node,
616
+ {
617
+ startPosition = ZERO_POINT,
618
+ endPosition = ZERO_POINT,
619
+ startIndex = 0,
620
+ endIndex = 0,
621
+ matchLimit = 0xFFFFFFFF,
622
+ maxStartDepth = 0xFFFFFFFF
623
+ } = {}
624
+ ) {
625
+ marshalNode(node);
626
+ const [returnedMatches, returnedNodes] = _matches.call(this, node.tree,
627
+ startPosition.row, startPosition.column,
628
+ endPosition.row, endPosition.column,
629
+ startIndex, endIndex, matchLimit, maxStartDepth
630
+ );
631
+ const nodes = unmarshalNodes(returnedNodes, node.tree);
632
+ const results = [];
633
+
634
+ let i = 0
635
+ let nodeIndex = 0;
636
+ while (i < returnedMatches.length) {
637
+ const patternIndex = returnedMatches[i++];
638
+ const captures = [];
639
+
640
+ while (i < returnedMatches.length && typeof returnedMatches[i] === 'string') {
641
+ const captureName = returnedMatches[i++];
642
+ captures.push({
643
+ name: captureName,
644
+ node: nodes[nodeIndex++],
645
+ })
646
+ }
647
+
648
+ if (this.predicates[patternIndex].every(p => p(captures))) {
649
+ const result = {pattern: patternIndex, captures};
650
+ const setProperties = this.setProperties[patternIndex];
651
+ const assertedProperties = this.assertedProperties[patternIndex];
652
+ const refutedProperties = this.refutedProperties[patternIndex];
653
+ if (setProperties) result.setProperties = setProperties;
654
+ if (assertedProperties) result.assertedProperties = assertedProperties;
655
+ if (refutedProperties) result.refutedProperties = refutedProperties;
656
+ results.push(result);
657
+ }
658
+ }
659
+
660
+ return results;
661
+ }
662
+
663
+ Query.prototype.captures = function(
664
+ node,
665
+ {
666
+ startPosition = ZERO_POINT,
667
+ endPosition = ZERO_POINT,
668
+ startIndex = 0,
669
+ endIndex = 0,
670
+ matchLimit = 0xFFFFFFFF,
671
+ maxStartDepth = 0xFFFFFFFF
672
+ } = {}
673
+ ) {
674
+ marshalNode(node);
675
+ const [returnedMatches, returnedNodes] = _captures.call(this, node.tree,
676
+ startPosition.row, startPosition.column,
677
+ endPosition.row, endPosition.column,
678
+ startIndex, endIndex, matchLimit, maxStartDepth
679
+ );
680
+ const nodes = unmarshalNodes(returnedNodes, node.tree);
681
+ const results = [];
682
+
683
+ let i = 0
684
+ let nodeIndex = 0;
685
+ while (i < returnedMatches.length) {
686
+ const patternIndex = returnedMatches[i++];
687
+ const captureIndex = returnedMatches[i++];
688
+ const captures = [];
689
+
690
+ while (i < returnedMatches.length && typeof returnedMatches[i] === 'string') {
691
+ const captureName = returnedMatches[i++];
692
+ captures.push({
693
+ name: captureName,
694
+ node: nodes[nodeIndex++],
695
+ })
696
+ }
697
+
698
+ if (this.predicates[patternIndex].every(p => p(captures))) {
699
+ const result = captures[captureIndex];
700
+ const setProperties = this.setProperties[patternIndex];
701
+ const assertedProperties = this.assertedProperties[patternIndex];
702
+ const refutedProperties = this.refutedProperties[patternIndex];
703
+ if (setProperties) result.setProperties = setProperties;
704
+ if (assertedProperties) result.assertedProperties = assertedProperties;
705
+ if (refutedProperties) result.refutedProperties = refutedProperties;
706
+ results.push(result);
707
+ }
708
+ }
709
+
710
+ return results;
711
+ }
712
+
713
+ /*
714
+ * LookaheadIterator
715
+ */
716
+
717
+ LookaheadIterator.prototype[Symbol.iterator] = function() {
718
+ const self = this;
719
+ return {
720
+ next() {
721
+ if (self._next()) {
722
+ return {done: false, value: self.currentType};
723
+ }
724
+
725
+ return {done: true, value: ''};
726
+ },
727
+ };
728
+ }
729
+
730
+ /*
731
+ * Other functions
732
+ */
733
+
734
+ function getTextFromString (node) {
735
+ return this.input.substring(node.startIndex, node.endIndex);
736
+ }
737
+
738
+ function getTextFromFunction ({startIndex, endIndex}) {
739
+ const {input} = this
740
+ let result = '';
741
+ const goalLength = endIndex - startIndex;
742
+ while (result.length < goalLength) {
743
+ const text = input(startIndex + result.length);
744
+ result += text;
745
+ }
746
+ return result.slice(0, goalLength);
747
+ }
748
+
749
+ const {pointTransferArray} = binding;
750
+
751
+ const NODE_FIELD_COUNT = 6;
752
+ const ERROR_TYPE_ID = 0xFFFF
753
+
754
+ function getID(buffer, offset) {
755
+ const low = BigInt(buffer[offset]);
756
+ const high = BigInt(buffer[offset + 1]);
757
+ return (high << 32n) + low;
758
+ }
759
+
760
+ function unmarshalNode(value, tree, offset = 0, cache = null) {
761
+ /* case 1: node from the tree cache */
762
+ if (typeof value === 'object') {
763
+ const node = value;
764
+ return node;
765
+ }
766
+
767
+ /* case 2: node being transferred */
768
+ const nodeTypeId = value;
769
+ const NodeClass = nodeTypeId === ERROR_TYPE_ID
770
+ ? SyntaxNode
771
+ : tree.language.nodeSubclasses[nodeTypeId];
772
+
773
+ const {nodeTransferArray} = binding;
774
+ const id = getID(nodeTransferArray, offset)
775
+ if (id === 0n) {
776
+ return null
777
+ }
778
+
779
+ let cachedResult;
780
+ if (cache && (cachedResult = cache.get(id)))
781
+ return cachedResult;
782
+
783
+ const result = new NodeClass(tree);
784
+ for (let i = 0; i < NODE_FIELD_COUNT; i++) {
785
+ result[i] = nodeTransferArray[offset + i];
786
+ }
787
+
788
+ if (cache)
789
+ cache.set(id, result);
790
+ else
791
+ tree._cacheNode(result);
792
+
793
+ return result;
794
+ }
795
+
796
+ function unmarshalNodes(nodes, tree) {
797
+ const cache = new Map();
798
+
799
+ let offset = 0;
800
+ for (let i = 0, {length} = nodes; i < length; i++) {
801
+ const node = unmarshalNode(nodes[i], tree, offset, cache);
802
+ if (node !== nodes[i]) {
803
+ nodes[i] = node;
804
+ offset += NODE_FIELD_COUNT
805
+ }
806
+ }
807
+
808
+ tree._cacheNodes(Array.from(cache.values()));
809
+
810
+ return nodes;
811
+ }
812
+
813
+ function marshalNode(node) {
814
+ if (!(node.tree instanceof Tree)){
815
+ throw new TypeError("SyntaxNode must belong to a Tree")
816
+ }
817
+ const {nodeTransferArray} = binding;
818
+ for (let i = 0; i < NODE_FIELD_COUNT; i++) {
819
+ nodeTransferArray[i] = node[i];
820
+ }
821
+ }
822
+
823
+ function unmarshalPoint() {
824
+ return {row: pointTransferArray[0], column: pointTransferArray[1]};
825
+ }
826
+
827
+ function pointToString(point) {
828
+ return `{row: ${point.row}, column: ${point.column}}`;
829
+ }
830
+
831
+ function initializeLanguageNodeClasses(language) {
832
+ const nodeTypeNamesById = binding.getNodeTypeNamesById(language);
833
+ const nodeFieldNamesById = binding.getNodeFieldNamesById(language);
834
+ const nodeTypeInfo = language.nodeTypeInfo || [];
835
+
836
+ const nodeSubclasses = [];
837
+ for (let id = 0, n = nodeTypeNamesById.length; id < n; id++) {
838
+ nodeSubclasses[id] = SyntaxNode;
839
+
840
+ const typeName = nodeTypeNamesById[id];
841
+ if (!typeName) continue;
842
+
843
+ const typeInfo = nodeTypeInfo.find(info => info.named && info.type === typeName);
844
+ if (!typeInfo) continue;
845
+
846
+ const fieldNames = [];
847
+ let classBody = '\n';
848
+ if (typeInfo.fields) {
849
+ for (const fieldName in typeInfo.fields) {
850
+ const fieldId = nodeFieldNamesById.indexOf(fieldName);
851
+ if (fieldId === -1) continue;
852
+ if (typeInfo.fields[fieldName].multiple) {
853
+ const getterName = camelCase(fieldName) + 'Nodes';
854
+ fieldNames.push(getterName);
855
+ classBody += `
856
+ get ${getterName}() {
857
+ marshalNode(this);
858
+ return unmarshalNodes(NodeMethods.childNodesForFieldId(this.tree, ${fieldId}), this.tree);
859
+ }
860
+ `.replace(/\s+/g, ' ') + '\n';
861
+ } else {
862
+ const getterName = camelCase(fieldName, false) + 'Node';
863
+ fieldNames.push(getterName);
864
+ classBody += `
865
+ get ${getterName}() {
866
+ marshalNode(this);
867
+ return unmarshalNode(NodeMethods.childNodeForFieldId(this.tree, ${fieldId}), this.tree);
868
+ }
869
+ `.replace(/\s+/g, ' ') + '\n';
870
+ }
871
+ }
872
+ }
873
+
874
+ const className = camelCase(typeName, true) + 'Node';
875
+ const nodeSubclass = eval(`class ${className} extends SyntaxNode {${classBody}}; ${className}`);
876
+ nodeSubclass.prototype.type = typeName;
877
+ nodeSubclass.prototype.fields = Object.freeze(fieldNames.sort())
878
+ nodeSubclasses[id] = nodeSubclass;
879
+ }
880
+
881
+ language.nodeSubclasses = nodeSubclasses
882
+ }
883
+
884
+ function camelCase(name, upperCase) {
885
+ name = name.replace(/_(\w)/g, (_match, letter) => letter.toUpperCase());
886
+ if (upperCase) name = name[0].toUpperCase() + name.slice(1);
887
+ return name;
888
+ }
889
+
890
+ module.exports = Parser;
891
+ module.exports.Query = Query;
892
+ module.exports.Tree = Tree;
893
+ module.exports.SyntaxNode = SyntaxNode;
894
+ module.exports.TreeCursor = TreeCursor;
895
+ module.exports.LookaheadIterator = LookaheadIterator;