@eagleoutice/flowr 2.10.8 → 2.10.10

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 (260) hide show
  1. package/README.md +106 -36
  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/script.js +3 -2
  23. package/cli/flowr.js +47 -10
  24. package/cli/repl/commands/repl-cfg.js +9 -9
  25. package/cli/repl/commands/repl-commands.js +5 -0
  26. package/cli/repl/commands/repl-dataflow.js +31 -24
  27. package/cli/repl/commands/repl-main.d.ts +6 -0
  28. package/cli/repl/commands/repl-normalize.js +15 -12
  29. package/cli/repl/commands/repl-parse.js +1 -1
  30. package/cli/repl/commands/repl-query.js +4 -5
  31. package/cli/repl/commands/repl-quit.js +2 -1
  32. package/cli/repl/core.d.ts +11 -0
  33. package/cli/repl/core.js +101 -3
  34. package/cli/repl/execute.js +3 -2
  35. package/cli/repl/parser/slice-query-parser.d.ts +16 -0
  36. package/cli/repl/parser/slice-query-parser.js +52 -0
  37. package/cli/repl/server/connection.d.ts +1 -0
  38. package/cli/repl/server/connection.js +25 -0
  39. package/cli/repl/server/messages/message-analysis.d.ts +10 -0
  40. package/cli/repl/server/messages/message-analysis.js +6 -2
  41. package/cli/repl/server/messages/message-slice.d.ts +1 -1
  42. package/cli/script-core/statistics-core.js +2 -1
  43. package/cli/script-core/statistics-helper-core.js +2 -1
  44. package/cli/wiki.d.ts +2 -1
  45. package/cli/wiki.js +4 -1
  46. package/config.d.ts +9 -0
  47. package/config.js +23 -1
  48. package/control-flow/diff-cfg.d.ts +1 -1
  49. package/control-flow/diff-cfg.js +1 -1
  50. package/control-flow/extract-cfg.js +9 -3
  51. package/control-flow/semantic-cfg-guided-visitor.js +1 -0
  52. package/control-flow/simple-visitor.js +6 -5
  53. package/control-flow/useless-loop.js +2 -2
  54. package/core/print/dataflow-printer.d.ts +2 -2
  55. package/core/print/dataflow-printer.js +2 -2
  56. package/core/steps/all/static-slicing/00-slice.js +1 -1
  57. package/core/steps/pipeline/default-pipelines.d.ts +146 -146
  58. package/dataflow/environments/append.d.ts +2 -1
  59. package/dataflow/environments/append.js +2 -1
  60. package/dataflow/environments/built-in-proc-name.d.ts +2 -0
  61. package/dataflow/environments/built-in-proc-name.js +2 -0
  62. package/dataflow/environments/built-in.d.ts +2 -0
  63. package/dataflow/environments/built-in.js +2 -0
  64. package/dataflow/environments/default-builtin-config.d.ts +122 -66
  65. package/dataflow/environments/default-builtin-config.js +324 -145
  66. package/dataflow/environments/environment.d.ts +2 -1
  67. package/dataflow/environments/environment.js +13 -9
  68. package/dataflow/environments/identifier.d.ts +55 -2
  69. package/dataflow/environments/identifier.js +14 -2
  70. package/dataflow/environments/reference-to-maybe.d.ts +2 -0
  71. package/dataflow/environments/reference-to-maybe.js +56 -11
  72. package/dataflow/environments/resolve-by-name.js +13 -7
  73. package/dataflow/eval/values/general.js +4 -0
  74. package/dataflow/extractor.js +22 -3
  75. package/dataflow/graph/df-helper.d.ts +6 -0
  76. package/dataflow/graph/df-helper.js +33 -0
  77. package/dataflow/graph/graph.js +7 -3
  78. package/dataflow/info.d.ts +1 -1
  79. package/dataflow/info.js +3 -1
  80. package/dataflow/internal/linker.d.ts +5 -1
  81. package/dataflow/internal/linker.js +34 -9
  82. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +3 -1
  83. package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +1 -1
  84. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +53 -0
  85. package/dataflow/internal/process/functions/call/built-in/built-in-namespace-access.d.ts +13 -0
  86. package/dataflow/internal/process/functions/call/built-in/built-in-namespace-access.js +58 -0
  87. package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.js +1 -1
  88. package/dataflow/internal/process/functions/call/built-in/built-in-rm.d.ts +1 -1
  89. package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +38 -14
  90. package/dataflow/internal/process/functions/call/built-in/built-in-source.js +19 -0
  91. package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +1 -1
  92. package/dataflow/internal/process/functions/call/known-call-handling.js +4 -3
  93. package/dataflow/internal/process/functions/call/named-call-handling.js +6 -0
  94. package/dataflow/origin/dfg-get-origin.d.ts +1 -1
  95. package/dataflow/origin/dfg-get-origin.js +1 -1
  96. package/dataflow/processor.d.ts +6 -0
  97. package/documentation/data/faq/faqs.d.ts +2 -1
  98. package/documentation/data/faq/faqs.js +75 -57
  99. package/documentation/data/server/doc-data-server-messages.d.ts +2 -1
  100. package/documentation/data/server/doc-data-server-messages.js +15 -7
  101. package/documentation/doc-readme.js +15 -15
  102. package/documentation/doc-util/doc-cfg.d.ts +3 -1
  103. package/documentation/doc-util/doc-cfg.js +3 -3
  104. package/documentation/doc-util/doc-dfg.d.ts +3 -1
  105. package/documentation/doc-util/doc-dfg.js +3 -3
  106. package/documentation/doc-util/doc-files.d.ts +3 -1
  107. package/documentation/doc-util/doc-files.js +9 -6
  108. package/documentation/doc-util/doc-normalized-ast.d.ts +3 -1
  109. package/documentation/doc-util/doc-normalized-ast.js +2 -2
  110. package/documentation/doc-util/doc-query.d.ts +2 -1
  111. package/documentation/doc-util/doc-query.js +2 -2
  112. package/documentation/doc-util/doc-repl.js +1 -0
  113. package/documentation/doc-util/doc-types.d.ts +6 -6
  114. package/documentation/doc-util/doc-types.js +11 -9
  115. package/documentation/issue-linting-rule.js +1 -2
  116. package/documentation/wiki-analyzer.js +9 -9
  117. package/documentation/wiki-cfg.js +40 -41
  118. package/documentation/wiki-core.js +119 -31
  119. package/documentation/wiki-create-linting-rules.d.ts +6 -0
  120. package/documentation/wiki-create-linting-rules.js +95 -0
  121. package/documentation/wiki-dataflow-graph.js +77 -76
  122. package/documentation/wiki-engine.js +1 -2
  123. package/documentation/wiki-faq.d.ts +2 -1
  124. package/documentation/wiki-faq.js +4 -4
  125. package/documentation/wiki-interface.js +19 -6
  126. package/documentation/wiki-linter.d.ts +1 -1
  127. package/documentation/wiki-linter.js +14 -6
  128. package/documentation/wiki-linting-and-testing.js +2 -2
  129. package/documentation/wiki-mk/doc-context.d.ts +3 -3
  130. package/documentation/wiki-mk/doc-maker.d.ts +2 -0
  131. package/documentation/wiki-mk/doc-maker.js +7 -1
  132. package/documentation/wiki-normalized-ast.js +5 -5
  133. package/documentation/wiki-onboarding.d.ts +2 -1
  134. package/documentation/wiki-onboarding.js +5 -5
  135. package/documentation/wiki-overview.js +3 -3
  136. package/documentation/wiki-query.js +85 -84
  137. package/documentation/wiki-search.js +4 -5
  138. package/documentation/wiki-setup.js +6 -7
  139. package/gas.d.ts +74 -0
  140. package/gas.js +18 -0
  141. package/linter/linter-executor.js +2 -8
  142. package/linter/linter-format.d.ts +4 -11
  143. package/linter/linter-rules.d.ts +88 -86
  144. package/linter/linter-rules.js +7 -1
  145. package/linter/rules/absolute-path.d.ts +2 -7
  146. package/linter/rules/absolute-path.js +6 -4
  147. package/linter/rules/dataframe-access-validation.d.ts +1 -6
  148. package/linter/rules/dataframe-access-validation.js +8 -6
  149. package/linter/rules/dead-code.d.ts +2 -11
  150. package/linter/rules/dead-code.js +16 -11
  151. package/linter/rules/deprecated-functions.d.ts +3 -3
  152. package/linter/rules/file-path-validity.d.ts +1 -6
  153. package/linter/rules/file-path-validity.js +5 -5
  154. package/linter/rules/function-finder-util.d.ts +7 -11
  155. package/linter/rules/function-finder-util.js +9 -6
  156. package/linter/rules/naming-convention.d.ts +2 -7
  157. package/linter/rules/naming-convention.js +3 -2
  158. package/linter/rules/network-functions.d.ts +2 -7
  159. package/linter/rules/network-functions.js +14 -12
  160. package/linter/rules/no-leaked-credentials.d.ts +36 -0
  161. package/linter/rules/no-leaked-credentials.js +75 -0
  162. package/linter/rules/problematic-inputs.d.ts +1 -8
  163. package/linter/rules/problematic-inputs.js +5 -4
  164. package/linter/rules/roxygen-arguments.d.ts +2 -7
  165. package/linter/rules/roxygen-arguments.js +13 -20
  166. package/linter/rules/seeded-randomness.d.ts +2 -7
  167. package/linter/rules/seeded-randomness.js +7 -4
  168. package/linter/rules/software-has-license.d.ts +31 -0
  169. package/linter/rules/software-has-license.js +46 -0
  170. package/linter/rules/software-has-tests.d.ts +38 -0
  171. package/linter/rules/software-has-tests.js +48 -0
  172. package/linter/rules/stop-with-call-arg.d.ts +2 -7
  173. package/linter/rules/stop-with-call-arg.js +3 -2
  174. package/linter/rules/unused-definition.d.ts +3 -8
  175. package/linter/rules/unused-definition.js +7 -5
  176. package/linter/rules/useless-loop.d.ts +2 -7
  177. package/linter/rules/useless-loop.js +5 -2
  178. package/package.json +3 -2
  179. package/project/context/flowr-analyzer-context.d.ts +13 -14
  180. package/project/context/flowr-analyzer-context.js +4 -0
  181. package/project/context/flowr-analyzer-files-context.d.ts +12 -0
  182. package/project/context/flowr-analyzer-files-context.js +12 -2
  183. package/project/context/flowr-analyzer-gas-context.d.ts +28 -0
  184. package/project/context/flowr-analyzer-gas-context.js +101 -0
  185. package/project/plugins/file-plugins/files/flowr-rmarkdown-file.d.ts +13 -7
  186. package/project/plugins/file-plugins/files/flowr-rmarkdown-file.js +56 -11
  187. package/project/plugins/file-plugins/notebooks/flowr-analyzer-qmd-file-plugin.d.ts +1 -1
  188. package/project/plugins/file-plugins/notebooks/flowr-analyzer-qmd-file-plugin.js +2 -2
  189. package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmd-file-plugin.d.ts +2 -1
  190. package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmd-file-plugin.js +5 -5
  191. package/project/plugins/flowr-analyzer-plugin.d.ts +15 -8
  192. package/project/plugins/flowr-analyzer-plugin.js +14 -7
  193. package/project/plugins/gas-plugins/flowr-analyzer-gas-plugin.d.ts +19 -0
  194. package/project/plugins/gas-plugins/flowr-analyzer-gas-plugin.js +35 -0
  195. package/project/plugins/plugin-registry.d.ts +2 -1
  196. package/project/plugins/plugin-registry.js +3 -1
  197. package/project/plugins/project-discovery/flowr-analyzer-gitignore-project-discovery-plugin.d.ts +22 -0
  198. package/project/plugins/project-discovery/flowr-analyzer-gitignore-project-discovery-plugin.js +47 -0
  199. package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +1 -1
  200. package/queries/catalog/call-context-query/call-context-query-executor.js +54 -8
  201. package/queries/catalog/call-context-query/call-context-query-format.d.ts +2 -2
  202. package/queries/catalog/dependencies-query/function-info/test-functions.d.ts +2 -0
  203. package/queries/catalog/dependencies-query/function-info/test-functions.js +18 -177
  204. package/queries/catalog/df-shape-query/df-shape-query-format.js +1 -1
  205. package/queries/catalog/dice-query/dice-query-executor.d.ts +8 -0
  206. package/queries/catalog/dice-query/dice-query-executor.js +52 -0
  207. package/queries/catalog/dice-query/dice-query-format.d.ts +53 -0
  208. package/queries/catalog/dice-query/dice-query-format.js +102 -0
  209. package/queries/catalog/happens-before-query/happens-before-query-executor.js +2 -2
  210. package/queries/catalog/input-sources-query/input-sources-query-format.d.ts +2 -0
  211. package/queries/catalog/input-sources-query/input-sources-query-format.js +1 -0
  212. package/queries/catalog/inspect-exceptions-query/inspect-exception-query-format.d.ts +2 -0
  213. package/queries/catalog/inspect-exceptions-query/inspect-exception-query-format.js +1 -0
  214. package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.d.ts +2 -0
  215. package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.js +1 -0
  216. package/queries/catalog/linter-query/linter-query-executor.js +7 -0
  217. package/queries/catalog/location-map-query/location-map-query-format.d.ts +2 -0
  218. package/queries/catalog/location-map-query/location-map-query-format.js +1 -0
  219. package/queries/catalog/origin-query/origin-query-format.d.ts +2 -0
  220. package/queries/catalog/origin-query/origin-query-format.js +1 -0
  221. package/queries/catalog/provenance-query/provenance-query-format.d.ts +2 -0
  222. package/queries/catalog/provenance-query/provenance-query-format.js +1 -0
  223. package/queries/catalog/resolve-value-query/resolve-value-query-format.d.ts +2 -0
  224. package/queries/catalog/resolve-value-query/resolve-value-query-format.js +1 -0
  225. package/queries/catalog/static-slice-query/static-slice-query-executor.js +1 -1
  226. package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +2 -0
  227. package/queries/catalog/static-slice-query/static-slice-query-format.js +1 -0
  228. package/queries/query.d.ts +18 -1
  229. package/queries/query.js +3 -1
  230. package/r-bridge/data/data.d.ts +5 -0
  231. package/r-bridge/data/data.js +6 -0
  232. package/r-bridge/lang-4.x/ast/model/nodes/r-string.d.ts +0 -1
  233. package/r-bridge/lang-4.x/ast/model/processing/decorate.js +10 -1
  234. package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-number.d.ts +1 -1
  235. package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-number.js +1 -1
  236. package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-string.d.ts +1 -1
  237. package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-string.js +1 -1
  238. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +63 -44
  239. package/r-bridge/parser.js +2 -9
  240. package/r-bridge/shell.d.ts +8 -1
  241. package/r-bridge/shell.js +26 -7
  242. package/search/flowr-search-builder.d.ts +2 -2
  243. package/search/flowr-search-builder.js +1 -1
  244. package/search/flowr-search-filters.d.ts +30 -9
  245. package/search/flowr-search-filters.js +26 -21
  246. package/search/search-executor/search-enrichers.d.ts +600 -0
  247. package/search/search-executor/search-enrichers.js +23 -2
  248. package/slicing/static/static-slicer.d.ts +39 -11
  249. package/slicing/static/static-slicer.js +44 -14
  250. package/util/collections/queue.d.ts +16 -0
  251. package/util/collections/queue.js +38 -0
  252. package/util/log.d.ts +1 -1
  253. package/util/log.js +1 -1
  254. package/util/mermaid/dfg.d.ts +2 -2
  255. package/util/mermaid/dfg.js +2 -2
  256. package/util/objects.d.ts +9 -0
  257. package/util/objects.js +57 -1
  258. package/util/proc.d.ts +6 -0
  259. package/util/proc.js +20 -0
  260. package/util/version.js +1 -1
