@eagleoutice/flowr 2.15.9 → 2.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (244) hide show
  1. package/README.md +47 -41
  2. package/abstract-interpretation/absint-inference.d.ts +2 -2
  3. package/abstract-interpretation/absint-inference.js +32 -79
  4. package/abstract-interpretation/data-frame/arguments.js +11 -7
  5. package/benchmark/slicer.d.ts +0 -1
  6. package/benchmark/slicer.js +1 -2
  7. package/cli/repl/commands/repl-signature.js +12 -3
  8. package/config.d.ts +5 -1
  9. package/control-flow/cfg-properties.js +0 -22
  10. package/control-flow/happens-before.d.ts +7 -2
  11. package/control-flow/happens-before.js +55 -31
  12. package/control-flow/useless-loop.d.ts +1 -1
  13. package/control-flow/useless-loop.js +29 -42
  14. package/dataflow/environments/apply-kill.js +6 -2
  15. package/dataflow/environments/built-in-config.d.ts +2 -0
  16. package/dataflow/environments/built-in-props.d.ts +16 -1
  17. package/dataflow/environments/built-in-props.js +33 -20
  18. package/dataflow/environments/built-in.d.ts +8 -3
  19. package/dataflow/environments/built-in.js +52 -82
  20. package/dataflow/environments/default-builtin-config.d.ts +551 -21
  21. package/dataflow/environments/default-builtin-config.js +121 -45
  22. package/dataflow/environments/define.d.ts +3 -2
  23. package/dataflow/environments/define.js +4 -3
  24. package/dataflow/environments/deprecation-info.d.ts +45 -0
  25. package/dataflow/environments/deprecation-info.js +13 -0
  26. package/dataflow/environments/environment.d.ts +7 -5
  27. package/dataflow/environments/environment.js +55 -121
  28. package/dataflow/environments/identifier.d.ts +6 -2
  29. package/dataflow/environments/identifier.js +23 -69
  30. package/dataflow/environments/reference-to-maybe.d.ts +9 -0
  31. package/dataflow/environments/reference-to-maybe.js +23 -51
  32. package/dataflow/environments/resolve-by-name.js +37 -76
  33. package/dataflow/eval/resolve/resolve-argument.d.ts +3 -1
  34. package/dataflow/eval/resolve/resolve-argument.js +61 -64
  35. package/dataflow/eval/resolve/resolve-working-directory.d.ts +8 -2
  36. package/dataflow/eval/resolve/resolve-working-directory.js +12 -20
  37. package/dataflow/eval/resolve/resolve.d.ts +4 -0
  38. package/dataflow/eval/resolve/resolve.js +23 -14
  39. package/dataflow/extractor.js +180 -58
  40. package/dataflow/fn/class-declaration.d.ts +8 -13
  41. package/dataflow/fn/class-declaration.js +95 -116
  42. package/dataflow/fn/exceptions-of-function.js +68 -37
  43. package/dataflow/fn/frame-reflection.d.ts +12 -4
  44. package/dataflow/fn/frame-reflection.js +51 -41
  45. package/dataflow/fn/function-props.js +15 -33
  46. package/dataflow/fn/function-semantics.d.ts +11 -3
  47. package/dataflow/fn/function-semantics.js +6 -0
  48. package/dataflow/fn/higher-order-function.d.ts +9 -1
  49. package/dataflow/fn/higher-order-function.js +27 -24
  50. package/dataflow/fn/strict-function.d.ts +13 -0
  51. package/dataflow/fn/strict-function.js +291 -123
  52. package/dataflow/graph/call-graph.d.ts +7 -6
  53. package/dataflow/graph/call-graph.js +35 -46
  54. package/dataflow/graph/graph.d.ts +13 -1
  55. package/dataflow/graph/graph.js +74 -66
  56. package/dataflow/graph/vertex.d.ts +1 -1
  57. package/dataflow/info.d.ts +8 -1
  58. package/dataflow/info.js +24 -30
  59. package/dataflow/internal/control-flow.d.ts +31 -4
  60. package/dataflow/internal/control-flow.js +61 -39
  61. package/dataflow/internal/linker.d.ts +17 -8
  62. package/dataflow/internal/linker.js +286 -213
  63. package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.d.ts +179 -0
  64. package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.js +874 -0
  65. package/dataflow/internal/process/functions/call/built-in/built-in-apply.d.ts +3 -1
  66. package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +60 -48
  67. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +4 -2
  68. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +135 -198
  69. package/dataflow/internal/process/functions/call/built-in/built-in-class-generator.js +7 -9
  70. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.d.ts +5 -1
  71. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +21 -14
  72. package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +14 -4
  73. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.d.ts +1 -1
  74. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +141 -146
  75. package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +56 -24
  76. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +292 -253
  77. package/dataflow/internal/process/functions/call/built-in/built-in-get.d.ts +1 -1
  78. package/dataflow/internal/process/functions/call/built-in/built-in-get.js +30 -32
  79. package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +68 -67
  80. package/dataflow/internal/process/functions/call/built-in/built-in-library.js +91 -129
  81. package/dataflow/internal/process/functions/call/built-in/built-in-local.d.ts +1 -3
  82. package/dataflow/internal/process/functions/call/built-in/built-in-local.js +16 -12
  83. package/dataflow/internal/process/functions/call/built-in/built-in-quote.d.ts +4 -4
  84. package/dataflow/internal/process/functions/call/built-in/built-in-quote.js +9 -35
  85. package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.js +2 -0
  86. package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +8 -3
  87. package/dataflow/internal/process/functions/call/built-in/built-in-s-four.d.ts +5 -3
  88. package/dataflow/internal/process/functions/call/built-in/built-in-s-four.js +13 -31
  89. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.d.ts +1 -1
  90. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +42 -119
  91. package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.d.ts +1 -3
  92. package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.js +21 -21
  93. package/dataflow/internal/process/functions/call/built-in/built-in-source.d.ts +2 -0
  94. package/dataflow/internal/process/functions/call/built-in/built-in-source.js +93 -102
  95. package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.d.ts +7 -3
  96. package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +173 -114
  97. package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.d.ts +1 -3
  98. package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +23 -26
  99. package/dataflow/internal/process/functions/call/built-in/built-in-with.d.ts +1 -1
  100. package/dataflow/internal/process/functions/call/built-in/built-in-with.js +34 -9
  101. package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.d.ts +1 -1
  102. package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +119 -93
  103. package/dataflow/internal/process/functions/call/common.d.ts +4 -4
  104. package/dataflow/internal/process/functions/call/common.js +49 -71
  105. package/dataflow/internal/process/functions/call/deferred.d.ts +12 -2
  106. package/dataflow/internal/process/functions/call/deferred.js +81 -63
  107. package/dataflow/internal/process/functions/call/known-call-handling.d.ts +4 -2
  108. package/dataflow/internal/process/functions/call/known-call-handling.js +65 -68
  109. package/dataflow/internal/process/functions/call/named-call-handling.d.ts +3 -5
  110. package/dataflow/internal/process/functions/call/named-call-handling.js +48 -19
  111. package/dataflow/internal/process/functions/call/quoted.d.ts +2 -0
  112. package/dataflow/internal/process/functions/call/quoted.js +257 -154
  113. package/dataflow/internal/process/functions/call/unnamed-call-handling.js +17 -38
  114. package/dataflow/internal/process/functions/process-parameter.js +25 -32
  115. package/dataflow/internal/process/process-symbol.js +4 -3
  116. package/dataflow/internal/program-order.d.ts +26 -0
  117. package/dataflow/internal/program-order.js +49 -0
  118. package/documentation/data/faq/faqs.js +3 -3
  119. package/documentation/data/interface/doc-writing-code.js +1 -2
  120. package/documentation/data/server/doc-data-server-messages.js +7 -7
  121. package/documentation/doc-capabilities.js +80 -34
  122. package/documentation/doc-util/doc-query.d.ts +0 -3
  123. package/documentation/doc-util/doc-query.js +4 -3
  124. package/documentation/wiki-analyzer.js +1 -1
  125. package/documentation/wiki-cfg.js +5 -6
  126. package/documentation/wiki-core.js +8 -8
  127. package/documentation/wiki-dataflow-graph.js +10 -11
  128. package/documentation/wiki-interface.js +2 -2
  129. package/documentation/wiki-linting-and-testing.js +3 -3
  130. package/documentation/wiki-overview.js +6 -6
  131. package/documentation/wiki-query.js +9 -101
  132. package/documentation/wiki-setup.js +23 -0
  133. package/documentation/wiki-signature-database.js +1 -1
  134. package/linter/linter-rules.d.ts +18 -9
  135. package/linter/rules/absolute-path.js +63 -87
  136. package/linter/rules/deprecated-functions.d.ts +1 -45
  137. package/linter/rules/deprecated-functions.js +24 -33
  138. package/linter/rules/file-path-validity.d.ts +4 -2
  139. package/linter/rules/file-path-validity.js +114 -80
  140. package/linter/rules/namespace-access.js +21 -33
  141. package/linter/rules/naming-convention.d.ts +1 -1
  142. package/linter/rules/naming-convention.js +60 -48
  143. package/linter/rules/network-functions.js +11 -7
  144. package/linter/rules/no-leaked-credentials.js +15 -18
  145. package/linter/rules/problematic-inputs.d.ts +2 -1
  146. package/linter/rules/problematic-inputs.js +39 -59
  147. package/linter/rules/roxygen-arguments.d.ts +9 -4
  148. package/linter/rules/roxygen-arguments.js +29 -48
  149. package/linter/rules/seeded-randomness.d.ts +7 -4
  150. package/linter/rules/seeded-randomness.js +128 -89
  151. package/linter/rules/stop-with-call-arg.d.ts +4 -2
  152. package/linter/rules/stop-with-call-arg.js +25 -22
  153. package/linter/rules/unclosed-connection.js +31 -24
  154. package/linter/rules/undefined-symbol.d.ts +4 -6
  155. package/linter/rules/undefined-symbol.js +58 -75
  156. package/linter/rules/unescaped-arguments.js +18 -44
  157. package/linter/rules/unused-definition.d.ts +6 -0
  158. package/linter/rules/unused-definition.js +105 -145
  159. package/linter/rules/unused-import.d.ts +3 -0
  160. package/linter/rules/unused-import.js +25 -43
  161. package/package.json +5 -2
  162. package/project/flowr-analyzer.d.ts +2 -0
  163. package/project/flowr-analyzer.js +28 -1
  164. package/project/plugins/file-plugins/files/flowr-jupyter-file.d.ts +2 -2
  165. package/project/plugins/file-plugins/files/flowr-jupyter-file.js +8 -12
  166. package/project/plugins/file-plugins/files/flowr-rda-file.d.ts +0 -2
  167. package/project/plugins/file-plugins/files/flowr-rda-file.js +10 -55
  168. package/project/plugins/file-plugins/files/flowr-rmarkdown-file.d.ts +7 -5
  169. package/project/plugins/file-plugins/files/flowr-rmarkdown-file.js +34 -56
  170. package/project/plugins/file-plugins/flowr-analyzer-file-plugin.js +2 -1
  171. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +22 -45
  172. package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +2 -2
  173. package/project/sigdb/build.js +4 -0
  174. package/project/sigdb/manifest.d.ts +2 -0
  175. package/project/sigdb/manifest.js +10 -1
  176. package/project/sigdb/reader.js +23 -61
  177. package/project/sigdb/sigdb-download.d.ts +29 -6
  178. package/project/sigdb/sigdb-download.js +212 -64
  179. package/queries/base-query-format.js +1 -2
  180. package/queries/catalog/absint-query/absint-query-format.js +1 -1
  181. package/queries/catalog/call-context-query/cascade-action.d.ts +3 -1
  182. package/queries/catalog/call-context-query/cascade-action.js +2 -0
  183. package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +3 -0
  184. package/queries/catalog/dataflow-query/dataflow-query-executor.js +2 -2
  185. package/queries/catalog/dataflow-query/dataflow-query-format.d.ts +2 -0
  186. package/queries/catalog/dataflow-query/dataflow-query-format.js +4 -7
  187. package/queries/catalog/dependencies-query/dependencies-query-executor.js +50 -114
  188. package/queries/catalog/dependencies-query/function-info/library-functions.d.ts +5 -9
  189. package/queries/catalog/dependencies-query/function-info/library-functions.js +6 -0
  190. package/queries/catalog/dependencies-query/function-info/read-functions.js +1 -1
  191. package/queries/catalog/dependencies-query/function-info/write-functions.js +7 -3
  192. package/queries/catalog/input-sources-query/simple-input-classifier.d.ts +4 -4
  193. package/queries/catalog/input-sources-query/simple-input-classifier.js +192 -301
  194. package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor.js +2 -1
  195. package/queries/catalog/origin-query/origin-query-executor.d.ts +1 -1
  196. package/queries/catalog/origin-query/origin-query-executor.js +2 -2
  197. package/queries/catalog/origin-query/origin-query-format.d.ts +2 -2
  198. package/queries/catalog/origin-query/origin-query-format.js +1 -1
  199. package/queries/query.d.ts +1 -1
  200. package/r-bridge/data/data.d.ts +21 -14
  201. package/r-bridge/data/data.js +28 -20
  202. package/r-bridge/lang-4.x/ast/model/model.d.ts +3 -1
  203. package/r-bridge/lang-4.x/ast/model/model.js +19 -43
  204. package/r-bridge/lang-4.x/ast/model/nodes/r-access.d.ts +1 -0
  205. package/r-bridge/lang-4.x/ast/model/nodes/r-argument.d.ts +3 -0
  206. package/r-bridge/lang-4.x/ast/model/nodes/r-argument.js +5 -12
  207. package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.d.ts +1 -0
  208. package/r-bridge/lang-4.x/ast/model/nodes/r-break.d.ts +1 -0
  209. package/r-bridge/lang-4.x/ast/model/nodes/r-comment.d.ts +1 -0
  210. package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.d.ts +1 -0
  211. package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.d.ts +1 -0
  212. package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.d.ts +1 -0
  213. package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.d.ts +1 -0
  214. package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.d.ts +1 -0
  215. package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.d.ts +1 -0
  216. package/r-bridge/lang-4.x/ast/model/nodes/r-logical.d.ts +1 -0
  217. package/r-bridge/lang-4.x/ast/model/nodes/r-next.d.ts +1 -0
  218. package/r-bridge/lang-4.x/ast/model/nodes/r-number.d.ts +1 -0
  219. package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.d.ts +1 -0
  220. package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.d.ts +1 -0
  221. package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.d.ts +1 -0
  222. package/r-bridge/lang-4.x/ast/model/nodes/r-string.d.ts +1 -0
  223. package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.d.ts +1 -0
  224. package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.d.ts +1 -0
  225. package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.d.ts +1 -0
  226. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.d.ts +2 -2
  227. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.js +11 -2
  228. package/r-bridge/roxygen2/roxygen-parse.js +28 -42
  229. package/r-bridge/shell.js +6 -0
  230. package/search/search-executor/search-enrichers.js +25 -37
  231. package/slicing/static/slice-call.d.ts +4 -3
  232. package/slicing/static/slice-call.js +56 -88
  233. package/slicing/static/static-slicer.js +115 -79
  234. package/slicing/static/visiting-queue.d.ts +4 -6
  235. package/slicing/static/visiting-queue.js +9 -13
  236. package/util/files.d.ts +2 -0
  237. package/util/files.js +3 -1
  238. package/util/mermaid/mermaid.js +6 -2
  239. package/util/proc.js +2 -1
  240. package/util/r-base-packages.d.ts +2 -0
  241. package/util/r-base-packages.js +23 -13
  242. package/util/text/playground-link.d.ts +12 -3
  243. package/util/text/playground-link.js +18 -27
  244. package/util/version.js +4 -10
