@eagleoutice/flowr 2.13.4 → 2.13.5

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 (130) hide show
  1. package/README.md +31 -31
  2. package/cli/repl/core.js +10 -2
  3. package/config.d.ts +4 -1
  4. package/config.js +10 -1
  5. package/control-flow/cfg-dead-code.js +19 -4
  6. package/control-flow/extract-cfg.js +12 -4
  7. package/dataflow/environments/built-in-config.d.ts +6 -3
  8. package/dataflow/environments/built-in-eval-name.d.ts +20 -0
  9. package/dataflow/environments/built-in-eval-name.js +25 -0
  10. package/dataflow/environments/built-in-props.d.ts +175 -0
  11. package/dataflow/environments/built-in-props.js +207 -0
  12. package/dataflow/environments/built-in.d.ts +26 -22
  13. package/dataflow/environments/built-in.js +37 -10
  14. package/dataflow/environments/default-builtin-config.d.ts +1046 -93
  15. package/dataflow/environments/default-builtin-config.js +485 -213
  16. package/dataflow/environments/identifier.d.ts +24 -1
  17. package/dataflow/environments/identifier.js +24 -2
  18. package/dataflow/environments/query-fn-props.d.ts +102 -0
  19. package/dataflow/environments/query-fn-props.js +188 -0
  20. package/dataflow/eval/resolve/alias-tracking.js +4 -1
  21. package/dataflow/eval/resolve/match-arguments.d.ts +15 -0
  22. package/dataflow/eval/resolve/match-arguments.js +77 -0
  23. package/dataflow/eval/resolve/resolve-numbers.d.ts +202 -0
  24. package/dataflow/eval/resolve/resolve-numbers.js +163 -0
  25. package/dataflow/eval/resolve/resolve-operators.d.ts +60 -0
  26. package/dataflow/eval/resolve/resolve-operators.js +115 -0
  27. package/dataflow/eval/resolve/resolve-strings.d.ts +98 -0
  28. package/dataflow/eval/resolve/resolve-strings.js +116 -0
  29. package/dataflow/eval/resolve/resolve.d.ts +5 -37
  30. package/dataflow/eval/resolve/resolve.js +56 -134
  31. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.d.ts +1 -1
  32. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +5 -4
  33. package/dataflow/internal/process/functions/call/built-in/built-in-source.js +1 -1
  34. package/dataflow/internal/process/functions/call/known-call-handling.d.ts +2 -1
  35. package/dataflow/internal/process/functions/call/known-call-handling.js +2 -1
  36. package/documentation/data/faq/faqs.js +11 -0
  37. package/documentation/doc-util/doc-types.js +1 -1
  38. package/documentation/wiki-analyzer.js +75 -0
  39. package/documentation/wiki-core.js +65 -16
  40. package/documentation/wiki-interface.js +3 -0
  41. package/linter/linter-rules.d.ts +10 -11
  42. package/linter/rules/deprecated-functions.js +5 -3
  43. package/linter/rules/function-finder-util.d.ts +2 -2
  44. package/linter/rules/function-finder-util.js +10 -3
  45. package/linter/rules/network-functions.d.ts +25 -5
  46. package/linter/rules/network-functions.js +51 -11
  47. package/linter/rules/problematic-inputs.d.ts +1 -1
  48. package/linter/rules/problematic-inputs.js +7 -1
  49. package/linter/rules/seeded-randomness.d.ts +5 -8
  50. package/linter/rules/seeded-randomness.js +17 -9
  51. package/package.json +3 -2
  52. package/project/cache/flowr-analyzer-cache.d.ts +4 -3
  53. package/project/cache/flowr-analyzer-cache.js +32 -13
  54. package/project/cache/flowr-cache.d.ts +39 -12
  55. package/project/cache/flowr-cache.js +5 -3
  56. package/project/context/flowr-analyzer-context.d.ts +8 -1
  57. package/project/context/flowr-analyzer-context.js +11 -1
  58. package/project/context/flowr-analyzer-dependencies-context.d.ts +4 -2
  59. package/project/context/flowr-analyzer-dependencies-context.js +15 -1
  60. package/project/context/flowr-analyzer-files-context.d.ts +8 -4
  61. package/project/context/flowr-analyzer-files-context.js +20 -1
  62. package/project/context/flowr-analyzer-incremental-analysis-context.d.ts +33 -0
  63. package/project/context/flowr-analyzer-incremental-analysis-context.js +63 -0
  64. package/project/context/flowr-analyzer-meta-context.d.ts +3 -1
  65. package/project/context/flowr-analyzer-meta-context.js +14 -0
  66. package/project/context/flowr-file.d.ts +25 -3
  67. package/project/context/flowr-file.js +24 -2
  68. package/project/dependency-version-space.d.ts +37 -0
  69. package/project/dependency-version-space.js +118 -26
  70. package/project/flowr-analyzer.d.ts +6 -0
  71. package/project/flowr-analyzer.js +6 -2
  72. package/project/incremental/incremental-parse/edit-computation.d.ts +7 -0
  73. package/project/incremental/incremental-parse/edit-computation.js +61 -0
  74. package/project/incremental/incremental-parse/incremental-parse.d.ts +12 -0
  75. package/project/incremental/incremental-parse/incremental-parse.js +37 -0
  76. package/project/plugins/file-plugins/files/flowr-jupyter-file.d.ts +1 -1
  77. package/project/plugins/file-plugins/files/flowr-manifest-files.d.ts +57 -0
  78. package/project/plugins/file-plugins/files/flowr-manifest-files.js +121 -0
  79. package/project/plugins/file-plugins/files/flowr-rmarkdown-file.d.ts +2 -2
  80. package/project/plugins/file-plugins/files/flowr-rmarkdown-file.js +2 -2
  81. package/project/plugins/file-plugins/files/flowr-sweave-file.d.ts +1 -1
  82. package/project/plugins/file-plugins/flowr-analyzer-manifest-file-plugin.d.ts +33 -0
  83. package/project/plugins/file-plugins/flowr-analyzer-manifest-file-plugin.js +53 -0
  84. package/project/plugins/file-plugins/flowr-analyzer-virtualenv-file-plugin.d.ts +1 -1
  85. package/project/plugins/file-plugins/flowr-analyzer-virtualenv-file-plugin.js +3 -3
  86. package/project/plugins/package-version-plugins/flowr-analyzer-meta-manifest-file-plugin.d.ts +27 -0
  87. package/project/plugins/package-version-plugins/flowr-analyzer-meta-manifest-file-plugin.js +47 -0
  88. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-lockfile-plugin.d.ts +7 -0
  89. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-lockfile-plugin.js +31 -3
  90. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.d.ts +10 -4
  91. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +17 -4
  92. package/project/plugins/plugin-registry.d.ts +4 -4
  93. package/project/plugins/plugin-registry.js +7 -4
  94. package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +4 -4
  95. package/project/sigdb/reader.d.ts +7 -0
  96. package/project/sigdb/reader.js +12 -0
  97. package/queries/catalog/dependencies-query/function-info/derived-functions.d.ts +10 -0
  98. package/queries/catalog/dependencies-query/function-info/derived-functions.js +41 -0
  99. package/queries/catalog/dependencies-query/function-info/read-functions.js +13 -12
  100. package/queries/catalog/dependencies-query/function-info/write-functions.js +16 -23
  101. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-executor.js +33 -3
  102. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.d.ts +31 -0
  103. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.js +9 -2
  104. package/queries/catalog/input-sources-query/input-source-functions.d.ts +8 -10
  105. package/queries/catalog/input-sources-query/input-source-functions.js +23 -388
  106. package/queries/catalog/input-sources-query/input-sources-query-format.d.ts +7 -0
  107. package/queries/catalog/input-sources-query/input-sources-query-format.js +27 -10
  108. package/queries/catalog/signature-query/signature-query-executor.d.ts +2 -1
  109. package/queries/catalog/signature-query/signature-query-executor.js +79 -3
  110. package/queries/catalog/signature-query/signature-query-format.d.ts +27 -0
  111. package/queries/catalog/signature-query/signature-query-render.js +21 -3
  112. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.d.ts +6 -2
  113. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.js +21 -2
  114. package/r-bridge/parser.d.ts +11 -1
  115. package/r-bridge/parser.js +7 -4
  116. package/r-bridge/shell-executor.d.ts +1 -0
  117. package/r-bridge/shell-executor.js +1 -0
  118. package/r-bridge/shell.d.ts +1 -0
  119. package/r-bridge/shell.js +1 -0
  120. package/search/flowr-search-filters.d.ts +1 -6
  121. package/search/flowr-search-filters.js +1 -8
  122. package/search/search-executor/search-enrichers.d.ts +2 -0
  123. package/search/search-executor/search-enrichers.js +29 -12
  124. package/util/version.js +1 -1
  125. package/project/plugins/file-plugins/files/flowr-rproject-file.d.ts +0 -31
  126. package/project/plugins/file-plugins/files/flowr-rproject-file.js +0 -66
  127. package/project/plugins/file-plugins/flowr-analyzer-rproject-file-plugin.d.ts +0 -22
  128. package/project/plugins/file-plugins/flowr-analyzer-rproject-file-plugin.js +0 -36
  129. package/project/plugins/package-version-plugins/flowr-analyzer-meta-rproject-file-plugin.d.ts +0 -13
  130. package/project/plugins/package-version-plugins/flowr-analyzer-meta-rproject-file-plugin.js +0 -32