@@ -3,43 +3,53 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.UnsupportedFunctions = void 0;
4
4
  const identifier_1 = require("../dataflow/environments/identifier");
5
5
  const vertex_1 = require("../dataflow/graph/vertex");
6
+ const record_1 = require("../util/record");
7
+ function unsupportedFunctions(functions) {
8
+ return record_1.Record.entries(functions).map(([identifier, info]) => ({ identifier: identifier_1.Identifier.parse(identifier), ...info }));
9
+ }
6
10
  /**
7
11
  * List of known function calls that may change the environment unresolvable/implicitly.
8
12
  */
9
- const UnsupportedFunctionsList = {
10
- '.Primitive': { package: 'base' },
11
- '.Internal': { package: 'base' },
12
- '.External': { package: 'base' },
13
- '.Call': { package: 'base' },
14
- '.C': { package: 'base' },
15
- '.Fortran': { package: 'base' },
16
- '.dyn.load': { package: 'base' },
17
- 'eval': { package: 'base' },
18
- 'evalq': { package: 'base' },
19
- 'eval.parent': { package: 'base' },
20
- 'eval_tidy': { package: 'rlang' },
21
- 'eval_bare': { package: 'rlang' },
22
- 'body<-': { package: 'base' },
23
- 'formals<-': { package: 'base' },
24
- 'environment<-': { package: 'base' },
25
- 'load': { package: 'base' },
26
- 'attach': { package: 'base' },
27
- 'detach': { package: 'base' },
28
- 'rm': { package: 'base' },
29
- 'remove': { package: 'base' },
30
- 'list2env': { package: 'base' },
31
- 'assignInNamespace': { package: 'utils' },
32
- 'assignInMyNamespace': { package: 'utils' },
33
- };
13
+ const UnsupportedFunctionsList = unsupportedFunctions({
14
+ 'base::.Primitive': {},
15
+ 'base::.Internal': {},
16
+ 'base::.External': {},
17
+ 'base::.Call': {},
18
+ 'base::.C': {},
19
+ 'base::.Fortran': {},
20
+ 'base::.dyn.load': {},
21
+ 'base::eval': {},
22
+ 'base::evalq': {},
23
+ 'base::eval.parent': {},
24
+ 'rlang::eval_tidy': {},
25
+ 'rlang::eval_bare': {},
26
+ 'base::body<-': {},
27
+ 'base::formals<-': {},
28
+ 'base::environment<-': {},
29
+ 'base::load': {},
30
+ 'base::attach': {},
31
+ 'base::detach': {},
32
+ 'base::rm': {},
33
+ 'base::remove': {},
34
+ 'base::list2env': {},
35
+ 'base::assign': { condition: (vertex, dfg) => dfg.unknownSideEffects.has(vertex.id) },
36
+ 'base::delayedAssign': { condition: (vertex, dfg) => dfg.unknownSideEffects.has(vertex.id) },
37
+ 'utils::assignInNamespace': {},
38
+ 'utils::assignInMyNamespace': {},
39
+ });
34
40
  /**
35
41
  * Helper for unsupported functions that may change the environment.
36
42
  */
