@eagleoutice/flowr 2.13.15 → 2.14.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 (225) hide show
  1. package/README.md +31 -37
  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/abstract-interpretation/unsupported-functions.d.ts +1 -0
  10. package/abstract-interpretation/unsupported-functions.js +1 -0
  11. package/benchmark/calibration.d.ts +12 -5
  12. package/benchmark/calibration.js +42 -14
  13. package/benchmark/slicer.d.ts +1 -1
  14. package/benchmark/slicer.js +5 -4
  15. package/benchmark/stats/size-of.js +1 -1
  16. package/benchmark/summarizer/first-phase/process.d.ts +2 -0
  17. package/benchmark/summarizer/first-phase/process.js +2 -0
  18. package/cli/common/options.d.ts +0 -31
  19. package/cli/common/options.js +1 -8
  20. package/cli/common/scripts-info.d.ts +0 -38
  21. package/cli/common/scripts-info.js +0 -8
  22. package/cli/repl/commands/repl-query.js +37 -2
  23. package/cli/repl/core.js +6 -3
  24. package/cli/repl/parser/slice-query-parser.js +1 -1
  25. package/cli/repl/print-version.js +2 -2
  26. package/config.d.ts +16 -0
  27. package/config.js +79 -0
  28. package/control-flow/control-flow-graph.d.ts +2 -0
  29. package/control-flow/control-flow-graph.js +2 -0
  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/built-in-props.d.ts +8 -1
  38. package/dataflow/environments/built-in-props.js +18 -0
  39. package/dataflow/environments/built-in.d.ts +7 -1
  40. package/dataflow/environments/built-in.js +42 -3
  41. package/dataflow/environments/default-builtin-config.d.ts +442 -10
  42. package/dataflow/environments/default-builtin-config.js +188 -18
  43. package/dataflow/environments/environment.d.ts +1 -1
  44. package/dataflow/environments/identifier.d.ts +7 -2
  45. package/dataflow/environments/identifier.js +6 -1
  46. package/dataflow/environments/query-fn-props.js +2 -2
  47. package/dataflow/environments/reference-to-maybe.js +5 -5
  48. package/dataflow/environments/resolve-by-name.d.ts +3 -0
  49. package/dataflow/environments/resolve-by-name.js +30 -5
  50. package/dataflow/environments/resolve-helper.d.ts +6 -0
  51. package/dataflow/environments/resolve-helper.js +6 -0
  52. package/dataflow/eval/resolve/alias-tracking.d.ts +5 -0
  53. package/dataflow/eval/resolve/alias-tracking.js +21 -14
  54. package/dataflow/eval/resolve/node-value.d.ts +6 -0
  55. package/dataflow/eval/resolve/node-value.js +15 -9
  56. package/dataflow/eval/resolve/resolve-argument.js +2 -2
  57. package/dataflow/eval/resolve/resolve-numbers.js +2 -2
  58. package/dataflow/eval/resolve/resolve-operators.js +4 -3
  59. package/dataflow/eval/resolve/resolve-strings.js +3 -3
  60. package/dataflow/eval/resolve/resolve-working-directory.js +2 -1
  61. package/dataflow/eval/resolve/resolve.d.ts +5 -5
  62. package/dataflow/eval/resolve/resolve.js +10 -11
  63. package/dataflow/eval/values/general.d.ts +4 -1
  64. package/dataflow/eval/values/general.js +4 -1
  65. package/dataflow/extractor.js +2 -1
  66. package/dataflow/fn/exceptions-of-function.js +5 -4
  67. package/dataflow/fn/higher-order-function.d.ts +1 -1
  68. package/dataflow/fn/higher-order-function.js +22 -2
  69. package/dataflow/graph/call-graph.d.ts +1 -1
  70. package/dataflow/graph/call-graph.js +15 -15
  71. package/dataflow/graph/df-helper.d.ts +17 -2
  72. package/dataflow/graph/df-helper.js +11 -5
  73. package/dataflow/graph/diff-dataflow-graph.js +6 -6
  74. package/dataflow/graph/edge.d.ts +27 -0
  75. package/dataflow/graph/edge.js +33 -0
  76. package/dataflow/graph/graph-helper.d.ts +4 -4
  77. package/dataflow/graph/graph-helper.js +5 -5
  78. package/dataflow/graph/graph.d.ts +11 -1
  79. package/dataflow/graph/graph.js +16 -5
  80. package/dataflow/graph/vertex.d.ts +47 -6
  81. package/dataflow/graph/vertex.js +47 -6
  82. package/dataflow/internal/linker.d.ts +1 -0
  83. package/dataflow/internal/linker.js +11 -9
  84. package/dataflow/internal/process/functions/call/built-in/built-in-access.js +2 -2
  85. package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +1 -1
  86. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +6 -5
  87. package/dataflow/internal/process/functions/call/built-in/built-in-class-generator.js +2 -2
  88. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +6 -7
  89. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +7 -6
  90. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.d.ts +1 -0
  91. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +19 -18
  92. package/dataflow/internal/process/functions/call/built-in/built-in-library.js +6 -1
  93. package/dataflow/internal/process/functions/call/built-in/built-in-list.js +2 -2
  94. package/dataflow/internal/process/functions/call/built-in/built-in-local.js +2 -2
  95. package/dataflow/internal/process/functions/call/built-in/built-in-pipe.js +2 -2
  96. package/dataflow/internal/process/functions/call/built-in/built-in-purrr-formula.js +5 -5
  97. package/dataflow/internal/process/functions/call/built-in/built-in-quote.js +1 -1
  98. package/dataflow/internal/process/functions/call/built-in/built-in-register-hook.js +3 -3
  99. package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +3 -3
  100. package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +2 -2
  101. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +3 -3
  102. package/dataflow/internal/process/functions/call/built-in/built-in-source.d.ts +1 -1
  103. package/dataflow/internal/process/functions/call/built-in/built-in-source.js +8 -2
  104. package/dataflow/internal/process/functions/call/built-in/built-in-string-template.js +1 -1
  105. package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +3 -3
  106. package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.d.ts +3 -1
  107. package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +15 -12
  108. package/dataflow/internal/process/functions/call/common.d.ts +9 -1
  109. package/dataflow/internal/process/functions/call/common.js +17 -6
  110. package/dataflow/internal/process/functions/call/deferred.d.ts +7 -0
  111. package/dataflow/internal/process/functions/call/deferred.js +24 -1
  112. package/dataflow/internal/process/functions/call/known-call-handling.d.ts +3 -1
  113. package/dataflow/internal/process/functions/call/known-call-handling.js +6 -3
  114. package/dataflow/internal/process/functions/call/named-call-handling.js +44 -12
  115. package/dataflow/internal/process/functions/call/nse.d.ts +34 -5
  116. package/dataflow/internal/process/functions/call/nse.js +114 -6
  117. package/dataflow/internal/process/functions/call/quoted.d.ts +6 -0
  118. package/dataflow/internal/process/functions/call/quoted.js +26 -11
  119. package/dataflow/origin/dfg-get-origin.d.ts +1 -0
  120. package/dataflow/origin/dfg-get-origin.js +9 -6
  121. package/documentation/data/faq/faqs.js +88 -88
  122. package/documentation/data/faq/recommended-configs.js +1 -1
  123. package/documentation/data/faq/wiki-faq-store.js +1 -1
  124. package/documentation/doc-capabilities.js +1 -1
  125. package/documentation/doc-readme.js +1 -1
  126. package/documentation/doc-util/doc-auto-gen.js +6 -2
  127. package/documentation/doc-util/doc-functions.js +1 -1
  128. package/documentation/wiki-cfg.js +2 -2
  129. package/documentation/wiki-create-linting-rules.js +45 -45
  130. package/documentation/wiki-dataflow-graph.js +25 -18
  131. package/documentation/wiki-linting-and-testing.js +93 -5
  132. package/documentation/wiki-mk/doc-maker.js +1 -1
  133. package/documentation/wiki-overview.js +12 -1
  134. package/documentation/wiki-signature-database.js +3 -0
  135. package/linter/linter-format.d.ts +1 -0
  136. package/linter/linter-format.js +1 -0
  137. package/linter/rules/file-path-validity.js +1 -1
  138. package/linter/rules/function-finder-util.js +1 -1
  139. package/linter/rules/naming-convention.js +1 -1
  140. package/linter/rules/no-leaked-credentials.js +2 -1
  141. package/linter/rules/stop-with-call-arg.js +4 -4
  142. package/linter/rules/undefined-symbol-util.d.ts +1 -1
  143. package/linter/rules/undefined-symbol-util.js +5 -4
  144. package/linter/rules/undefined-symbol.js +3 -3
  145. package/linter/rules/unused-definition.js +2 -1
  146. package/package.json +35 -45
  147. package/project/context/flowr-analyzer-environment-context.d.ts +23 -0
  148. package/project/context/flowr-analyzer-environment-context.js +25 -0
  149. package/project/dependency-version-space.js +1 -2
  150. package/project/flowr-analyzer.js +1 -1
  151. package/project/plugins/file-plugins/files/flowr-rda-file.js +3 -3
  152. package/project/plugins/file-plugins/files/flowr-rmarkdown-file.js +2 -2
  153. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +3 -1
  154. package/project/sigdb/build.js +16 -16
  155. package/project/sigdb/codec.d.ts +1 -1
  156. package/project/sigdb/codec.js +13 -13
  157. package/project/sigdb/decompress.d.ts +1 -1
  158. package/project/sigdb/decompress.js +33 -33
  159. package/project/sigdb/index-format.js +2 -2
  160. package/project/sigdb/manifest.js +21 -21
  161. package/project/sigdb/memory-source.d.ts +64 -0
  162. package/project/sigdb/memory-source.js +133 -0
  163. package/project/sigdb/reader.js +13 -13
  164. package/queries/catalog/absint-query/absint-query-format.js +1 -1
  165. package/queries/catalog/call-context-query/call-context-query-executor.js +1 -1
  166. package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +2 -2
  167. package/queries/catalog/dependencies-query/dependencies-query-executor.js +2 -2
  168. package/queries/catalog/dependencies-query/dependencies-query-format.js +1 -1
  169. package/queries/catalog/dependencies-query/link-devices.js +2 -2
  170. package/queries/catalog/does-call-query/does-call-query-executor.js +2 -1
  171. package/queries/catalog/does-call-query/does-call-query-format.js +2 -1
  172. package/queries/catalog/input-sources-query/input-sources-query-format.js +1 -1
  173. package/queries/catalog/input-sources-query/simple-input-classifier.js +4 -4
  174. package/queries/catalog/inspect-exceptions-query/inspect-exception-query-format.js +1 -1
  175. package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.js +1 -1
  176. package/queries/catalog/inspect-recursion-query/inspect-recursion-query-format.js +1 -1
  177. package/queries/catalog/location-map-query/location-map-query-format.js +2 -2
  178. package/queries/catalog/origin-query/origin-query-format.js +1 -1
  179. package/queries/catalog/provenance-query/provenance-query-format.js +1 -1
  180. package/queries/catalog/resolve-value-query/resolve-value-query-executor.js +2 -2
  181. package/queries/catalog/resolve-value-query/resolve-value-query-format.js +1 -1
  182. package/queries/catalog/signature-query/signature-query-executor.d.ts +2 -0
  183. package/queries/catalog/signature-query/signature-query-executor.js +3 -2
  184. package/r-bridge/lang-4.x/ast/model/nodes/info/r-delimiter.d.ts +1 -0
  185. package/r-bridge/lang-4.x/ast/model/nodes/info/r-delimiter.js +1 -0
  186. package/r-bridge/lang-4.x/ast/model/processing/node-id.js +3 -3
  187. package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-call.js +1 -1
  188. package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-definition.js +1 -1
  189. package/r-bridge/retriever.d.ts +2 -1
  190. package/r-bridge/retriever.js +3 -2
  191. package/r-bridge/roxygen2/documentation-provider.d.ts +1 -0
  192. package/r-bridge/roxygen2/documentation-provider.js +1 -0
  193. package/r-bridge/roxygen2/roxygen-parse.d.ts +1 -1
  194. package/r-bridge/roxygen2/roxygen-parse.js +1 -1
  195. package/search/flowr-search-filters.d.ts +1 -1
  196. package/search/flowr-search-filters.js +2 -2
  197. package/search/search-executor/search-enrichers.js +4 -4
  198. package/search/search-executor/search-generators.js +1 -1
  199. package/slicing/criterion/parse.d.ts +1 -0
  200. package/slicing/criterion/parse.js +4 -3
  201. package/slicing/static/slice-call.d.ts +1 -1
  202. package/slicing/static/slice-call.js +2 -2
  203. package/slicing/static/static-slicer.js +4 -3
  204. package/util/assert.js +1 -1
  205. package/util/log.d.ts +4 -1
  206. package/util/log.js +15 -2
  207. package/util/logic.js +2 -2
  208. package/util/mermaid/cfg.js +1 -1
  209. package/util/mermaid/dfg.js +6 -6
  210. package/util/mermaid/mermaid.js +3 -1
  211. package/util/quads.js +19 -6
  212. package/util/r-version.d.ts +2 -0
  213. package/util/r-version.js +2 -0
  214. package/util/record.d.ts +1 -0
  215. package/util/record.js +1 -0
  216. package/util/schema.js +2 -2
  217. package/util/text/ansi.d.ts +2 -0
  218. package/util/text/ansi.js +8 -0
  219. package/util/text/name-rank.d.ts +29 -0
  220. package/util/text/name-rank.js +39 -0
  221. package/util/text/url-encoding.d.ts +15 -0
  222. package/util/text/url-encoding.js +59 -0
  223. package/util/version.js +1 -1
  224. package/cli/export-quads-app.d.ts +0 -7
  225. package/cli/export-quads-app.js +0 -44
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.FlowrAnalyzerEnvironmentContext = void 0;
4
4
  const environment_1 = require("../../dataflow/environments/environment");
