@eagleoutice/flowr 2.13.16 → 2.14.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (253) hide show
  1. package/README.md +36 -25
  2. package/abstract-interpretation/absint-visitor.js +1 -1
  3. package/abstract-interpretation/data-frame/mappers/access-mapper.js +4 -4
  4. package/abstract-interpretation/data-frame/mappers/arguments.js +7 -4
  5. package/abstract-interpretation/data-frame/mappers/function-mapper.js +18 -17
  6. package/abstract-interpretation/data-frame/mappers/replacement-mapper.js +6 -6
  7. package/abstract-interpretation/data-frame/resolve-args.d.ts +9 -4
  8. package/abstract-interpretation/data-frame/resolve-args.js +10 -5
  9. package/benchmark/calibration.d.ts +16 -7
  10. package/benchmark/calibration.js +44 -17
  11. package/benchmark/slicer.d.ts +3 -2
  12. package/benchmark/slicer.js +9 -5
  13. package/benchmark/stats/size-of.js +1 -1
  14. package/benchmark/summarizer/first-phase/process.d.ts +2 -0
  15. package/benchmark/summarizer/first-phase/process.js +2 -0
  16. package/cli/benchmark-app.js +4 -1
  17. package/cli/benchmark-helper-app.d.ts +1 -0
  18. package/cli/benchmark-helper-app.js +2 -2
  19. package/cli/common/options.d.ts +5 -31
  20. package/cli/common/options.js +2 -8
  21. package/cli/common/scripts-info.d.ts +5 -38
  22. package/cli/common/scripts-info.js +0 -8
  23. package/cli/repl/core.js +1 -1
  24. package/cli/repl/execute.d.ts +2 -2
  25. package/cli/repl/execute.js +2 -2
  26. package/cli/repl/parser/slice-query-parser.js +1 -1
  27. package/cli/repl/print-version.js +2 -2
  28. package/config.d.ts +16 -0
  29. package/config.js +83 -5
  30. package/control-flow/extract-cfg.js +1 -1
  31. package/control-flow/semantic-cfg-guided-visitor.d.ts +1 -1
  32. package/control-flow/semantic-cfg-guided-visitor.js +1 -1
  33. package/control-flow/useless-loop.js +1 -1
  34. package/core/print/slice-diff-ansi.js +1 -1
  35. package/core/steps/pipeline/create-pipeline.js +1 -1
  36. package/dataflow/cluster.js +2 -2
  37. package/dataflow/environments/apply-kill.js +1 -1
  38. package/dataflow/environments/built-in-props.d.ts +13 -2
  39. package/dataflow/environments/built-in-props.js +23 -1
  40. package/dataflow/environments/built-in.d.ts +7 -1
  41. package/dataflow/environments/built-in.js +42 -3
  42. package/dataflow/environments/default-builtin-config.d.ts +518 -11
  43. package/dataflow/environments/default-builtin-config.js +218 -23
  44. package/dataflow/environments/environment.d.ts +10 -2
  45. package/dataflow/environments/environment.js +25 -7
  46. package/dataflow/environments/identifier.d.ts +8 -2
  47. package/dataflow/environments/identifier.js +6 -1
  48. package/dataflow/environments/query-fn-props.d.ts +6 -0
  49. package/dataflow/environments/query-fn-props.js +22 -2
  50. package/dataflow/environments/reference-to-maybe.js +5 -5
  51. package/dataflow/environments/resolve-by-name.d.ts +3 -0
  52. package/dataflow/environments/resolve-by-name.js +44 -7
  53. package/dataflow/environments/resolve-helper.d.ts +6 -0
  54. package/dataflow/environments/resolve-helper.js +6 -0
  55. package/dataflow/eval/resolve/alias-tracking.d.ts +5 -0
  56. package/dataflow/eval/resolve/alias-tracking.js +21 -14
  57. package/dataflow/eval/resolve/node-value.d.ts +6 -0
  58. package/dataflow/eval/resolve/node-value.js +15 -9
  59. package/dataflow/eval/resolve/resolve-argument.js +2 -2
  60. package/dataflow/eval/resolve/resolve-numbers.js +2 -2
  61. package/dataflow/eval/resolve/resolve-operators.js +5 -4
  62. package/dataflow/eval/resolve/resolve-strings.js +3 -3
  63. package/dataflow/eval/resolve/resolve-working-directory.d.ts +1 -1
  64. package/dataflow/eval/resolve/resolve-working-directory.js +3 -3
  65. package/dataflow/eval/resolve/resolve.d.ts +5 -5
  66. package/dataflow/eval/resolve/resolve.js +10 -11
  67. package/dataflow/eval/values/general.d.ts +4 -1
  68. package/dataflow/eval/values/general.js +1 -1
  69. package/dataflow/extractor.js +2 -1
  70. package/dataflow/fn/exceptions-of-function.d.ts +3 -1
  71. package/dataflow/fn/exceptions-of-function.js +87 -39
  72. package/dataflow/fn/higher-order-function.js +5 -4
  73. package/dataflow/fn/strict-function.d.ts +40 -0
  74. package/dataflow/fn/strict-function.js +337 -0
  75. package/dataflow/graph/call-graph.js +14 -14
  76. package/dataflow/graph/df-helper.d.ts +24 -1
  77. package/dataflow/graph/df-helper.js +29 -7
  78. package/dataflow/graph/diff-dataflow-graph.js +6 -6
  79. package/dataflow/graph/edge.d.ts +27 -0
  80. package/dataflow/graph/edge.js +33 -0
  81. package/dataflow/graph/graph-helper.d.ts +3 -4
  82. package/dataflow/graph/graph-helper.js +4 -5
  83. package/dataflow/graph/graph.d.ts +39 -3
  84. package/dataflow/graph/graph.js +75 -7
  85. package/dataflow/graph/vertex.d.ts +42 -6
  86. package/dataflow/graph/vertex.js +42 -6
  87. package/dataflow/info.d.ts +26 -0
  88. package/dataflow/info.js +28 -1
  89. package/dataflow/internal/linker.d.ts +1 -0
  90. package/dataflow/internal/linker.js +11 -9
  91. package/dataflow/internal/process/functions/call/built-in/built-in-access.js +2 -2
  92. package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +1 -1
  93. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +6 -5
  94. package/dataflow/internal/process/functions/call/built-in/built-in-class-generator.js +2 -2
  95. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +6 -7
  96. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +7 -6
  97. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.d.ts +1 -0
  98. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +19 -18
  99. package/dataflow/internal/process/functions/call/built-in/built-in-library.js +6 -1
  100. package/dataflow/internal/process/functions/call/built-in/built-in-list.js +2 -2
  101. package/dataflow/internal/process/functions/call/built-in/built-in-local.js +2 -2
  102. package/dataflow/internal/process/functions/call/built-in/built-in-pipe.js +2 -2
  103. package/dataflow/internal/process/functions/call/built-in/built-in-purrr-formula.js +5 -5
  104. package/dataflow/internal/process/functions/call/built-in/built-in-quote.js +1 -1
  105. package/dataflow/internal/process/functions/call/built-in/built-in-register-hook.js +3 -3
  106. package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +3 -3
  107. package/dataflow/internal/process/functions/call/built-in/built-in-rm.d.ts +1 -0
  108. package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +29 -3
  109. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +3 -3
  110. package/dataflow/internal/process/functions/call/built-in/built-in-source.js +1 -1
  111. package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +3 -3
  112. package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.d.ts +3 -1
  113. package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +44 -20
  114. package/dataflow/internal/process/functions/call/common.d.ts +9 -1
  115. package/dataflow/internal/process/functions/call/common.js +17 -6
  116. package/dataflow/internal/process/functions/call/deferred.js +2 -1
  117. package/dataflow/internal/process/functions/call/known-call-handling.d.ts +3 -1
  118. package/dataflow/internal/process/functions/call/known-call-handling.js +6 -3
  119. package/dataflow/internal/process/functions/call/named-call-handling.js +44 -12
  120. package/dataflow/internal/process/functions/call/nse.d.ts +33 -5
  121. package/dataflow/internal/process/functions/call/nse.js +113 -6
  122. package/dataflow/internal/process/functions/call/quoted.d.ts +5 -0
  123. package/dataflow/internal/process/functions/call/quoted.js +21 -9
  124. package/dataflow/origin/dfg-get-origin.d.ts +1 -0
  125. package/dataflow/origin/dfg-get-origin.js +9 -6
  126. package/documentation/data/faq/faqs.js +88 -88
  127. package/documentation/data/faq/recommended-configs.js +1 -1
  128. package/documentation/data/faq/wiki-faq-store.js +1 -1
  129. package/documentation/doc-capabilities.js +1 -1
  130. package/documentation/doc-readme.js +1 -1
  131. package/documentation/doc-util/doc-auto-gen.js +6 -2
  132. package/documentation/doc-util/doc-functions.js +1 -1
  133. package/documentation/wiki-cfg.js +2 -2
  134. package/documentation/wiki-core.js +1 -1
  135. package/documentation/wiki-create-linting-rules.js +45 -45
  136. package/documentation/wiki-dataflow-graph.js +18 -18
  137. package/documentation/wiki-linter.js +1 -0
  138. package/documentation/wiki-linting-and-testing.js +93 -5
  139. package/documentation/wiki-mk/doc-maker.js +1 -1
  140. package/documentation/wiki-overview.js +12 -1
  141. package/documentation/wiki-query.js +53 -0
  142. package/documentation/wiki-signature-database.js +3 -0
  143. package/linter/linter-output.js +1 -1
  144. package/linter/linter-rules.d.ts +24 -0
  145. package/linter/linter-rules.js +3 -1
  146. package/linter/rules/file-path-validity.js +1 -1
  147. package/linter/rules/function-finder-util.js +1 -1
  148. package/linter/rules/naming-convention.js +1 -1
  149. package/linter/rules/network-functions.d.ts +1 -1
  150. package/linter/rules/no-leaked-credentials.js +2 -1
  151. package/linter/rules/stop-with-call-arg.js +4 -4
  152. package/linter/rules/unclosed-connection.d.ts +44 -0
  153. package/linter/rules/unclosed-connection.js +200 -0
  154. package/linter/rules/undefined-symbol-util.d.ts +1 -1
  155. package/linter/rules/undefined-symbol-util.js +5 -4
  156. package/linter/rules/undefined-symbol.js +3 -3
  157. package/linter/rules/unused-definition.js +2 -1
  158. package/package.json +38 -51
  159. package/project/context/flowr-analyzer-environment-context.d.ts +23 -0
  160. package/project/context/flowr-analyzer-environment-context.js +25 -0
  161. package/project/dependency-version-space.d.ts +3 -3
  162. package/project/dependency-version-space.js +3 -4
  163. package/project/flowr-analyzer.js +1 -1
  164. package/project/plugins/file-plugins/files/flowr-description-file.d.ts +1 -1
  165. package/project/plugins/file-plugins/files/flowr-description-file.js +1 -1
  166. package/project/plugins/file-plugins/files/flowr-namespace-file.d.ts +1 -1
  167. package/project/plugins/file-plugins/files/flowr-namespace-file.js +1 -1
  168. package/project/plugins/file-plugins/files/flowr-news-file.d.ts +1 -1
  169. package/project/plugins/file-plugins/files/flowr-news-file.js +1 -1
  170. package/project/plugins/file-plugins/files/flowr-rda-file.d.ts +1 -1
  171. package/project/plugins/file-plugins/files/flowr-rda-file.js +4 -4
  172. package/project/plugins/file-plugins/files/flowr-rmarkdown-file.js +2 -2
  173. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.d.ts +5 -5
  174. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +36 -7
  175. package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +2 -2
  176. package/project/sigdb/build.js +16 -16
  177. package/project/sigdb/codec.d.ts +1 -1
  178. package/project/sigdb/codec.js +13 -13
  179. package/project/sigdb/decompress.d.ts +1 -1
  180. package/project/sigdb/decompress.js +33 -33
  181. package/project/sigdb/index-format.js +2 -2
  182. package/project/sigdb/manifest.d.ts +3 -1
  183. package/project/sigdb/manifest.js +68 -27
  184. package/project/sigdb/memory-source.d.ts +64 -0
  185. package/project/sigdb/memory-source.js +133 -0
  186. package/project/sigdb/reader.js +14 -14
  187. package/project/sigdb/schema.d.ts +2 -2
  188. package/project/sigdb/schema.js +2 -2
  189. package/queries/catalog/call-context-query/call-context-query-executor.js +1 -1
  190. package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +2 -2
  191. package/queries/catalog/dependencies-query/dependencies-query-executor.js +2 -2
  192. package/queries/catalog/dependencies-query/dependencies-query-format.js +1 -1
  193. package/queries/catalog/dependencies-query/link-devices.js +3 -9
  194. package/queries/catalog/does-call-query/does-call-query-executor.js +2 -1
  195. package/queries/catalog/input-sources-query/simple-input-classifier.js +4 -4
  196. package/queries/catalog/inspect-exceptions-query/inspect-exception-query-executor.js +2 -1
  197. package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor.js +1 -0
  198. package/queries/catalog/inspect-strictness-query/inspect-strictness-query-executor.d.ts +6 -0
  199. package/queries/catalog/inspect-strictness-query/inspect-strictness-query-executor.js +25 -0
  200. package/queries/catalog/inspect-strictness-query/inspect-strictness-query-format.d.ts +31 -0
  201. package/queries/catalog/inspect-strictness-query/inspect-strictness-query-format.js +56 -0
  202. package/queries/catalog/location-map-query/location-map-query-format.js +1 -1
  203. package/queries/catalog/resolve-value-query/resolve-value-query-executor.js +2 -2
  204. package/queries/catalog/signature-query/signature-query-executor.d.ts +2 -0
  205. package/queries/catalog/signature-query/signature-query-executor.js +3 -2
  206. package/queries/catalog/slice-query-options.d.ts +1 -1
  207. package/queries/catalog/slice-query-options.js +1 -1
  208. package/queries/query-function-filter.d.ts +8 -2
  209. package/queries/query-function-filter.js +11 -1
  210. package/queries/query.d.ts +11 -1
  211. package/queries/query.js +2 -0
  212. package/r-bridge/lang-4.x/ast/model/model.d.ts +4 -4
  213. package/r-bridge/lang-4.x/ast/model/model.js +4 -4
  214. package/r-bridge/lang-4.x/ast/model/processing/node-id.js +3 -3
  215. package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-call.js +1 -1
  216. package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-definition.js +1 -1
  217. package/r-bridge/retriever.d.ts +2 -1
  218. package/r-bridge/retriever.js +3 -2
  219. package/r-bridge/roxygen2/documentation-provider.d.ts +1 -0
  220. package/r-bridge/roxygen2/documentation-provider.js +1 -0
  221. package/r-bridge/roxygen2/roxygen-parse.d.ts +1 -1
  222. package/r-bridge/roxygen2/roxygen-parse.js +1 -1
  223. package/search/flowr-search-filters.d.ts +1 -1
  224. package/search/flowr-search-filters.js +2 -14
  225. package/search/search-executor/search-enrichers.js +4 -4
  226. package/search/search-executor/search-generators.js +1 -1
  227. package/slicing/criterion/parse.d.ts +2 -2
  228. package/slicing/criterion/parse.js +5 -5
  229. package/slicing/static/fingerprint.js +1 -1
  230. package/slicing/static/slice-call.d.ts +1 -1
  231. package/slicing/static/slice-call.js +2 -2
  232. package/slicing/static/static-slicer.js +4 -3
  233. package/util/assert.js +1 -1
  234. package/util/log.d.ts +4 -1
  235. package/util/log.js +15 -2
  236. package/util/logic.js +2 -2
  237. package/util/mermaid/cfg.js +1 -1
  238. package/util/mermaid/dfg.js +6 -6
  239. package/util/mermaid/mermaid.js +3 -1
  240. package/util/objects.d.ts +12 -0
  241. package/util/objects.js +48 -0
  242. package/util/quads.js +19 -6
  243. package/util/schema.js +2 -2
  244. package/util/simple-df/dfg-ascii.js +14 -3
  245. package/util/text/ansi.d.ts +2 -0
  246. package/util/text/ansi.js +8 -0
  247. package/util/text/name-rank.d.ts +29 -0
  248. package/util/text/name-rank.js +39 -0
  249. package/util/text/url-encoding.d.ts +15 -0
  250. package/util/text/url-encoding.js +59 -0
  251. package/util/version.js +1 -1
  252. package/cli/export-quads-app.d.ts +0 -7
  253. package/cli/export-quads-app.js +0 -44