37
43
  exports.UnsupportedFunctions = {
38
44
  /**
39
- * Checks whether a data flow graph vertex represents a unsupported (environment-changing) function call (e.g. `eval`, `load`, `attach`, `rm`, ...)
45
+ * Checks whether a data flow graph vertex represents an unsupported (environment-changing) function call (e.g. `eval`, `load`, `attach`, `rm`, ...)
40
46
  */
41
- isUnsupportedCall(vertex) {
42
- return (0, vertex_1.isFunctionCallVertex)(vertex) && Object.hasOwn(UnsupportedFunctionsList, identifier_1.Identifier.getName(vertex.name));
47
+ isUnsupportedCall(vertex, dfg) {
48
+ if (!(0, vertex_1.isFunctionCallVertex)(vertex)) {
49
+ return false;
50
+ }
51
+ const entry = UnsupportedFunctionsList.find(entry => identifier_1.Identifier.matches(vertex.name, entry.identifier));
52
+ return entry !== undefined && (entry.condition?.(vertex, dfg) ?? true);
43
53
  }
44
54
  };
45
55
  //# sourceMappingURL=unsupported-functions.js.map
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const fs_1 = __importDefault(require("fs"));
7
+ const proc_1 = require("../util/proc");
7
8
  const path_1 = __importDefault(require("path"));
8
9
  const seedrandom_1 = __importDefault(require("seedrandom"));
9
10
  const assert_1 = require("../util/assert");
@@ -20,7 +21,7 @@ const options = (0, script_1.processCommandLineArgs)('benchmark', [], {
20
21
  });
21
22
  if (options.input.length === 0) {
22
23
  console.error('No input files given. Nothing to do. See \'--help\' if this is an error.');
23
- process.exit(0);
24
+ (0, proc_1.exitSafe)(0);
24
25
  }
25
26
  const numberRegex = /^\d+$/;
26
27
  (0, assert_1.guard)(options.slice === 'all' || options.slice === 'no' || numberRegex.test(options.slice), 'slice must be either all, no, or a number');
@@ -14,6 +14,7 @@ const command_line_usage_1 = __importDefault(require("command-line-usage"));
14
14
  const command_line_args_1 = __importDefault(require("command-line-args"));
15
15
  const ansi_1 = require("../../util/text/ansi");
16
16
  const log_1 = require("../../util/log");
17
+ const proc_1 = require("../../util/proc");
17
18
  /**
18
19
  * Automatically generates a uniform help from a given script (see {@link scripts}).
19
20
  * Additionally, you can pass usage examples that may make use of the formatting instructions `{italic x}` and `{bold x}`.
@@ -41,7 +42,7 @@ function processCommandLineArgs(script, requireAdditionally, help) {
41
42
  const options = (0, command_line_args_1.default)(scripts_info_1.scripts[script].options);
42
43
  if (options.help) {
43
44
  console.log(helpForOptions(script, help));
44
- process.exit(0);
45
+ (0, proc_1.exitSafe)(0);
45
46
  }
46
47
  else if (requireAdditionally.length > 0) {
47
48
  const keys = new Set(Object.keys(options));
@@ -49,7 +50,7 @@ function processCommandLineArgs(script, requireAdditionally, help) {
49
50
  if (missing.length > 0) {
50
51
  console.error((0, ansi_1.italic)(`Missing required arguments: ${missing.join(', ')}. Showing help.`));
51
52
  console.log(helpForOptions(script, help));
52
- process.exit(0);
53
+ (0, proc_1.exitSafe)(0);
53
54
  }
54
55
  }
55
56
  log_1.log.updateSettings(l => l.settings.minLevel = options.verbose ? 1 /* LogLevel.Trace */ : 5 /* LogLevel.Error */);