@@ -10,11 +10,11 @@ class FlowrJupyterFile extends flowr_file_1.FlowrFile {
10
10
  wrapped;
11
11
  /**
12
12
  * Prefer the static {@link FlowrJupyterFile.from} method
13
- * @param file - the file to load as Jupyter
13
+ * @param wrapped - the file to load as Jupyter
14
14
  */
15
- constructor(file) {
16
- super(file.path(), file.roles ? [...file.roles, flowr_file_1.FileRole.Source] : [flowr_file_1.FileRole.Source]);
17
- this.wrapped = file;
15
+ constructor(wrapped) {
16
+ super(wrapped.path(), wrapped.roles ? [...wrapped.roles, flowr_file_1.FileRole.Source] : [flowr_file_1.FileRole.Source]);
17
+ this.wrapped = wrapped;
18
18
  }
19
19
  /**
20
20
  * Loads and parses the content of the wrapped file.
@@ -37,14 +37,10 @@ class FlowrJupyterFile extends flowr_file_1.FlowrFile {
37
37
  }
38
38
  exports.FlowrJupyterFile = FlowrJupyterFile;
39
39
  function loadJupyter(content) {
40
- const nb = JSON.parse(content);
41
- return nb.cells.map(cell => {
42
- if (cell.cell_type === 'code') {
43
- return typeof cell.source === 'object' ? cell.source.join('') : cell.source;
44
- }
45
- else {
46
- return typeof cell.source === 'object' ? cell.source.map(s => `# ${s}`).join('') : `# ${cell.source}`;
47
- }
40
+ return JSON.parse(content).cells.map(cell => {
41
+ const source = typeof cell.source === 'object' ? cell.source.join('') : cell.source;
42
+ /* every line of a text cell becomes a comment, whether the notebook stores the cell as lines or as one string */
43
+ return cell.cell_type === 'code' ? source : source.replace(/^/gm, '# ');
48
44
  }).join('\n');