@@ -11,8 +11,6 @@ const search_enrichers_1 = require("./search-executor/search-enrichers");
11
11
  const objects_1 = require("../util/objects");
12
12
  const search_generators_1 = require("./search-executor/search-generators");
13
13
  const query_fn_props_1 = require("../dataflow/environments/query-fn-props");
14
- const df_helper_1 = require("../dataflow/graph/df-helper");
15
- const environment_1 = require("../dataflow/environments/environment");
16
14
  var FlowrFilter;
17
15
  (function (FlowrFilter) {
18
16
  /**
@@ -60,7 +58,7 @@ exports.FlowrFilters = {
60
58
  }),
61
59
  [FlowrFilter.OriginKind]: ((e, args, data) => {
62
60
  const dfgNode = data.dataflow.graph.getVertex(e.node.info.id);
63
- if (!dfgNode || dfgNode.tag !== vertex_1.VertexType.FunctionCall) {
61
+ if (!dfgNode || !vertex_1.FunctionCallVertex.is(dfgNode)) {
64
62
  return args.keepNonFunctionCalls ?? false;
65
63
  }
66
64
  const match = typeof args.origin === 'string' ?
@@ -78,17 +76,7 @@ exports.FlowrFilters = {
78
76
  return rx.test(file ?? '');
79
77
  }),
80
78
  [FlowrFilter.CallProps]: ((e, args, data) => {
81
- const graph = data.dataflow.graph;
82
- const vertex = graph.getVertex(e.node.info.id);
83
- if (vertex?.tag !== vertex_1.VertexType.FunctionCall) {
84
- return false;
85
- }
86
- /* what the call resolved to decides, as a definition in the analyzed code shadows the built-in; a call
87
- * flowR settled on the built-ins keeps no environment, and a later redefinition must not speak for it */
88
- const known = vertex.environment ?? data.dataflow.environment;
89
- const environment = vertex.onlyBuiltin ? { level: 0, current: environment_1.REnvironment.findBuiltIn(known.current) } : known;
90
- const name = df_helper_1.Dataflow.qualify(e.node.info.id, graph, false) ?? vertex.name;
91
- const props = (0, query_fn_props_1.queryFnProps)(name, { environment })?.props ?? 0;
79
+ const props = (0, query_fn_props_1.callFnProps)(e.node.info.id, data.dataflow)?.props ?? 0;
92
80
  return args.matchType === 'every' ? (props & args.props) === args.props : (props & args.props) !== 0;
93
81
  })