package/cli/flowr.js CHANGED
@@ -1,11 +1,42 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
2
35
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
37
  };
5
38
  Object.defineProperty(exports, "__esModule", { value: true });
6
39
  exports.optionHelp = exports.toolName = void 0;
7
- const server_1 = require("./repl/server/server");
8
- const net_1 = require("./repl/server/net");
9
40
  const version_1 = require("../util/version");
10
41
  const command_line_usage_1 = __importDefault(require("command-line-usage"));
11
42
  const log_1 = require("../util/log");
@@ -17,6 +48,7 @@ const scripts_info_1 = require("./common/scripts-info");
17
48
  const execute_1 = require("./repl/execute");
18
49
  const repl_main_1 = require("./repl/commands/repl-main");
19
50
  const core_1 = require("./repl/core");
51
+ const proc_1 = require("../util/proc");
20
52
  const print_version_1 = require("./repl/print-version");
21
53
  const flowr_main_options_1 = require("./flowr-main-options");
22
54
  const fs_1 = __importDefault(require("fs"));
@@ -97,7 +129,7 @@ function hookSignalHandlers(engines) {
97
129
  console.log(`\n${(0, ansi_1.italic)('Exiting...')}`);
98
130
  }
99
131
  Object.values(engines.engines).forEach(e => e?.close());
