@eagleoutice/flowr 2.10.9 → 2.11.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 (417) hide show
  1. package/README.md +116 -38
  2. package/abstract-interpretation/absint-visitor.js +6 -3
  3. package/abstract-interpretation/domains/abstract-domain.d.ts +1 -1
  4. package/abstract-interpretation/domains/bounded-set-domain.d.ts +1 -1
  5. package/abstract-interpretation/domains/bounded-set-domain.js +1 -1
  6. package/abstract-interpretation/domains/interval-domain.d.ts +1 -1
  7. package/abstract-interpretation/domains/interval-domain.js +1 -1
  8. package/abstract-interpretation/domains/lattice.d.ts +1 -1
  9. package/abstract-interpretation/domains/partial-product-domain.d.ts +1 -1
  10. package/abstract-interpretation/domains/partial-product-domain.js +2 -2
  11. package/abstract-interpretation/domains/set-range-domain.d.ts +1 -1
  12. package/abstract-interpretation/domains/set-range-domain.js +1 -1
  13. package/abstract-interpretation/domains/set-upper-bound-domain.d.ts +1 -1
  14. package/abstract-interpretation/domains/set-upper-bound-domain.js +1 -1
  15. package/abstract-interpretation/domains/singleton-domain.d.ts +1 -1
  16. package/abstract-interpretation/domains/singleton-domain.js +1 -1
  17. package/abstract-interpretation/domains/state-abstract-domain.d.ts +1 -1
  18. package/abstract-interpretation/domains/state-abstract-domain.js +2 -2
  19. package/abstract-interpretation/unsupported-functions.d.ts +3 -2
  20. package/abstract-interpretation/unsupported-functions.js +38 -28
  21. package/cli/benchmark-app.js +2 -1
  22. package/cli/common/options.d.ts +2 -108
  23. package/cli/common/options.js +3 -27
  24. package/cli/common/script.js +3 -2
  25. package/cli/common/scripts-info.d.ts +2 -123
  26. package/cli/common/scripts-info.js +0 -17
  27. package/cli/flowr-main-options.d.ts +5 -0
  28. package/cli/flowr-main-options.js +10 -0
  29. package/cli/flowr.js +48 -11
  30. package/cli/repl/commands/repl-cfg.js +9 -9
  31. package/cli/repl/commands/repl-commands.js +5 -0
  32. package/cli/repl/commands/repl-dataflow.js +31 -24
  33. package/cli/repl/commands/repl-main.d.ts +6 -0
  34. package/cli/repl/commands/repl-normalize.js +15 -12
  35. package/cli/repl/commands/repl-parse.js +1 -1
  36. package/cli/repl/commands/repl-query.js +4 -5
  37. package/cli/repl/commands/repl-quit.js +2 -1
  38. package/cli/repl/core.d.ts +11 -0
  39. package/cli/repl/core.js +101 -3
  40. package/cli/repl/execute.js +3 -2
  41. package/cli/repl/parser/slice-query-parser.d.ts +16 -0
  42. package/cli/repl/parser/slice-query-parser.js +52 -0
  43. package/cli/repl/print-version.d.ts +3 -1
  44. package/cli/repl/print-version.js +21 -2
  45. package/cli/repl/server/connection.d.ts +3 -0
  46. package/cli/repl/server/connection.js +65 -31
  47. package/cli/repl/server/messages/message-analysis.d.ts +10 -0
  48. package/cli/repl/server/messages/message-analysis.js +6 -2
  49. package/cli/repl/server/messages/message-slice.d.ts +1 -1
  50. package/cli/script-core/summarizer-core.js +13 -32
  51. package/cli/wiki.d.ts +3 -1
  52. package/cli/wiki.js +6 -1
  53. package/config.d.ts +22 -10
  54. package/config.js +33 -7
  55. package/control-flow/diff-cfg.d.ts +1 -1
  56. package/control-flow/diff-cfg.js +1 -1
  57. package/control-flow/semantic-cfg-guided-visitor.js +2 -0
  58. package/control-flow/simple-visitor.js +6 -5
  59. package/control-flow/useless-loop.js +2 -2
  60. package/core/print/dataflow-printer.d.ts +2 -2
  61. package/core/print/dataflow-printer.js +2 -2
  62. package/core/steps/all/static-slicing/00-slice.js +1 -1
  63. package/data/pkgdb/pkgdb-latest.json.br +0 -0
  64. package/data/pkgdb/pkgdb-tiny.json.br +0 -0
  65. package/dataflow/environments/append.d.ts +2 -2
  66. package/dataflow/environments/append.js +4 -10
  67. package/dataflow/environments/apply-kill.d.ts +21 -0
  68. package/dataflow/environments/apply-kill.js +155 -0
  69. package/dataflow/environments/built-in-proc-name.d.ts +4 -0
  70. package/dataflow/environments/built-in-proc-name.js +4 -0
  71. package/dataflow/environments/built-in.d.ts +4 -0
  72. package/dataflow/environments/built-in.js +4 -0
  73. package/dataflow/environments/default-builtin-config.d.ts +183 -67
  74. package/dataflow/environments/default-builtin-config.js +358 -147
  75. package/dataflow/environments/environment.d.ts +49 -31
  76. package/dataflow/environments/environment.js +144 -25
  77. package/dataflow/environments/identifier.d.ts +65 -2
  78. package/dataflow/environments/identifier.js +37 -2
  79. package/dataflow/environments/overwrite.js +2 -10
  80. package/dataflow/environments/reference-to-maybe.d.ts +2 -0
  81. package/dataflow/environments/reference-to-maybe.js +56 -11
  82. package/dataflow/environments/resolve-by-name.d.ts +1 -1
  83. package/dataflow/environments/resolve-by-name.js +23 -9
  84. package/dataflow/environments/scoping.d.ts +9 -2
  85. package/dataflow/environments/scoping.js +15 -2
  86. package/dataflow/eval/values/general.js +4 -0
  87. package/dataflow/extractor.js +35 -4
  88. package/dataflow/graph/df-helper.d.ts +14 -0
  89. package/dataflow/graph/df-helper.js +41 -0
  90. package/dataflow/graph/graph.d.ts +4 -1
  91. package/dataflow/graph/graph.js +6 -2
  92. package/dataflow/info.d.ts +27 -1
  93. package/dataflow/internal/linker.d.ts +5 -1
  94. package/dataflow/internal/linker.js +34 -9
  95. package/dataflow/internal/process/functions/call/built-in/built-in-access.js +7 -5
  96. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +19 -0
  97. package/dataflow/internal/process/functions/call/built-in/built-in-attach.d.ts +1 -8
  98. package/dataflow/internal/process/functions/call/built-in/built-in-attach.js +7 -13
  99. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.d.ts +9 -48
  100. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +30 -47
  101. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +17 -0
  102. package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +7 -2
  103. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.d.ts +2 -2
  104. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +61 -1
  105. package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +9 -0
  106. package/dataflow/internal/process/functions/call/built-in/built-in-library.d.ts +37 -3
  107. package/dataflow/internal/process/functions/call/built-in/built-in-library.js +391 -21
  108. package/dataflow/internal/process/functions/call/built-in/built-in-namespace-access.d.ts +13 -0
  109. package/dataflow/internal/process/functions/call/built-in/built-in-namespace-access.js +58 -0
  110. package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.js +1 -1
  111. package/dataflow/internal/process/functions/call/built-in/built-in-rm.d.ts +3 -2
  112. package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +132 -25
  113. package/dataflow/internal/process/functions/call/built-in/built-in-source.js +9 -10
  114. package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.d.ts +25 -0
  115. package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.js +94 -0
  116. package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +11 -4
  117. package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.d.ts +30 -0
  118. package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +279 -0
  119. package/dataflow/internal/process/functions/call/known-call-handling.js +4 -3
  120. package/dataflow/internal/process/functions/call/named-call-handling.d.ts +1 -1
  121. package/dataflow/internal/process/functions/call/named-call-handling.js +23 -0
  122. package/dataflow/origin/dfg-get-origin.d.ts +1 -1
  123. package/dataflow/origin/dfg-get-origin.js +1 -1
  124. package/dataflow/processor.d.ts +6 -0
  125. package/documentation/data/faq/faqs.d.ts +2 -1
  126. package/documentation/data/faq/faqs.js +78 -57
  127. package/documentation/data/interface/doc-writing-code.js +4 -80
  128. package/documentation/data/server/doc-data-server-messages.d.ts +2 -1
  129. package/documentation/data/server/doc-data-server-messages.js +15 -7
  130. package/documentation/doc-readme.js +15 -15
  131. package/documentation/doc-util/doc-cfg.d.ts +3 -1
  132. package/documentation/doc-util/doc-cfg.js +3 -3
  133. package/documentation/doc-util/doc-dfg.d.ts +3 -1
  134. package/documentation/doc-util/doc-dfg.js +3 -3
  135. package/documentation/doc-util/doc-files.d.ts +3 -1
  136. package/documentation/doc-util/doc-files.js +9 -6
  137. package/documentation/doc-util/doc-normalized-ast.d.ts +3 -1
  138. package/documentation/doc-util/doc-normalized-ast.js +2 -2
  139. package/documentation/doc-util/doc-query.d.ts +2 -1
  140. package/documentation/doc-util/doc-query.js +2 -2
  141. package/documentation/doc-util/doc-repl.js +1 -0
  142. package/documentation/doc-util/doc-structure.js +1 -2
  143. package/documentation/doc-util/doc-types.d.ts +6 -6
  144. package/documentation/doc-util/doc-types.js +11 -9
  145. package/documentation/issue-linting-rule.js +1 -2
  146. package/documentation/wiki-analyzer.js +9 -9
  147. package/documentation/wiki-cfg.js +40 -41
  148. package/documentation/wiki-core.js +121 -32
  149. package/documentation/wiki-create-linting-rules.d.ts +6 -0
  150. package/documentation/wiki-create-linting-rules.js +95 -0
  151. package/documentation/wiki-dataflow-graph.js +112 -77
  152. package/documentation/wiki-engine.js +1 -2
  153. package/documentation/wiki-faq.d.ts +2 -1
  154. package/documentation/wiki-faq.js +4 -4
  155. package/documentation/wiki-interface.js +22 -8
  156. package/documentation/wiki-linter.d.ts +1 -1
  157. package/documentation/wiki-linter.js +16 -6
  158. package/documentation/wiki-linting-and-testing.js +2 -2
  159. package/documentation/wiki-mk/doc-context.d.ts +3 -3
  160. package/documentation/wiki-mk/doc-maker.d.ts +2 -0
  161. package/documentation/wiki-mk/doc-maker.js +7 -1
  162. package/documentation/wiki-normalized-ast.js +5 -5
  163. package/documentation/wiki-onboarding.d.ts +2 -1
  164. package/documentation/wiki-onboarding.js +5 -5
  165. package/documentation/wiki-overview.js +4 -17
  166. package/documentation/wiki-package-database.d.ts +9 -0
  167. package/documentation/wiki-package-database.js +63 -0
  168. package/documentation/wiki-query.js +86 -84
  169. package/documentation/wiki-search.js +4 -5
  170. package/documentation/wiki-setup.js +6 -7
  171. package/gas.d.ts +74 -0
  172. package/gas.js +18 -0
  173. package/linter/linter-executor.js +2 -8
  174. package/linter/linter-format.d.ts +4 -11
  175. package/linter/linter-rules.d.ts +111 -86
  176. package/linter/linter-rules.js +9 -1
  177. package/linter/rules/absolute-path.d.ts +2 -7
  178. package/linter/rules/absolute-path.js +8 -5
  179. package/linter/rules/dataframe-access-validation.d.ts +1 -6
  180. package/linter/rules/dataframe-access-validation.js +8 -6
  181. package/linter/rules/dead-code.d.ts +2 -11
  182. package/linter/rules/dead-code.js +16 -11
  183. package/linter/rules/deprecated-functions.d.ts +3 -3
  184. package/linter/rules/file-path-validity.d.ts +1 -6
  185. package/linter/rules/file-path-validity.js +5 -5
  186. package/linter/rules/function-finder-util.d.ts +7 -11
  187. package/linter/rules/function-finder-util.js +9 -6
  188. package/linter/rules/naming-convention.d.ts +2 -7
  189. package/linter/rules/naming-convention.js +3 -2
  190. package/linter/rules/network-functions.d.ts +2 -7
  191. package/linter/rules/network-functions.js +14 -12
  192. package/linter/rules/no-leaked-credentials.d.ts +36 -0
  193. package/linter/rules/no-leaked-credentials.js +75 -0
  194. package/linter/rules/problematic-inputs.d.ts +1 -8
  195. package/linter/rules/problematic-inputs.js +5 -4
  196. package/linter/rules/roxygen-arguments.d.ts +2 -7
  197. package/linter/rules/roxygen-arguments.js +13 -20
  198. package/linter/rules/seeded-randomness.d.ts +2 -7
  199. package/linter/rules/seeded-randomness.js +7 -4
  200. package/linter/rules/software-has-license.d.ts +31 -0
  201. package/linter/rules/software-has-license.js +46 -0
  202. package/linter/rules/software-has-tests.d.ts +38 -0
  203. package/linter/rules/software-has-tests.js +48 -0
  204. package/linter/rules/stop-with-call-arg.d.ts +2 -7
  205. package/linter/rules/stop-with-call-arg.js +3 -2
  206. package/linter/rules/undefined-symbol.d.ts +39 -0
  207. package/linter/rules/undefined-symbol.js +80 -0
  208. package/linter/rules/unused-definition.d.ts +3 -8
  209. package/linter/rules/unused-definition.js +7 -5
  210. package/linter/rules/useless-loop.d.ts +2 -7
  211. package/linter/rules/useless-loop.js +5 -2
  212. package/package.json +5 -5
  213. package/project/cache/flowr-analyzer-cache.d.ts +2 -0
  214. package/project/cache/flowr-analyzer-cache.js +9 -1
  215. package/project/context/flowr-analyzer-context.d.ts +13 -14
  216. package/project/context/flowr-analyzer-context.js +4 -0
  217. package/project/context/flowr-analyzer-dependencies-context.d.ts +16 -8
  218. package/project/context/flowr-analyzer-dependencies-context.js +36 -4
  219. package/project/context/flowr-analyzer-environment-context.d.ts +2 -4
  220. package/project/context/flowr-analyzer-environment-context.js +3 -4
  221. package/project/context/flowr-analyzer-files-context.d.ts +13 -0
  222. package/project/context/flowr-analyzer-files-context.js +12 -2
  223. package/project/context/flowr-analyzer-gas-context.d.ts +28 -0
  224. package/project/context/flowr-analyzer-gas-context.js +101 -0
  225. package/project/context/flowr-file.d.ts +2 -0
  226. package/project/context/flowr-file.js +2 -0
  227. package/project/flowr-analyzer-builder.js +3 -0
  228. package/project/flowr-analyzer.d.ts +2 -1
  229. package/project/flowr-analyzer.js +3 -1
  230. package/project/plugins/file-plugins/files/flowr-namespace-file.d.ts +13 -15
  231. package/project/plugins/file-plugins/files/flowr-namespace-file.js +36 -13
  232. package/project/plugins/file-plugins/files/flowr-rmarkdown-file.d.ts +13 -7
  233. package/project/plugins/file-plugins/files/flowr-rmarkdown-file.js +56 -11
  234. package/project/plugins/file-plugins/flowr-analyzer-virtualenv-file-plugin.d.ts +27 -0
  235. package/project/plugins/file-plugins/flowr-analyzer-virtualenv-file-plugin.js +41 -0
  236. package/project/plugins/file-plugins/notebooks/flowr-analyzer-qmd-file-plugin.d.ts +1 -1
  237. package/project/plugins/file-plugins/notebooks/flowr-analyzer-qmd-file-plugin.js +2 -2
  238. package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmd-file-plugin.d.ts +2 -1
  239. package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmd-file-plugin.js +5 -5
  240. package/project/plugins/flowr-analyzer-plugin.d.ts +15 -8
  241. package/project/plugins/flowr-analyzer-plugin.js +14 -7
  242. package/project/plugins/gas-plugins/flowr-analyzer-gas-plugin.d.ts +19 -0
  243. package/project/plugins/gas-plugins/flowr-analyzer-gas-plugin.js +35 -0
  244. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-lockfile-plugin.d.ts +18 -0
  245. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-lockfile-plugin.js +62 -0
  246. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-pkgdb-plugin.d.ts +63 -0
  247. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-pkgdb-plugin.js +174 -0
  248. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-plugin.d.ts +10 -0
  249. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-plugin.js +6 -0
  250. package/project/plugins/package-version-plugins/package.d.ts +3 -0
  251. package/project/plugins/package-version-plugins/package.js +12 -0
  252. package/project/plugins/package-version-plugins/pkgdb.d.ts +133 -0
  253. package/project/plugins/package-version-plugins/pkgdb.js +370 -0
  254. package/project/plugins/plugin-registry.d.ts +5 -1
  255. package/project/plugins/plugin-registry.js +10 -1
  256. package/project/plugins/project-discovery/flowr-analyzer-gitignore-project-discovery-plugin.d.ts +22 -0
  257. package/project/plugins/project-discovery/flowr-analyzer-gitignore-project-discovery-plugin.js +47 -0
  258. package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +1 -1
  259. package/queries/catalog/call-context-query/call-context-query-executor.js +62 -8
  260. package/queries/catalog/call-context-query/call-context-query-format.d.ts +4 -2
  261. package/queries/catalog/call-context-query/call-context-query-format.js +1 -0
  262. package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +8 -0
  263. package/queries/catalog/dependencies-query/dependencies-query-executor.js +31 -3
  264. package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +3 -1
  265. package/queries/catalog/dependencies-query/dependencies-query-format.js +3 -2
  266. package/queries/catalog/dependencies-query/function-info/function-info.d.ts +1 -1
  267. package/queries/catalog/dependencies-query/function-info/other-path-functions.d.ts +2 -0
  268. package/queries/catalog/dependencies-query/function-info/other-path-functions.js +27 -0
  269. package/queries/catalog/dependencies-query/function-info/read-functions.js +5 -4
  270. package/queries/catalog/dependencies-query/function-info/test-functions.d.ts +2 -0
  271. package/queries/catalog/dependencies-query/function-info/test-functions.js +18 -177
  272. package/queries/catalog/dependencies-query/function-info/visualize-functions.js +3 -1
  273. package/queries/catalog/df-shape-query/df-shape-query-format.js +1 -1
  274. package/queries/catalog/dice-query/dice-query-executor.d.ts +8 -0
  275. package/queries/catalog/dice-query/dice-query-executor.js +52 -0
  276. package/queries/catalog/dice-query/dice-query-format.d.ts +53 -0
  277. package/queries/catalog/dice-query/dice-query-format.js +102 -0
  278. package/queries/catalog/happens-before-query/happens-before-query-executor.js +2 -2
  279. package/queries/catalog/input-sources-query/input-sources-query-format.d.ts +2 -0
  280. package/queries/catalog/input-sources-query/input-sources-query-format.js +1 -0
  281. package/queries/catalog/inspect-exceptions-query/inspect-exception-query-format.d.ts +2 -0
  282. package/queries/catalog/inspect-exceptions-query/inspect-exception-query-format.js +1 -0
  283. package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.d.ts +2 -0
  284. package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.js +1 -0
  285. package/queries/catalog/linter-query/linter-query-executor.js +8 -0
  286. package/queries/catalog/location-map-query/location-map-query-format.d.ts +2 -0
  287. package/queries/catalog/location-map-query/location-map-query-format.js +1 -0
  288. package/queries/catalog/origin-query/origin-query-format.d.ts +2 -0
  289. package/queries/catalog/origin-query/origin-query-format.js +1 -0
  290. package/queries/catalog/provenance-query/provenance-query-format.d.ts +2 -0
  291. package/queries/catalog/provenance-query/provenance-query-format.js +1 -0
  292. package/queries/catalog/resolve-value-query/resolve-value-query-format.d.ts +2 -0
  293. package/queries/catalog/resolve-value-query/resolve-value-query-format.js +1 -0
  294. package/queries/catalog/static-slice-query/static-slice-query-executor.js +1 -1
  295. package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +2 -0
  296. package/queries/catalog/static-slice-query/static-slice-query-format.js +1 -0
  297. package/queries/query.d.ts +18 -1
  298. package/queries/query.js +3 -1
  299. package/r-bridge/data/data.d.ts +7 -2
  300. package/r-bridge/data/data.js +8 -2
  301. package/r-bridge/lang-4.x/ast/model/nodes/r-string.d.ts +0 -1
  302. package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-number.d.ts +1 -1
  303. package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-number.js +1 -1
  304. package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-string.d.ts +1 -1
  305. package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-string.js +1 -1
  306. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.js +13 -4
  307. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +55 -44
  308. package/r-bridge/parser.js +2 -9
  309. package/r-bridge/shell.d.ts +8 -1
  310. package/r-bridge/shell.js +26 -7
  311. package/search/flowr-search-builder.d.ts +2 -2
  312. package/search/flowr-search-builder.js +1 -1
  313. package/search/flowr-search-filters.d.ts +30 -9
  314. package/search/flowr-search-filters.js +26 -21
  315. package/search/search-executor/search-enrichers.d.ts +601 -1
  316. package/search/search-executor/search-enrichers.js +30 -6
  317. package/slicing/static/static-slicer.d.ts +39 -11
  318. package/slicing/static/static-slicer.js +44 -14
  319. package/util/collections/queue.d.ts +16 -0
  320. package/util/collections/queue.js +38 -0
  321. package/util/log.d.ts +1 -1
  322. package/util/log.js +1 -1
  323. package/util/mermaid/dfg.d.ts +2 -2
  324. package/util/mermaid/dfg.js +2 -2
  325. package/util/mermaid/mermaid.d.ts +4 -0
  326. package/util/mermaid/mermaid.js +8 -1
  327. package/util/objects.d.ts +9 -0
  328. package/util/objects.js +54 -0
  329. package/util/proc.d.ts +6 -0
  330. package/util/proc.js +20 -0
  331. package/util/version.js +10 -2
  332. package/cli/common/features.d.ts +0 -9
  333. package/cli/common/features.js +0 -35
  334. package/cli/script-core/statistics-core.d.ts +0 -6
  335. package/cli/script-core/statistics-core.js +0 -103
  336. package/cli/script-core/statistics-helper-core.d.ts +0 -6
  337. package/cli/script-core/statistics-helper-core.js +0 -85
  338. package/cli/statistics-app.d.ts +0 -11
  339. package/cli/statistics-app.js +0 -16
  340. package/cli/statistics-helper-app.d.ts +0 -11
  341. package/cli/statistics-helper-app.js +0 -14
  342. package/statistics/features/common-syntax-probability.d.ts +0 -38
  343. package/statistics/features/common-syntax-probability.js +0 -169
  344. package/statistics/features/feature.d.ts +0 -179
  345. package/statistics/features/feature.js +0 -38
  346. package/statistics/features/post-processing.d.ts +0 -18
  347. package/statistics/features/post-processing.js +0 -26
  348. package/statistics/features/supported/assignments/assignments.d.ts +0 -12
  349. package/statistics/features/supported/assignments/assignments.js +0 -56
  350. package/statistics/features/supported/assignments/post-process.d.ts +0 -6
  351. package/statistics/features/supported/assignments/post-process.js +0 -126
  352. package/statistics/features/supported/comments/comments.d.ts +0 -18
  353. package/statistics/features/supported/comments/comments.js +0 -143
  354. package/statistics/features/supported/comments/post-process.d.ts +0 -6
  355. package/statistics/features/supported/comments/post-process.js +0 -51
  356. package/statistics/features/supported/control-flow/control-flow.d.ts +0 -17
  357. package/statistics/features/supported/control-flow/control-flow.js +0 -69
  358. package/statistics/features/supported/control-flow/post-process.d.ts +0 -6
  359. package/statistics/features/supported/control-flow/post-process.js +0 -66
  360. package/statistics/features/supported/data-access/data-access.d.ts +0 -15
  361. package/statistics/features/supported/data-access/data-access.js +0 -122
  362. package/statistics/features/supported/data-access/post-process.d.ts +0 -6
  363. package/statistics/features/supported/data-access/post-process.js +0 -108
  364. package/statistics/features/supported/defined-functions/defined-functions.d.ts +0 -34
  365. package/statistics/features/supported/defined-functions/defined-functions.js +0 -145
  366. package/statistics/features/supported/defined-functions/post-process.d.ts +0 -6
  367. package/statistics/features/supported/defined-functions/post-process.js +0 -168
  368. package/statistics/features/supported/expression-list/post-process.d.ts +0 -6
  369. package/statistics/features/supported/expression-list/post-process.js +0 -45
  370. package/statistics/features/supported/expression-list/statistics-expression-list.d.ts +0 -9
  371. package/statistics/features/supported/expression-list/statistics-expression-list.js +0 -37
  372. package/statistics/features/supported/loops/loops.d.ts +0 -20
  373. package/statistics/features/supported/loops/loops.js +0 -81
  374. package/statistics/features/supported/loops/post-process.d.ts +0 -6
  375. package/statistics/features/supported/loops/post-process.js +0 -73
  376. package/statistics/features/supported/used-functions/post-process.d.ts +0 -6
  377. package/statistics/features/supported/used-functions/post-process.js +0 -176
  378. package/statistics/features/supported/used-functions/used-functions.d.ts +0 -24
  379. package/statistics/features/supported/used-functions/used-functions.js +0 -99
  380. package/statistics/features/supported/used-packages/post-process.d.ts +0 -6
  381. package/statistics/features/supported/used-packages/post-process.js +0 -122
  382. package/statistics/features/supported/used-packages/used-packages.d.ts +0 -16
  383. package/statistics/features/supported/used-packages/used-packages.js +0 -140
  384. package/statistics/features/supported/values/post-process.d.ts +0 -6
  385. package/statistics/features/supported/values/post-process.js +0 -73
  386. package/statistics/features/supported/values/values.d.ts +0 -14
  387. package/statistics/features/supported/values/values.js +0 -111
  388. package/statistics/features/supported/variables/post-process.d.ts +0 -15
  389. package/statistics/features/supported/variables/post-process.js +0 -126
  390. package/statistics/features/supported/variables/variables.d.ts +0 -15
  391. package/statistics/features/supported/variables/variables.js +0 -62
  392. package/statistics/meta-statistics.d.ts +0 -32
  393. package/statistics/meta-statistics.js +0 -16
  394. package/statistics/output/file-provider.d.ts +0 -36
  395. package/statistics/output/file-provider.js +0 -96
  396. package/statistics/output/print-stats.d.ts +0 -29
  397. package/statistics/output/print-stats.js +0 -81
  398. package/statistics/output/statistics-file.d.ts +0 -36
  399. package/statistics/output/statistics-file.js +0 -68
  400. package/statistics/statistics.d.ts +0 -29
  401. package/statistics/statistics.js +0 -108
  402. package/statistics/summarizer/auto-detect.d.ts +0 -5
  403. package/statistics/summarizer/auto-detect.js +0 -34
  404. package/statistics/summarizer/first-phase/process.d.ts +0 -6
  405. package/statistics/summarizer/first-phase/process.js +0 -81
  406. package/statistics/summarizer/post-process/clusterer.d.ts +0 -25
  407. package/statistics/summarizer/post-process/clusterer.js +0 -40
  408. package/statistics/summarizer/post-process/file-based-count.d.ts +0 -16
  409. package/statistics/summarizer/post-process/file-based-count.js +0 -47
  410. package/statistics/summarizer/post-process/histogram.d.ts +0 -57
  411. package/statistics/summarizer/post-process/histogram.js +0 -126
  412. package/statistics/summarizer/post-process/post-process-output.d.ts +0 -14
  413. package/statistics/summarizer/post-process/post-process-output.js +0 -102
  414. package/statistics/summarizer/second-phase/process.d.ts +0 -15
  415. package/statistics/summarizer/second-phase/process.js +0 -118
  416. package/statistics/summarizer/summarizer.d.ts +0 -34
  417. package/statistics/summarizer/summarizer.js +0 -141