@@ -39,6 +39,8 @@ export interface PackageSignatureSource {
39
39
  packageNames(): string[];
40
40
  /** whether the package is an R-core / base package (its versions are the R releases it shipped with) */
41
41
  isBaseR(pkg: string): boolean;
42
+ /** how often the package was downloaded when the database was built, the popularity {@link SigDbPkgMeta} records */
43
+ downloads(pkg: string): number;
42
44
  /** for a base package, the R versions it was part of core (ascending); `undefined` otherwise */
43
45
  coreVersions(pkg: string): RVersion[] | undefined;
44
46
  /** the release date of a package version (defaulting to the newest release), or `undefined` if unknown */
@@ -99,6 +101,7 @@ export declare class MergedSignatureSource implements PackageSignatureSource {
99
101
  dependencies(pkg: string, version?: string): ResolvedDependency[] | undefined;
100
102
  packageNames(): string[];
101
103
  isBaseR(pkg: string): boolean;
104
+ downloads(pkg: string): number;
102
105
  coreVersions(pkg: string): RVersion[] | undefined;
103
106
  releaseDate(pkg: string, version?: string): Date | undefined;
104
107
  releaseDates(pkg: string): VersionRelease[];
@@ -181,6 +184,8 @@ export declare class SigDatabase implements PackageSignatureSource {
181
184
  dependencies(pkg: string, version?: string): ResolvedDependency[] | undefined;
182
185
  /** whether this is an R-core / base package (its versions are the R releases it shipped with; see {@link SigDbPkgMeta}) */
183
186
  isBaseR(pkg: string): boolean;
187
+ /** the download count recorded for the package, `0` when this source does not carry it */
188
+ downloads(pkg: string): number;
184
189
  /**
185
190
  * The R versions a base package was part of core, in ascending R-version order (exactly its stored
186
191
  * versions). `undefined` for a non-base package. E.g. `mva` returns `…1.9.1`, `parallel` `2.14.0…`.
@@ -278,6 +283,8 @@ export declare class SigDatabaseSet implements PackageSignatureSource {
278
283
  dependencies(pkg: string, version?: string): ResolvedDependency[] | undefined;
279
284
  /** whether this is an R-core / base package (see {@link SigDatabase.isBaseR}); O(1) via the hoisted metadata */
280
285
  isBaseR(pkg: string): boolean;
286
+ /** the download count of the package; O(1) via the hoisted metadata, so no shard has to be unpacked for it */
287
+ downloads(pkg: string): number;
281
288
  /** the R versions a base package was part of core (ascending); `undefined` if not a base package */
282
289
  coreVersions(pkg: string): RVersion[] | undefined;
283
290
  /** every known release of a package (version + date), ascending, read once from the most complete shard */
@@ -210,6 +210,9 @@ class MergedSignatureSource {
210
210
  isBaseR(pkg) {
211
211
  return this.sources.some(s => s.has(pkg) && s.isBaseR(pkg));
212
212
  }
213
+ downloads(pkg) {
214
+ return Math.max(0, ...this.sources.map(s => s.downloads(pkg)));
215
+ }
213
216
  coreVersions(pkg) {
214
217
  return this.sources.find(s => s.has(pkg))?.coreVersions(pkg);
215
218
  }
@@ -442,6 +445,10 @@ class SigDatabase {
442
445
  isBaseR(pkg) {
443
446
  return this.index.meta[pkg]?.[3] === 1;
444
447
  }
448
+ /** the download count recorded for the package, `0` when this source does not carry it */
449
+ downloads(pkg) {
450
+ return this.index.meta[pkg]?.[2] ?? 0;
451
+ }
445
452
  /**
446
453
  * The R versions a base package was part of core, in ascending R-version order (exactly its stored
447
454
  * versions). `undefined` for a non-base package. E.g. `mva` returns `…1.9.1`, `parallel` `2.14.0…`.
@@ -757,6 +764,11 @@ class SigDatabaseSet {
757
764
  }
758
765
  return this.route(pkg).some(i => this.shard(i).isBaseR(pkg));
759
766
  }
767
+ /** the download count of the package; O(1) via the hoisted metadata, so no shard has to be unpacked for it */
768
+ downloads(pkg) {
769
+ const meta = this.manifest.meta?.[pkg];
770
+ return meta ? meta[2] : Math.max(0, ...this.route(pkg).map(i => this.shard(i).downloads(pkg)));
771
+ }
760
772
  /** the R versions a base package was part of core (ascending); `undefined` if not a base package */
761
773
  coreVersions(pkg) {
762
774
  if (!this.isBaseR(pkg)) {
@@ -0,0 +1,10 @@
1
+ import type { FunctionInfo } from './function-info';
2
+ import type { CallProps } from '../../../../dataflow/environments/built-in-props';
3
+ /**
4
+ * The built-ins that carry all of `props` and name the resource they act on, as entries of a dependency
5
+ * category. This is what the {@link DefaultBuiltinConfig} already states, so only the functions it does not
6
+ * know (most package functions) and the ones needing more than a resource argument (`ignoreIf`, `linkTo`,
7
+ * a default, ...) have to be written down in the category itself. Names in `except` stay with whoever
8
+ * wrote them down.
9
+ */
10
+ export declare function functionInfosFromProps(props: CallProps, except: readonly FunctionInfo[]): FunctionInfo[];
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.functionInfosFromProps = functionInfosFromProps;
4
+ const built_in_props_1 = require("../../../../dataflow/environments/built-in-props");
5
+ const default_builtin_config_1 = require("../../../../dataflow/environments/default-builtin-config");
6
+ const query_fn_props_1 = require("../../../../dataflow/environments/query-fn-props");
7
+ const identifier_1 = require("../../../../dataflow/environments/identifier");
8
+ /** what an entry links to, like `sink` for `cat`: the link reports it already, so it is not an entry of its own */
9
+ function linkTargets(f) {
10
+ return (f.linkTo ?? []).flatMap(l => typeof l.callName === 'string' ? [l.callName]
11
+ : Array.isArray(l.callName) ? l.callName.map(n => identifier_1.Identifier.getName(n)) : []);
12
+ }
13
+ /**
14
+ * The built-ins that carry all of `props` and name the resource they act on, as entries of a dependency
15
+ * category. This is what the {@link DefaultBuiltinConfig} already states, so only the functions it does not
16
+ * know (most package functions) and the ones needing more than a resource argument (`ignoreIf`, `linkTo`,
17
+ * a default, ...) have to be written down in the category itself. Names in `except` stay with whoever
18
+ * wrote them down.
19
+ */
20
+ function functionInfosFromProps(props, except) {
21
+ const taken = new Set(except.flatMap(f => [f.name, ...linkTargets(f)]));
22
+ const found = [];
23
+ for (const d of default_builtin_config_1.DefaultBuiltinConfig) {
24
+ const info = d.type !== 'constant' ? d.config : undefined;
25
+ if (info?.props === undefined || (info.props & props) !== props || info.sig === undefined) {
26
+ continue;
27
+ }
28
+ const argIdx = info.sig.findIndex(([, p]) => (p & built_in_props_1.ArgProp.Resource) !== 0);
29
+ if (argIdx < 0) {
30
+ continue;
31
+ }
32
+ for (const id of (0, query_fn_props_1.builtInNames)(d)) {
33
+ const name = identifier_1.Identifier.getName(id);
34
+ if (!taken.has(name)) {
35
+ found.push({ package: identifier_1.Identifier.getNamespace(id), name, argIdx, argName: info.sig[argIdx][0], resolveValue: true });
36
+ }
37
+ }
38
+ }
39
+ return found;
40
+ }
41
+ //# sourceMappingURL=derived-functions.js.map
@@ -1,7 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ReadFunctions = void 0;
4
- exports.ReadFunctions = [
4
+ const built_in_props_1 = require("../../../../dataflow/environments/built-in-props");
5
+ const derived_functions_1 = require("./derived-functions");
6
+ const other_path_functions_1 = require("./other-path-functions");
7
+ const ReadFunctionsWithMore = [
5
8
  { package: 'base', name: 'parse', argName: 'file', resolveValue: true, ignoreIf: 'arg-missing' },
6
9
  { package: 'base', name: 'read.table', argIdx: 0, argName: 'file', resolveValue: true, ignoreIf: 'arg-set', additionalArgs: { argSet: { argName: 'text' } } },
7
10
  { package: 'utils', name: 'read.csv', argIdx: 0, argName: 'file', resolveValue: true, ignoreIf: 'arg-set', additionalArgs: { argSet: { argName: 'text' } } },
@@ -9,22 +12,16 @@ exports.ReadFunctions = [
9
12
  { package: 'utils', name: 'read.delim', argIdx: 0, argName: 'file', resolveValue: true, ignoreIf: 'arg-set', additionalArgs: { argSet: { argName: 'text' } } },
10
13
  { package: 'utils', name: 'read.delim2', argIdx: 0, argName: 'file', resolveValue: true, ignoreIf: 'arg-set', additionalArgs: { argSet: { argName: 'text' } } },
11
14
  { package: 'base', name: 'read.dcf', argIdx: 0, argName: 'file', resolveValue: true },
12
- { package: 'base', name: 'scan', argIdx: 0, argName: 'file', resolveValue: true },
13
15
  { package: 'utils', name: 'read.fwf', argIdx: 0, argName: 'file', resolveValue: true },
14
16
  { package: 'base', name: 'file', argIdx: 0, argName: 'description', resolveValue: true, ignoreIf: 'mode-only-write', additionalArgs: { mode: { argIdx: 1, argName: 'open', resolveValue: true } } },
15
17
  { package: 'base', name: 'url', argIdx: 0, argName: 'description', resolveValue: true, ignoreIf: 'mode-only-write', additionalArgs: { mode: { argIdx: 1, argName: 'open', resolveValue: true } } },
16
- { package: 'base', name: 'load', argIdx: 0, argName: 'file', resolveValue: true },
17
- { package: 'base', name: 'gzfile', argIdx: 1, argName: 'open', resolveValue: true },
18
- { package: 'base', name: 'bzfile', argIdx: 1, argName: 'open', resolveValue: true },
18
+ { package: 'base', name: 'gzfile', argIdx: 0, argName: 'description', resolveValue: true, ignoreIf: 'mode-only-write', additionalArgs: { mode: { argIdx: 1, argName: 'open', resolveValue: true } } },
19
+ { package: 'base', name: 'bzfile', argIdx: 0, argName: 'description', resolveValue: true, ignoreIf: 'mode-only-write', additionalArgs: { mode: { argIdx: 1, argName: 'open', resolveValue: true } } },
19
20
  { package: 'utils', name: 'download.file', argIdx: 0, argName: 'url', resolveValue: true },
20
- { package: 'base', name: 'pipe', argIdx: 1, argName: 'open', resolveValue: true },
21
- { package: 'base', name: 'fifo', argIdx: 1, argName: 'open', resolveValue: true },
22
- { package: 'base', name: 'unz', argIdx: 1, argName: 'open', resolveValue: true },
21
+ { package: 'base', name: 'pipe', argIdx: 0, argName: 'description', resolveValue: true, ignoreIf: 'mode-only-write', additionalArgs: { mode: { argIdx: 1, argName: 'open', resolveValue: true } } },
22
+ { package: 'base', name: 'fifo', argIdx: 0, argName: 'description', resolveValue: true, ignoreIf: 'mode-only-write', additionalArgs: { mode: { argIdx: 1, argName: 'open', resolveValue: true } } },
23
+ { package: 'base', name: 'unz', argIdx: 0, argName: 'description', resolveValue: true, ignoreIf: 'mode-only-write', additionalArgs: { mode: { argIdx: 1, argName: 'open', resolveValue: true } } },
23
24
  { package: 'base', name: 'matrix', argIdx: 0, argName: 'data', resolveValue: true },
24
- { package: 'base', name: 'readRDS', argIdx: 0, argName: 'file', resolveValue: true },
25
- { package: 'base', name: 'readLines', argIdx: 0, argName: 'con', resolveValue: true },
26
- { package: 'base', name: 'readChar', argIdx: 0, argName: 'con', resolveValue: true },
27
- { package: 'base', name: 'readBin', argIdx: 0, argName: 'con', resolveValue: true },
28
25
  { package: 'base', name: 'readRenviron', argIdx: 0, argName: 'path', resolveValue: true },
29
26
  { package: 'readr', name: 'read_csv', argIdx: 0, argName: 'file', resolveValue: true },
30
27
  { package: 'readr', name: 'read_csv2', argIdx: 0, argName: 'file', resolveValue: true },
@@ -138,4 +135,8 @@ exports.ReadFunctions = [
138
135
  /* shinyjs - loads an external JavaScript file */
139
136
  { package: 'shinyjs', name: 'extendShinyjs', argIdx: 0, argName: 'script', resolveValue: true, ignoreIf: 'arg-missing' }
140
137
  ];
138
+ exports.ReadFunctions = [
139
+ ...ReadFunctionsWithMore,
140
+ ...(0, derived_functions_1.functionInfosFromProps)(built_in_props_1.CallProp.File | built_in_props_1.CallProp.Reads, [...ReadFunctionsWithMore, ...other_path_functions_1.OtherPathFunctions])
141
+ ];
141
142
  //# sourceMappingURL=read-functions.js.map
@@ -2,18 +2,17 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.WriteFunctions = void 0;
4
4
  const function_info_1 = require("./function-info");
5
+ const built_in_props_1 = require("../../../../dataflow/environments/built-in-props");
6
+ const derived_functions_1 = require("./derived-functions");
7
+ const other_path_functions_1 = require("./other-path-functions");
8
+ const read_functions_1 = require("./read-functions");
5
9
  const OutputRedirects = [
6
10
  { type: 'link-to-last-call', callName: 'sink', attachLinkInfo: { argIdx: 0, argName: 'file', when: function_info_1.DependencyInfoLinkConstraint.IfUnknown, resolveValue: true } }
7
11
  ];
8
- exports.WriteFunctions = [
9
- { package: 'base', name: 'save', argName: 'file', resolveValue: true },
10
- { package: 'base', name: 'save.image', argIdx: 1, argName: 'file', resolveValue: true, defaultValue: '.RData' },
11
- { package: 'base', name: 'write', argIdx: 1, argName: 'file', resolveValue: true },
12
- { package: 'base', name: 'dput', argIdx: 1, argName: 'file', resolveValue: true },
12
+ const WriteFunctionsWithMore = [
13
+ { package: 'base', name: 'save.image', argIdx: 0, argName: 'file', resolveValue: true, defaultValue: '.RData' },
13
14
  { package: 'base', name: 'dump', argIdx: 1, argName: 'file', resolveValue: true },
14
- { package: 'utils', name: 'write.table', argIdx: 1, argName: 'file', resolveValue: true },
15
15
  { package: 'utils', name: 'write.csv', argIdx: 1, argName: 'file', resolveValue: true },
16
- { package: 'base', name: 'saveRDS', argIdx: 1, argName: 'file', resolveValue: true },
17
16
  {
18
17
  package: 'base',
19
18
  name: 'try',
@@ -36,9 +35,6 @@ exports.WriteFunctions = [
36
35
  { package: 'rlang', name: 'inform', linkTo: OutputRedirects, resolveValue: false },
37
36
  { package: 'cli', name: 'cli_warn', linkTo: OutputRedirects, resolveValue: false },
38
37
  { package: 'cli', name: 'cli_abort', linkTo: OutputRedirects, resolveValue: false },
39
- { package: 'base', name: 'writeLines', argIdx: 1, argName: 'con', resolveValue: true },
40
- { package: 'base', name: 'writeChar', argIdx: 1, argName: 'con', resolveValue: true },
41
- { package: 'base', name: 'writeBin', argIdx: 1, argName: 'con', resolveValue: true },
42
38
  { package: 'base', name: 'file', argIdx: 0, argName: 'description', resolveValue: true, ignoreIf: 'mode-only-read', additionalArgs: { mode: { argIdx: 1, argName: 'open', resolveValue: true } } },
43
39
  { package: 'base', name: 'url', argIdx: 0, argName: 'description', resolveValue: true, ignoreIf: 'mode-only-read', additionalArgs: { mode: { argIdx: 1, argName: 'open', resolveValue: true } } },
44
40
  { package: 'readr', name: 'write_csv', argIdx: 1, argName: 'file', resolveValue: true },
@@ -62,18 +58,13 @@ exports.WriteFunctions = [
62
58
  { package: 'foreign', name: 'write.foreign', argIdx: 1, argName: 'file', resolveValue: true },
63
59
  { package: 'xlsx', name: 'write.xlsx', argIdx: 1, argName: 'file', resolveValue: true },
64
60
  { package: 'xlsx', name: 'write.xlsx2', argIdx: 1, argName: 'file', resolveValue: true },
65
- { package: 'grDevices', name: 'pdf', argIdx: 0, argName: 'file', resolveValue: true },
66
- { package: 'grDevices', name: 'jpeg', argIdx: 0, argName: 'file', resolveValue: true },
67
- { package: 'grDevices', name: 'png', argIdx: 0, argName: 'file', resolveValue: true },
61
+ { package: 'grDevices', name: 'jpeg', argIdx: 0, argName: 'filename', resolveValue: true },
62
+ { package: 'grDevices', name: 'png', argIdx: 0, argName: 'filename', resolveValue: true },
68
63
  { package: 'grDevices', name: 'windows', argIdx: 0, argName: 'file', resolveValue: true },
69
- { package: 'grDevices', name: 'postscript', argIdx: 0, argName: 'file', resolveValue: true },
70
- { package: 'grDevices', name: 'xfig', argIdx: 0, argName: 'file', resolveValue: true },
71
- { package: 'grDevices', name: 'bitmap', argIdx: 0, argName: 'file', resolveValue: true },
72
- { package: 'grDevices', name: 'pictex', argIdx: 0, argName: 'file', resolveValue: true },
73
- { package: 'grDevices', name: 'cairo_pdf', argIdx: 0, argName: 'file', resolveValue: true },
74
- { package: 'grDevices', name: 'svg', argIdx: 0, argName: 'file', resolveValue: true },
75
- { package: 'grDevices', name: 'bmp', argIdx: 0, argName: 'file', resolveValue: true },
76
- { package: 'grDevices', name: 'tiff', argIdx: 0, argName: 'file', resolveValue: true },
64
+ { package: 'grDevices', name: 'cairo_pdf', argIdx: 0, argName: 'filename', resolveValue: true },
65
+ { package: 'grDevices', name: 'svg', argIdx: 0, argName: 'filename', resolveValue: true },
66
+ { package: 'grDevices', name: 'bmp', argIdx: 0, argName: 'filename', resolveValue: true },
67
+ { package: 'grDevices', name: 'tiff', argIdx: 0, argName: 'filename', resolveValue: true },
77
68
  { package: 'grDevices', name: 'X11', argIdx: 0, argName: 'file', resolveValue: true },
78
69
  { package: 'grDevices', name: 'quartz', argIdx: 0, argName: 'file', resolveValue: true },
79
70
  { package: 'car', name: 'Export', argIdx: 0, argName: 'file', resolveValue: true },
@@ -101,8 +92,6 @@ exports.WriteFunctions = [
101
92
  { package: 'cowplot', name: 'ggsave2', argIdx: 0, argName: 'filename', resolveValue: true },
102
93
  { package: 'tinyplot', name: 'tinyplot', argName: 'file', resolveValue: true, ignoreIf: 'arg-missing' },
103
94
  { package: 'tinyplot', name: 'plt', argName: 'file', resolveValue: true, ignoreIf: 'arg-missing' },
104
- { package: 'rasterpdf', name: 'raster_pdf', argIdx: 0, argName: 'filename', resolveValue: true },
105
- { package: 'rasterpdf', name: 'agg_pdf', argIdx: 0, argName: 'filename', resolveValue: true },
106
95
  { package: 'highcharter', name: 'hc_exporting', argName: 'filename', resolveValue: true },
107
96
  { package: 'jsonlite', name: 'write_json', argIdx: 1, argName: 'path', resolveValue: true },
108
97
  { package: 'rpolars', name: 'sink_ipc', argIdx: 0, argName: 'path', resolveValue: true, ignoreIf: 'arg-missing' },
@@ -141,4 +130,8 @@ exports.WriteFunctions = [
141
130
  { package: 'seewave', name: 'savewav', argName: 'filename', resolveValue: true, defaultValue: '<wave-name>' },
142
131
  { package: 'audio', name: 'save.wave', argIdx: 1, argName: 'where', resolveValue: true }
143
132
  ];
133
+ exports.WriteFunctions = [
134
+ ...WriteFunctionsWithMore,
135
+ ...(0, derived_functions_1.functionInfosFromProps)(built_in_props_1.CallProp.File | built_in_props_1.CallProp.Writes, [...WriteFunctionsWithMore, ...other_path_functions_1.OtherPathFunctions, ...read_functions_1.ReadFunctions])
136
+ ];
144
137
  //# sourceMappingURL=write-functions.js.map
@@ -4,7 +4,10 @@ exports.executeGuessDepVersionsQuery = executeGuessDepVersionsQuery;
4
4
  const guess_dep_versions_query_format_1 = require("./guess-dep-versions-query-format");
5
5
  const r_version_1 = require("../../../util/r-version");
6
6
  const objects_1 = require("../../../util/objects");
7
+ const visualize_functions_1 = require("../dependencies-query/function-info/visualize-functions");
7
8
  const dependency_version_space_1 = require("../../../project/dependency-version-space");
9
+ /** flowR's curated builtin-library function to package map (e.g. `ggplot` to `ggplot2`), disambiguating an orphan call several packages re-export */
10
+ const BuiltinLibraryByFunction = new Map(visualize_functions_1.VisualizeFunctions.filter(f => f.package !== undefined).map(f => [f.name, f.package]));
8
11
  /** the sources `query` disables: `clean` is sugar for disabling `declared`+`transitive`, `disabled` adds any others by name */
9
12
  function disabledSources(query) {
10
13
  if (!query.clean && !query.disabled?.length) {
@@ -99,7 +102,7 @@ function rangeString(survivors, nonContiguous, unsatisfiable, declaredRange, dec
99
102
  return survivors.length <= cap ? survivors.join(', ') : `${min}...${max} (${survivors.length} discrete)`;
100
103
  }
101
104
  /** build the reported guess for one package from its already-computed surviving versions and provenance */
102
- function guessPackage(name, cap, surviving, evidence, { used, linkedWith, coupledWith }) {
105
+ function guessPackage(name, cap, surviving, evidence, { used, linkedWith, coupledWith, orphanFunctions, orphanAlternatives }) {
103
106
  const { declaredRange, declaredConstraints, unsatisfiable } = surviving;
104
107
  const survivors = surviving.survivors.map(e => e.ver);
105
108
  const preSignature = surviving.preSignature.map(e => e.ver);
@@ -121,6 +124,10 @@ function guessPackage(name, cap, surviving, evidence, { used, linkedWith, couple
121
124
  unsatisfiable: unsatisfiable ? true : undefined,
122
125
  linkedWith: linkedWith && linkedWith.length > 0 ? linkedWith : undefined,
123
126
  coupledWith: coupledWith && coupledWith.length > 0 ? coupledWith : undefined,
127
+ known: surviving.known ? undefined : false,
128
+ orphan: orphanFunctions && orphanFunctions.length > 0 ? true : undefined,
129
+ orphanFunctions: orphanFunctions && orphanFunctions.length > 0 ? orphanFunctions : undefined,
130
+ orphanAlternatives: orphanAlternatives && orphanAlternatives.length > 0 ? orphanAlternatives : undefined,
124
131
  used
125
132
  });
126
133
  }
@@ -150,9 +157,14 @@ async function executeGuessDepVersionsQuery({ analyzer }, queries) {
150
157
  }
151
158
  // bound base packages by R only when the version is genuinely known; in `auto` mode with nothing detected, base tries every R release
152
159
  const rVersion = ctx.rVersionKnown ? (ctx.meta.getRVersion() ?? ctx.resolvedRVersion) : undefined;
153
- const usage = (0, dependency_version_space_1.collectUsage)((await analyzer.dataflow()).graph, deps);
154
160
  // the analyzed package guesses versions for its dependencies, not for itself
155
161
  const self = ctx.meta.getNamespace();
162
+ const graph = (await analyzer.dataflow()).graph;
163
+ const usage = (0, dependency_version_space_1.collectUsage)(graph, deps);
164
+ // fold orphan calls (`ggplot()` with ggplot2 neither declared nor loaded) into usage; a package the project does
165
+ // not already know is flagged for downstream attachment (see collectOrphanUsage)
166
+ const known = new Set([...deps.getDependencies().map(d => d.name), ...deps.declaredPackageNames()]);
167
+ const orphans = (0, dependency_version_space_1.collectOrphanUsage)(graph, deps, usage, pkg => known.has(pkg), { self, builtinLibraryOf: name => BuiltinLibraryByFunction.get(name) });
156
168
  const sorted = (query.packages && query.packages.length > 0 ? [...query.packages] : (0, dependency_version_space_1.defaultTargets)(deps, usage)).filter(name => name !== self).sort();
157
169
  const disabled = disabledSources(query);
158
170
  const space = new dependency_version_space_1.VersionSpace({ deps, usage, cutoff, rVersion, disabled });
@@ -222,13 +234,31 @@ async function executeGuessDepVersionsQuery({ analyzer }, queries) {
222
234
  coupledWith.set(pkg, [...coupledWith.get(pkg) ?? [], c.always ? partner : `${partner} (partial)`]);
223
235
  }
224
236
  }
237
+ // the packages an orphan could have meant instead, resolved in a space of their own so that reporting them
238
+ // does not turn them into dependencies of the project; built only when an orphan actually had a choice
239
+ const altSpace = orphans.alternativeUsage.size > 0
240
+ ? new dependency_version_space_1.VersionSpace({ deps, usage: orphans.alternativeUsage, cutoff, rVersion, disabled }) : undefined;
241
+ const orphanAlternatives = (pkg) => (orphans.alternatives.get(pkg) ?? []).map(alt => {
242
+ const s = altSpace.survivors(alt, []);
243
+ const versions = s.survivors.map(e => e.ver);
244
+ return (0, objects_1.compactRecord)({
245
+ package: alt,
246
+ range: rangeString(versions, false, s.unsatisfiable, s.declaredRange, s.declaredConstraints, cap),
247
+ minVersion: versions[0],
248
+ maxVersion: versions[versions.length - 1],
249
+ candidateCount: versions.length,
250
+ totalVersions: s.total
251
+ });
252
+ });
225
253
  const dependencies = [];
226
254
  const ordered = [];
227
255
  for (const g of guessedAll) {
228
256
  dependencies.push(guessPackage(g.name, cap, g.surviving, g.evidence, {
229
257
  used: usage.has(g.name),
230
258
  linkedWith: linkedWith.get(g.name),
231
- coupledWith: coupledWith.get(g.name)
259
+ coupledWith: coupledWith.get(g.name),
260
+ orphanFunctions: [...orphans.attributed.get(g.name) ?? []].sort(),
261
+ orphanAlternatives: orphanAlternatives(g.name)
232
262
  }));
233
263
  const oc = query.explode ? (0, dependency_version_space_1.orderedCandidatesOf)(space.resolve(g.name).src, g.name, g.surviving, query.explode.prefer?.[g.name], explodeOrder) : undefined;
234
264
  if (oc) {
@@ -56,6 +56,16 @@ export type GuessEvidenceSource = ConstraintSource;
56
56
  * it can answer "it must be `>= 4.2.0` because ...". This is the resolver's {@link DerivedConstraint}.
57
57
  */
58
58
  export type GuessVersionEvidence = DerivedConstraint;
59
+ /** one package an orphan call could have meant instead, with the versions of it that fit those calls */
60
+ export interface OrphanAlternativeView {
61
+ readonly package: string;
62
+ /** the version range of this package that would accept the orphan calls, in the notation {@link GuessedDependency.range} uses */
63
+ readonly range: string;
64
+ readonly minVersion?: string;
65
+ readonly maxVersion?: string;
66
+ readonly candidateCount: number;
67
+ readonly totalVersions: number;
68
+ }
59
69
  /** the guessed version range of one dependency */
60
70
  export interface GuessedDependency {
61
71
  readonly package: string;
@@ -93,6 +103,27 @@ export interface GuessedDependency {
93
103
  * no direct `zoo::`/`library(zoo)` call.
94
104
  */
95
105
  readonly used?: boolean;
106
+ /**
107
+ * Set to `false` when the signature database has no record of the package at all (e.g. a Bioconductor package),
108
+ * distinguishing it from one the database carries but cannot constrain. Such a package has no `minVersion`/`maxVersion`
109
+ * and never appears in {@link GuessDepVersionsQueryResult.assignments}, so a consumer should resolve it by other means.
110
+ */
111
+ readonly known?: boolean;
112
+ /**
113
+ * Set when this package was inferred purely from *orphan* calls: bare calls (`ggplot()`) that flowR could not
114
+ * resolve and that no loaded package defines, but whose name is exported by exactly this one package in the
115
+ * signature database. The symbol would be undefined were the package not loaded, so a downstream handler may
116
+ * attach `library(package)`. See {@link orphanFunctions} for the calls that implicated it.
117
+ */
118
+ readonly orphan?: boolean;
119
+ /** the undefined orphan function names that inferred this package (only set when {@link orphan}), e.g. `['ggplot']` */
120
+ readonly orphanFunctions?: readonly string[];
121
+ /**
122
+ * The other packages that export the {@link orphanFunctions}, each with the versions of it that would fit the
123
+ * calls. Attributing an orphan is a guess: the most downloaded exporter wins, and these are the ones it beat,
124
+ * so whoever reads the result can pick another. Ordered as the guess ranked them, best first.
125
+ */
126
+ readonly orphanAlternatives?: readonly OrphanAlternativeView[];
96
127
  }
97
128
  export interface GuessDepVersionsQueryResult extends BaseQueryResult {
98
129
  readonly dependencies: readonly GuessedDependency[];
@@ -278,9 +278,11 @@ exports.GuessDepVersionsQueryDefinition = {
278
278
  const coupled = dep.coupledWith ?? [];
279
279
  const groupTag = (dep.base ? ' ' + (0, ansi_1.italic)('[base]', formatter)
280
280
  : dep.linkedWith ? ' ' + (0, ansi_1.italic)(`[linked: ${dep.linkedWith.join(', ')}]`, formatter) : '')
281
- + (coupled.length > 0 ? ' ' + (0, ansi_1.italic)(`[coupled: ${truncatedList(coupled, 3)}]`, formatter) : '');
281
+ + (coupled.length > 0 ? ' ' + (0, ansi_1.italic)(`[coupled: ${truncatedList(coupled, 3)}]`, formatter) : '')
282
+ + (dep.orphan ? ' ' + (0, ansi_1.color)(`[orphan: attach library(${dep.package}) for ${truncatedList(dep.orphanFunctions ?? [], 3)}]`, 3 /* Colors.Yellow */, formatter) : '');
282
283
  const anyVersion = coupled.length > 0 ? '(any version on its own)' : '(any version)';
283
- const note = dep.base ? '' : dep.used === false ? ' ' + (0, ansi_1.faint)('(not called)', formatter) : !isConstrained(dep) && dep.totalVersions ? ' ' + (0, ansi_1.faint)(anyVersion, formatter) : '';
284
+ const note = dep.known === false ? ' ' + (0, ansi_1.color)('(not in database)', 1 /* Colors.Red */, formatter)
285
+ : dep.base ? '' : dep.used === false ? ' ' + (0, ansi_1.faint)('(not called)', formatter) : !isConstrained(dep) && dep.totalVersions ? ' ' + (0, ansi_1.faint)(anyVersion, formatter) : '';
284
286
  const tag = groupTag + note;
285
287
  const range = dep.unsatisfiable ? (0, ansi_1.color)('unsatisfiable', 1 /* Colors.Red */, formatter) : (0, ansi_1.bold)(dep.range, formatter);
286
288
  const count = dep.totalVersions !== undefined ? `${dep.candidateCount}/${dep.totalVersions} versions` : `${dep.candidateCount} candidate${dep.candidateCount === 1 ? '' : 's'}`;
@@ -288,6 +290,11 @@ exports.GuessDepVersionsQueryDefinition = {
288
290
  const dbGe = versionBound(tightestBound(avail, '>='))?.ver, dbLe = versionBound(tightestBound(avail, '<='))?.ver;
289
291
  const dbRange = dbGe !== undefined && dbLe !== undefined ? `, db ${dbGe} - ${dbLe}` : '';
290
292
  result.push(` ${(0, ansi_1.bold)('━ ' + dep.package, formatter)}${tag} ${range} ${(0, ansi_1.faint)('(' + count + dbRange + ')', formatter)}`);
293
+ if (dep.orphanAlternatives?.length) {
294
+ // attributing an orphan is a guess, so name the exporters it beat and what each of them would fit
295
+ const alts = dep.orphanAlternatives.map(a => `${a.package} ${a.range}`);
296
+ result.push(` ${(0, ansi_1.italic)('or instead', formatter)}: ${truncatedList(alts, 4)}`);
297
+ }
291
298
  // only enforced evidence sets the tightest bound; a partial one narrows nothing and must not hide a real bound
292
299
  const enforced = dep.evidence.filter(e => !e.partial);
293
300
  const tightestGe = versionBound(tightestBound(enforced, '>='))?.ver;
@@ -1,5 +1,5 @@
1
- import { Identifier } from '../../../dataflow/environments/identifier';
2
1
  import type { LinkedInputEntryPoint, LinkedInputObject, NarrowingFunction } from './simple-input-classifier';
2
+ import { BuiltInIndex } from '../../../dataflow/environments/query-fn-props';
3
3
  /**
4
4
  * Objects that a framework binds for its users, without a definition visible in the code.
5
5
  * The `withParams` and `requires` guards keep ordinary functions that happen to have a parameter of the same
@@ -7,17 +7,15 @@ import type { LinkedInputEntryPoint, LinkedInputObject, NarrowingFunction } from
7
7
  * @see {@link LinkedInputObject}
8
8
  */
9
9
  export declare const LinkedInputObjects: readonly LinkedInputObject[];
10
- export declare const NarrowingFunctions: readonly NarrowingFunction[];
10
+ /**
11
+ * The functions whose result is bounded no matter what flows in, read back from the {@link CallProp.Narrows}
12
+ * built-ins: with an {@link ArgProp.Bounds} parameter the result is one of that argument's values (`match.arg`
13
+ * and its `choices`), without one it is a count, an index, or a logical of the call's own making. Label a
14
+ * built-in `Narrows` (in the {@link DefaultBuiltinConfig} or your own definitions) and it shows up here.
15
+ */
16
+ export declare function narrowingFunctions(index?: BuiltInIndex): readonly NarrowingFunction[];
11
17
  /**
12
18
  * Calls that hand a function to a framework which binds its parameters by position.
13
19
  * @see {@link LinkedInputEntryPoint}
14
20
  */
15
21
  export declare const LinkedInputEntryPoints: readonly LinkedInputEntryPoint[];
16
- export declare const PureFunctions: Identifier[];
17
- export declare const SystemFunctions: Identifier[];
18
- export declare const FfiFunctions: Identifier[];
19
- export declare const LangFunctions: Identifier[];
20
- export declare const OptionsFunctions: Identifier[];
21
- export declare const UserFunctions: Identifier[];
22
- /** R functions that produce temporary file/directory paths (sub-type of {@link InputType.File}). */
23
- export declare const TempFileFunctions: Identifier[];