100
- process.exit(0);
132
+ (0, proc_1.exitSafe)(0);
101
133
  };
102
134
  process.on('SIGINT', end);
103
135
  process.on('SIGTERM', end);
@@ -121,11 +153,11 @@ async function mainRepl() {
121
153
  console.log(`Running script '${ansi_1.formatter.format(options.script, { style: 1 /* FontStyles.Bold */ })}'`);
122
154
  log_1.log.debug(`Script maps to "${target}"`);
123
155
  await (0, execute_1.waitOnScript)(`${__dirname}/${target}`, process.argv.slice(3), undefined, true);
124
- process.exit(0);
156
+ return (0, proc_1.exitSafe)(0);
125
157
  }
126
158
  if (options.help) {
127
159
  console.log((0, command_line_usage_1.default)(exports.optionHelp));
128
- process.exit(0);
160
+ return (0, proc_1.exitSafe)(0);
129
161
  }
130
162
  const engines = await (0, engines_1.retrieveEngineInstances)(config);
131
163
  const defaultEngine = engines.engines[engines.default];
@@ -134,7 +166,7 @@ async function mainRepl() {
134
166
  await (0, version_1.printVersionInformation)(repl_main_1.standardReplOutput, engine);
135
167
  engine?.close();
136
168
  }
137
- process.exit(0);
169
+ return (0, proc_1.exitSafe)(0);
138
170
  }
139
171
  hookSignalHandlers(engines);
140
172
  const analyzer = new flowr_analyzer_builder_1.FlowrAnalyzerBuilder(false)
@@ -152,16 +184,21 @@ async function mainRepl() {
152
184
  console.log(w('use ') + ansi_1.ansiFormatter.format(':help', { color: 7 /* Colors.White */, effect: ansi_1.ColorEffect.Foreground, style: 1 /* FontStyles.Bold */ }) + w(' to get a list of available commands.'));
153
185
  await (0, core_1.repl)({ analyzer, allowRSessionAccess });
154
186
  }
155
- process.exit(0);
187
+ (0, proc_1.exitSafe)(0);
156
188
  }