@@ -0,0 +1,18 @@
1
+ import { FlowrAnalyzerPackageVersionsPlugin } from './flowr-analyzer-package-versions-plugin';
2
+ import { SemVer } from 'semver';
3
+ import type { FlowrAnalyzerContext } from '../../context/flowr-analyzer-context';
4
+ export declare const lockfileLog: import("tslog").Logger<import("tslog").ILogObj>;
5
+ /** Reads package versions from an `renv.lock` (JSON). renv pins are exact. */
6
+ export declare class FlowrAnalyzerPackageVersionsRenvPlugin extends FlowrAnalyzerPackageVersionsPlugin {
7
+ readonly name = "flowr-analyzer-package-versions-renv-plugin";
8
+ readonly description = "Extracts package versions from an renv.lock lockfile.";
9
+ readonly version: SemVer;
10
+ process(ctx: FlowrAnalyzerContext): void;
11
+ }
12
+ /** Reads package versions from an `rv.lock` (the resolved rv project lockfile, TOML). */
13
+ export declare class FlowrAnalyzerPackageVersionsRvPlugin extends FlowrAnalyzerPackageVersionsPlugin {
14
+ readonly name = "flowr-analyzer-package-versions-rv-plugin";
15
+ readonly description = "Extracts package versions from an rv.lock lockfile.";
16
+ readonly version: SemVer;
17
+ process(ctx: FlowrAnalyzerContext): void;
18
+ }
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FlowrAnalyzerPackageVersionsRvPlugin = exports.FlowrAnalyzerPackageVersionsRenvPlugin = exports.lockfileLog = void 0;
4
+ const flowr_analyzer_package_versions_plugin_1 = require("./flowr-analyzer-package-versions-plugin");
5
+ const semver_1 = require("semver");
6
+ const package_1 = require("./package");
7
+ const flowr_file_1 = require("../../context/flowr-file");
8
+ const built_in_source_1 = require("../../../dataflow/internal/process/functions/call/built-in/built-in-source");
9
+ const log_1 = require("../../../util/log");
10
+ exports.lockfileLog = log_1.log.getSubLogger({ name: 'flowr-analyzer-package-versions-lockfile-plugin' });
11
+ /** The {@link FileRole.VirtualEnv} lockfiles named `name` (e.g. `renv.lock`), collected by role like the DESCRIPTION reader. */
12
+ function virtualEnvFiles(ctx, name) {
13
+ return ctx.files.getFilesByRole(flowr_file_1.FileRole.VirtualEnv).filter(f => (0, built_in_source_1.platformBasename)(f.path()) === name);
14
+ }
15
+ function pin(ctx, name, version) {
16
+ const range = package_1.Package.parsePackageVersionRange(undefined, version);
17
+ ctx.deps.addDependency(new package_1.Package({ name, versionConstraints: range ? [range] : undefined }));
18
+ }
19
+ /** Reads package versions from an `renv.lock` (JSON). renv pins are exact. */
20
+ class FlowrAnalyzerPackageVersionsRenvPlugin extends flowr_analyzer_package_versions_plugin_1.FlowrAnalyzerPackageVersionsPlugin {
21
+ name = 'flowr-analyzer-package-versions-renv-plugin';
22
+ description = 'Extracts package versions from an renv.lock lockfile.';
23
+ version = new semver_1.SemVer('0.1.0');
24
+ process(ctx) {
25
+ for (const file of virtualEnvFiles(ctx, 'renv.lock')) {
26
+ let lock;
27
+ try {
28
+ lock = JSON.parse(file.content().toString());
29
+ }
30
+ catch (e) {
31
+ exports.lockfileLog.warn(`Could not parse renv.lock: ${e.message}`);
32
+ continue;
33
+ }
34
+ for (const [pkg, meta] of Object.entries(lock.Packages ?? {})) {
35
+ if (typeof meta?.Version === 'string') {
36
+ pin(ctx, pkg, meta.Version);
37
+ }
38
+ }
39
+ }
40
+ }
41
+ }
42
+ exports.FlowrAnalyzerPackageVersionsRenvPlugin = FlowrAnalyzerPackageVersionsRenvPlugin;
43
+ /** Reads package versions from an `rv.lock` (the resolved rv project lockfile, TOML). */
44
+ class FlowrAnalyzerPackageVersionsRvPlugin extends flowr_analyzer_package_versions_plugin_1.FlowrAnalyzerPackageVersionsPlugin {
45
+ name = 'flowr-analyzer-package-versions-rv-plugin';
46
+ description = 'Extracts package versions from an rv.lock lockfile.';
47
+ version = new semver_1.SemVer('0.1.0');
48
+ process(ctx) {
49
+ for (const file of virtualEnvFiles(ctx, 'rv.lock')) {
50
+ // rv.lock is TOML with repeated `[[packages]]` tables carrying `name`/`version`
51
+ for (const block of file.content().toString().split(/\[\[packages\]\]/).slice(1)) {
52
+ const name = /^\s*name\s*=\s*"([^"]+)"/m.exec(block)?.[1];
53
+ const version = /^\s*version\s*=\s*"([^"]+)"/m.exec(block)?.[1];
54
+ if (name && version) {
55
+ pin(ctx, name, version);
56
+ }
57
+ }
58
+ }
59
+ }
60
+ }
61
+ exports.FlowrAnalyzerPackageVersionsRvPlugin = FlowrAnalyzerPackageVersionsRvPlugin;
62
+ //# sourceMappingURL=flowr-analyzer-package-versions-lockfile-plugin.js.map
@@ -0,0 +1,63 @@
1
+ import { FlowrAnalyzerPackageVersionsPlugin, type PkgDbLoadedInfo } from './flowr-analyzer-package-versions-plugin';
2
+ import { SemVer } from 'semver';
3
+ import type { FlowrAnalyzerContext } from '../../context/flowr-analyzer-context';
4
+ import { PkgDatabase, type PkgDb } from './pkgdb';
5
+ /** the plugin's instance name (pass to `unregisterPlugins` to disable the default pkgdb resolver) */
6
+ export declare const PkgDbPluginName = "flowr-analyzer-package-versions-pkgdb-plugin";
7
+ export declare const pkgDbLog: import("tslog").Logger<import("tslog").ILogObj>;
8
+ /** a database, a parsed object, or a local file path */
9
+ export type PkgDbSource = PkgDatabase | PkgDb | string;
10
+ /**
11
+ * The database flattens S3 methods into the export list, so we recover the `generic -> classes` map for
12
+ * dispatch: an export `generic.class` is a method when the `generic` is itself exported (e.g. `print.foo`).
13
+ */
14
+ export declare function reconstructS3Generics(exported: readonly string[]): Map<string, string[]>;
15
+ /**
16
+ * Resolves `library(pkg)` / `use(pkg, fn)` from precomputed `flowr-pkgdb` databases: the one bundled
17
+ * with flowR plus any extra sources (constructor args or `$FLOWR_PKGDB`). Extra sources are consulted
18
+ * first, so they override the bundle; packages only in the bundle still resolve. Everything is loaded
19
+ * lazily on the first miss (never touched if a project uses no external packages). On by default; opt
20
+ * out via `unregisterPlugins(PkgDbPluginName)` or `$FLOWR_DISABLE_DEFAULT_PKGDB`.
21
+ *
22
+ * A source may be an `http(s)` URL to a downloadable summary; call {@link preload} once at the
23
+ * analyzer boundary to fetch it, so resolution falls through to it for packages not in the bundle.
24
+ */
25
+ export declare class FlowrAnalyzerPackageVersionsPkgDbPlugin extends FlowrAnalyzerPackageVersionsPlugin {
26
+ readonly name = "flowr-analyzer-package-versions-pkgdb-plugin";
27
+ readonly description = "Resolves library exports from precomputed flowr-pkgdb databases.";
28
+ readonly version: SemVer;
29
+ /**
30
+ * Process-wide cache of parsed file databases, keyed by their source path, so a flowR session parses
31
+ * each file once. Parsing the bundled database is ~25ms and a fresh plugin instance is created per
32
+ * analyzer, so without this every analysis touching a `library()` call would re-parse the multi-MB file.
33
+ */
34
+ private static readonly fileCache;
35
+ private readonly extraSources;
36
+ private databases;
37
+ constructor(...sources: PkgDbSource[]);
38
+ process(ctx: FlowrAnalyzerContext): void;
39
+ /** Mount the databases up front (see `solver.eagerlyLoadPackageDatabase`) instead of on the first library load. */
40
+ preloadDatabasesSync(): void;
41
+ /** metadata of the databases currently loaded (the synchronously available, non-URL sources) */
42
+ loadedDatabases(): PkgDbLoadedInfo[];
43
+ /**
44
+ * Sources in priority order: explicit constructor sources, then `$FLOWR_PKGDB`, then the bundled
45
+ * default. The bundled default is skipped when `$FLOWR_DISABLE_DEFAULT_PKGDB` is set (explicit
46
+ * sources are always honored) - the env opt-out for the shipped database.
47
+ */
48
+ private sources;
49
+ private static isUrl;
50
+ /** synchronously loaded databases; remote (URL) summaries are only added by {@link preload}. */
51
+ private loadDatabases;
52
+ /**
53
+ * Download and load every source, including remote (URL) summaries. Call this once at the
54
+ * analyzer boundary to let `library()` resolution fall through to additional downloaded databases
55
+ * (e.g. the full `all` summary or a richer `latest`). Without it, only local sources are used.
56
+ */
57
+ preload(): Promise<void>;
58
+ private load;
59
+ private mustLoad;
60
+ /** Load a file source once per session, reusing the parsed database across analyzer instances. */
61
+ private static loadFileCached;
62
+ private resolve;
63
+ }
@@ -0,0 +1,174 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.FlowrAnalyzerPackageVersionsPkgDbPlugin = exports.pkgDbLog = exports.PkgDbPluginName = void 0;
7
+ exports.reconstructS3Generics = reconstructS3Generics;
8
+ const flowr_analyzer_package_versions_plugin_1 = require("./flowr-analyzer-package-versions-plugin");
9
+ const semver_1 = require("semver");
10
+ const path_1 = __importDefault(require("path"));
11
+ const package_1 = require("./package");
12
+ const pkgdb_1 = require("./pkgdb");
13
+ const log_1 = require("../../../util/log");
14
+ /** the plugin's instance name (pass to `unregisterPlugins` to disable the default pkgdb resolver) */
15
+ exports.PkgDbPluginName = 'flowr-analyzer-package-versions-pkgdb-plugin';
16
+ exports.pkgDbLog = log_1.log.getSubLogger({ name: exports.PkgDbPluginName });
17
+ /** additional sources from `$FLOWR_PKGDB` (path-delimiter separated), highest priority after explicit ones */
18
+ function envSources() {
19
+ const env = typeof process !== 'undefined' ? process.env?.FLOWR_PKGDB : undefined;
20
+ return env ? env.split(path_1.default.delimiter).filter(s => s.length > 0) : [];
21
+ }
22
+ /**
23
+ * The database flattens S3 methods into the export list, so we recover the `generic -> classes` map for
24
+ * dispatch: an export `generic.class` is a method when the `generic` is itself exported (e.g. `print.foo`).
25
+ */
26
+ function reconstructS3Generics(exported) {
27
+ const names = new Set(exported);
28
+ const generics = new Map();
29
+ for (const name of exported) {
30
+ const dot = name.indexOf('.');
31
+ const generic = dot > 0 ? name.slice(0, dot) : undefined;
32
+ if (generic !== undefined && names.has(generic)) {
33
+ const classes = generics.get(generic) ?? [];
34
+ classes.push(name.slice(dot + 1));
35
+ generics.set(generic, classes);
36
+ }
37
+ }
38
+ return generics;
39
+ }
40
+ /**
41
+ * Resolves `library(pkg)` / `use(pkg, fn)` from precomputed `flowr-pkgdb` databases: the one bundled
42
+ * with flowR plus any extra sources (constructor args or `$FLOWR_PKGDB`). Extra sources are consulted
43
+ * first, so they override the bundle; packages only in the bundle still resolve. Everything is loaded
44
+ * lazily on the first miss (never touched if a project uses no external packages). On by default; opt
45
+ * out via `unregisterPlugins(PkgDbPluginName)` or `$FLOWR_DISABLE_DEFAULT_PKGDB`.
46
+ *
47
+ * A source may be an `http(s)` URL to a downloadable summary; call {@link preload} once at the
48
+ * analyzer boundary to fetch it, so resolution falls through to it for packages not in the bundle.
49
+ */
50
+ class FlowrAnalyzerPackageVersionsPkgDbPlugin extends flowr_analyzer_package_versions_plugin_1.FlowrAnalyzerPackageVersionsPlugin {
51
+ name = exports.PkgDbPluginName;
52
+ description = 'Resolves library exports from precomputed flowr-pkgdb databases.';
53
+ version = new semver_1.SemVer('0.1.0');
54
+ /**
55
+ * Process-wide cache of parsed file databases, keyed by their source path, so a flowR session parses
56
+ * each file once. Parsing the bundled database is ~25ms and a fresh plugin instance is created per
57
+ * analyzer, so without this every analysis touching a `library()` call would re-parse the multi-MB file.
58
+ */
59
+ static fileCache = new Map();
60
+ extraSources;
61
+ databases;
62
+ constructor(...sources) {
63
+ super();
64
+ this.extraSources = sources;
65
+ }
66
+ process(ctx) {
67
+ this.databases = undefined; // reload on (re)registration so config/source changes take effect
68
+ ctx.deps.addLazyResolver((name, existing) => this.resolve(name, existing));
69
+ }
70
+ /** Mount the databases up front (see `solver.eagerlyLoadPackageDatabase`) instead of on the first library load. */
71
+ preloadDatabasesSync() {
72
+ this.loadDatabases();
73
+ }
74
+ /** metadata of the databases currently loaded (the synchronously available, non-URL sources) */
75
+ loadedDatabases() {
76
+ return this.loadDatabases().map(db => ({ scope: db.scope, version: db.content.version, date: db.content.date }));
77
+ }
78
+ /**
79
+ * Sources in priority order: explicit constructor sources, then `$FLOWR_PKGDB`, then the bundled
80
+ * default. The bundled default is skipped when `$FLOWR_DISABLE_DEFAULT_PKGDB` is set (explicit
81
+ * sources are always honored) - the env opt-out for the shipped database.
82
+ */
83
+ sources() {
84
+ const disableBundled = typeof process !== 'undefined' && process.env?.FLOWR_DISABLE_DEFAULT_PKGDB;
85
+ const bundled = disableBundled ? undefined : (0, pkgdb_1.defaultPkgDbPath)(); // richest bundled tier (all > latest > tiny)
86
+ return [...this.extraSources, ...envSources(), ...(bundled ? [bundled] : [])];
87
+ }
88
+ static isUrl(s) {
89
+ return typeof s === 'string' && /^https?:\/\//.test(s);
90
+ }
91
+ /** synchronously loaded databases; remote (URL) summaries are only added by {@link preload}. */
92
+ loadDatabases() {
93
+ if (this.databases === undefined) {
94
+ this.databases = this.sources()
95
+ .filter(s => !FlowrAnalyzerPackageVersionsPkgDbPlugin.isUrl(s))
96
+ .map(s => this.load(s))
97
+ .filter((d) => d !== undefined);
98
+ }
99
+ return this.databases;
100
+ }
101
+ /**
102
+ * Download and load every source, including remote (URL) summaries. Call this once at the
103
+ * analyzer boundary to let `library()` resolution fall through to additional downloaded databases
104
+ * (e.g. the full `all` summary or a richer `latest`). Without it, only local sources are used.
105
+ */
106
+ async preload() {
107
+ const dbs = [];
108
+ for (const source of this.sources()) {
109
+ try {
110
+ dbs.push(FlowrAnalyzerPackageVersionsPkgDbPlugin.isUrl(source) ? await pkgdb_1.PkgDatabase.fromUrl(source) : this.mustLoad(source));
111
+ }
112
+ catch (e) {
113
+ exports.pkgDbLog.warn(`Could not load pkgdb source: ${e.message}`);
114
+ }
115
+ }
116
+ this.databases = dbs;
117
+ }
118
+ load(source) {
119
+ try {
120
+ return this.mustLoad(source);
121
+ }
122
+ catch (e) {
123
+ exports.pkgDbLog.warn(`Could not load pkgdb source: ${e.message}`);
124
+ return undefined;
125
+ }
126
+ }
127
+ mustLoad(source) {
128
+ if (source instanceof pkgdb_1.PkgDatabase) {
129
+ return source;
130
+ }
131
+ if (typeof source !== 'string') {
132
+ return pkgdb_1.PkgDatabase.fromObject(source);
133
+ }
134
+ return FlowrAnalyzerPackageVersionsPkgDbPlugin.loadFileCached(source);
135
+ }
136
+ /** Load a file source once per session, reusing the parsed database across analyzer instances. */
137
+ static loadFileCached(file) {
138
+ const cache = FlowrAnalyzerPackageVersionsPkgDbPlugin.fileCache;
139
+ let db = cache.get(file);
140
+ if (db === undefined) {
141
+ db = pkgdb_1.PkgDatabase.fromFileSync(file);
142
+ cache.set(file, db);
143
+ }
144
+ return db;
145
+ }
146
+ resolve(name, existing) {
147
+ const pinned = existing?.derivedVersion ? (0, semver_1.minVersion)(existing.derivedVersion)?.version : undefined;
148
+ for (const db of this.loadDatabases()) {
149
+ const info = db.lookup(name, pinned);
150
+ if (!info) {
151
+ continue;
152
+ }
153
+ if (pinned && info.version !== pinned) {
154
+ exports.pkgDbLog.warn(`project pins ${name}@${pinned} but the export database only has ${info.version}; analyzing with ${info.version}`);
155
+ }
156
+ else if (!pinned) {
157
+ exports.pkgDbLog.debug(`no pinned version for ${name}; using ${info.version}`);
158
+ }
159
+ const namespaceInfo = {
160
+ exportedSymbols: info.exported,
161
+ exportedFunctions: [],
162
+ exportS3Generics: reconstructS3Generics(info.exported),
163
+ exportedPatterns: [],
164
+ importedPackages: new Map(),
165
+ loadsWithSideEffects: false,
166
+ callable: info.exported
167
+ };
168
+ return new package_1.Package({ name, namespaceInfo });
169
+ }
170
+ return undefined;
171
+ }
172
+ }
173
+ exports.FlowrAnalyzerPackageVersionsPkgDbPlugin = FlowrAnalyzerPackageVersionsPkgDbPlugin;
174
+ //# sourceMappingURL=flowr-analyzer-package-versions-pkgdb-plugin.js.map
@@ -1,4 +1,10 @@
1
1
  import { FlowrAnalyzerPlugin, PluginType } from '../flowr-analyzer-plugin';
