@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
@@ -85,7 +85,7 @@ class FlowrAnalyzer {
85
85
  addRequest(...request) {
86
86
  for (const r of request) {
87
87
  if (typeof r === 'string') {
88
- const trimmed = r.substring(retriever_1.fileProtocol.length);
88
+ const trimmed = r.slice(retriever_1.fileProtocol.length);
89
89
  if (r.startsWith(retriever_1.fileProtocol) && !(0, files_1.isFilePath)(trimmed)) {
90
90
  this.addAnalysisRequest({ request: 'project', content: trimmed });
91
91
  }
@@ -25,7 +25,7 @@ export declare class FlowrDescriptionFile extends FlowrFile<DeepReadonly<DCF>> {
25
25
  */
26
26
  protected loadContent(): DCF;
27
27
  /**
28
- * Creates a FlowrDescriptionFile from given DCF content, path and optional roles.
28
+ * Creates a FlowrDescriptionFile from given DCF content, path, and optional roles.
29
29
  * This is useful if you already have the DCF content parsed and want to create a description file instance without re-parsing.
30
30
  */
31
31
  static fromDCF(dcf: DCF, path: string, roles?: FileRole[]): FlowrDescriptionFile;
@@ -35,7 +35,7 @@ class FlowrDescriptionFile extends flowr_file_1.FlowrFile {
35
35
  return parseDCF(this.wrapped);
36
36
  }
37
37
  /**
38
- * Creates a FlowrDescriptionFile from given DCF content, path and optional roles.
38
+ * Creates a FlowrDescriptionFile from given DCF content, path, and optional roles.
39
39
  * This is useful if you already have the DCF content parsed and want to create a description file instance without re-parsing.
40
40
  */
41
41
  static fromDCF(dcf, path, roles) {
@@ -65,7 +65,7 @@ export declare function isExportedInNamespaceFormat(this: void, fmt: NamespaceFo
65
65
  * @param nsInfo - The namespace info to check in
66
66
  */
67
67
  export declare function isExportedInInfo(this: void, name: string, nsInfo: NamespaceInfo): boolean | RNode<ParentInformation>[];
68
- /** All exported names of a namespace that can be referenced (functions, symbols, patterns and S3 methods as `generic.class`). */
68
+ /** All exported names of a namespace that can be referenced (functions, symbols, patterns, and S3 methods as `generic.class`). */
69
69
  export declare function getExportedNames(info: NamespaceInfo): string[];
70
70
  /** The names a package makes callable: the explicitly configured {@link NamespaceInfo#callable} subset, or all exports (see {@link getExportedNames}) by default. */
71
71
  export declare function getCallables(info: NamespaceInfo): string[];
@@ -194,7 +194,7 @@ function parseNamespaceComplex(file, ctx) {
194
194
  }
195
195
  });
196
196
  }
197
- /** All exported names of a namespace that can be referenced (functions, symbols, patterns and S3 methods as `generic.class`). */
197
+ /** All exported names of a namespace that can be referenced (functions, symbols, patterns, and S3 methods as `generic.class`). */
198
198
  function getExportedNames(info) {
199
199
  const s3 = [];
200
200
  for (const [g, methods] of info.exportS3Generics) {
@@ -25,7 +25,7 @@ export declare class FlowrNewsFile extends FlowrFile<NewsChunk[]> {
25
25
  */
26
26
  static from(file: FlowrFileProvider | FlowrNewsFile, role?: FileRole): FlowrNewsFile;
27
27
  /**
28
- * Creates a FlowrNewsFile from given news chunks, path and optional roles. This is useful if you already have the news content parsed and want to create a news file instance without re-parsing.
28
+ * Creates a FlowrNewsFile from given news chunks, path, and optional roles. This is useful if you already have the news content parsed and want to create a news file instance without re-parsing.
29
29
  */
30
30
  static fromNewsChunks(chunks: NewsChunk[], path: string, roles?: FileRole[]): FlowrNewsFile;
31
31
  }
@@ -34,7 +34,7 @@ class FlowrNewsFile extends flowr_file_1.FlowrFile {
34
34
  return file instanceof FlowrNewsFile ? file : new FlowrNewsFile(file);
35
35
  }
36
36
  /**
37
- * Creates a FlowrNewsFile from given news chunks, path and optional roles. This is useful if you already have the news content parsed and want to create a news file instance without re-parsing.
37
+ * Creates a FlowrNewsFile from given news chunks, path, and optional roles. This is useful if you already have the news content parsed and want to create a news file instance without re-parsing.
38
38
  */
39
39
  static fromNewsChunks(chunks, path, roles) {
40
40
  const file = new FlowrNewsFile(new flowr_file_1.FlowrTextFile(path, roles));
@@ -205,7 +205,7 @@ export declare class RDAParser {
205
205
  /**
206
206
  * Parses an RDA file.
207
207
  *
208
- * The file is decompressed, deserialized and converted into a flattened
208
+ * The file is decompressed, deserialized, and converted into a flattened
209
209
  * object representation.
210
210
  * @param file - RDA file provider.
211
211
  * @param shortcut - When `true`, only names and types are collected.
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.RDAParser = exports.SerializationFormat = exports.SexpType = exports.SerializationTypeTag = exports.CompressionType = exports.FlowrRDAFile = void 0;
7
7
  const flowr_file_1 = require("../../../context/flowr-file");
8
- const node_fs_1 = __importDefault(require("node:fs"));
8
+ const fs_1 = __importDefault(require("fs"));
9
9
  const r_fun_tab_1 = require("./r-fun-tab");
10
10
  const shell_executor_1 = require("../../../../r-bridge/shell-executor");
11
11
  /**
@@ -197,14 +197,14 @@ class RDAParser {
197
197
  /**
198
198
  * Parses an RDA file.
199
199
  *
200
- * The file is decompressed, deserialized and converted into a flattened
200
+ * The file is decompressed, deserialized, and converted into a flattened
201
201
  * object representation.
202
202
  * @param file - RDA file provider.
203
203
  * @param shortcut - When `true`, only names and types are collected.
204
204
  * @returns List of found {@link RObjectData} or `null` if the file is empty.
205
205
  */
206
206
  parse() {
207
- const fileContent = node_fs_1.default.readFileSync(this.file.path());
207
+ const fileContent = fs_1.default.readFileSync(this.file.path());
208
208
  const compressionType = this.detectCompression(fileContent);
209
209
  this.buffer = this.decompress(fileContent, compressionType);
210
210
  const result = this.deserialize2();
@@ -273,7 +273,7 @@ class RDAParser {
273
273
  switch (compressionType) {
274
274
  case CompressionType.CompGz: {
275
275
  // eslint-disable-next-line @typescript-eslint/no-require-imports,@typescript-eslint/no-unsafe-assignment
276
- const zlib = require('node:zlib');
276
+ const zlib = require('zlib');
277
277
  try {
278
278
  // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
279
279
  buffer = zlib.gunzipSync(fileContent);
@@ -247,14 +247,14 @@ const OptionsRegex = /([\w_.-]*)\s*[:=]\s*["']?([^,"']*)/g;
247
247
  function parseCodeBlockOptions(header, content) {
248
248
  const headerOpts = header.length === 3 // '{r}' => header.length=3 (no options in header)
249
249
  ? ''
250
- : header.substring(3, header.length - 1).trim();
250
+ : header.slice(3, -1).trim();
251
251
  const cellLines = [];
252
252
  for (const line of content.split('\n')) {
253
253
  if (!line.trim().startsWith('#|')) {
254
254
  break;
255
255
  }
256
256
  // keep the indentation, yaml block scalars rely on it
257
- cellLines.push(line.trim().substring(2).replace(/^ /, ''));
257
+ cellLines.push(line.trim().slice(2).replace(/^ /, ''));
258
258
  }
259
259
  const options = parseOptionString(headerOpts);
260
260
  for (const [key, value] of parseCellOptions(cellLines)) {
@@ -52,7 +52,7 @@ export declare class FlowrAnalyzerPackageVersionsSigDbPlugin extends FlowrAnalyz
52
52
  /** the `additionalPaths` the current {@link sources} were assembled with, so a later config resolves a rebuild */
53
53
  private sourcesKey;
54
54
  private analyzerCtx;
55
- /** `packagesExporting` answers, merged across the source set and self-filtered; the scan itself is {@link ExportIndex} */
55
+ /** `packagesExporting` answers, merged across the source set and self-filtered; the per-source half is {@link exportOwners} */
56
56
  private exportsByName;
57
57
  /** `pkg@assumedR` keys already reported via {@link baseVersionFor}'s fallback, so the info is logged once */
58
58
  private readonly baseFallbacksLogged;
@@ -97,10 +97,10 @@ export declare class FlowrAnalyzerPackageVersionsSigDbPlugin extends FlowrAnalyz
97
97
  /**
98
98
  * Packages in the loaded sources (respecting `self`-package exclusion) that export `name`, **most downloaded
99
99
  * first**, so whoever has to pick one (or show only a few) starts with the package a script most likely means.
100
- * Backed by {@link ExportIndex}, a reverse index built once per *source* (and hence shared by every analyzer
101
- * mounting the same bundle), so repeated hint lookups (e.g. from the `undefined-symbol` linter) do not re-scan
102
- * every package. Self-package exclusion is applied here rather than baked into the index, which keeps the
103
- * index analyzer-independent.
100
+ * Backed by {@link exportOwners}, which memoizes per *source* (and hence shares across every analyzer mounting
101
+ * the same bundle), so the repeated hint lookups of a linter run scan every package once per distinct name
102
+ * rather than once per call. Self-package exclusion is applied here rather than in that memo, which keeps the
103
+ * memo analyzer-independent.
104
104
  */
105
105
  packagesExporting(name: string): readonly string[];
106
106
  /**
@@ -112,6 +112,27 @@ function reconstructS3Generics(exported) {
112
112
  }
113
113
  /** the built {@link ExportIndex} of each source, see {@link ExportIndex.of} for why it is keyed by the source */
114
114
  const exportIndices = new WeakMap();
115
+ /**
116
+ * `name -> the packages of a source exporting it`, filled one name at a time as it is asked for and shared by
117
+ * every analyzer mounting that source. The eager {@link ExportIndex} answers the same question with no scan at
118
+ * all, but it holds every export name of the bundle (~1.1M for the shipped one); a lint run asks for a few
119
+ * hundred distinct names, so this keeps the memo proportional to what was actually asked instead.
120
+ */
121
+ const exportOwnersBySource = new WeakMap();
122
+ /** The packages of `src` exporting `name`, most downloaded first, scanning only the first time a name is asked. */
123
+ function exportOwners(src, name) {
124
+ let byName = exportOwnersBySource.get(src);
125
+ if (byName === undefined) {
126
+ byName = new Map();
127
+ exportOwnersBySource.set(src, byName);
128
+ }
129
+ let owners = byName.get(name);
130
+ if (owners === undefined) {
131
+ owners = src.packagesExporting(name);
132
+ byName.set(name, owners);
133
+ }
134
+ return owners;
135
+ }
115
136
  /**
116
137
  * The reverse `export name -> packages exporting it` view of a signature source, each entry ordered by download
117
138
  * count (descending, ties by name) so whoever has to pick one exporter starts with the package a script most
@@ -125,6 +146,10 @@ const exportIndices = new WeakMap();
125
146
  */
126
147
  exports.ExportIndex = {
127
148
  name: 'ExportIndex',
149
+ /* not what `packagesExporting` uses: building this reads every package blob of the bundle to hold every export
150
+ * name (~1.1M for the shipped one), which measured both slower and ~330MB heavier than the few hundred scans
151
+ * {@link exportOwners} does for the names a run actually asks about. Kept for a caller that needs the whole
152
+ * reverse mapping at once. */
128
153
  /** The index of `src`, built on first use and shared by every later caller; see {@link ExportIndex}. */
129
154
  of(src) {
130
155
  const cached = exportIndices.get(src);
@@ -177,7 +202,7 @@ class FlowrAnalyzerPackageVersionsSigDbPlugin extends flowr_analyzer_package_ver
177
202
  /** the `additionalPaths` the current {@link sources} were assembled with, so a later config resolves a rebuild */
178
203
  sourcesKey;
179
204
  analyzerCtx;
180
- /** `packagesExporting` answers, merged across the source set and self-filtered; the scan itself is {@link ExportIndex} */
205
+ /** `packagesExporting` answers, merged across the source set and self-filtered; the per-source half is {@link exportOwners} */
181
206
  exportsByName = new Map();
182
207
  /** `pkg@assumedR` keys already reported via {@link baseVersionFor}'s fallback, so the info is logged once */
183
208
  baseFallbacksLogged = new Set();
@@ -306,10 +331,10 @@ class FlowrAnalyzerPackageVersionsSigDbPlugin extends flowr_analyzer_package_ver
306
331
  /**
307
332
  * Packages in the loaded sources (respecting `self`-package exclusion) that export `name`, **most downloaded
308
333
  * first**, so whoever has to pick one (or show only a few) starts with the package a script most likely means.
309
- * Backed by {@link ExportIndex}, a reverse index built once per *source* (and hence shared by every analyzer
310
- * mounting the same bundle), so repeated hint lookups (e.g. from the `undefined-symbol` linter) do not re-scan
311
- * every package. Self-package exclusion is applied here rather than baked into the index, which keeps the
312
- * index analyzer-independent.
334
+ * Backed by {@link exportOwners}, which memoizes per *source* (and hence shares across every analyzer mounting
335
+ * the same bundle), so the repeated hint lookups of a linter run scan every package once per distinct name
336
+ * rather than once per call. Self-package exclusion is applied here rather than in that memo, which keeps the
337
+ * memo analyzer-independent.
313
338
  */
314
339
  packagesExporting(name) {
315
340
  if (!(0, config_1.isSigDbEnabled)(this.analyzerCtx?.config)) {
@@ -323,7 +348,9 @@ class FlowrAnalyzerPackageVersionsSigDbPlugin extends flowr_analyzer_package_ver
323
348
  const seen = new Set();
324
349
  const owners = [];
325
350
  for (const src of sources) {
326
- for (const pkg of src.packagesExporting(name)) {
351
+ /* memoized per source, not per analyzer: the same handful of unresolved names comes back for every
352
+ * file the linter walks, and a miss is a scan over every package of the bundle */
353
+ for (const pkg of exportOwners(src, name)) {
327
354
  if (!seen.has(pkg) && !this.isSelfPackage(pkg)) {
328
355
  seen.add(pkg);
329
356
  owners.push(pkg);
@@ -558,7 +585,9 @@ class FlowrAnalyzerPackageVersionsSigDbPlugin extends flowr_analyzer_package_ver
558
585
  loadsWithSideEffects: false,
559
586
  callable: exported
560
587
  };
561
- return new package_1.Package({ name, namespaceInfo, resolvedVersion: info.version });
588
+ /* a source may know the exports without knowing which release they are from, and then the package
589
+ carries no version rather than a made-up one */
590
+ return new package_1.Package({ name, namespaceInfo, resolvedVersion: info.version || undefined });
562
591
  }
563
592
  }
564
593
  exports.FlowrAnalyzerPackageVersionsSigDbPlugin = FlowrAnalyzerPackageVersionsSigDbPlugin;
@@ -96,7 +96,7 @@ class FlowrAnalyzerFullProjectDiscoveryPlugin extends FlowrAnalyzerProjectDiscov
96
96
  }
97
97
  }
98
98
  exports.FlowrAnalyzerFullProjectDiscoveryPlugin = FlowrAnalyzerFullProjectDiscoveryPlugin;
99
- // noise directories pruned from the scoped walk on top of `ignorePathsWith`: build output, checks, rendered docs and packaged data
99
+ // noise directories pruned from the scoped walk on top of `ignorePathsWith`: build output, checks, rendered docs, and packaged data
100
100
  const noiseDirs = /(^|\/)(\.git|\.svn|\.hg|node_modules|__pycache__|\.Rproj\.user|\.uvr|[^/]*\.Rcheck|(packrat|renv|rv)\/(lib|library|src|staging|sandbox|bundles|cache)[^/]*|build|dist|_build|_site|_book|\.quarto|\.cache|Rtmp[^/]*|man|inst\/(extdata|doc))(\/|$)/i;
101
101
  // binary/data blobs, dropped even inside an otherwise kept directory
102
102
  const noiseFiles = /\.(rds|rda|rdata|rd|png|jpe?g|gif|svg|pdf|ico|zip|tar|t?gz|bz2|xz|so|o|a|dll|dylib|exe|jar|woff2?|ttf|eot|feather|parquet|xls[xm]?|docx?|pptx?)$/i;
@@ -120,7 +120,7 @@ function resolveRules(override) {
120
120
  exclude: (override?.exclude ?? []).map(glob_1.globMatcher)
121
121
  };
122
122
  }
123
- /** over-approximating default: R sources, role metadata and `tests/`/`vignettes/` count as project files */
123
+ /** over-approximating default: R sources, role metadata, and `tests/`/`vignettes/` count as project files */
124
124
  function keptByDefault(rel) {
125
125
  const base = path_1.default.basename(rel);
126
126
  return exports.discoverRSourcesRegex.test(rel) || metadataFilePatterns.some(p => p.test(base)) || testOrVignetteDir.test(rel);
@@ -15,9 +15,9 @@ exports.writeShardedDatabase = writeShardedDatabase;
15
15
  * dictionary, blob-only shards, and the sharded {@link SigDbManifest}). Split out of `../sigdb` so the reader
16
16
  * there is not weighed down by the (build-time only) encoder; imports only sibling format/codec modules.
17
17
  */
18
- const node_fs_1 = __importDefault(require("node:fs"));
19
- const node_path_1 = __importDefault(require("node:path"));
20
- const node_events_1 = require("node:events");
18
+ const fs_1 = __importDefault(require("fs"));
19
+ const path_1 = __importDefault(require("path"));
20
+ const events_1 = require("events");
21
21
  const schema_1 = require("./schema");
22
22
  const r_version_1 = require("../../util/r-version");
23
23
  const decode_1 = require("./decode");
@@ -496,10 +496,10 @@ class LineWriter {
496
496
  byteOff = 0;
497
497
  constructor(plain, compress) {
498
498
  noteZstdSupport();
499
- node_fs_1.default.mkdirSync(node_path_1.default.dirname(node_path_1.default.resolve(plain)), { recursive: true });
500
- this.plainOut = node_fs_1.default.createWriteStream(plain);
499
+ fs_1.default.mkdirSync(path_1.default.dirname(path_1.default.resolve(plain)), { recursive: true });
500
+ this.plainOut = fs_1.default.createWriteStream(plain);
501
501
  for (const spec of (0, codec_1.writeCodecs)()) {
502
- const file = node_fs_1.default.createWriteStream(`${plain}${spec.ext}`);
502
+ const file = fs_1.default.createWriteStream(`${plain}${spec.ext}`);
503
503
  const stream = spec.createCompress(codecOptions(spec, compress));
504
504
  stream.pipe(file);
505
505
  this.sinks.push({ stream, file });
@@ -509,11 +509,11 @@ class LineWriter {
509
509
  const chunk = text + '\n';
510
510
  const back = [];
511
511
  if (!this.plainOut.write(chunk)) {
512
- back.push((0, node_events_1.once)(this.plainOut, 'drain'));
512
+ back.push((0, events_1.once)(this.plainOut, 'drain'));
513
513
  }
514
514
  for (const { stream } of this.sinks) {
515
515
  if (!stream.write(chunk)) {
516
- back.push((0, node_events_1.once)(stream, 'drain'));
516
+ back.push((0, events_1.once)(stream, 'drain'));
517
517
  }
518
518
  }
519
519
  if (back.length > 0) {
@@ -526,7 +526,7 @@ class LineWriter {
526
526
  for (const { stream } of this.sinks) {
527
527
  stream.end();
528
528
  }
529
- await Promise.all([(0, node_events_1.once)(this.plainOut, 'close'), ...this.sinks.map(s => (0, node_events_1.once)(s.file, 'close'))]);
529
+ await Promise.all([(0, events_1.once)(this.plainOut, 'close'), ...this.sinks.map(s => (0, events_1.once)(s.file, 'close'))]);
530
530
  }
531
531
  }
532
532
  /** Write `<outBase>.sigs.ndjson` (+ `.br`, `.zst` when supported, `.idx`) -- a single self-contained bundle (its own dictionary). */
@@ -556,7 +556,7 @@ async function writeSignatureDb(outBase, db, compress = {}) {
556
556
  }
557
557
  await w.close();
558
558
  const index = { byteCount: w.byteOff, dict, blobs, pkgs: db.pkgs, meta: db.meta };
559
- node_fs_1.default.writeFileSync(`${plain}.idx`, JSON.stringify((0, index_format_1.encodeIndex)(index)));
559
+ fs_1.default.writeFileSync(`${plain}.idx`, JSON.stringify((0, index_format_1.encodeIndex)(index)));
560
560
  return index;
561
561
  }
562
562
  /** the extension of a standalone shared-dictionary file */
@@ -572,7 +572,7 @@ async function writeDictionary(outBase, id, strings, compress = {}) {
572
572
  }
573
573
  const range = [start, w.byteOff - start];
574
574
  await w.close();
575
- return { id, path: `${node_path_1.default.basename(outBase)}${exports.SigDbDictExt}`, hash: (0, hash_1.dictionaryHash)(strings), range, byteCount: w.byteOff, strings: strings.length };
575
+ return { id, path: `${path_1.default.basename(outBase)}${exports.SigDbDictExt}`, hash: (0, hash_1.dictionaryHash)(strings), range, byteCount: w.byteOff, strings: strings.length };
576
576
  }
577
577
  /** Write one blob-only shard (references a shared dictionary) to `<outBase>.<id>.sigs.ndjson` (+ `.br`/`.zst`). */
578
578
  async function writeShardBundle(outBase, shard, cranBase, compress = {}) {
@@ -604,7 +604,7 @@ async function writeShardBundle(outBase, shard, cranBase, compress = {}) {
604
604
  async function writeShardedDatabase(outBase, db, manifestFile, opts = {}) {
605
605
  const compress = { level: opts.level, brotliQuality: opts.brotliQuality, brotliLgwin: opts.brotliLgwin };
606
606
  const exts = (0, codec_1.writeCodecs)().map(c => c.ext); // every compressed variant produced (`.br` always, `.zst` when supported)
607
- const base = node_path_1.default.basename(outBase);
607
+ const base = path_1.default.basename(outBase);
608
608
  const dictRef = await writeDictionary(outBase, 'shared', db.strings, compress);
609
609
  const shardRefs = [];
610
610
  for (const s of db.shards) {
@@ -624,14 +624,14 @@ async function writeShardedDatabase(outBase, db, manifestFile, opts = {}) {
624
624
  (0, manifest_1.writeManifest)(manifestFile, manifest);
625
625
  if (opts.pack) {
626
626
  // a self-contained folder to copy into flowR: every compressed variant of the dictionary + shards + the (index-embedding) manifest
627
- node_fs_1.default.mkdirSync(opts.pack, { recursive: true });
627
+ fs_1.default.mkdirSync(opts.pack, { recursive: true });
628
628
  for (const ext of exts) {
629
- node_fs_1.default.copyFileSync(`${outBase}${exports.SigDbDictExt}${ext}`, node_path_1.default.join(opts.pack, `${dictRef.path}${ext}`));
629
+ fs_1.default.copyFileSync(`${outBase}${exports.SigDbDictExt}${ext}`, path_1.default.join(opts.pack, `${dictRef.path}${ext}`));
630
630
  for (const ref of shardRefs) {
631
- node_fs_1.default.copyFileSync(`${outBase}.${ref.id}${schema_1.SigDbExt}${ext}`, node_path_1.default.join(opts.pack, `${ref.path}${ext}`));
631
+ fs_1.default.copyFileSync(`${outBase}.${ref.id}${schema_1.SigDbExt}${ext}`, path_1.default.join(opts.pack, `${ref.path}${ext}`));
632
632
  }
633
633
  }
634
- (0, manifest_1.writeManifest)(node_path_1.default.join(opts.pack, `${base}.manifest.json`), manifest);
634
+ (0, manifest_1.writeManifest)(path_1.default.join(opts.pack, `${base}.manifest.json`), manifest);
635
635
  }
636
636
  return manifest;
637
637
  }
@@ -1,4 +1,4 @@
1
- import type { Transform } from 'node:stream';
1
+ import type { Transform } from 'stream';
2
2
  /** whether the running Node exposes the `node:zlib` zstd API (Node 22.15+ / 23.8+) */
3
3
  export declare function zstdSupported(): boolean;
4
4
  /** on-disk compression codec for a sigdb bundle */
@@ -21,8 +21,8 @@ exports.decompressSyncFor = decompressSyncFor;
21
21
  * including the older Node bundled in the VS Code extension host. Only the outer compression changes -- the
22
22
  * ranged reads and `.idx` seek logic operate on the decompressed plain NDJSON and are codec-agnostic.
23
23
  */
24
- const node_zlib_1 = __importDefault(require("node:zlib"));
25
- const zstd = node_zlib_1.default;
24
+ const zlib_1 = __importDefault(require("zlib"));
25
+ const zstd = zlib_1.default;
26
26
  /** whether the running Node exposes the `node:zlib` zstd API (Node 22.15+ / 23.8+) */
27
27
  function zstdSupported() {
28
28
  return typeof zstd.zstdCompressSync === 'function' && typeof zstd.createZstdDecompress === 'function';
@@ -53,16 +53,16 @@ function stripCompressedExt(name) {
53
53
  /** regex alternation matching an optional trailing compressed extension, e.g. `(?:\.br|\.zst|\.gz)?` */
54
54
  exports.CompressedExtPattern = `(?:${exports.CompressedExts.map(e => e.replace(/\./g, '\\.')).join('|')})?`;
55
55
  // reading large-window brotli requires opting in; every `.br` flowR writes uses large windows, so this is always safe
56
- const BrotliDecodeParams = { params: { [node_zlib_1.default.constants.BROTLI_DECODER_PARAM_LARGE_WINDOW]: 1 } };
56
+ const BrotliDecodeParams = { params: { [zlib_1.default.constants.BROTLI_DECODER_PARAM_LARGE_WINDOW]: 1 } };
57
57
  function brotliParams(opts) {
58
58
  const lgwin = opts.lgwin ?? 30;
59
59
  const params = {
60
- [node_zlib_1.default.constants.BROTLI_PARAM_QUALITY]: opts.level ?? 11,
61
- [node_zlib_1.default.constants.BROTLI_PARAM_LGWIN]: lgwin,
62
- [node_zlib_1.default.constants.BROTLI_PARAM_LARGE_WINDOW]: lgwin > 24 ? 1 : 0
60
+ [zlib_1.default.constants.BROTLI_PARAM_QUALITY]: opts.level ?? 11,
61
+ [zlib_1.default.constants.BROTLI_PARAM_LGWIN]: lgwin,
62
+ [zlib_1.default.constants.BROTLI_PARAM_LARGE_WINDOW]: lgwin > 24 ? 1 : 0
63
63
  };
64
64
  if (opts.sizeHint !== undefined) {
65
- params[node_zlib_1.default.constants.BROTLI_PARAM_SIZE_HINT] = opts.sizeHint;
65
+ params[zlib_1.default.constants.BROTLI_PARAM_SIZE_HINT] = opts.sizeHint;
66
66
  }
67
67
  return params;
68
68
  }
@@ -72,8 +72,8 @@ function zstdParams(opts) {
72
72
  exports.BrotliCodec = {
73
73
  codec: 'brotli',
74
74
  ext: '.br',
75
- compressSync: (buf, opts = {}) => node_zlib_1.default.brotliCompressSync(buf, { params: brotliParams(opts) }),
76
- createCompress: (opts = {}) => node_zlib_1.default.createBrotliCompress({ params: brotliParams(opts) })
75
+ compressSync: (buf, opts = {}) => zlib_1.default.brotliCompressSync(buf, { params: brotliParams(opts) }),
76
+ createCompress: (opts = {}) => zlib_1.default.createBrotliCompress({ params: brotliParams(opts) })
77
77
  };
78
78
  exports.ZstdCodec = {
79
79
  codec: 'zstd',
@@ -105,9 +105,9 @@ function createDecompressFor(file) {
105
105
  return requireZstd().createZstdDecompress();
106
106
  }
107
107
  if (file.endsWith('.gz')) {
108
- return node_zlib_1.default.createGunzip();
108
+ return zlib_1.default.createGunzip();
109
109
  }
110
- return node_zlib_1.default.createBrotliDecompress(BrotliDecodeParams);
110
+ return zlib_1.default.createBrotliDecompress(BrotliDecodeParams);
111
111
  }
112
112
  /** synchronously decompress a compressed buffer, choosing the codec by the source's extension */
113
113
  function decompressSyncFor(file, raw) {
@@ -115,8 +115,8 @@ function decompressSyncFor(file, raw) {
115
115
  return requireZstd().zstdDecompressSync(raw);
116
116
  }
117
117
  if (file.endsWith('.gz')) {
118
- return node_zlib_1.default.gunzipSync(raw);
118
+ return zlib_1.default.gunzipSync(raw);
119
119
  }
120
- return node_zlib_1.default.brotliDecompressSync(raw, BrotliDecodeParams);
120
+ return zlib_1.default.brotliDecompressSync(raw, BrotliDecodeParams);
121
121
  }
122
122
  //# sourceMappingURL=codec.js.map
@@ -1,4 +1,4 @@
1
- import type { Readable } from 'node:stream';
1
+ import type { Readable } from 'stream';
2
2
  import { type SigDbIndex } from './index-format';
3
3
  /** whether a bundle path is a compressed (`.br`/`.zst`/`.gz`) source that must be decompressed to be seekable */
4
4
  export declare const isCompressed: (f: string) => boolean;
@@ -18,11 +18,11 @@ exports.ensurePlainSync = ensurePlainSync;
18
18
  * the cache directory. Split out of `../sigdb` so the reader there only consumes plain, seekable files. The codec
19
19
  * is detected by extension (see `./codec`), so existing `.br` and new `.zst` bundles read transparently.
20
20
  */
21
- const node_fs_1 = __importDefault(require("node:fs"));
22
- const node_os_1 = __importDefault(require("node:os"));
23
- const node_path_1 = __importDefault(require("node:path"));
24
- const node_readline_1 = __importDefault(require("node:readline"));
25
- const promises_1 = require("node:stream/promises");
21
+ const fs_1 = __importDefault(require("fs"));
22
+ const os_1 = __importDefault(require("os"));
23
+ const path_1 = __importDefault(require("path"));
24
+ const readline_1 = __importDefault(require("readline"));
25
+ const promises_1 = require("stream/promises");
26
26
  const schema_1 = require("./schema");
27
27
  const index_format_1 = require("./index-format");
28
28
  const hash_1 = require("../../util/hash");
@@ -41,11 +41,11 @@ function parseHeader(text) {
41
41
  }
42
42
  }
43
43
  function decompressStream(file) {
44
- return node_fs_1.default.createReadStream(file).pipe((0, codec_1.createDecompressFor)(file));
44
+ return fs_1.default.createReadStream(file).pipe((0, codec_1.createDecompressFor)(file));
45
45
  }
46
46
  /** a readable stream of the bundle's plain NDJSON, transparently decompressing `.gz`/`.br`/`.zst` inputs */
47
47
  function sigDbStream(file) {
48
- return (0, exports.isCompressed)(file) ? decompressStream(file) : node_fs_1.default.createReadStream(file);
48
+ return (0, exports.isCompressed)(file) ? decompressStream(file) : fs_1.default.createReadStream(file);
49
49
  }
50
50
  /**
51
51
  * Resolve a manifest-relative file to the best source this runtime can read: a plain (already seekable) file
@@ -54,13 +54,13 @@ function sigDbStream(file) {
54
54
  * (it could not be decompressed), so `.br`-only bundles read on any Node. Falls back to the plain path.
55
55
  */
56
56
  function resolveSource(baseDir, relPath) {
57
- const plain = node_path_1.default.resolve(baseDir, relPath);
58
- if (node_fs_1.default.existsSync(plain)) {
57
+ const plain = path_1.default.resolve(baseDir, relPath);
58
+ if (fs_1.default.existsSync(plain)) {
59
59
  return plain;
60
60
  }
61
61
  for (const ext of (0, codec_1.readableExtsPreferred)()) {
62
62
  const compressed = `${plain}${ext}`;
63
- if (node_fs_1.default.existsSync(compressed)) {
63
+ if (fs_1.default.existsSync(compressed)) {
64
64
  return compressed;
65
65
  }
66
66
  }
@@ -75,38 +75,38 @@ function resolveSource(baseDir, relPath) {
75
75
  function sigDbCacheDir(override, create = true) {
76
76
  const base = override
77
77
  ?? process.env.FLOWR_SIGDB_CACHE ?? process.env.FLOWR_CACHE_DIR
78
- ?? (process.env.XDG_CACHE_HOME ? node_path_1.default.join(process.env.XDG_CACHE_HOME, 'flowr') : undefined)
79
- ?? (process.env.LOCALAPPDATA ? node_path_1.default.join(process.env.LOCALAPPDATA, 'flowr', 'cache') : undefined)
80
- ?? node_path_1.default.join(node_os_1.default.homedir?.() || node_os_1.default.tmpdir(), '.cache', 'flowr');
81
- const dir = node_path_1.default.join(base, 'sigdb');
78
+ ?? (process.env.XDG_CACHE_HOME ? path_1.default.join(process.env.XDG_CACHE_HOME, 'flowr') : undefined)
79
+ ?? (process.env.LOCALAPPDATA ? path_1.default.join(process.env.LOCALAPPDATA, 'flowr', 'cache') : undefined)
80
+ ?? path_1.default.join(os_1.default.homedir?.() || os_1.default.tmpdir(), '.cache', 'flowr');
81
+ const dir = path_1.default.join(base, 'sigdb');
82
82
  if (!create) {
83
83
  return dir;
84
84
  }
85
85
  try {
86
- node_fs_1.default.mkdirSync(dir, { recursive: true });
86
+ fs_1.default.mkdirSync(dir, { recursive: true });
87
87
  return dir;
88
88
  }
89
89
  catch {
90
- const tmp = node_path_1.default.join(node_os_1.default.tmpdir(), 'flowr-sigdb-cache');
91
- node_fs_1.default.mkdirSync(tmp, { recursive: true });
90
+ const tmp = path_1.default.join(os_1.default.tmpdir(), 'flowr-sigdb-cache');
91
+ fs_1.default.mkdirSync(tmp, { recursive: true });
92
92
  return tmp;
93
93
  }
94
94
  }
95
95
  /** read the (small) header line of a possibly-compressed bundle without decompressing the whole thing */
96
96
  async function readHeaderOf(source) {
97
97
  if (!(0, exports.isCompressed)(source)) {
98
- const fd = node_fs_1.default.openSync(source, 'r');
98
+ const fd = fs_1.default.openSync(source, 'r');
99
99
  try {
100
100
  const buf = Buffer.allocUnsafe(65536);
101
- const n = node_fs_1.default.readSync(fd, buf, 0, buf.length, 0);
101
+ const n = fs_1.default.readSync(fd, buf, 0, buf.length, 0);
102
102
  return parseHeader(buf.toString('utf8', 0, n));
103
103
  }
104
104
  finally {
105
- node_fs_1.default.closeSync(fd);
105
+ fs_1.default.closeSync(fd);
106
106
  }
107
107
  }
108
108
  const input = decompressStream(source);
109
- const rl = node_readline_1.default.createInterface({ input, crlfDelay: Infinity });
109
+ const rl = readline_1.default.createInterface({ input, crlfDelay: Infinity });
110
110
  try {
111
111
  const line = (await rl[Symbol.asyncIterator]().next()).value; // just the first line (the header)
112
112
  return line !== undefined ? JSON.parse(line) : undefined;
@@ -117,24 +117,24 @@ async function readHeaderOf(source) {
117
117
  }
118
118
  }
119
119
  function cachePaths(hash, cacheDir) {
120
- const plain = node_path_1.default.join(sigDbCacheDir(cacheDir), `sigdb-${hash}${schema_1.SigDbExt}`);
120
+ const plain = path_1.default.join(sigDbCacheDir(cacheDir), `sigdb-${hash}${schema_1.SigDbExt}`);
121
121
  return { plain, idx: `${plain}.idx` };
122
122
  }
123
123
  /** whether a compressed source with the given content hash has already been unpacked into its decompressed cache */
124
124
  function isUnpacked(hash, cacheDir) {
125
- return node_fs_1.default.existsSync(cachePaths(hash, cacheDir).plain);
125
+ return fs_1.default.existsSync(cachePaths(hash, cacheDir).plain);
126
126
  }
127
127
  /** materialize the `.idx` for a freshly decompressed cache file -- from the supplied index or the source's sibling */
128
128
  function writeCacheIndex(source, idx, index) {
129
129
  if (index) {
130
- node_fs_1.default.writeFileSync(idx, JSON.stringify((0, index_format_1.encodeIndex)(index)));
130
+ fs_1.default.writeFileSync(idx, JSON.stringify((0, index_format_1.encodeIndex)(index)));
131
131
  return;
132
132
  }
133
133
  const srcIdx = source.replace(/\.(br|zst|gz)$/, '') + '.idx';
134
- if (!node_fs_1.default.existsSync(srcIdx)) {
134
+ if (!fs_1.default.existsSync(srcIdx)) {
135
135
  throw new Error(`missing sidecar index next to ${source} (expected ${srcIdx}), and none was supplied`);
136
136
  }
137
- node_fs_1.default.copyFileSync(srcIdx, idx);
137
+ fs_1.default.copyFileSync(srcIdx, idx);
138
138
  }
139
139
  /**
140
140
  * Ensure a seekable plain `.sigs.ndjson` (+ its `.idx`) exists for `source`, decompressing a `.br`/`.zst`/`.gz`
@@ -151,12 +151,12 @@ async function ensurePlain(source, opts = {}) {
151
151
  hash = content?.hash ?? new hash_1.Hash53().update(source).digest();
152
152
  }
153
153
  const { plain, idx } = cachePaths(hash, opts.cacheDir);
154
- if (node_fs_1.default.existsSync(plain) && (opts.indexless || node_fs_1.default.existsSync(idx))) {
154
+ if (fs_1.default.existsSync(plain) && (opts.indexless || fs_1.default.existsSync(idx))) {
155
155
  return plain;
156
156
  }
157
157
  const tmp = `${plain}.${process.pid}.tmp`;
158
- await (0, promises_1.pipeline)(decompressStream(source), node_fs_1.default.createWriteStream(tmp));
159
- node_fs_1.default.renameSync(tmp, plain);
158
+ await (0, promises_1.pipeline)(decompressStream(source), fs_1.default.createWriteStream(tmp));
159
+ fs_1.default.renameSync(tmp, plain);
160
160
  if (!opts.indexless) {
161
161
  writeCacheIndex(source, idx, opts.index);
162
162
  }
@@ -168,14 +168,14 @@ function ensurePlainSync(source, opts) {
168
168
  return source;
169
169
  }
170
170
  const { plain, idx } = cachePaths(opts.hash, opts.cacheDir);
171
- if (node_fs_1.default.existsSync(plain) && (opts.indexless || node_fs_1.default.existsSync(idx))) {
171
+ if (fs_1.default.existsSync(plain) && (opts.indexless || fs_1.default.existsSync(idx))) {
172
172
  return plain;
173
173
  }
174
- const raw = node_fs_1.default.readFileSync(source);
174
+ const raw = fs_1.default.readFileSync(source);
175
175
  const out = (0, codec_1.decompressSyncFor)(source, raw);
176
176
  const tmp = `${plain}.${process.pid}.tmp`;
177
- node_fs_1.default.writeFileSync(tmp, out);
178
- node_fs_1.default.renameSync(tmp, plain);
177
+ fs_1.default.writeFileSync(tmp, out);
178
+ fs_1.default.renameSync(tmp, plain);
179
179
  if (!opts.indexless) {
180
180
  writeCacheIndex(source, idx, opts.index);
181
181
  }
@@ -11,7 +11,7 @@ exports.readSigDbIndex = readSigDbIndex;
11
11
  * package routing/metadata, and its compact on-disk (wire) form. Split out of `../sigdb` so the reader/writer
12
12
  * there does not carry the index encoding.
13
13
  */
14
- const node_fs_1 = __importDefault(require("node:fs"));
14
+ const fs_1 = __importDefault(require("fs"));
15
15
  /** encode an index to its compact on-disk form; omit `meta` when it is hoisted elsewhere (a manifest) */
16
16
  function encodeIndex(i, withMeta = true) {
17
17
  return { n: i.byteCount, d: i.dict, b: i.blobs, p: i.pkgs, ...(withMeta ? { m: i.meta } : {}) };
@@ -23,6 +23,6 @@ function decodeIndex(w, meta) {
23
23
  }
24
24
  /** read a plain bundle's sidecar `.idx` file and decode it */
25
25
  function readSigDbIndex(plainFile) {
26
- return decodeIndex(JSON.parse(node_fs_1.default.readFileSync(`${plainFile}.idx`, 'utf8')));
26
+ return decodeIndex(JSON.parse(fs_1.default.readFileSync(`${plainFile}.idx`, 'utf8')));
27
27
  }
28
28
  //# sourceMappingURL=index-format.js.map