157
- async function mainServer(backend = new net_1.NetServer()) {
189
+ async function mainServer(useWebSocket) {
158
190
  const config = createConfig();
159
191
  const engines = await (0, engines_1.retrieveEngineInstances)(config);
160
192
  hookSignalHandlers(engines);
161
- await new server_1.FlowRServer(engines.engines, engines.default, options['r-session-access'], config, backend).start(options.port);
193
+ // the server stack (incl. the `ws` websocket library) is only loaded when actually running a server,
194
+ // so the common one-shot analysis path does not pay for evaluating it
195
+ const { FlowRServer } = await Promise.resolve().then(() => __importStar(require('./repl/server/server')));
196
+ const { NetServer, WebSocketServerWrapper } = await Promise.resolve().then(() => __importStar(require('./repl/server/net')));
197
+ const backend = useWebSocket ? new WebSocketServerWrapper() : new NetServer();
198
+ await new FlowRServer(engines.engines, engines.default, options['r-session-access'], config, backend).start(options.port);
162
199
  }
163
200
  if (options.server) {
164
- void mainServer(options.ws ? new net_1.WebSocketServerWrapper() : new net_1.NetServer());
201
+ void mainServer(options.ws);
165
202
  }
166
203
  else {
167
204
  void mainRepl();
@@ -34,7 +34,6 @@ var __importStar = (this && this.__importStar) || (function () {
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.controlflowBbStarCommand = exports.controlflowBbCommand = exports.controlflowStarCommand = exports.controlflowCommand = void 0;
37
- const retriever_1 = require("../../../r-bridge/retriever");
38
37
  const cfg_1 = require("../../../util/mermaid/cfg");
39
38
  const ansi_1 = require("../../../util/text/ansi");
40
39
  const cfg_simplification_1 = require("../../../control-flow/cfg-simplification");
@@ -47,16 +46,17 @@ async function produceAndPrintCfg(analyzer, output, simplifications, cfgConverte
47
46
  const normalizedAst = await analyzer.normalize();
48
47
  const mermaid = cfgConverter(cfg, normalizedAst);
49
48
  output.stdout(mermaid);
50
- try {
51
- const clipboard = await Promise.resolve().then(() => __importStar(require('clipboardy')));
52
- clipboard.default.writeSync(mermaid);
53
- output.stdout(formatInfo(output, 'mermaid code'));
54
- }
55
- catch { /* do nothing this is a service thing */
49
+ if (output.allowClipboard !== false) {
50
+ try {
51
+ const clipboard = await Promise.resolve().then(() => __importStar(require('clipboardy')));
52
+ clipboard.default.writeSync(mermaid);
53
+ output.stdout(formatInfo(output, 'mermaid code'));
54
+ }
55
+ catch { /* do nothing this is a service thing */ }
56
56
  }
57
57
  }
58
58
  exports.controlflowCommand = {
59
- description: `Get mermaid code for the control-flow graph of R code, start with '${retriever_1.fileProtocol}' to indicate a file`,
59
+ description: 'Get mermaid code for the control-flow graph of R code',
60
60
  isCodeCommand: true,
61
61
  usageExample: ':controlflow',
62
62
  aliases: ['cfg', 'cf'],
@@ -78,7 +78,7 @@ exports.controlflowStarCommand = {
78
78
  }
79
79
  };
80
80
  exports.controlflowBbCommand = {
81
- description: `Get mermaid code for the control-flow graph with basic blocks, start with '${retriever_1.fileProtocol}' to indicate a file`,
81
+ description: 'Get mermaid code for the control-flow graph with basic blocks',
82
82
  isCodeCommand: true,
83
83
  usageExample: ':controlflowbb',
84
84
  aliases: ['cfgb', 'cfb'],
@@ -65,6 +65,11 @@ Furthermore, you can directly call the following scripts which accept arguments.
65
65
  ${Array.from(Object.entries(getReplCommands())).filter(([, { script }]) => script).map(([command, { description }]) => ` ${(0, ansi_1.bold)(padCmd(':' + command), output.formatter)}${description}`).sort().join('\n')}
66
66
 
67
67
  You can combine commands by separating them with a semicolon ${(0, ansi_1.bold)(';', output.formatter)}.
68
+
69
+ Commands that accept a file path support two path prefixes:
70
+ ${(0, ansi_1.bold)('file://<path>', output.formatter)} run the command once on the given file or folder
71
+ ${(0, ansi_1.bold)('watch://<path>', output.formatter)} re-run the command whenever the file (or any file in the folder) changes
72
+ Press Ctrl+C or enter any other command to leave watch mode.
68
73
  `);
69
74
  }
70
75
  };
@@ -34,7 +34,6 @@ var __importStar = (this && this.__importStar) || (function () {
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.dataflowSimpleStarCommand = exports.dataflowSimplifiedCommand = exports.dataflowSilentCommand = exports.dataflowAsciiCommand = exports.dataflowStarCommand = exports.dataflowCommand = void 0;
37
- const retriever_1 = require("../../../r-bridge/retriever");
38
37
  const ansi_1 = require("../../../util/text/ansi");
39
38
  const core_1 = require("../core");
40
39
  const vertex_1 = require("../../../dataflow/graph/vertex");
@@ -44,7 +43,7 @@ function formatInfo(out, type, meta) {
44
43
  return out.formatter.format(`Copied ${type} to clipboard (dataflow: ${meta['.meta'].timing + 'ms'}).`, { color: 7 /* Colors.White */, effect: ansi_1.ColorEffect.Foreground, style: 3 /* FontStyles.Italic */ });
45
44
  }
46
45
  exports.dataflowCommand = {
47
- description: `Get mermaid code for the dataflow graph, start with '${retriever_1.fileProtocol}' to indicate a file`,
46
+ description: 'Get mermaid code for the dataflow graph',
48
47
  isCodeCommand: true,
49
48
  usageExample: ':dataflow',
50
49
  aliases: ['d', 'df'],
@@ -54,12 +53,14 @@ exports.dataflowCommand = {
54
53
  const result = await analyzer.dataflow();
55
54
  const mermaid = df_helper_1.Dataflow.visualize.mermaid.convert({ graph: result.graph, includeEnvironments: false }).string;
56
55
  output.stdout(mermaid);
57
- try {
58
- const clipboard = await Promise.resolve().then(() => __importStar(require('clipboardy')));
59
- clipboard.default.writeSync(mermaid);
60
- output.stdout(formatInfo(output, 'mermaid code', result));
61
- }
62
- catch { /* do nothing this is a service thing */
56
+ if (output.allowClipboard !== false) {
57
+ try {
58
+ const clipboard = await Promise.resolve().then(() => __importStar(require('clipboardy')));
59
+ clipboard.default.writeSync(mermaid);
60
+ output.stdout(formatInfo(output, 'mermaid code', result));
61
+ }
62
+ catch { /* do nothing this is a service thing */
63
+ }
63
64
  }
64
65
  }
65
66
  };
@@ -74,12 +75,14 @@ exports.dataflowStarCommand = {
74
75
  const result = await analyzer.dataflow();
75
76
  const mermaid = df_helper_1.Dataflow.visualize.mermaid.url(result.graph, false);
76
77
  output.stdout(mermaid);
77
- try {
78
- const clipboard = await Promise.resolve().then(() => __importStar(require('clipboardy')));
79
- clipboard.default.writeSync(mermaid);
80
- output.stdout(formatInfo(output, 'mermaid url', result));
78
+ if (output.allowClipboard !== false) {
79
+ try {
80
+ const clipboard = await Promise.resolve().then(() => __importStar(require('clipboardy')));
81
+ clipboard.default.writeSync(mermaid);
82
+ output.stdout(formatInfo(output, 'mermaid url', result));
83
+ }
84
+ catch { /* do nothing this is a service thing */ }
81
85
  }
82
- catch { /* do nothing this is a service thing */ }
83
86
  }
84
87
  };
85
88
  exports.dataflowAsciiCommand = {
@@ -118,7 +121,7 @@ exports.dataflowSilentCommand = {
118
121
  }
119
122
  };
120
123
  exports.dataflowSimplifiedCommand = {
121
- description: `Get mermaid code for the simplified dataflow graph, start with '${retriever_1.fileProtocol}' to indicate a file`,
124
+ description: 'Get mermaid code for the simplified dataflow graph',
122
125
  isCodeCommand: true,
123
126
  usageExample: ':dataflowsimple',
124
127
  aliases: ['ds', 'dfs'],
@@ -128,12 +131,14 @@ exports.dataflowSimplifiedCommand = {
128
131
  const result = await analyzer.dataflow();
129
132
  const mermaid = df_helper_1.Dataflow.visualize.mermaid.convert({ graph: result.graph, includeEnvironments: false, simplified: true }).string;
130
133
  output.stdout(mermaid);
131
- try {
132
- const clipboard = await Promise.resolve().then(() => __importStar(require('clipboardy')));
133
- clipboard.default.writeSync(mermaid);
134
- output.stdout(formatInfo(output, 'mermaid code', result));
134
+ if (output.allowClipboard !== false) {
135
+ try {
136
+ const clipboard = await Promise.resolve().then(() => __importStar(require('clipboardy')));
137
+ clipboard.default.writeSync(mermaid);
138
+ output.stdout(formatInfo(output, 'mermaid code', result));
139
+ }
140
+ catch { /* do nothing this is a service thing */ }
135
141
  }
136
- catch { /* do nothing this is a service thing */ }
137
142
  }
138
143
  };
139
144
  exports.dataflowSimpleStarCommand = {
@@ -147,12 +152,14 @@ exports.dataflowSimpleStarCommand = {
147
152
  const result = await analyzer.dataflow();
148
153
  const mermaid = df_helper_1.Dataflow.visualize.mermaid.url(result.graph, false, undefined, true);
149
154
  output.stdout(mermaid);
150
- try {
151
- const clipboard = await Promise.resolve().then(() => __importStar(require('clipboardy')));
152
- clipboard.default.writeSync(mermaid);
153
- output.stdout(formatInfo(output, 'mermaid url', result));
155
+ if (output.allowClipboard !== false) {
156
+ try {
157
+ const clipboard = await Promise.resolve().then(() => __importStar(require('clipboardy')));
158
+ clipboard.default.writeSync(mermaid);
159
+ output.stdout(formatInfo(output, 'mermaid url', result));
160
+ }
161
+ catch { /* do nothing this is a service thing */ }
154
162
  }
155
- catch { /* do nothing this is a service thing */ }
156
163
  }
157
164
  };
158
165
  //# sourceMappingURL=repl-dataflow.js.map
@@ -11,6 +11,12 @@ export interface ReplOutput {
11
11
  formatter: OutputFormatter;
12
12
  stdout(msg: string): void;
13
13
  stderr(msg: string): void;
14
+ /**
15
+ * When `false`, REPL commands must skip clipboard operations and must not emit
16
+ * "Copied to clipboard" messages. Defaults to `true` (clipboard allowed).
17
+ * Set to `false` in non-interactive contexts such as wiki generation or tests.
18
+ */
19
+ allowClipboard?: boolean;
14
20
  }
15
21
  /**
16
22
  * Default repl output that redirects everything to the stdout and stderror channels (linked to `console`).
@@ -34,7 +34,6 @@ var __importStar = (this && this.__importStar) || (function () {
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.normalizeHashCommand = exports.normalizeStarCommand = exports.normalizeCommand = void 0;
37
- const retriever_1 = require("../../../r-bridge/retriever");
38
37
  const ast_1 = require("../../../util/mermaid/ast");
39
38
  const ansi_1 = require("../../../util/text/ansi");
40
39
  const core_1 = require("../core");
@@ -44,7 +43,7 @@ function formatInfo(out, type, meta) {
44
43
  return out.formatter.format(`Copied ${type} to clipboard (normalize: ${meta['.meta'].timing + 'ms'}).`, { color: 7 /* Colors.White */, effect: ansi_1.ColorEffect.Foreground, style: 3 /* FontStyles.Italic */ });
45
44
  }
46
45
  exports.normalizeCommand = {
47
- description: `Get mermaid code for the normalized AST of R code, start with '${retriever_1.fileProtocol}' to indicate a file`,
46
+ description: 'Get mermaid code for the normalized AST of R code',
48
47
  isCodeCommand: true,
49
48
  usageExample: ':normalize',
50
49
  aliases: ['n'],
@@ -54,12 +53,14 @@ exports.normalizeCommand = {
54
53
  const result = await analyzer.normalize();
55
54
  const mermaid = (0, ast_1.normalizedAstToMermaid)(result.ast);
56
55
  output.stdout(mermaid);
57
- try {
58
- const clipboard = await Promise.resolve().then(() => __importStar(require('clipboardy')));
59
- clipboard.default.writeSync(mermaid);
60
- output.stdout(formatInfo(output, 'mermaid url', result));
56
+ if (output.allowClipboard !== false) {
57
+ try {
58
+ const clipboard = await Promise.resolve().then(() => __importStar(require('clipboardy')));
59
+ clipboard.default.writeSync(mermaid);
60
+ output.stdout(formatInfo(output, 'mermaid url', result));
61
+ }
62
+ catch { /* do nothing this is a service thing */ }
61
63
  }
62
- catch { /* do nothing this is a service thing */ }
63
64
  }
64
65
  };
65
66
  exports.normalizeStarCommand = {
@@ -73,12 +74,14 @@ exports.normalizeStarCommand = {
73
74
  const result = await analyzer.normalize();
74
75
  const mermaid = (0, ast_1.normalizedAstToMermaidUrl)(result.ast);
75
76
  output.stdout(mermaid);
76
- try {
77
- const clipboard = await Promise.resolve().then(() => __importStar(require('clipboardy')));
78
- clipboard.default.writeSync(mermaid);
79
- output.stdout(formatInfo(output, 'mermaid url', result));
77
+ if (output.allowClipboard !== false) {
78
+ try {
79
+ const clipboard = await Promise.resolve().then(() => __importStar(require('clipboardy')));
80
+ clipboard.default.writeSync(mermaid);
81
+ output.stdout(formatInfo(output, 'mermaid url', result));
82
+ }
83
+ catch { /* do nothing this is a service thing */ }
80
84
  }
81
- catch { /* do nothing this is a service thing */ }
82
85
  }
83
86
  };
84
87
  exports.normalizeHashCommand = {
@@ -126,7 +126,7 @@ function depthListToTextTree(list, f) {
126
126
  return result;
127
127
  }
128
128
  exports.parseCommand = {
129
- description: `Prints ASCII Art of the parsed, unmodified AST, start with '${retriever_1.fileProtocol}' to indicate a file`,
129
+ description: 'Prints ASCII Art of the parsed, unmodified AST',
130
130
  isCodeCommand: true,
131
131
  usageExample: ':parse',
132
132
  aliases: ['p'],
@@ -3,15 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.queryStarCommand = exports.queryCommand = void 0;
4
4
  const ansi_1 = require("../../../util/text/ansi");
5
5
  const query_1 = require("../../../queries/query");
6
- const retriever_1 = require("../../../r-bridge/retriever");
7
6
  const query_print_1 = require("../../../queries/query-print");
8
7
  const json_1 = require("../../../util/json");
9
8
  const args_1 = require("../../../util/text/args");
9
+ const record_1 = require("../../../util/record");
10
10
  function printHelp(output) {
11
11
  output.stderr(`Format: ${(0, ansi_1.italic)(':query <query> <code>', output.formatter)}`);
12
12
  output.stdout('Queries starting with \'@<type>\' are interpreted as a query of the given type.');
13
13
  output.stdout(`With this, ${(0, ansi_1.bold)(':query @config', output.formatter)} prints the result of the config query.`);
14
- output.stdout(`If you want to run the linter on a project use:\n ${(0, ansi_1.bold)(':query @linter file://<path>', output.formatter)}.`);
14
+ output.stdout(`If you want to run the linter on a project use:\n ${(0, ansi_1.bold)(':query @linter file://<path>', output.formatter)} (or ${(0, ansi_1.bold)('watch://<path>', output.formatter)} to re-run on changes).`);
15
15
  output.stdout((0, ansi_1.ansiInfo)('Otherwise, you can also directly pass the query json. Then, the query is an array of query objects to represent multiple queries.'));
16
16
  output.stdout((0, ansi_1.ansiInfo)('The example') + (0, ansi_1.italic)(String.raw `:query "[{\"type\": \"call-context\", \"callName\": \"mean\" }]" mean(1:10)`, output.formatter, { color: 7 /* Colors.White */, effect: ansi_1.ColorEffect.Foreground }) + (0, ansi_1.ansiInfo)('would return the call context of the mean function.'));
17
17
  output.stdout('Please have a look at the wiki for more info: https://github.com/flowr-analysis/flowr/wiki/Query-API');
@@ -98,7 +98,7 @@ function parseArgs(line) {
98
98
  };
99
99
  }
100
100
  exports.queryCommand = {
101
- description: `Query the given R code, start with '${retriever_1.fileProtocol}' to indicate a file. The query is to be a valid query in json format (use 'help' to get more information).`,
101
+ description: 'Query the given R code (use \'help\' for more information)',
102
102
  isCodeCommand: true,
103
103
  usageExample: ':query "<query>" <code>',
104
104
  aliases: [],
@@ -123,8 +123,7 @@ exports.queryStarCommand = {
123
123
  fn: async ({ output, analyzer, remainingArgs }) => {
124
124
  const results = await processQueryArgs(output, analyzer, remainingArgs);
125
125
  if (results) {
126
- const json = Object.fromEntries(Object.entries(results.query)
127
- .map(([query, queryResults]) => [query, query_1.SupportedQueries[query]?.jsonFormatter?.(queryResults) ?? queryResults]));
126
+ const json = record_1.Record.map(results.query, ([query, queryResults]) => [query, query_1.SupportedQueries[query]?.jsonFormatter?.(queryResults) ?? queryResults]);
128
127
  output.stdout(JSON.stringify(json, json_1.jsonReplacer));
129
128
  }
130
129
  }
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.quitCommand = void 0;
4
4
  const log_1 = require("../../../util/log");
5
+ const proc_1 = require("../../../util/proc");
5
6
  exports.quitCommand = {
6
7
  description: 'End the repl',
7
8
  isCodeCommand: false,
@@ -10,7 +11,7 @@ exports.quitCommand = {
10
11
  script: false,
11
12
  fn: () => {
12
13
  log_1.log.info('bye');
13
- process.exit(0);
14
+ (0, proc_1.exitSafe)(0);
14
15
  }
15
16
  };
16
17
  //# sourceMappingURL=repl-quit.js.map
@@ -1,4 +1,5 @@
1
1
  import * as readline from 'readline';
2
+ import fs from 'fs';
2
3
  import { type ReplOutput } from './commands/repl-main';
3
4
  import type { MergeableRecord } from '../../util/objects';
4
5
  import type { FlowrConfig } from '../../config';
@@ -30,6 +31,16 @@ export declare function handleString(code: string): {
30
31
  rCode: string | undefined;
31
32
  remaining: never[];
32
33
  };
34
+ /** Path prefix that activates watch mode; use instead of {@link fileProtocol} to re-run on every file change. */
35
+ export declare const watchProtocol = "watch://";
36
+ /** Convert a statement containing {@link watchProtocol} into one using {@link fileProtocol} so it can be executed. */
37
+ export declare function toFileStatement(statement: string): string;
38
+ /** Return the watch path from the first `watch://<path>` token in `statement`, or `undefined` if none is present. */
39
+ export declare function extractWatchPath(statement: string): string | undefined;
40
+ /** Stop the active watcher. Pass `notify = false` when silently switching to a new watch target. */
41
+ export declare function stopWatching(output: ReplOutput, notify?: boolean): void;
42
+ /** `watchImpl` is injectable so tests can pass a fake `fs.watch`. */
43
+ export declare function startWatching(watchPath: string, output: ReplOutput, onFire: () => void, watchImpl?: typeof fs.watch): fs.FSWatcher;
33
44
  /**
34
45
  * This function interprets the given `expr` as a REPL command (see {@link repl} for more on the semantics).
35
46
  * @param analyzer - The flowR analyzer to use.