5
5
  const built_in_config_1 = require("../../dataflow/environments/built-in-config");
6
+ const identifier_1 = require("../../dataflow/environments/identifier");
6
7
  const fingerprint_1 = require("../../slicing/static/fingerprint");
7
8
  /**
8
9
  * Provides the built-in environment, created from the {@link FlowrAnalyzerContext} configuration.
@@ -12,6 +13,8 @@ class FlowrAnalyzerEnvironmentContext {
12
13
  builtInEnv;
13
14
  emptyBuiltInEnv;
14
15
  builtInEnvFingerprint;
16
+ /** the packages {@link knowsPackage} answers for, collected from the built-in environment on first use */
17
+ knownPackages;
15
18
  constructor(ctx) {
16
19
  const builtInsConfig = ctx.config.semantics.environment.overwriteBuiltIns;
17
20
  const builtIns = (0, built_in_config_1.getBuiltInDefinitions)(builtInsConfig.definitions, builtInsConfig.loadDefaults);
@@ -26,6 +29,28 @@ class FlowrAnalyzerEnvironmentContext {
26
29
  get emptyBuiltInEnvironment() {
27
30
  return this.emptyBuiltInEnv;
28
31
  }
32
+ builtInDefinitionsOf(name) {
33
+ return this.builtInEnv.memory.get(identifier_1.Identifier.getName(name)) ?? [];
34
+ }
35
+ knowsPackage(pkg) {
36
+ if (this.knownPackages === undefined) {
37
+ this.knownPackages = new Set();
38
+ for (const [, definitions] of this.builtInEnv.memory) {
39
+ for (const definition of definitions) {
40
+ const namespace = definition.name === undefined ? undefined : identifier_1.Identifier.getNamespace(definition.name);
41
+ if (namespace !== undefined) {
42
+ this.knownPackages.add(String(namespace));
43
+ }
44
+ }
45
+ }
46
+ }
47
+ return this.knownPackages.has(pkg);
48
+ }
49
+ builtInFunctionOf(name) {
50
+ const namespace = identifier_1.Identifier.getNamespace(name);
51
+ return this.builtInDefinitionsOf(name).find((d) => d.type === identifier_1.ReferenceType.BuiltInFunction && typeof d.processor === 'function'
52
+ && (namespace === undefined || (d.name !== undefined && identifier_1.Identifier.getNamespace(d.name) === namespace)));
53
+ }
29
54
  makeCleanEnv() {
30
55
  return {
31
56
  current: new environment_1.Environment(this.builtInEnv).asGlobal(),
@@ -36,7 +36,6 @@ const identifier_1 = require("../dataflow/environments/identifier");
36
36
  const vertex_1 = require("../dataflow/graph/vertex");
37
37
  const graph_1 = require("../dataflow/graph/graph");
38
38
  const df_helper_1 = require("../dataflow/graph/df-helper");
39
- const dfg_get_origin_1 = require("../dataflow/origin/dfg-get-origin");
40
39
  const r_base_packages_1 = require("../util/r-base-packages");
41
40
  const undefined_symbol_util_1 = require("../linter/rules/undefined-symbol-util");
42
41
  const type_1 = require("../r-bridge/lang-4.x/ast/model/type");
@@ -271,7 +270,7 @@ function collectOrphanUsage(graph, deps, usage, isKnown, options = {}) {
271
270
  const name = identifier_1.Identifier.getName(vertex.name);
272
271
  // a call bound to a real definition (local, parameter, closure, or import) *is* that definition, not a package
273
272
  // export; only an unresolved or builtin-modeled call can be an orphan (flowR models e.g. `ggplot` as a builtin)
274
- if ((0, dfg_get_origin_1.getOriginInDfg)(graph, id)?.some(o => o.type === 2 /* OriginType.FunctionCallOrigin */) === true) {
273
+ if (df_helper_1.Dataflow.origin(graph, id)?.some(o => o.type === 2 /* OriginType.FunctionCallOrigin */) === true) {
275
274
  continue;
276
275
  }
277
276
  // a bare name from a default-attached base package (or a base primitive) is defined without a library() call
@@ -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
  }
@@ -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
  /**
@@ -204,7 +204,7 @@ class RDAParser {
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)) {
@@ -558,7 +558,9 @@ class FlowrAnalyzerPackageVersionsSigDbPlugin extends flowr_analyzer_package_ver
558
558
  loadsWithSideEffects: false,
559
559
  callable: exported
560
560
  };
561
- return new package_1.Package({ name, namespaceInfo, resolvedVersion: info.version });
561
+ /* a source may know the exports without knowing which release they are from, and then the package
562
+ carries no version rather than a made-up one */
563
+ return new package_1.Package({ name, namespaceInfo, resolvedVersion: info.version || undefined });
562
564
  }
563
565
  }
564
566
  exports.FlowrAnalyzerPackageVersionsSigDbPlugin = FlowrAnalyzerPackageVersionsSigDbPlugin;
@@ -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
@@ -14,8 +14,8 @@ exports.defaultSigDbPaths = defaultSigDbPaths;
14
14
  * database), reading/writing it, and discovering the bundled manifests/bundles on flowR's search path. Split
15
15
  * out of `../sigdb` as pure format + filesystem discovery, with no dependency on the reader/writer classes.
16
16
  */
17
- const node_fs_1 = __importDefault(require("node:fs"));
18
- const node_path_1 = __importDefault(require("node:path"));
17
+ const fs_1 = __importDefault(require("fs"));
18
+ const path_1 = __importDefault(require("path"));
19
19
  const schema_1 = require("./schema");
20
20
  const codec_1 = require("./codec");
21
21
  const decompress_1 = require("./decompress");
@@ -23,11 +23,11 @@ exports.SigDbManifestMagic = 'flowr-sigdb-manifest';
23
23
  exports.SigDbManifestSchema = 2;
24
24
  /** write a {@link SigDbManifest} (compact JSON) plus a compressed copy per available codec (`.br` always, `.zst` when supported) beside it */
25
25
  function writeManifest(file, manifest) {
26
- node_fs_1.default.mkdirSync(node_path_1.default.dirname(node_path_1.default.resolve(file)), { recursive: true });
26
+ fs_1.default.mkdirSync(path_1.default.dirname(path_1.default.resolve(file)), { recursive: true });
27
27
  const json = JSON.stringify(manifest);
28
- node_fs_1.default.writeFileSync(file, json);
28
+ fs_1.default.writeFileSync(file, json);
29
29
  for (const spec of (0, codec_1.writeCodecs)()) {
30
- node_fs_1.default.writeFileSync(`${file}${spec.ext}`, spec.compressSync(json, { level: 11, sizeHint: json.length }));
30
+ fs_1.default.writeFileSync(`${file}${spec.ext}`, spec.compressSync(json, { level: 11, sizeHint: json.length }));
31
31
  }
32
32
  }
33
33
  /** how cheap a file is to read (lower is better); one we cannot decompress here sorts last */
@@ -44,7 +44,7 @@ function readManifestFile(manifestFile) {
44
44
  return JSON.parse(readManifestText(manifestFile));
45
45
  }
46
46
  function readManifestText(manifestFile) {
47
- const raw = node_fs_1.default.readFileSync(manifestFile);
47
+ const raw = fs_1.default.readFileSync(manifestFile);
48
48
  return (0, codec_1.compressedExtOf)(manifestFile) ? (0, codec_1.decompressSyncFor)(manifestFile, raw).toString('utf8') : raw.toString('utf8');
49
49
  }
50
50
  /**
@@ -65,14 +65,14 @@ const ManifestFilePattern = new RegExp(`\\.manifest\\.json${codec_1.CompressedEx
65
65
  /** a `<name>.sigs.ndjson` bundle, in any of the codecs we can read */
66
66
  const BundleFilePattern = new RegExp(`${schema_1.SigDbExt.replace(/\./g, '\\.')}${codec_1.CompressedExtPattern}$`);
67
67
  function sigDbBundleDirs() {
68
- if (typeof node_fs_1.default?.readdirSync !== 'function') {
68
+ if (typeof fs_1.default?.readdirSync !== 'function') {
69
69
  return [];
70
70
  }
71
71
  try {
72
- const bundles = node_path_1.default.join((0, decompress_1.sigDbCacheDir)(undefined, false), 'bundles');
73
- return node_fs_1.default.readdirSync(bundles, { withFileTypes: true })
72
+ const bundles = path_1.default.join((0, decompress_1.sigDbCacheDir)(undefined, false), 'bundles');
73
+ return fs_1.default.readdirSync(bundles, { withFileTypes: true })
74
74
  .filter(e => e.isDirectory())
75
- .map(e => node_path_1.default.join(bundles, e.name));
75
+ .map(e => path_1.default.join(bundles, e.name));
76
76
  }
77
77
  catch {
78
78
  return [];
@@ -83,7 +83,7 @@ function sigDbSearchRoots(extra) {
83
83
  const roots = [...(extra ?? [])];
84
84
  const env = typeof process !== 'undefined' ? process.env?.FLOWR_SIGDB_DIR : undefined;
85
85
  if (env) {
86
- roots.push(...env.split(node_path_1.default.delimiter).filter(Boolean));
86
+ roots.push(...env.split(path_1.default.delimiter).filter(Boolean));
87
87
  }
88
88
  if (typeof __dirname !== 'undefined') {
89
89
  roots.push(__dirname);
@@ -101,7 +101,7 @@ function sigDbSearchRoots(extra) {
101
101
  * bundled `base`. Node only (needs `fs`); pass `searchRoots` to override where it looks.
102
102
  */
103
103
  function defaultSigDbPath(scope, searchRoots) {
104
- if (typeof node_fs_1.default?.existsSync !== 'function') {
104
+ if (typeof fs_1.default?.existsSync !== 'function') {
105
105
  return undefined;
106
106
  }
107
107
  const scopes = scope ? [scope] : SigDbScopeOrder;
@@ -109,8 +109,8 @@ function defaultSigDbPath(scope, searchRoots) {
109
109
  for (const sub of SigDbSubDirs) {
110
110
  for (const s of scopes) {
111
111
  for (const suffix of ['', ...(0, codec_1.readableExtsPreferred)()]) {
112
- const candidate = node_path_1.default.join(dir, sub, `${s}.manifest.json${suffix}`);
113
- if (node_fs_1.default.existsSync(candidate)) {
112
+ const candidate = path_1.default.join(dir, sub, `${s}.manifest.json${suffix}`);
113
+ if (fs_1.default.existsSync(candidate)) {
114
114
  return candidate;
115
115
  }
116
116
  }
@@ -124,7 +124,7 @@ function defaultSigDbPath(scope, searchRoots) {
124
124
  if (hit !== undefined) {
125
125
  return hit;
126
126
  }
127
- const parent = node_path_1.default.dirname(dir);
127
+ const parent = path_1.default.dirname(dir);
128
128
  if (parent === dir) {
129
129
  break;
130
130
  }
@@ -147,7 +147,7 @@ function defaultSigDbPath(scope, searchRoots) {
147
147
  * shard and dictionary files a manifest already owns are skipped. Deduped by filename, first search location wins.
148
148
  */
149
149
  function defaultSigDbPaths(searchRoots) {
150
- if (typeof node_fs_1.default?.readdirSync !== 'function') {
150
+ if (typeof fs_1.default?.readdirSync !== 'function') {
151
151
  return [];
152
152
  }
153
153
  const manifests = new Map(); // `<name>.manifest.json` (ignoring compression ext) -> first-found path
@@ -168,18 +168,18 @@ function defaultSigDbPaths(searchRoots) {
168
168
  for (const sub of SigDbSubDirs) {
169
169
  let entries;
170
170
  try {
171
- entries = node_fs_1.default.readdirSync(node_path_1.default.join(base, sub));
171
+ entries = fs_1.default.readdirSync(path_1.default.join(base, sub));
172
172
  }
173
173
  catch {
174
174
  continue; // directory does not exist on this root
175
175
  }
176
- const dir = node_path_1.default.join(base, sub);
176
+ const dir = path_1.default.join(base, sub);
177
177
  for (const file of entries) {
178
178
  if (ManifestFilePattern.test(file)) {
179
- keep(manifests, (0, codec_1.stripCompressedExt)(file), node_path_1.default.join(dir, file), dir);
179
+ keep(manifests, (0, codec_1.stripCompressedExt)(file), path_1.default.join(dir, file), dir);
180
180
  }
181
181
  else if (BundleFilePattern.test(file) && !file.includes('.dict' + schema_1.SigDbExt)) {
182
- keep(standalones, (0, codec_1.stripCompressedExt)(file), node_path_1.default.join(dir, file), dir);
182
+ keep(standalones, (0, codec_1.stripCompressedExt)(file), path_1.default.join(dir, file), dir);
183
183
  }
184
184
  }
185
185
  }
@@ -187,7 +187,7 @@ function defaultSigDbPaths(searchRoots) {
187
187
  for (const root of sigDbSearchRoots(searchRoots)) {
188
188
  for (let dir = root, i = 0; i < 10; i++) {
189
189
  scanDir(dir);
190
- const parent = node_path_1.default.dirname(dir);
190
+ const parent = path_1.default.dirname(dir);
191
191
  if (parent === dir) {
192
192
  break;
193
193
  }