2
+ /** metadata of a package database a plugin currently has loaded */
3
+ export interface PkgDbLoadedInfo {
4
+ scope: string;
5
+ version: number;
6
+ date: string;
7
+ }
2
8
  /**
3
9
  * This is the base class for all plugins that identify package and dependency versions used in the project.
4
10
  * These plugins interplay with the {@link FlowrAnalyzerDependenciesContext} to gather information about the packages used in the project.
@@ -7,4 +13,8 @@ import { FlowrAnalyzerPlugin, PluginType } from '../flowr-analyzer-plugin';
7
13
  export declare abstract class FlowrAnalyzerPackageVersionsPlugin extends FlowrAnalyzerPlugin<undefined, void> {
8
14
  readonly type = PluginType.DependencyIdentification;
9
15
  static defaultPlugin(): FlowrAnalyzerPackageVersionsPlugin;
16
+ /** metadata of the databases this plugin currently has loaded (empty for plugins without any) */
17
+ loadedDatabases(): PkgDbLoadedInfo[];
18
+ /** Eagerly parse and mount this plugin's databases up front (no-op for plugins without any). */
19
+ preloadDatabasesSync(): void;
10
20
  }
@@ -13,6 +13,12 @@ class FlowrAnalyzerPackageVersionsPlugin extends flowr_analyzer_plugin_1.FlowrAn
13
13
  static defaultPlugin() {
14
14
  return new DefaultFlowrAnalyzerPackageVersionsPlugin();
15
15
  }