49
45
  }
50
46
  //# sourceMappingURL=flowr-jupyter-file.js.map
@@ -403,8 +403,6 @@ export declare class RDAParser {
403
403
  * See {@link https://github.com/wch/r-source/blob/2196e6982a8f49082ee5c3d3521f6dd6596ea72c/src/main/memory.c#L4122-L4142 | R source: VECTOR_ELT}
404
404
  */
405
405
  VECTOR_ELT(x: RObjectData, i: number): RObject;
406
- /** Whether a {@link SexpType.BcodesSxp}'s version is within the supported range. See {@link https://github.com/wch/r-source/blob/2196e6982a8f49082ee5c3d3521f6dd6596ea72c/src/main/eval.c#L7166-L7175 | R source: R_BCVersionOK} */
407
- R_BCVersionOK(s: RObjectData): boolean;
408
406
  /** Source-language expression for an unsupported bytecode object: its first constant pool entry, or {@link RValues.NilValue}. See {@link https://github.com/wch/r-source/blob/2196e6982a8f49082ee5c3d3521f6dd6596ea72c/src/main/eval.c#L5566-L5574 | R source: bytecodeExpr} */
409
407
  R_BytecodeExpr(s: RObjectData): RObject;
410
408
  /**
@@ -121,6 +121,8 @@ const BareStreamFormats = new Set(['A', 'B', 'X']);
121
121
  function isBareSerializationStream(buf) {
122
122
  return buf.length >= 2 && buf[1] === 0x0a && BareStreamFormats.has(String.fromCodePoint(buf[0]));
123
123
  }
124
+ /** The control characters an ASCII-format string spells with a backslash escape; any other escaped character stands for itself. */
125
+ const AsciiEscapes = { n: '\n', t: '\t', v: '\v', b: '\b', r: '\r', f: '\f', a: '\x07' };
124
126
  /** The variants {@link RDAParser.deserialize} handles. */
125
127
  const SupportedSerializationTypes = new Set([
126
128
  SerializationTypeTag.MagicAsciiV2, SerializationTypeTag.MagicBinaryV2, SerializationTypeTag.MagicXdrV2,
@@ -406,7 +408,7 @@ class RDAParser {
406
408
  if (neLen > RDAParser.R_CODE_SET_MAX || neLen < 0) {
407
409
  throw new Error('invalid length of encoding name');
408
410
  }
409
- const _nativeEncoding = this.inString(neLen);
411
+ this.inString(neLen);
410
412
  break;
411
413
  }
412
414
  default:
@@ -536,37 +538,13 @@ class RDAParser {
536
538
  c = String.fromCodePoint(this.buffer[this.offset++]);
537
539
  switch (c) {
538
540
  case 'n':
539
- result.push('\n');
540
- break;
541
541
  case 't':
542
- result.push('\t');
543
- break;
544
542
  case 'v':
545
- result.push('\v');
546
- break;
547
543
  case 'b':
548
- result.push('\b');
549
- break;
550
544
  case 'r':
551
- result.push('\r');
552
- break;
553
545
  case 'f':
554
- result.push('\f');
555
- break;
556
546
  case 'a':
557
- result.push('\x07');
558
- break; // \a
559
- case '\\':
560
- result.push('\\');
561
- break;
562
- case '?':
563
- result.push('?');
564
- break;
565
- case '\'':
566
- result.push('\'');
567
- break;
568
- case '"':
569
- result.push('"');
547
+ result.push(AsciiEscapes[c]);
570
548
  break;
571
549
  case '0':
572
550
  case '1':
@@ -641,28 +619,21 @@ class RDAParser {
641
619
  const shell = new shell_executor_1.RShellExecutor();
642
620
  const result = shell.run(code);
643
621
  shell.close();
644
- const val = { type: SexpType.EnvSxp };
645
- if (result === '<environment: R_GlobalEnv>') {
646
- val.value = RValues.GlobalEnv;
647
- }
648
- return val;
622
+ return result === '<environment: R_GlobalEnv>' ? { type: SexpType.EnvSxp, value: RValues.GlobalEnv } : { type: SexpType.EnvSxp };
649
623
  }
650
624
  /**
651
625
  * Resolves a namespace reference by name via `getNamespace()` in R. Simpler variant of {@link R_FindNamespace1}.
652
626
  * @see {@link https://github.com/wch/r-source/blob/2196e6982a8f49082ee5c3d3521f6dd6596ea72c/src/main/envir.c#L3795-L3804 | R source: R_FindNamespace}
653
627
  */
654
628
  R_FindNamespace(info) {
655
- const namespaceName = info.value.name;
656
- return this.runNamespaceLookup(`getNamespace("${namespaceName}")`);
629
+ return this.runNamespaceLookup(`getNamespace("${info.value.name}")`);
657
630
  }
658
631
  /**
659
632
  * Resolves a serialized namespace reference by executing R at runtime. See {@link R_FindNamespace} for the result shape.
660
633
  * @see {@link https://github.com/wch/r-source/blob/2196e6982a8f49082ee5c3d3521f6dd6596ea72c/src/main/serialize.c#L1785-L1796 | R source: R_FindNamespace1}
661
634
  */
662
635
  R_FindNamespace1(info) {
663
- const where = this.lastName;
664
- const code = `..getNamespace("${info.value[0].name}", "${where}")`;
665
- return this.runNamespaceLookup(code);
636
+ return this.runNamespaceLookup(`..getNamespace("${info.value[0].name}", "${this.lastName}")`);
666
637
  }
667
638
  /**
668
639
  * Deserializes a single SEXP node, dispatching on its encoded {@link SexpType}.
@@ -933,7 +904,7 @@ class RDAParser {
933
904
  s.attributes = hasAttribute ? [skip ? this.skipItem() : this.assertRObjectData(this.readItem())] : undefined;
934
905
  this.currentDepth--;
935
906
  }
936
- if (!skip && s.type === SexpType.BcodesSxp && !this.R_BCVersionOK(s)) {
907
+ if (!skip && s.type === SexpType.BcodesSxp) {
937
908
  return this.R_BytecodeExpr(s);
938
909
  }
939
910
  return s;
@@ -1597,28 +1568,12 @@ class RDAParser {
1597
1568
  return x.value[i];
1598
1569
  }
1599
1570
  }
1600
- /** Whether a {@link SexpType.BcodesSxp}'s version is within the supported range. See {@link https://github.com/wch/r-source/blob/2196e6982a8f49082ee5c3d3521f6dd6596ea72c/src/main/eval.c#L7166-L7175 | R source: R_BCVersionOK} */
1601
- R_BCVersionOK(s) {
1602
- if (s.type !== SexpType.BcodesSxp) {
1603
- return false;
1604
- }
1605
- // const version = s.code;
1606
- const version = 0;
1607
- return version >= 9 && version <= 12;
1608
- }
1609
1571
  /** Source-language expression for an unsupported bytecode object: its first constant pool entry, or {@link RValues.NilValue}. See {@link https://github.com/wch/r-source/blob/2196e6982a8f49082ee5c3d3521f6dd6596ea72c/src/main/eval.c#L5566-L5574 | R source: bytecodeExpr} */
1610
1572
  R_BytecodeExpr(s) {
1611
- if (s.type === SexpType.BcodesSxp) {
1612
- if (s.cdr.value?.length > 0) {
1613
- return this.VECTOR_ELT(s.cdr, 0);
1614
- }
1615
- else {
1616
- return RValues.NilValue;
1617
- }
1618
- }
1619
- else {
1573
+ if (s.type !== SexpType.BcodesSxp) {
1620
1574
  return s;
1621
1575
  }
1576
+ return s.cdr.value?.length > 0 ? this.VECTOR_ELT(s.cdr, 0) : RValues.NilValue;
1622
1577
  }
1623
1578
  /**
1624
1579
  * Attempts to unserialize an ALTREP object. Throws error if the base type is not a supported vector type.
@@ -7,17 +7,17 @@ import type { FlowrAnalyzerContext } from '../../../context/flowr-analyzer-conte
7
7
  * Finally, it provides access to the single cells, and all cells fused together as one R file.
8
8
  */
9
9
  export declare class FlowrRMarkdownFile extends FlowrFile {
10
- private data?;
11
- private mergedCode?;
12
10
  private readonly wrapped;
13
11
  private readonly context;
12
+ private data?;
13
+ private mergedCode?;
14
14
  private readonly included;
15
15
  /**
16
16
  * Prefer the static {@link FlowrRMarkdownFile.from} method
17
- * @param file - the file to load as R Markdown
18
- * @param ctx - the analyzer context the chunks are read with
17
+ * @param wrapped - the file to load as R Markdown
18
+ * @param context - the analyzer context the chunks are read with
19
19
  */
20
- constructor(file: FlowrFileProvider<string>, ctx: FlowrAnalyzerContext);
20
+ constructor(wrapped: FlowrFileProvider<string>, context: FlowrAnalyzerContext);
21
21
  /**
22
22
  * Gets the parsed R Markdown information
23
23
  */
@@ -74,6 +74,8 @@ export declare function globalChunkOptions(frontmatter: object): CodeBlockOption
74
74
  * @returns Rmd Info
75
75
  */
76
76
  export declare function parseRMarkdownFile(raw: string): RmdInfo;
77
+ /** The info string of an R chunk, `{r}` or `{r label, eval = FALSE}`; the `[\s,]` keeps `{rust}` out */
78
+ export declare const RTagRegex: RegExp;
77
79
  /**
78
80
  * Checks whether a CommonMark node is an R code block
79
81
  */
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FlowrRMarkdownFile = void 0;
3
+ exports.RTagRegex = exports.FlowrRMarkdownFile = void 0;
4
4
  exports.isExecutableCell = isExecutableCell;
5
5
  exports.continuesAfterError = continuesAfterError;
6
6
  exports.globalChunkOptions = globalChunkOptions;
@@ -19,20 +19,20 @@ const built_in_source_1 = require("../../../../dataflow/internal/process/functio
19
19
  * Finally, it provides access to the single cells, and all cells fused together as one R file.
20
20
  */
21
21
  class FlowrRMarkdownFile extends flowr_file_1.FlowrFile {
22
- data;
23
- mergedCode;
24
22
  wrapped;
25
23
  context;
24
+ data;
25
+ mergedCode;
26
26
  included = [];
27
27
  /**
28
28
  * Prefer the static {@link FlowrRMarkdownFile.from} method
29
- * @param file - the file to load as R Markdown
30
- * @param ctx - the analyzer context the chunks are read with
29
+ * @param wrapped - the file to load as R Markdown
30
+ * @param context - the analyzer context the chunks are read with
31
31
  */
32
- constructor(file, ctx) {
33
- super(file.path(), file.roles ? [...file.roles, flowr_file_1.FileRole.Source] : [flowr_file_1.FileRole.Source]);
34
- this.wrapped = file;
35
- this.context = ctx;
32
+ constructor(wrapped, context) {
33
+ super(wrapped.path(), wrapped.roles ? [...wrapped.roles, flowr_file_1.FileRole.Source] : [flowr_file_1.FileRole.Source]);
34
+ this.wrapped = wrapped;
35
+ this.context = context;
36
36
  }
37
37
  /**
38
38
  * Gets the parsed R Markdown information
@@ -68,10 +68,7 @@ class FlowrRMarkdownFile extends flowr_file_1.FlowrFile {
68
68
  (0, assert_1.guard)(this.data !== undefined);
69
69
  for (const block of this.data.blocks) {
70
70
  const childOpt = block.options.get('child');
71
- if (childOpt === undefined) {
72
- continue;
73
- }
74
- const childPath = (0, built_in_source_1.findSource)(this.context.config.solver.resolveSource, childOpt, {
71
+ const childPath = childOpt === undefined ? undefined : (0, built_in_source_1.findSource)(this.context.config.solver.resolveSource, childOpt, {
75
72
  ctx: this.context,
76
73
  referenceChain: [this.path()]
77
74
  });
@@ -138,8 +135,12 @@ function wrapErrorTolerant(code) {
138
135
  */
139
136
  function globalChunkOptions(frontmatter) {
140
137
  const knitr = frontmatter.knitr;
138
+ return scalarOptions([frontmatter.execute, knitr?.opts_chunk]);
139
+ }
140
+ /** The scalar entries of the given yaml objects as options, later ones overriding earlier ones. */
141
+ function scalarOptions(sources) {
141
142
  const options = new Map();
142
- for (const source of [frontmatter.execute, knitr?.opts_chunk]) {
143
+ for (const source of sources) {
143
144
  if (typeof source !== 'object' || source === null) {
144
145
  continue;
145
146
  }
@@ -183,20 +184,14 @@ function parseFrontmatter(raw) {
183
184
  * @returns Rmd Info
184
185
  */
185
186
  function parseRMarkdownFile(raw) {
186
- // Read and Parse Markdown
187
- const parser = new commonmark_1.Parser();
188
- const ast = parser.parse(raw);
189
- // Parse Frontmatter
190
187
  let frontmatter;
191
188
  try {
192
189
  frontmatter = parseFrontmatter(raw);
193
190
  }
194
191
  catch (e) {
195
192
  log_1.log.warn(`Failed to parse frontmatter of Rmd file, ignoring it. Error was: ${JSON.stringify(e)}`);
196
- frontmatter = undefined;
197
193
  }
198
- // Parse Codeblocks
199
- const walker = ast.walker();
194
+ const walker = new commonmark_1.Parser().parse(raw).walker();
200
195
  const blocks = [];
201
196
  let e;
202
197
  while ((e = walker.next())) {
@@ -206,48 +201,42 @@ function parseRMarkdownFile(raw) {
206
201
  }
207
202
  const options = parseCodeBlockOptions(node.info, node.literal);
208
203
  const engineOpt = options.get('engine');
209
- if (engineOpt !== undefined && engineOpt.trim().toLowerCase() !== 'r') {
210
- continue;
204
+ if (engineOpt === undefined || engineOpt.trim().toLowerCase() === 'r') {
205
+ blocks.push({
206
+ code: node.literal,
207
+ options,
208
+ header: node.info,
209
+ startpos: { line: node.sourcepos[0][0] + 1, col: 0 }
210
+ });
211
211
  }
212
- blocks.push({
213
- code: node.literal,
214
- options: options,
215
- header: node.info,
216
- startpos: { line: node.sourcepos[0][0] + 1, col: 0 }
217
- });
218
212
  }
219
213
  blocks.push(...parseIncludeShortcodes(raw));
220
214
  blocks.sort((a, b) => a.startpos.line - b.startpos.line);
221
215
  return {
222
- blocks: blocks,
216
+ blocks,
223
217
  options: typeof frontmatter === 'object' && frontmatter !== null ? frontmatter : {}
224
218
  };
225
219
  }
226
220
  const IncludeShortcodeRegex = /{{<\s*include\s+["']?(.+?)["']?\s*>}}/;
227
221
  /** Collects quarto's `{{< include other.qmd >}}` as blocks carrying a `child`, resolved like knitr's option */
228
222
  function parseIncludeShortcodes(raw) {
229
- const blocks = [];
230
- const lines = raw.split(LineRegex);
231
- for (let i = 0; i < lines.length; i++) {
232
- const match = IncludeShortcodeRegex.exec(lines[i]);
233
- if (match) {
234
- blocks.push({
223
+ return raw.split(LineRegex).flatMap((line, i) => {
224
+ const match = IncludeShortcodeRegex.exec(line);
225
+ return match ? [{
235
226
  code: '',
236
227
  options: new Map([['child', match[1]]]),
237
228
  header: '',
238
229
  startpos: { line: i + 1, col: 0 }
239
- });
240
- }
241
- }
242
- return blocks;
230
+ }] : [];
231
+ });
243
232
  }
244
- // We need the [\s,] part, otherwise {rust} would also match
245
- const RTagRegex = /{[rR](?:[\s,][^}]*)?}/;
233
+ /** The info string of an R chunk, `{r}` or `{r label, eval = FALSE}`; the `[\s,]` keeps `{rust}` out */
234
+ exports.RTagRegex = /{[rR](?:[\s,][^}]*)?}/;
246
235
  /**
247
236
  * Checks whether a CommonMark node is an R code block
248
237
  */
249
238
  function isRCodeBlock(node) {
250
- return node.type === 'code_block' && node.literal !== null && node.info !== null && RTagRegex.test(node.info);
239
+ return node.type === 'code_block' && node.literal !== null && node.info !== null && exports.RTagRegex.test(node.info);
251
240
  }
252
241
  const LineRegex = /\r\n|\r|\n/;
253
242
  function countNewlines(str) {
@@ -269,7 +258,6 @@ function restoreBlocksWithoutMd(blocks, totalLines) {
269
258
  output += block.code;
270
259
  line += countNewlines(block.code);
271
260
  }
272
- // Add remainder of file
273
261
  goToLine(totalLines + 1);
274
262
  return output;
275
263
  }
@@ -289,11 +277,7 @@ function parseCodeBlockOptions(header, content) {
289
277
  // keep the indentation, yaml block scalars rely on it
290
278
  cellLines.push(line.trim().slice(2).replace(/^ /, ''));
291
279
  }
292
- const options = parseOptionString(headerOpts);
293
- for (const [key, value] of parseCellOptions(cellLines)) {
294
- options.set(key, value);
295
- }
296
- return options;
280
+ return new Map([...parseOptionString(headerOpts), ...parseCellOptions(cellLines)]);
297
281
  }
298
282
  /** Parses knitr's `key=value` option syntax as used in the chunk header */
299
283
  function parseOptionString(opts) {
@@ -314,13 +298,7 @@ function parseCellOptions(lines) {
314
298
  const parsed = parseFrontmatter(`---\n${lines.join('\n')}\n---\n`);
315
299
  // a bare scalar is knitr's `key=value` syntax, not yaml
316
300
  if (typeof parsed === 'object' && parsed !== null && !Array.isArray(parsed) && Object.keys(parsed).length > 0) {
317
- const options = new Map();
318
- for (const [key, value] of Object.entries(parsed)) {
319
- if (value !== null && typeof value !== 'object') {
320
- options.set(key, String(value));
321
- }
322
- }
323
- return options;
301
+ return scalarOptions([parsed]);
324
302
  }
325
303
  }
326
304
  catch (e) {
@@ -4,6 +4,7 @@ exports.FlowrAnalyzerRoleFilePlugin = exports.FlowrAnalyzerPatternFilePlugin = e
4
4
  const flowr_analyzer_plugin_1 = require("../flowr-analyzer-plugin");
5
5
  const flowr_file_1 = require("../../context/flowr-file");
6
6
  const semver_1 = require("semver");
7
+ const files_1 = require("../../../util/files");
7
8
  const built_in_source_1 = require("../../../dataflow/internal/process/functions/call/built-in/built-in-source");
8
9
  /**
9
10
  * This is the base class for all plugins that load and possibly transform files when they are loaded.
@@ -34,7 +35,7 @@ class DefaultFlowrAnalyzerFilePlugin extends FlowrAnalyzerFilePlugin {
34
35
  }
35
36
  process(_ctx, arg) {
36
37
  const path = arg.path().toString();
37
- if (/\.r$/i.test(path)) {
38
+ if (/\.r$/i.test(path) || files_1.rPackageSourceRegex.test(path)) {
38
39
  // we just assign the role :D
39
40
  arg.assignRole(flowr_file_1.FileRole.Source);
40
41
  }
@@ -57,22 +57,15 @@ const defaultmap_1 = require("../../../util/collections/defaultmap");
57
57
  const arrays_1 = require("../../../util/collections/arrays");
58
58
  /** the plugin's instance name (pass to `unregisterPlugins` to disable the default sigdb resolver) */
59
59
  exports.SigDbPluginName = 'flowr-analyzer-package-versions-sigdb-plugin';
60
- /** map a resolved source's compressed extension to a codec name for display (`undefined` extension is a plain file) */
61
- function codecNameOf(ext) {
62
- switch (ext) {
63
- case '.zst': return 'zstd';
64
- case '.br': return 'brotli';
65
- case '.gz': return 'gzip';
66
- default: return 'plain';
67
- }
68
- }
60
+ /** a resolved source's compressed extension as a codec name for display, a file without one is `plain` */
61
+ const CodecNames = { '.zst': 'zstd', '.br': 'brotli', '.gz': 'gzip' };
69
62
  /** the codec name of a manifest's resolved shard + dict sources, or `mixed` when they do not all agree */
70
63
  function manifestFormat(set) {
71
64
  const paths = [
72
65
  ...set.manifest.shards.map(s => s.path),
73
66
  ...(set.manifest.dicts?.map(d => d.path) ?? [])
74
67
  ];
75
- const codecs = (0, arrays_1.uniqueArray)(paths.map(p => codecNameOf((0, codec_1.compressedExtOf)((0, decompress_1.resolveSource)(set.baseDir, p)))));
68
+ const codecs = (0, arrays_1.uniqueArray)(paths.map(p => CodecNames[(0, codec_1.compressedExtOf)((0, decompress_1.resolveSource)(set.baseDir, p)) ?? ''] ?? 'plain'));
76
69
  return codecs.length === 1 ? codecs[0] : 'mixed';
77
70
  }
78
71
  /** describe one loaded source for `:version` / diagnostics: a single bundle, a sharded set, or an in-memory source */
@@ -201,16 +194,18 @@ class FlowrAnalyzerPackageVersionsSigDbPlugin extends flowr_analyzer_package_ver
201
194
  if (!dl.sigDbNeedsSync()) {
202
195
  return;
203
196
  }
204
- exports.sigDbLog.info('sigdb: committed link file changed, re-syncing shards in the background');
205
- const { files } = await dl.downloadFullSigDb({
197
+ exports.sigDbLog.info('sigdb: the committed link file names shards missing from the cache, syncing them in the background');
198
+ const { tag, files, downloaded, stale } = await dl.downloadFullSigDb({
206
199
  repo: ctx.config.solver.sigdb.downloadRepo,
207
200
  onProgress: msg => exports.sigDbLog.info(`sigdb sync: ${msg}`)
208
201
  });
209
- for (const manifest of files.filter(f => /\.manifest\.json(\.br)?$/.test(f))) {
202
+ const manifests = files.filter(f => dl.isManifestFile(f));
203
+ for (const manifest of manifests) {
210
204
  await ctx.deps.addDatabaseSource(manifest);
211
205
  }
206
+ exports.sigDbLog.info(`sigdb sync: ${tag} ready (${downloaded.length} file(s) fetched, ${manifests.length} manifest(s) mounted${stale.length > 0 ? `, ${stale.length} older bundle(s) still cached` : ''})`);
212
207
  })().catch((e) => {
213
- exports.sigDbLog.warn(`background sigdb sync failed (keeping the cached shards): ${e.message}`);
208
+ exports.sigDbLog.warn(`background sigdb sync failed, analyzing with the signatures already cached: ${e.message}`);
214
209
  });
215
210
  }
216
211
  warmPromise;
@@ -283,16 +278,7 @@ class FlowrAnalyzerPackageVersionsSigDbPlugin extends flowr_analyzer_package_ver
283
278
  /* the historical bundle is not asked: a name is hinted so a `library()` can be added for it, and a package
284
279
  only that bundle carries is one nothing can attach today */
285
280
  const sources = this.loadSources().filter(s => describeLoadedDatabase(s).scope !== 'history');
286
- const seen = new Set();
287
- const owners = [];
288
- for (const src of sources) {
289
- for (const pkg of exportOwners(src, name)) {
290
- if (!seen.has(pkg) && !this.isSelfPackage(pkg)) {
291
- seen.add(pkg);
292
- owners.push(pkg);
293
- }
294
- }
295
- }
281
+ const owners = (0, arrays_1.uniqueArray)(sources.flatMap(src => exportOwners(src, name))).filter(pkg => !this.isSelfPackage(pkg));
296
282
  // each source's list is already sorted; a merge of several needs one more pass to be globally ordered
297
283
  if (owners.length > 1 && sources.length > 1) {
298
284
  /* the comparator runs O(n log n) times, so each package is counted once up front */
@@ -393,12 +379,8 @@ class FlowrAnalyzerPackageVersionsSigDbPlugin extends flowr_analyzer_package_ver
393
379
  return undefined;
394
380
  }
395
381
  const target = this.analyzerCtx?.resolvedRVersion ?? (0, config_1.resolveAssumedRVersion)(undefined);
396
- let chosen; // versions are ascending; keep the newest core release <= target
397
- for (const v of versions) {
398
- if (r_version_1.RVersion.compare(v.str, target) <= 0) {
399
- chosen = v;
400
- }
401
- }
382
+ // versions are ascending; keep the newest core release <= target
383
+ let chosen = versions.findLast(v => r_version_1.RVersion.compare(v.str, target) <= 0);
402
384
  if (chosen === undefined) {
403
385
  // the assumed R version is older than the earliest recorded core release: fall back to the closest one
404
386
  chosen = versions[0];
@@ -479,24 +461,17 @@ class FlowrAnalyzerPackageVersionsSigDbPlugin extends flowr_analyzer_package_ver
479
461
  if (info && (range === undefined || r_version_1.RRange.satisfies(info.version, range))) {
480
462
  return info;
481
463
  }
482
- if (range !== undefined) {
483
- const versions = this.availableVersions(src, name);
484
- for (let i = versions.length - 1; i >= 0; i--) {
485
- if (r_version_1.RRange.satisfies(versions[i], range)) {
486
- return src.lookup(name, versions[i]);
487
- }
488
- }
464
+ if (range === undefined) {
465
+ return undefined;
489
466
  }
490
- return undefined;
467
+ const satisfying = this.availableVersions(src, name).findLast(version => r_version_1.RRange.satisfies(version, range));
468
+ return satisfying === undefined ? undefined : src.lookup(name, satisfying);
491
469
  }
492
470
  /** Lowest stored version satisfying the constraint (using the store's actual R-form version strings). */
493
471
  oldestSatisfying(src, name, range) {
494
- for (const version of this.availableVersions(src, name)) { // ascending
495
- if (range === undefined || r_version_1.RRange.satisfies(version, range)) {
496
- return src.lookup(name, version);
497
- }
498
- }
499
- return undefined;
472
+ // versions are ascending, so the first satisfying one is the oldest
473
+ const satisfying = this.availableVersions(src, name).find(version => range === undefined || r_version_1.RRange.satisfies(version, range));
474
+ return satisfying === undefined ? undefined : src.lookup(name, satisfying);
500
475
  }
501
476
  /**
502
477
  * The versions the source can answer for a package (dated releases, base-R core releases, and the latest),
@@ -507,7 +482,9 @@ class FlowrAnalyzerPackageVersionsSigDbPlugin extends flowr_analyzer_package_ver
507
482
  }
508
483
  /** build the resolved {@link Package} (namespace + version) from a source's export view */
509
484
  toResolvedPackage(name, info) {
510
- const exported = info.exported.slice();
485
+ /* what the configuration states for the package is part of its interface, even where the database misses it */
486
+ const stated = this.analyzerCtx?.env.statedFor(name);
487
+ const exported = stated === undefined ? info.exported.slice() : (0, arrays_1.uniqueArray)([...info.exported, ...[...stated.keys()].map(String)]);
511
488
  const namespaceInfo = {
512
489
  exportedSymbols: exported,
513
490
  exportedFunctions: [],
@@ -29,8 +29,8 @@ class FlowrAnalyzerProjectDiscoveryPlugin extends flowr_analyzer_plugin_1.FlowrA
29
29
  }
30
30
  }
31
31
  exports.FlowrAnalyzerProjectDiscoveryPlugin = FlowrAnalyzerProjectDiscoveryPlugin;
32
- // `.Rprofile`/`Rprofile.site` carry no extension but are plain R sources
33
- exports.discoverRSourcesRegex = /(\.(r|rmd|rmarkdown|ipynb|qmd|rnw)|(^|[\\/])\.?Rprofile(\.site)?)$/i;
32
+ // `.Rprofile`/`Rprofile.site` carry no extension but are plain R sources, as are the `.S`/`.s`/`.q` files below `R/`
33
+ exports.discoverRSourcesRegex = new RegExp(`(\\.(r|rmd|rmarkdown|ipynb|qmd|rnw)|(^|[\\\\/])\\.?Rprofile(\\.site)?)$|${files_1.rPackageSourceRegex.source}`, 'i');
34
34
  // matched against the posix path relative to the project root
35
35
  exports.ignorePathsWith = /(^|\/)(\.git|\.svn|\.hg|node_modules|__pycache__|\.Rproj\.user|\.uvr|Rtmp[^/]*|(packrat|renv|rv)\/(lib|library|src|staging|sandbox|bundles)[^/]*)(\/|$)/i;
36
36
  exports.excludeRequestsForPaths = /vignettes?|tests?|revdep|inst|data/i;
@@ -502,6 +502,10 @@ const NdjsonBatchBytes = 8_000_000;
502
502
  * rather than a JSON array of quoted strings, which loads as a single `split('\n')` instead of parsing ~1.4M elements.
503
503
  */
504
504
  function* dictLines(strings) {
505
+ /* a line holding no names would read back as one empty name */
506
+ if (strings.length === 0) {
507
+ return;
508
+ }
505
509
  let start = 0;
506
510
  let parts = [];
507
511
  let bytes = 0;
@@ -55,6 +55,8 @@ export declare function readManifestFile(manifestFile: string): SigDbManifest;
55
55
  export declare function readManifestDate(manifestFile: string): string | undefined;
56
56
  /** breadth/temporal scope of a bundled sigdb: base R only, `current` (latest CRAN + base R), or the `full` history */
57
57
  export type SigDbScope = 'base' | 'current' | 'full';
58
+ /** the bundle directories in the cache, the most recently synced first (it takes precedence) */
59
+ export declare function sigDbBundleDirs(watched?: [string, number][]): string[];
58
60
  /**
59
61
  * Location of a bundled sigdb **manifest**, found by walking up from several roots (this module,
60
62
  * `$FLOWR_SIGDB_DIR`, the working directory) across the dev (`src`), build (`dist`), and data-mount
@@ -7,6 +7,7 @@ exports.SigDbManifestSchema = exports.SigDbManifestMagic = void 0;
7
7
  exports.writeManifest = writeManifest;
8
8
  exports.readManifestFile = readManifestFile;
9
9
  exports.readManifestDate = readManifestDate;
10
+ exports.sigDbBundleDirs = sigDbBundleDirs;
10
11
  exports.defaultSigDbPath = defaultSigDbPath;
11
12
  exports.defaultSigDbPaths = defaultSigDbPaths;
12
13
  /**
@@ -65,6 +66,7 @@ const SigDbSubDirs = ['', 'data/sigdb', 'src/data/sigdb', 'dist/src/data/sigdb']
65
66
  const ManifestFilePattern = new RegExp(`\\.manifest\\.json${codec_1.CompressedExtPattern}$`);
66
67
  /** a `<name>.sigs.ndjson` bundle, in any of the codecs we can read */
67
68
  const BundleFilePattern = new RegExp(`${schema_1.SigDbExt.replace(/\./g, '\\.')}${codec_1.CompressedExtPattern}$`);
69
+ /** the bundle directories in the cache, the most recently synced first (it takes precedence) */
68
70
  function sigDbBundleDirs(watched) {
69
71
  if (typeof fs_1.default?.readdirSync !== 'function') {
70
72
  return [];
@@ -72,9 +74,16 @@ function sigDbBundleDirs(watched) {
72
74
  try {
73
75
  const bundles = path_1.default.join((0, decompress_1.sigDbCacheDir)(undefined, false), 'bundles');
74
76
  const mtimeMs = fs_1.default.statSync(bundles).mtimeMs;
77
+ /* a bundle of every release synced so far stays in the cache, and the first one found wins: the most recently
78
+ synced comes first, or an update to a release that happens to sort before the old one would be ignored */
75
79
  const dirs = fs_1.default.readdirSync(bundles, { withFileTypes: true })
76
80
  .filter(e => e.isDirectory())
77
- .map(e => path_1.default.join(bundles, e.name));
81
+ .map(e => {
82
+ const dir = path_1.default.join(bundles, e.name);
83
+ return { dir, mtimeMs: fs_1.default.statSync(dir).mtimeMs };
84
+ })
85
+ .sort((a, b) => b.mtimeMs - a.mtimeMs)
86
+ .map(e => e.dir);
78
87
  watched?.push([bundles, mtimeMs]); // a bundle directory appearing here has to be picked up too
79
88
  return dirs;
80
89
  }