94
82
  };
@@ -13,7 +13,7 @@ const cfg_kind_1 = require("../../project/cfg-kind");
13
13
  const identify_link_to_last_call_relation_1 = require("../../queries/catalog/call-context-query/identify-link-to-last-call-relation");
14
14
  const identifier_1 = require("../../dataflow/environments/identifier");
15
15
  const df_helper_1 = require("../../dataflow/graph/df-helper");
16
- const documentation_provider_1 = require("../../r-bridge/roxygen2/documentation-provider");
16
+ const model_1 = require("../../r-bridge/lang-4.x/ast/model/model");
17
17
  /**
18
18
  * An enumeration that stores the names of the available enrichments that can be applied to a set of search elements.
19
19
  * See {@link FlowrSearchBuilder.with} for more information on how to apply enrichments.
@@ -43,7 +43,7 @@ exports.Enrichments = {
43
43
  const df = shared?.dfg ?? await analyzer.dataflow();
44
44
  const n = shared?.ast ?? await analyzer.normalize();
45
45
  const callVertex = df.graph.getVertex(e.node.info.id);
46
- if (callVertex?.tag === vertex_1.VertexType.FunctionCall) {
46
+ if (vertex_1.FunctionCallVertex.is(callVertex)) {
47
47
  const origins = df_helper_1.Dataflow.origin(df.graph, callVertex.id);
48
48
  if (!origins || origins.length === 0) {
49
49
  const name = (0, node_id_1.recoverName)(callVertex.id, n.idMap);
@@ -111,7 +111,7 @@ exports.Enrichments = {
111
111
  const shared = s.enrichmentContent(Enrichment.LastCall);
112
112
  const df = (shared?.dfg ?? await analyzer.dataflow()).graph;
113
113
  const vertex = df.getVertex(e.node.info.id);
114
- if (vertex?.tag === vertex_1.VertexType.FunctionCall) {
114
+ if (vertex_1.FunctionCallVertex.is(vertex)) {
115
115
  const n = shared?.ast ?? await analyzer.normalize();
116
116
  const cfg = (shared?.cfg ?? await analyzer.controlflow(undefined, cfg_kind_1.CfgKind.Quick)).graph;
117
117
  for (const arg of args) {
@@ -168,7 +168,7 @@ exports.Enrichments = {
168
168
  });
169
169
  const shared = search.enrichmentContent(Enrichment.Roxygen);
170
170
  const normalize = shared?.ast ?? await analyzer.normalize();
171
- const roxygen = (0, documentation_provider_1.getDocumentationOf)(e.node.info.id, normalize.idMap);
171
+ const roxygen = model_1.RNode.documentation(e.node.info.id, normalize.idMap);
172
172
  if (roxygen !== undefined) {
173
173
  const comments = (Array.isArray(roxygen) ? roxygen : [roxygen]);
174
174
  content.documentation.push(...comments);
@@ -114,7 +114,7 @@ async function generateSyntax(input, args) {
114
114
  args.captures = [defaultCaptureName];
115
115
  }
116
116
  // allow specifying capture names with or without the @ in front :)
117
- const captures = new Set(args.captures.map(c => c.startsWith('@') ? c.substring(1) : c));
117
+ const captures = new Set(args.captures.map(c => c.startsWith('@') ? c.slice(1) : c));
118
118
  const info = input.parserInformation();
119
119
  (0, assert_1.guard)(info.name === 'tree-sitter', 'treeSitterQuery can only be used with TreeSitterExecutor parsers!');
120
120
  const result = await info.treeSitterQuery(args.source);
@@ -6,7 +6,7 @@ type FileFilterSuffix = '' | `(${string})`;
6
6
  export type SlicingCriterion = `${number}:${number}${FileFilterSuffix}` | `${number}~${number}${FileFilterSuffix}` | `${number}^${FileFilterSuffix}` | `${number}@${string}` | `$${NodeId | number}`;
7
7
  /**
8
8
  * The helper object associated with {@link SlicingCriterion} which makes it easy
9
- * to parse, validate and resolve slicing criteria.
9
+ * to parse, validate, and resolve slicing criteria.
10
10
  */