16
+ /** metadata of the databases this plugin currently has loaded (empty for plugins without any) */
17
+ loadedDatabases() {
18
+ return [];
19
+ }
20
+ /** Eagerly parse and mount this plugin's databases up front (no-op for plugins without any). */
21
+ preloadDatabasesSync() { }
16
22
  }
17
23
  exports.FlowrAnalyzerPackageVersionsPlugin = FlowrAnalyzerPackageVersionsPlugin;
18
24
  /**
@@ -18,6 +18,8 @@ export declare class Package {
18
18
  constructor(info: {
19
19
  name: string;
20
20
  } & PackageOptions);
21
+ /** Builds a package from a raw `NAMESPACE` body and its list of callable exports. */
22
+ static fromConstants(name: string, namespace: string, callable: string[]): Package;
21
23
  has(name: string, className?: string): boolean;
22
24
  s3For(generic: string): string[];
23
25
  mergeInPlace(other: Package): void;
@@ -25,4 +27,5 @@ export declare class Package {
25
27
  getInfo(): this;
26
28
  deriveVersion(): Range | undefined;
27
29
  static parsePackageVersionRange(constraint?: string, version?: string): Range | undefined;
30
+ static funcIdentif(dependency: string, func: string): string;
28
31
  }
@@ -2,6 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Package = void 0;
4
4
  const assert_1 = require("../../../util/assert");