11
11
  export declare const SlicingCriterion: {
12
12
  readonly name: "SlicingCriterion";
@@ -41,7 +41,7 @@ export interface DecodedCriterion {
41
41
  }
42
42
  export type DecodedCriteria = ReadonlyArray<DecodedCriterion>;
43
43
  /**
44
- * The helper object associated with {@link SlicingCriteria} which makes it easy to parse, validate and resolve slicing criteria.
44
+ * The helper object associated with {@link SlicingCriteria} which makes it easy to parse, validate, and resolve slicing criteria.
45
45
  */
46
46
  export declare const SlicingCriteria: {
47
47
  readonly name: "SlicingCriteria";
@@ -8,7 +8,7 @@ const static_slicer_1 = require("../static/static-slicer");
8
8
  const type_1 = require("../../r-bridge/lang-4.x/ast/model/type");
9
9
  /**
10
10
  * The helper object associated with {@link SlicingCriterion} which makes it easy
11
- * to parse, validate and resolve slicing criteria.
11
+ * to parse, validate, and resolve slicing criteria.
12
12
  */
13
13
  exports.SlicingCriterion = {
14
14
  name: 'SlicingCriterion',
@@ -48,7 +48,7 @@ exports.SlicingCriterion = {
48
48
  tryParse(criterion, idMap) {
49
49
  criterion = criterion.toString(); // in case it's a number
50
50
  if (criterion.startsWith('$')) {
51
- return node_id_1.NodeId.normalize(criterion.substring(1));
51
+ return node_id_1.NodeId.normalize(criterion.slice(1));
52
52
  }
53
53
  const split = splitFileFilter(criterion);
54
54
  if (split === undefined) {
@@ -57,8 +57,8 @@ exports.SlicingCriterion = {
57
57
  const { rest: base, file } = split;
58
58
  if (base.includes('@')) {
59
59
  const at = base.indexOf('@');
60
- const line = parseLineNumber(base.substring(0, at), idMap, file);
61
- const name = base.substring(at + 1);
60
+ const line = parseLineNumber(base.slice(0, Math.max(0, at)), idMap, file);
61
+ const name = base.slice(Math.max(0, at + 1));
62
62
  if (line === undefined || name.length === 0) {
63
63
  return undefined;
64
64
  }
@@ -89,7 +89,7 @@ exports.SlicingCriterion = {
89
89
  }
90
90
  };
91
91
  /**
92
- * The helper object associated with {@link SlicingCriteria} which makes it easy to parse, validate and resolve slicing criteria.
92
+ * The helper object associated with {@link SlicingCriteria} which makes it easy to parse, validate, and resolve slicing criteria.
93
93
  */
94
94
  exports.SlicingCriteria = {
95
95
  name: 'SlicingCriteria',
@@ -15,7 +15,7 @@ const HashOptions = {
15
15
  ignoreUnknown: true,
16
16
  replacer: (v) => (0, environment_1.isDefaultBuiltInEnvironment)(v) ? undefined : v
17
17
  };
18
- /* definitions, definition maps and frames are shared across the environments a slice builds, and a definition may
18
+ /* definitions, definition maps, and frames are shared across the environments a slice builds, and a definition may
19
19
  * hold a whole environment of its own (`envState`), so each is hashed once instead of on every fingerprint. The
20
20
  * map is keyed separately from the frame because cloning a frame shares its definitions until one side writes
21
21
  * (see {@link Environment#clone}): the graph holds many frames per distinct set of definitions, and hashing that
@@ -1,7 +1,7 @@
1
1
  import type { NodeToSlice } from './slicer-types';
2
2
  import type { VisitingQueue } from './visiting-queue';
3
3
  import { type Fingerprint } from './fingerprint';
4
- import { type DataflowGraphVertexFunctionCall, type DataflowGraphVertexInfo } from '../../dataflow/graph/vertex';
4
+ import type { DataflowGraphVertexFunctionCall, DataflowGraphVertexInfo } from '../../dataflow/graph/vertex';
5
5
  import type { REnvironmentInformation } from '../../dataflow/environments/environment';
6
6
  import { type DataflowGraph, type OutgoingEdges } from '../../dataflow/graph/graph';
7
7
  import { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
@@ -9,7 +9,6 @@ exports.handleReturns = handleReturns;
9
9
  const assert_1 = require("../../util/assert");
10
10
  const fingerprint_1 = require("./fingerprint");
11
11
  const linker_1 = require("../../dataflow/internal/linker");
12
- const vertex_1 = require("../../dataflow/graph/vertex");
13
12
  const graph_1 = require("../../dataflow/graph/graph");
14
13
  const resolve_helper_1 = require("../../dataflow/environments/resolve-helper");
15
14
  const edge_1 = require("../../dataflow/graph/edge");
@@ -19,6 +18,7 @@ const built_in_function_definition_1 = require("../../dataflow/internal/process/
19
18
  const static_slicer_1 = require("./static-slicer");
20
19
  const type_1 = require("../../r-bridge/lang-4.x/ast/model/type");
21
20
  const model_1 = require("../../r-bridge/lang-4.x/ast/model/model");
21
+ const vertex_1 = require("../../dataflow/graph/vertex");
22
22
  /**
23
23
  * Returns the function call targets (definitions) by the given caller
24
24
  */
@@ -105,7 +105,7 @@ function findEnclosingFunctionDefinition(id, idMap) {
105
105
  */
106
106
  function sliceReachesFunctionInterface(fnDefId, graph, queue, idMap, ctx) {
107
107
  const vertex = graph.getVertex(fnDefId);
108
- if (vertex === undefined || vertex.tag !== vertex_1.VertexType.FunctionDefinition) {
108
+ if (vertex === undefined || !vertex_1.FunctionDefinitionVertex.is(vertex)) {
109
109
  return false;
110
110
  }
111
111
  // (a) the slice reaches a parameter of this definition
@@ -14,6 +14,7 @@ const edge_1 = require("../../dataflow/graph/edge");
14
14
  const df_helper_1 = require("../../dataflow/graph/df-helper");
15
15
  const slice_direction_1 = require("../../util/slice-direction");
16
16
  const model_1 = require("../../r-bridge/lang-4.x/ast/model/model");
17
+ const graph_1 = require("../../dataflow/graph/graph");
17
18
  exports.slicerLogger = log_1.log.getSubLogger({ name: 'slicer' });
18
19
  /**
19
20
  * Computes the node ids to include in a static slice, starting from the given seed ids.
@@ -98,7 +99,7 @@ function staticSlice(options) {
98
99
  }
99
100
  }
100
101
  if (!onlyForSideEffects) {
101
- if (currentVertex.tag === vertex_1.VertexType.FunctionCall && !currentVertex.onlyBuiltin) {
102
+ if (vertex_1.FunctionCallVertex.is(currentVertex) && !currentVertex.onlyBuiltin) {
102
103
  (0, slice_call_1.sliceForCall)(current, currentVertex, info, queue, ctx);
103
104
  }
104
105
  const ret = (0, slice_call_1.handleReturns)(id, queue, currentEdges, baseEnvFingerprint, baseEnvironment);
@@ -151,11 +152,11 @@ function staticSlice(options) {
151
152
  function freeNamesOf(slice, graph) {
152
153
  const free = new Set();
153
154
  for (const id of slice) {
154
- if (graph.getVertex(id)?.tag !== vertex_1.VertexType.Use) {
155
+ if (!vertex_1.UseVertex.is(graph.getVertex(id))) {
155
156
  continue;
156
157
  }
157
158
  let defined = false;
158
- for (const [target, edge] of graph.outgoingEdges(id) ?? []) {
159
+ for (const [target, edge] of graph.outgoingEdges(id) ?? graph_1.NoEdges) {
159
160
  if (edge_1.DfEdge.includesType(edge, edge_1.EdgeType.Reads) && (slice.has(target) || node_id_1.NodeId.isBuiltIn(target))) {
160
161
  defined = true;
161
162
  break;
package/util/assert.js CHANGED
@@ -102,7 +102,7 @@ node version: ${process.version}
102
102
  node arch: ${process.arch}
103
103
  node platform: ${process.platform}
104
104
  message: \`${message}\`
105
- stack trace:\n\`\`\`\n${prepareStack(new Error().stack)}\n\`\`\`
105
+ stack trace:\n\`\`\`\n${prepareStack(new Error('stack capture for the issue report').stack)}\n\`\`\`
106
106
 
107
107
  ---
108
108
  `).replaceAll('(', '%28').replaceAll(')', '%29').replaceAll('-', '%2D');
package/util/log.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { type ILogObj, type ISettingsParam, Logger } from 'tslog';
2
- import { type Options } from 'rotating-file-stream';
2
+ import type { Options } from 'rotating-file-stream';
3
3
  export declare const expensiveTrace: (log: Logger<ILogObj> | undefined, supplier: () => string) => void;
4
4
  export declare class FlowrLogger extends Logger<ILogObj> {
5
5
  /** by keeping track of all children we can propagate updates of the settings (e.g., in tests) */
@@ -8,6 +8,9 @@ export declare class FlowrLogger extends Logger<ILogObj> {
8
8
  updateSettings(updater: (logger: Logger<ILogObj>) => void): void;
9
9
  /**
10
10
  * make the logger log to a file as well
11
+ *
12
+ * Rotation needs the optional `rotating-file-stream` dependency. Without it (the slim runtime images install with
13
+ * `--omit=optional`) the log is appended to a single file instead.
11
14
  */
12
15
  logToFile(filename?: string, options?: Options): void;
13
16
  }
package/util/log.js CHANGED
@@ -3,13 +3,23 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.log = exports.LogLevelNames = exports.FlowrLogger = exports.expensiveTrace = void 0;
4
4
  exports.setLogLevel = setLogLevel;
5
5
  const tslog_1 = require("tslog");
6
- const rotating_file_stream_1 = require("rotating-file-stream");
6
+ const fs_1 = require("fs");
7
7
  const expensiveTrace = (log, supplier) => {
8
8
  if (log !== undefined && log.settings.minLevel <= 1 /* LogLevel.Trace */) {
9
9
  log.trace(supplier());
10
10
  }
11
11
  };
12
12
  exports.expensiveTrace = expensiveTrace;
13
+ /** The rotating stream, or `undefined` if the optional dependency is not installed. */
14
+ function rotatingStream(filename, options) {
15
+ try {
16
+ // eslint-disable-next-line @typescript-eslint/no-require-imports -- optional dependency, absent by design in slim installs
17
+ return require('rotating-file-stream').createStream(filename, options);
18
+ }
19
+ catch {
20
+ return undefined;
21
+ }
22
+ }
13
23
  class FlowrLogger extends tslog_1.Logger {
14
24
  /** by keeping track of all children we can propagate updates of the settings (e.g., in tests) */
15
25
  childLoggers = [];
@@ -26,13 +36,16 @@ class FlowrLogger extends tslog_1.Logger {
26
36
  }
27
37
  /**
28
38
  * make the logger log to a file as well
39
+ *
40
+ * Rotation needs the optional `rotating-file-stream` dependency. Without it (the slim runtime images install with
41
+ * `--omit=optional`) the log is appended to a single file instead.
29
42
  */
30
43
  logToFile(filename = 'flowr.log', options = {
31
44
  size: '10M',
32
45
  interval: '1d',
33
46
  compress: 'gzip',
34
47
  }) {
35
- const stream = (0, rotating_file_stream_1.createStream)(filename, options);
48
+ const stream = rotatingStream(filename, options) ?? (0, fs_1.createWriteStream)(filename, { flags: 'a' });
36
49
  exports.log.attachTransport((logObj) => {
37
50
  stream.write(`${JSON.stringify(logObj)}\n`);
38
51
  });
package/util/logic.js CHANGED
@@ -20,10 +20,10 @@ exports.TernaryLogic = {
20
20
  return Ternary.Maybe;
21
21
  },
22
22
  or(...values) {
23
- if (values.some(value => value === Ternary.Always)) {
23
+ if (values.includes(Ternary.Always)) {
24
24
  return Ternary.Always;
25
25
  }
26
- else if (values.some(value => value === Ternary.Maybe)) {
26
+ else if (values.includes(Ternary.Maybe)) {
27
27
  return Ternary.Maybe;
28
28
  }
29
29
  return Ternary.Never;
@@ -165,6 +165,6 @@ function limitTo(str, limit) {
165
165
  if (str.length <= limit) {
166
166
  return str;
167
167
  }
168
- return `${str.substring(0, limit)}...`;
168
+ return `${str.slice(0, Math.max(0, limit))}...`;
169
169
  }
170
170
  //# sourceMappingURL=cfg.js.map
@@ -12,12 +12,12 @@ const identifier_1 = require("../../dataflow/environments/identifier");
12
12
  const r_function_call_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
13
13
  const edge_1 = require("../../dataflow/graph/edge");
14
14
  const vertex_1 = require("../../dataflow/graph/vertex");
15
- const dfg_get_origin_1 = require("../../dataflow/origin/dfg-get-origin");
16
15
  const type_1 = require("../../r-bridge/lang-4.x/ast/model/type");
17
16
  const info_1 = require("./info");
18
17
  const range_1 = require("../range");
19
18
  const model_1 = require("../../r-bridge/lang-4.x/ast/model/model");
20
19
  const info_2 = require("../../dataflow/info");
20
+ const df_helper_1 = require("../../dataflow/graph/df-helper");
21
21
  function subflowToMermaid(nodeId, subflow, mermaid, idPrefix = '') {
22
22
  if (subflow === undefined) {
23
23
  return;
@@ -160,7 +160,7 @@ function builtInDisplayName(builtInId) {
160
160
  return pkgFn ? `${pkgFn[0]}::${pkgFn[1]}` : String(builtInId).replace('built-in:', '');
161
161
  }
162
162
  function vertexToMermaid(info, mermaid, id, idPrefix, mark, includeOnlyIds) {
163
- const fCall = info.tag === vertex_1.VertexType.FunctionCall;
163
+ const fCall = vertex_1.FunctionCallVertex.is(info);
164
164
  const { open, close } = mermaidNodeBrackets(info.tag);
165
165
  const origId = id;
166
166
  id = mermaid_1.Mermaid.escapeId(id);
@@ -184,7 +184,7 @@ function vertexToMermaid(info, mermaid, id, idPrefix, mark, includeOnlyIds) {
184
184
  const lexeme = node?.lexeme ?? (node?.type === type_1.RType.ExpressionList ? node?.grouping?.[0]?.lexeme : '') ?? '??';
185
185
  let display = lexeme;
186
186
  if (fCall && vertex_1.FunctionCallVertex.is(info)) {
187
- const q = identifier_1.Identifier.toQualified((0, dfg_get_origin_1.getOriginInDfg)(mermaid.rootGraph, origId), info.name, mermaid.qualifyBaseR !== false);
187
+ const q = identifier_1.Identifier.toQualified(df_helper_1.Dataflow.origin(mermaid.rootGraph, origId), info.name, mermaid.qualifyBaseR !== false);
188
188
  const qs = q !== undefined ? identifier_1.Identifier.toString(q) : undefined;
189
189
  if (qs !== undefined && qs !== lexeme) {
190
190
  display = qs;
@@ -199,10 +199,10 @@ function vertexToMermaid(info, mermaid, id, idPrefix, mark, includeOnlyIds) {
199
199
  const escapedName = node ? `*${mermaid_1.Mermaid.escape(`[${node.type}]`)}* ${boldLexeme(lexeme, display)}` : '??';
200
200
  const deps = info.cds ? ', ' + info.cds.map(c => mermaid_1.Mermaid.escapeId(c.id) + (c.when ? '+' : '-')).join(', ') : '';
201
201
  const lnks = info.link?.origin ? ', links: ' + info.link.origin.map(o => mermaid_1.Mermaid.escapeId(o)).join(', ') : '';
202
- const source = info.tag === vertex_1.VertexType.VariableDefinition ? info.source : undefined;
202
+ const source = vertex_1.VariableDefinitionVertex.is(info) ? info.source : undefined;
203
203
  const sources = source ? ', v: ' + source.map(s => mermaid_1.Mermaid.escapeId(s)).join(', ') : '';
204
204
  const n = node?.info.fullRange ?? node?.location ?? (node?.type === type_1.RType.ExpressionList ? node?.grouping?.[0].location : undefined);
205
- mermaid.nodeLines.push(` ${idPrefix}${id}${open}"\`${escapedName}\n *${range_1.SourceRange.format(n)}* (**id: ${id}**${deps}${lnks}${sources})${fCall ? displayFunctionArgMapping(info.args) : '' + (info.tag === vertex_1.VertexType.FunctionDefinition && info.mode && info.mode.length > 0 ? mermaid_1.Mermaid.escape(JSON.stringify(info.mode)) : '')}\`"${close}`);
205
+ mermaid.nodeLines.push(` ${idPrefix}${id}${open}"\`${escapedName}\n *${range_1.SourceRange.format(n)}* (**id: ${id}**${deps}${lnks}${sources})${fCall ? displayFunctionArgMapping(info.args) : '' + (vertex_1.FunctionDefinitionVertex.is(info) && info.mode && info.mode.length > 0 ? mermaid_1.Mermaid.escape(JSON.stringify(info.mode)) : '')}\`"${close}`);
206
206
  }
207
207
  if (mark?.has(id)) {
208
208
  mermaid.nodeLines.push(` style ${idPrefix}${id} ${mermaid.markStyle.vertex} `);
@@ -210,7 +210,7 @@ function vertexToMermaid(info, mermaid, id, idPrefix, mark, includeOnlyIds) {
210
210
  if (mermaid.rootGraph.unknownSideEffects.values().some(l => node_id_1.NodeId.normalize(l) === node_id_1.NodeId.normalize(origId))) {
211
211
  mermaid.nodeLines.push(` style ${idPrefix}${id} stroke:red,stroke-width:5px; `);
212
212
  }
213
- if (info.tag === vertex_1.VertexType.FunctionDefinition) {
213
+ if (vertex_1.FunctionDefinitionVertex.is(info)) {
214
214
  subflowToMermaid(origId, info.subflow, mermaid, idPrefix);
215
215
  }
216
216
  const edges = mermaid.rootGraph.outgoingEdges(node_id_1.NodeId.normalize(origId));
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Mermaid = void 0;
4
+ const url_encoding_1 = require("../text/url-encoding");
4
5
  /**
5
6
  * Global mermaid helper object with useful functions.
6
7
  */
@@ -81,7 +82,8 @@ exports.Mermaid = {
81
82
  autoSync: true
82
83
  }
83
84
  };
84
- return `https://mermaid.live/${edit ? 'edit' : 'view'}#base64:${Buffer.from(JSON.stringify(obj)).toString('base64')}`;
85
+ /* `btoa` rather than a `Buffer`, so the pages flowR ships can build this url as well */
86
+ return `https://mermaid.live/${edit ? 'edit' : 'view'}#base64:${(0, url_encoding_1.toBase64)(new TextEncoder().encode(JSON.stringify(obj)))}`;
85
87
  }
86
88
  };
87
89
  //# sourceMappingURL=mermaid.js.map
package/util/objects.d.ts CHANGED
@@ -58,4 +58,16 @@ export declare function deepClonePreserveUnclonable<T>(obj: T): T;
58
58
  * @param logger - The logger to use for trace debugging.
59
59
  */
60
60
  export declare function looselyCompareObjects(obj: Record<string, unknown>, expected: Record<string, unknown>, arrayMatch?: 'some' | 'every', logger?: Logger<ILogObj>): boolean;
61
+ /**
62
+ * Reads the value at the given dot-separated `path` of `obj` (e.g. `solver.sigdb.additionalPaths`),
63
+ * or `undefined` if any segment along the way is missing.
64
+ * @see {@link setOnPath} for the counterpart that writes such a path
65
+ */
66
+ export declare function getOnPath(obj: unknown, path: string): unknown;
67
+ /**
68
+ * Writes `value` at the given dot-separated `path` of `obj`, creating the intermediate steps that do not exist yet.
69
+ * An intermediate is created as an array if the segment indexing it is a number, and as an object otherwise.
70
+ * @see {@link getOnPath} for the counterpart that reads such a path
71
+ */
72
+ export declare function setOnPath(obj: object, path: string, value: unknown): void;
61
73
  export {};
package/util/objects.js CHANGED
@@ -7,6 +7,9 @@ exports.deepMergeObjectInPlace = deepMergeObjectInPlace;
7
7
  exports.compactRecord = compactRecord;
8
8
  exports.deepClonePreserveUnclonable = deepClonePreserveUnclonable;
9
9
  exports.looselyCompareObjects = looselyCompareObjects;
10
+ exports.getOnPath = getOnPath;
11
+ exports.setOnPath = setOnPath;
12
+ const assert_1 = require("./assert");
10
13
  const json_1 = require("./json");
11
14
  const log_1 = require("./log");
12
15
  /**
@@ -194,4 +197,49 @@ function looselyCompareObjects(obj, expected, arrayMatch, logger) {
194
197
  (0, log_1.expensiveTrace)(logger, () => `Object ${JSON.stringify(obj)} matches ${JSON.stringify(expected)}`);
195
198
  return true;
196
199
  }
200
+ /** Segments that would let a dotted path reach into the prototype chain. */
201
+ const magicPathSegments = new Set(['__proto__', 'prototype', 'constructor']);
202
+ /**
203
+ * Splits a dot-separated path into its segments, turning integral segments into numbers
204
+ * so that `a.0.b` indexes an array rather than an object with the key `'0'`.
205
+ */
206
+ function pathSegments(path) {
207
+ return path.split('.').map(segment => {
208
+ (0, assert_1.guard)(!magicPathSegments.has(segment), () => `refusing to walk the magic property '${segment}' in path '${path}'`);
209
+ const asInt = parseInt(segment);
210
+ return String(asInt) === segment ? asInt : segment;
211
+ });
212
+ }
213
+ /**
214
+ * Reads the value at the given dot-separated `path` of `obj` (e.g. `solver.sigdb.additionalPaths`),
215
+ * or `undefined` if any segment along the way is missing.
216
+ * @see {@link setOnPath} for the counterpart that writes such a path
217
+ */
218
+ function getOnPath(obj, path) {
219
+ let at = obj;
220
+ for (const segment of pathSegments(path)) {
221
+ if (at === null || typeof at !== 'object' || !Object.prototype.hasOwnProperty.call(at, segment)) {
222
+ return undefined;
223
+ }
224
+ at = at[segment];
225
+ }
226
+ return at;
227
+ }
228
+ /**
229
+ * Writes `value` at the given dot-separated `path` of `obj`, creating the intermediate steps that do not exist yet.
230
+ * An intermediate is created as an array if the segment indexing it is a number, and as an object otherwise.
231
+ * @see {@link getOnPath} for the counterpart that reads such a path
232
+ */
233
+ function setOnPath(obj, path, value) {
234
+ const segments = pathSegments(path);
235
+ let at = obj;
236
+ for (let i = 0; i < segments.length - 1; i++) {
237
+ const segment = segments[i];
238
+ if (at[segment] === undefined) {
239
+ at[segment] = typeof segments[i + 1] === 'number' ? [] : {};
240
+ }
241
+ at = at[segment];
242
+ }
243
+ at[segments[segments.length - 1]] = value;
244
+ }
197
245
  //# sourceMappingURL=objects.js.map
package/util/quads.js CHANGED
@@ -13,13 +13,25 @@ exports.defaultQuadIdGenerator = defaultQuadIdGenerator;
13
13
  exports.defaultQuadIgnoreIf = defaultQuadIgnoreIf;
14
14
  exports.serialize2quads = serialize2quads;
15
15
  exports.graph2quads = graph2quads;
16
- const n3_1 = require("n3");
17
- const namedNode = (v) => n3_1.DataFactory.namedNode(v);
18
- const quad = (s, p, o, g) => n3_1.DataFactory.quad(s, p, o, g);
16
+ /**
17
+ * The `n3` module, or a clear error if the optional dependency is missing.
18
+ * Install it to serialize quads (`npm i n3`), everything else works without it.
19
+ */
20
+ function n3() {
21
+ try {
22
+ // eslint-disable-next-line @typescript-eslint/no-require-imports -- optional dependency, resolved only when quads are requested
23
+ return require('n3');
24
+ }
25
+ catch {
26
+ throw new Error('quad serialization needs the optional `n3` dependency, install it with `npm i n3`');
27
+ }
28
+ }
29
+ const namedNode = (v) => n3().DataFactory.namedNode(v);
30
+ const quad = (s, p, o, g) => n3().DataFactory.quad(s, p, o, g);
19
31
  const objects_1 = require("./objects");
20
32
  const assert_1 = require("./assert");
21
33
  const defaultmap_1 = require("./collections/defaultmap");
22
- const literal = (v, n) => n3_1.DataFactory.literal(v, n);
34
+ const literal = (v, n) => n3().DataFactory.literal(v, n);
23
35
  const log_1 = require("./log");
24
36
  const domain = 'https://uni-ulm.de/r-ast/';
25
37
  /**
@@ -46,7 +58,8 @@ exports.DefaultQuadSerializationConfiguration = {
46
58
  function retrieveContext(context, obj) {
47
59
  return typeof context === 'string' ? context : context(obj);
48
60
  }
49
- const writer = new n3_1.Writer({ format: 'N-Quads' });
61
+ let cachedWriter;
62
+ const writer = () => cachedWriter ??= new (n3().Writer)({ format: 'N-Quads' });
50
63
  /**
51
64
  * Serializes the given object or array to rdf quads.
52
65
  * @param obj - The object to serialize (must be a Record and no array etc.)
@@ -61,7 +74,7 @@ function serialize2quads(obj, config) {
61
74
  store = new Set();
62
75
  const quads = [];
63
76
  serializeObject(obj, quads, useConfig);
64
- return writer.quadsToString(quads);
77
+ return writer().quadsToString(quads);
65
78
  }
66
79
  /**
67
80
  * Serializes the given directed graph to rdf quads.
package/util/schema.js CHANGED
@@ -75,7 +75,7 @@ function firstUnknownSchemaSegment(description, path) {
75
75
  const pattern = patternObject(node);
76
76
  if (pattern !== undefined) {
77
77
  if (pattern.keyValids !== undefined && !pattern.keyValids.includes(path[i])) {
78
- return { segment: path[i], available: pattern.keyValids.map(v => String(v)), at: path.slice(0, i) };
78
+ return { segment: path[i], available: pattern.keyValids.map(String), at: path.slice(0, i) };
79
79
  }
80
80
  node = pattern.value;
81
81
  continue;
@@ -110,7 +110,7 @@ function descriptionPathKeys(description, path) {
110
110
  }
111
111
  const keys = Object.keys((node.keys ?? {}));
112
112
  // a `.pattern()` object declares no keys, but a `.valid(...)` key schema restricts them to a known set
113
- const valids = patternObject(node)?.keyValids?.map(v => String(v)) ?? [];
113
+ const valids = patternObject(node)?.keyValids?.map(String) ?? [];
114
114
  return [...keys, ...valids.filter(v => !keys.includes(v))];
115
115
  }
116
116
  /** every settable path in a schema description, intermediate objects included */
@@ -1,10 +1,20 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.dfgToAscii = dfgToAscii;
4
- const dagre_1 = require("dagre");
5
4
  const node_id_1 = require("../../r-bridge/lang-4.x/ast/model/processing/node-id");
6
5
  const vertex_1 = require("../../dataflow/graph/vertex");
7
6
  const edge_1 = require("../../dataflow/graph/edge");
7
+ let dagreModule;
8
+ /* type-only import above, `dagre` is optional: the ascii layout is a side feature, so the package is resolved at call time */
9
+ function dagre() {
10
+ try {
11
+ // eslint-disable-next-line @typescript-eslint/no-require-imports -- loaded on demand, see above
12
+ return dagreModule ??= require('dagre');
13
+ }
14
+ catch {
15
+ throw new Error('the optional dependency `dagre` is required to render a dataflow graph as ascii, install it with `npm i dagre`');
16
+ }
17
+ }
8
18
  function combineAscii(has, add) {
9
19
  if (has === ' ' || has === add) {
10
20
  return add;
@@ -72,7 +82,8 @@ class AsciiCanvas {
72
82
  * Converts the given dataflow graph to an ASCII representation.
73
83
  */
74
84
  function dfgToAscii(dfg) {
75
- const g = new dagre_1.graphlib.Graph();
85
+ const { graphlib: dagreGraphlib, layout } = dagre();
86
+ const g = new dagreGraphlib.Graph();
76
87
  const verts = Array.from(dfg.vertices(true));
77
88
  g.setGraph({
78
89
  nodesep: 1,
@@ -106,7 +117,7 @@ function dfgToAscii(dfg) {
106
117
  edgesDone.add(`${from}-${to}`);
107
118
  }
108
119
  }
109
- (0, dagre_1.layout)(g, {
120
+ layout(g, {
110
121
  minlen: 2
111
122
  });
112
123
  const canvas = new AsciiCanvas();
@@ -63,6 +63,8 @@ export declare function faint(s: string, f?: OutputFormatter, options?: FormatOp
63
63
  */
64
64
  export declare function ansiInfo(s: string, f?: OutputFormatter): string;
65
65
  export declare const escape = "\u001B[";
66
+ /** The text without any colouring, for wherever an escape sequence would only show up as `[0m`. */
67
+ export declare function stripAnsi(text: string): string;
66
68
  /** best-effort, env-based OSC 8 hyperlink support (`FORCE_HYPERLINK`/`NO_HYPERLINK` override; unknown terminals are treated as unsupported) */
67
69
  export declare function supportsHyperlinks(): boolean;
68
70
  export declare const ansiFormatter: {
package/util/text/ansi.js CHANGED
@@ -6,6 +6,7 @@ exports.bold = bold;
6
6
  exports.color = color;
7
7
  exports.faint = faint;
8
8
  exports.ansiInfo = ansiInfo;
9
+ exports.stripAnsi = stripAnsi;
9
10
  exports.supportsHyperlinks = supportsHyperlinks;
10
11
  exports.setFormatter = setFormatter;
11
12
  // noinspection JSUnusedGlobalSymbols
@@ -90,6 +91,13 @@ function ansiInfo(s, f = exports.formatter) {
90
91
  return f.format(s, { color: 7 /* Colors.White */, effect: ColorEffect.Foreground, style: 3 /* FontStyles.Italic */ });
91
92
  }
92
93
  exports.escape = '\x1b[';
94
+ /** every {@link escape} sequence, so a place that cannot colour (a browser, a log file) can drop them */
95
+ // eslint-disable-next-line no-control-regex -- the escape character is what an escape sequence starts with
96
+ const AnsiSequence = /\x1b\[[\d;]*m/g;
97
+ /** The text without any colouring, for wherever an escape sequence would only show up as `[0m`. */
98
+ function stripAnsi(text) {
99
+ return text.replaceAll(AnsiSequence, '');
100
+ }
93
101
  const colorSuffix = 'm';
94
102
  let hyperlinkSupport;
95
103
  /** best-effort, env-based OSC 8 hyperlink support (`FORCE_HYPERLINK`/`NO_HYPERLINK` override; unknown terminals are treated as unsupported) */
@@ -0,0 +1,29 @@
1
+ /**
2
+ * What a reader most likely meant when typing a name: a well-used package first, base R ahead of CRAN, and
3
+ * the things one rarely reaches for last, which are S3 methods, `%operators%`, and names starting with a dot.
4
+ *
5
+ * The signature browser and the playground's completion both offer names out of the same database, so they
6
+ * order them with the same {@link rankName}, and what one of them learns the other one knows.
7
+ */
8
+ export interface NameRankInput {
9
+ /** the name being offered */
10
+ readonly name: string;
11
+ /** what was typed, empty when nothing was */
12
+ readonly needle: string;
13
+ /** how far down the fuzzy match sits, `0` being the closest; `0` when nothing was typed */
14
+ readonly rank?: number;
15
+ /** how often the owning package was downloaded, `0` when unknown */
16
+ readonly downloads?: number;
17
+ /** the owning package ships with R */
18
+ readonly baseR?: boolean;
19
+ /** the owning package is `base` itself */
20
+ readonly base?: boolean;
21
+ /** flowR carries a definition of its own for the name, so it is one people actually call */
22
+ readonly known?: boolean;
23
+ /** the name is an S3 method, like `print.foo` */
24
+ readonly s3?: boolean;
25
+ /** the name holds a value rather than a function */
26
+ readonly variable?: boolean;
27
+ }
28
+ /** The points {@link NameRankInput} earns, higher being offered first. */
29
+ export declare function rankName(of: NameRankInput): number;