5
+ const flowr_namespace_file_1 = require("../file-plugins/files/flowr-namespace-file");
6
+ const flowr_file_1 = require("../../context/flowr-file");
5
7
  const r_version_1 = require("../../../util/r-version");
6
8
  class Package {
7
9
  name;
@@ -14,6 +16,13 @@ class Package {
14
16
  this.name = info.name;
15
17
  this.addInfo(info);
16
18
  }
19
+ /** Builds a package from a raw `NAMESPACE` body and its list of callable exports. */
20
+ static fromConstants(name, namespace, callable) {
21
+ return new Package({
22
+ name,
23
+ namespaceInfo: (0, flowr_namespace_file_1.setCallable)(flowr_namespace_file_1.FlowrNamespaceFile.from(new flowr_file_1.FlowrInlineTextFile('NAMESPACE', namespace)).content().current, callable)
24
+ });
25
+ }
17
26
  has(name, className) {
18
27
  if (!this.namespaceInfo) {
19
28
  return false;
@@ -79,6 +88,9 @@ class Package {
79
88
  return undefined;
80
89
  }
81
90
  }
91
+ static funcIdentif(dependency, func) {
92
+ return `${dependency}:${func}`;
93
+ }
82
94
  }
83
95
  exports.Package = Package;
84
96
  //# sourceMappingURL=package.js.map
@@ -0,0 +1,133 @@
1
+ export declare const PkgDbMagic = "flowr-pkgdb";
2
+ export declare const PkgDbSchema = 4;
3
+ export declare const DefaultCranBase = "https://cran.r-project.org/src/contrib/";
4
+ export type PkgDbItem = number | string;
5
+ export type PkgDbLatestEntry = [version: string, exported: PkgDbItem[]];
6
+ /** one version in the `all` scope: `[version, exported, internal?, deprecated?]` of `lists` indices */
7
+ export type PkgDbAllVersion = [string, number] | [string, number, number] | [string, number, number, number];
8
+ /** `all`-scope package: `[latest, versions, nonCranVersions?]` (all arrays, no keys) */
9
+ export type PkgDbAllEntry = [string, PkgDbAllVersion[]] | [string, PkgDbAllVersion[], string[]];
10
+ /** optional definition location `[fileIndex, line]` indexing the `files` pool */
11
+ export type PkgDbLoc = readonly [fileIndex: number, line: number];
12
+ export interface PkgDbContent {
13
+ version: number;
14
+ date: string;
15
+ hash: string;
16
+ generated: number;
17
+ packages: number;
18
+ versions: number;
19
+ }
20
+ interface PkgDbCommon {
21
+ format: string;
22
+ schema: number;
23
+ content: PkgDbContent;
24
+ cranBase?: string;
25
+ strings: string[];
26
+ archived?: string[];
27
+ noncran?: string[];
28
+ }
29
+ export interface PkgDbLatest extends PkgDbCommon {
30
+ scope: 'latest';
31
+ pkgs: Record<string, PkgDbLatestEntry>;
32
+ }
33
+ export interface PkgDbAll extends PkgDbCommon {
34
+ scope: 'all';
35
+ lists: PkgDbItem[][];
36
+ pkgs: Record<string, PkgDbAllEntry>;
37
+ /** optional file-path pool for {@link locs} */
38
+ files?: string[];
39
+ /** optional definition locations of the latest version: `pkg -> identifier -> [fileIndex, line]` */
40
+ locs?: Record<string, Record<string, PkgDbLoc>>;
41
+ }
42
+ export type PkgDb = PkgDbLatest | PkgDbAll;
43
+ /** a definition location surfaced from the `all` scope when the database carries them */
44
+ export interface PkgDbDefinitionLocation {
45
+ file: string;
46
+ line: number;
47
+ }
48
+ /** the resolved identifiers of one package version */
49
+ export interface LibraryExports {
50
+ version: string;
51
+ exported: string[];
52
+ /** defined-but-not-exported identifiers (only available in the `all` scope) */
53
+ internal: string[];
54
+ deprecated: string[];
55
+ cran: boolean;
56
+ cranUrl?: string;
57
+ /** definition location per identifier, if the database carries them (`all` scope, latest version) */
58
+ locations?: ReadonlyMap<string, PkgDbDefinitionLocation>;
59
+ }
60
+ /** Reconstruct the CRAN source blob link; the newest non-archived version lives under `src/contrib`, every other under `Archive`. */
61
+ export declare function cranBlobUrl(cranBase: string, pkg: string, version: string, opts: {
62
+ latest: string;
63
+ archived: boolean;
64
+ cran: boolean;
65
+ }): string | undefined;
66
+ /** Validate the structural invariants of a decoded database, throwing a descriptive error on failure. */
67
+ export declare function validatePkgDb(o: unknown): asserts o is PkgDb;
68
+ export type PkgDbScope = 'all' | 'latest' | 'tiny';
69
+ /**
70
+ * Location of a bundled database, found by walking up from several roots (this module,
71
+ * `$FLOWR_PKGDB_DIR`, the working directory) across the dev (`src`) and build (`dist`) layouts. With
72
+ * no `scope` it returns the richest available tier (brotli, then gzip, then plain json). Node only
73
+ * (needs `fs`); pass `searchRoots` to override where it looks.
74
+ */
75
+ export declare function defaultPkgDbPath(scope?: PkgDbScope, searchRoots?: readonly string[]): string | undefined;
76
+ /** classified identifiers of one package version, fed to {@link PkgDbBuilder} */
77
+ export interface VersionExports {
78
+ exported: readonly string[];
79
+ internal: readonly string[];
80
+ deprecated: readonly string[];
81
+ cran: boolean;
82
+ /** optional definition location per identifier: `name -> [file, line]` (emitted only in the `all` scope) */
83
+ locations?: ReadonlyMap<string, readonly [file: string, line: number]>;
84
+ }
85
+ /**
86
+ * Serializes a {@link PkgDb}. Accumulate per-version exports with {@link addPackage}/{@link addVersion},
87
+ * then {@link build} a scope. The multi-use string pool is computed per scope; the `latest` scope may
88
+ * be pruned to the most-downloaded packages. This is the counterpart of {@link PkgDatabase} (the reader).
89
+ */
90
+ export declare class PkgDbBuilder {
91
+ private readonly raw;
92
+ private versionCount;
93
+ addPackage(name: string, opts: {
94
+ latest: string;
95
+ archived?: boolean;
96
+ downloads?: number;
97
+ }): void;
98
+ addVersion(name: string, version: string, exports: VersionExports): void;
99
+ private relevant;
100
+ private buildPool;
101
+ build(scope: 'latest' | 'all', meta: {
102
+ version: number;
103
+ date: string;
104
+ generated: number;
105
+ cranBase?: string;
106
+ minDownloads?: number;
107
+ topN?: number;
108
+ }): PkgDb;
109
+ }
110
+ export declare class PkgDatabase {
111
+ private readonly db;
112
+ private readonly archived;
113
+ private readonly noncran;
114
+ constructor(db: PkgDb);
115
+ get content(): PkgDbContent;
116
+ get scope(): 'latest' | 'all';
117
+ /** parse an already-loaded object (validates the schema, throwing a descriptive error on failure) */
118
+ static fromObject(obj: unknown): PkgDatabase;
119
+ /** portable async load from raw bytes (gzip auto-detected) */
120
+ static fromBytes(bytes: Uint8Array): Promise<PkgDatabase>;
121
+ /** portable async load from a URL (works in Node 18+, browser and VS Code) */
122
+ static fromUrl(url: string): Promise<PkgDatabase>;
123
+ /** synchronous load from a local file (Node only; brotli by `.br`, else gzip auto-detected, else plain) */
124
+ static fromFileSync(file: string): PkgDatabase;
125
+ has(pkg: string): boolean;
126
+ private decode;
127
+ private result;
128
+ /** definition locations of the latest version, if the (`all`-scope) database carries them */
129
+ private locations;
130
+ /** look up the identifiers of a package (defaulting to its latest version) */
131
+ lookup(pkg: string, version?: string): LibraryExports | undefined;
132
+ }
133
+ export {};