@eagleoutice/flowr 2.13.2 → 2.13.3

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 (97) hide show
  1. package/README.md +46 -44
  2. package/abstract-interpretation/data-frame/mappers/access-mapper.js +1 -0
  3. package/abstract-interpretation/data-frame/mappers/function-mapper.d.ts +1 -1
  4. package/abstract-interpretation/data-frame/mappers/function-mapper.js +3 -0
  5. package/abstract-interpretation/domains/state-domain-like.d.ts +1 -1
  6. package/config.d.ts +8 -0
  7. package/config.js +9 -1
  8. package/control-flow/control-flow-graph.js +2 -1
  9. package/control-flow/semantic-cfg-guided-visitor.d.ts +1 -1
  10. package/core/steps/all/core/11-normalize-tree-sitter.d.ts +1 -1
  11. package/dataflow/environments/append.d.ts +1 -1
  12. package/dataflow/environments/clone.d.ts +1 -1
  13. package/dataflow/environments/environment.d.ts +28 -4
  14. package/dataflow/environments/environment.js +66 -11
  15. package/dataflow/environments/overwrite.d.ts +1 -1
  16. package/dataflow/eval/resolve/alias-tracking.d.ts +1 -1
  17. package/dataflow/graph/dataflowgraph-builder.d.ts +1 -1
  18. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +1 -1
  19. package/dataflow/internal/process/functions/call/built-in/built-in-attach.js +1 -1
  20. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.d.ts +7 -0
  21. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +51 -0
  22. package/dataflow/internal/process/functions/call/built-in/built-in-eval.d.ts +1 -1
  23. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +1 -1
  24. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.d.ts +1 -1
  25. package/dataflow/internal/process/functions/call/built-in/built-in-library.d.ts +5 -2
  26. package/dataflow/internal/process/functions/call/built-in/built-in-library.js +15 -9
  27. package/dataflow/internal/process/functions/call/built-in/built-in-list.d.ts +1 -1
  28. package/dataflow/internal/process/functions/call/built-in/built-in-quote.d.ts +1 -1
  29. package/dataflow/internal/process/functions/call/built-in/built-in-register-hook.d.ts +1 -1
  30. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-dispatch.d.ts +1 -1
  31. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.d.ts +7 -1
  32. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +9 -2
  33. package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.d.ts +1 -1
  34. package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.js +2 -2
  35. package/dataflow/internal/process/functions/call/built-in/built-in-vector.d.ts +1 -1
  36. package/documentation/doc-readme.js +14 -12
  37. package/documentation/doc-util/doc-normalized-ast.d.ts +1 -1
  38. package/documentation/wiki-dataflow-graph.js +4 -24
  39. package/documentation/wiki-query.js +47 -0
  40. package/documentation/wiki-signature-database.js +3 -2
  41. package/linter/rules/dataframe-access-validation.d.ts +1 -1
  42. package/linter/rules/undefined-symbol-util.js +3 -1
  43. package/linter/rules/undefined-symbol.js +3 -4
  44. package/package.json +21 -9
  45. package/project/context/flowr-analyzer-context.d.ts +4 -4
  46. package/project/context/flowr-analyzer-context.js +3 -3
  47. package/project/context/flowr-analyzer-dependencies-context.d.ts +11 -5
  48. package/project/context/flowr-analyzer-dependencies-context.js +8 -3
  49. package/project/context/flowr-analyzer-meta-context.d.ts +1 -0
  50. package/project/dependency-version-space.d.ts +118 -26
  51. package/project/dependency-version-space.js +343 -87
  52. package/project/plugins/file-plugins/files/flowr-description-file.d.ts +4 -0
  53. package/project/plugins/file-plugins/files/flowr-description-file.js +8 -1
  54. package/project/plugins/file-plugins/files/flowr-rda-file.js +27 -25
  55. package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmd-file-plugin.d.ts +1 -1
  56. package/project/plugins/file-plugins/notebooks/flowr-analyzer-sweave-file-plugin.d.ts +1 -1
  57. package/project/plugins/package-version-plugins/flowr-analyzer-meta-description-file-plugin.js +2 -1
  58. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.d.ts +1 -1
  59. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +4 -4
  60. package/project/plugins/package-version-plugins/package.d.ts +27 -10
  61. package/project/plugins/package-version-plugins/package.js +50 -25
  62. package/project/sigdb/reader.d.ts +26 -16
  63. package/project/sigdb/reader.js +52 -21
  64. package/queries/catalog/dependencies-query/dependencies-query-executor.js +1 -1
  65. package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +2 -2
  66. package/queries/catalog/dependencies-query/dependencies-query-format.js +2 -2
  67. package/queries/catalog/does-call-query/does-call-query-format.d.ts +1 -1
  68. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-executor.js +39 -77
  69. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.d.ts +12 -0
  70. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.js +53 -23
  71. package/queries/catalog/input-sources-query/input-source-functions.d.ts +13 -0
  72. package/queries/catalog/input-sources-query/input-source-functions.js +96 -1
  73. package/queries/catalog/input-sources-query/input-sources-query-executor.js +40 -4
  74. package/queries/catalog/input-sources-query/input-sources-query-format.js +21 -3
  75. package/queries/catalog/input-sources-query/input-types.d.ts +58 -0
  76. package/queries/catalog/input-sources-query/input-types.js +64 -0
  77. package/queries/catalog/input-sources-query/simple-input-classifier.d.ts +62 -52
  78. package/queries/catalog/input-sources-query/simple-input-classifier.js +334 -101
  79. package/queries/catalog/project-query/project-query-executor.js +1 -1
  80. package/queries/catalog/signature-query/signature-query-executor.d.ts +7 -1
  81. package/queries/catalog/signature-query/signature-query-executor.js +112 -39
  82. package/queries/catalog/signature-query/signature-query-format.d.ts +5 -1
  83. package/queries/catalog/signature-query/signature-query-format.js +1 -1
  84. package/queries/catalog/signature-query/signature-query-render.js +8 -3
  85. package/r-bridge/lang-4.x/ast/parser/json/format.js +1 -1
  86. package/r-bridge/retriever.d.ts +1 -1
  87. package/search/flowr-search-printer.js +10 -8
  88. package/slicing/static/static-slicer.d.ts +2 -2
  89. package/util/objects.js +6 -4
  90. package/util/r-base-packages.d.ts +2 -0
  91. package/util/r-base-packages.js +3 -0
  92. package/util/r-license.js +1 -4
  93. package/util/r-version.d.ts +12 -0
  94. package/util/r-version.js +16 -0
  95. package/util/range.d.ts +6 -2
  96. package/util/range.js +33 -15
  97. package/util/version.js +1 -1
@@ -92,6 +92,13 @@ class FlowrDescriptionFile extends flowr_file_1.FlowrFile {
92
92
  const suggests = this.content().get('Suggests');
93
93
  return suggests ? parsePackagesWithVersions(suggests, 'package') : undefined;
94
94
  }
95
+ /**
96
+ * Returns the parsed enhanced packages from the 'Enhances' field in the DESCRIPTION file.
97
+ */
98
+ enhances() {
99
+ const enhances = this.content().get('Enhances');
100
+ return enhances ? parsePackagesWithVersions(enhances, 'package') : undefined;
101
+ }
95
102
  /**
96
103
  * Returns the 'Collate' field from the DESCRIPTION file.
97
104
  */
@@ -157,7 +164,7 @@ function emplaceDCF(key, val, result) {
157
164
  if (!key) {
158
165
  return;
159
166
  }
160
- let values = [];
167
+ let values;
161
168
  if (key.includes('@')) {
162
169
  values = [val.trim()];
163
170
  }
@@ -1235,13 +1235,13 @@ class RDAParser {
1235
1235
  }
1236
1236
  break;
1237
1237
  default: {
1238
- let t = 0;
1239
- for (let done = 0; done < len; done += t) {
1240
- t = Math.min(RDAParser.CHUNK_SIZE, len - done);
1238
+ for (let done = 0; done < len;) {
1239
+ const t = Math.min(RDAParser.CHUNK_SIZE, len - done);
1241
1240
  for (let i = 0; i < t; i++) {
1242
1241
  result[done + i] = this.buffer[this.offset];
1243
1242
  this.offset += 1;
1244
1243
  }
1244
+ done += t;
1245
1245
  }
1246
1246
  }
1247
1247
  }
@@ -1260,12 +1260,12 @@ class RDAParser {
1260
1260
  }
1261
1261
  }
1262
1262
  else {
1263
- let t = 0;
1264
- for (let done = 0; done < len; done += t) {
1265
- t = Math.min(RDAParser.CHUNK_SIZE, len - done);
1263
+ for (let done = 0; done < len;) {
1264
+ const t = Math.min(RDAParser.CHUNK_SIZE, len - done);
1266
1265
  for (let i = 0; i < t; i++) {
1267
1266
  this.offset += 1;
1268
1267
  }
1268
+ done += t;
1269
1269
  }
1270
1270
  }
1271
1271
  }
@@ -1619,10 +1619,9 @@ class RDAParser {
1619
1619
  switch (this.format) {
1620
1620
  case SerializationFormat.Xdr:
1621
1621
  {
1622
- let t = 0;
1623
1622
  const result = [];
1624
- for (let done = 0; done < len; done += t) {
1625
- t = Math.min(RDAParser.CHUNK_SIZE, len - done);
1623
+ for (let done = 0; done < len;) {
1624
+ const t = Math.min(RDAParser.CHUNK_SIZE, len - done);
1626
1625
  for (let cnt = 0; cnt < t; cnt++) {
1627
1626
  if (this.offset + 4 > this.buffer.length) {
1628
1627
  throw new Error('XDR read failed');
@@ -1630,6 +1629,7 @@ class RDAParser {
1630
1629
  result[done + cnt] = this.buffer.readInt32BE(this.offset);
1631
1630
  this.offset += 4;
1632
1631
  }
1632
+ done += t;
1633
1633
  }
1634
1634
  return result;
1635
1635
  }
@@ -1658,15 +1658,15 @@ class RDAParser {
1658
1658
  switch (this.format) {
1659
1659
  case SerializationFormat.Xdr:
1660
1660
  {
1661
- let t = 0;
1662
- for (let done = 0; done < len; done += t) {
1663
- t = Math.min(RDAParser.CHUNK_SIZE, len - done);
1661
+ for (let done = 0; done < len;) {
1662
+ const t = Math.min(RDAParser.CHUNK_SIZE, len - done);
1664
1663
  for (let cnt = 0; cnt < t; cnt++) {
1665
1664
  if (this.offset + 4 > this.buffer.length) {
1666
1665
  throw new Error('XDR read failed');
1667
1666
  }
1668
1667
  this.offset += 4;
1669
1668
  }
1669
+ done += t;
1670
1670
  }
1671
1671
  break;
1672
1672
  }
@@ -1693,9 +1693,8 @@ class RDAParser {
1693
1693
  switch (this.format) {
1694
1694
  case SerializationFormat.Xdr: {
1695
1695
  const result = [];
1696
- let t = 0;
1697
- for (let done = 0; done < len; done += t) {
1698
- t = Math.min(RDAParser.CHUNK_SIZE, len - done);
1696
+ for (let done = 0; done < len;) {
1697
+ const t = Math.min(RDAParser.CHUNK_SIZE, len - done);
1699
1698
  const chunkBytes = t * RDAParser.SIZE_OF_DOUBLE;
1700
1699
  const chunk = this.buffer.subarray(this.offset, this.offset + chunkBytes);
1701
1700
  this.offset += chunkBytes;
@@ -1703,6 +1702,7 @@ class RDAParser {
1703
1702
  const value = chunk.readDoubleBE(i * RDAParser.SIZE_OF_DOUBLE);
1704
1703
  result.push(value);
1705
1704
  }
1705
+ done += t;
1706
1706
  }
1707
1707
  return result;
1708
1708
  }
@@ -1730,11 +1730,11 @@ class RDAParser {
1730
1730
  skipRealVec(len) {
1731
1731
  switch (this.format) {
1732
1732
  case SerializationFormat.Xdr: {
1733
- let t = 0;
1734
- for (let done = 0; done < len; done += t) {
1735
- t = Math.min(RDAParser.CHUNK_SIZE, len - done);
1733
+ for (let done = 0; done < len;) {
1734
+ const t = Math.min(RDAParser.CHUNK_SIZE, len - done);
1736
1735
  const chunkBytes = t * RDAParser.SIZE_OF_DOUBLE;
1737
1736
  this.offset += chunkBytes;
1737
+ done += t;
1738
1738
  }
1739
1739
  break;
1740
1740
  }
@@ -1822,12 +1822,12 @@ class RDAParser {
1822
1822
  switch (this.format) {
1823
1823
  case SerializationFormat.Xdr: {
1824
1824
  const result = [];
1825
- let t = 0;
1826
- for (let done = 0; done < len; done += t) {
1827
- t = Math.min(RDAParser.CHUNK_SIZE, len - done);
1825
+ for (let done = 0; done < len;) {
1826
+ const t = Math.min(RDAParser.CHUNK_SIZE, len - done);
1828
1827
  for (let cnt = 0; cnt < t; cnt++) {
1829
1828
  result[done] = this.inComplex();
1830
1829
  }
1830
+ done += t;
1831
1831
  }
1832
1832
  return result;
1833
1833
  }
@@ -1853,12 +1853,12 @@ class RDAParser {
1853
1853
  skipComplexVec(len) {
1854
1854
  switch (this.format) {
1855
1855
  case SerializationFormat.Xdr: {
1856
- let t = 0;
1857
- for (let done = 0; done < len; done += t) {
1858
- t = Math.min(RDAParser.CHUNK_SIZE, len - done);
1856
+ for (let done = 0; done < len;) {
1857
+ const t = Math.min(RDAParser.CHUNK_SIZE, len - done);
1859
1858
  for (let cnt = 0; cnt < t; cnt++) {
1860
1859
  this.skipComplex();
1861
1860
  }
1861
+ done += t;
1862
1862
  }
1863
1863
  break;
1864
1864
  }
@@ -2146,6 +2146,7 @@ class RDAParser {
2146
2146
  this.skipInteger();
2147
2147
  type = this.assertInteger(this.inInteger());
2148
2148
  }
2149
+ /* eslint-disable no-useless-assignment -- mirrors the read path */
2149
2150
  switch (type) {
2150
2151
  case SexpType.AltLangSxp:
2151
2152
  type = SexpType.LangSxp;
@@ -2156,6 +2157,7 @@ class RDAParser {
2156
2157
  hasAttr = true;
2157
2158
  break;
2158
2159
  }
2160
+ /* eslint-enable no-useless-assignment */
2159
2161
  this.currentDepth++;
2160
2162
  if (hasAttr) {
2161
2163
  this.skipItem();
@@ -2376,7 +2378,7 @@ class RDAParser {
2376
2378
  }
2377
2379
  const name = n.tag?.name;
2378
2380
  if (name !== undefined) {
2379
- let copy = {};
2381
+ let copy;
2380
2382
  if (shortcut) {
2381
2383
  copy = {
2382
2384
  name: n.tag.name,
@@ -1,7 +1,7 @@
1
1
  import type { PathLike } from 'fs';
2
2
  import { SemVer } from 'semver';
3
3
  import type { FlowrAnalyzerContext } from '../../../context/flowr-analyzer-context';
4
- import { type FlowrFileProvider } from '../../../context/flowr-file';
4
+ import type { FlowrFileProvider } from '../../../context/flowr-file';
5
5
  import { FlowrAnalyzerFilePlugin } from '../flowr-analyzer-file-plugin';
6
6
  import { FlowrRMarkdownFile } from '../files/flowr-rmarkdown-file';
7
7
  export declare const RmdPattern: RegExp;
@@ -1,7 +1,7 @@
1
1
  import type { PathLike } from 'fs';
2
2
  import { SemVer } from 'semver';
3
3
  import type { FlowrAnalyzerContext } from '../../../context/flowr-analyzer-context';
4
- import { type FlowrFileProvider } from '../../../context/flowr-file';
4
+ import type { FlowrFileProvider } from '../../../context/flowr-file';
5
5
  import { FlowrAnalyzerFilePlugin } from '../flowr-analyzer-file-plugin';
6
6
  import { FlowrSweaveFile } from '../files/flowr-sweave-file';
7
7
  /**
@@ -38,7 +38,8 @@ class FlowrAnalyzerMetaDescriptionFilePlugin extends flowr_analyzer_package_vers
38
38
  imports: deps.imports(),
39
39
  depends: deps.depends(),
40
40
  suggests: deps.suggests(),
41
- linkingTo: deps.linkingTo()
41
+ linkingTo: deps.linkingTo(),
42
+ enhances: deps.enhances()
42
43
  }
43
44
  }, flowr_analyzer_meta_context_1.MetaPriority.Description);
44
45
  }
@@ -80,7 +80,7 @@ export declare class FlowrAnalyzerPackageVersionsSigDbPlugin extends FlowrAnalyz
80
80
  private buildExportIndex;
81
81
  /**
82
82
  * The raw sources in priority order: explicit constructor sources, `$FLOWR_SIGDB`, then **every** bundled
83
- * database discovered in the data dirs (see {@link defaultSigDbPaths}) -- so an extra bundle dropped next to
83
+ * database discovered in the data dirs (see {@link defaultSigDbPaths}), so an extra bundle dropped next to
84
84
  * the default (e.g. a downloaded full-history one) is mounted automatically. All bundled defaults are skipped
85
85
  * when `$FLOWR_DISABLE_DEFAULT_SIGDB` is set; explicit sources are always honored.
86
86
  */
@@ -183,7 +183,7 @@ class FlowrAnalyzerPackageVersionsSigDbPlugin extends flowr_analyzer_package_ver
183
183
  if (!dl.sigDbNeedsSync()) {
184
184
  return;
185
185
  }
186
- exports.sigDbLog.info('sigdb: committed link file changed -- re-syncing shards in the background');
186
+ exports.sigDbLog.info('sigdb: committed link file changed, re-syncing shards in the background');
187
187
  const { files } = await dl.downloadFullSigDb({
188
188
  repo: ctx.config.solver.sigdb.downloadRepo,
189
189
  onProgress: msg => exports.sigDbLog.info(`sigdb sync: ${msg}`)
@@ -286,7 +286,7 @@ class FlowrAnalyzerPackageVersionsSigDbPlugin extends flowr_analyzer_package_ver
286
286
  }
287
287
  /**
288
288
  * The raw sources in priority order: explicit constructor sources, `$FLOWR_SIGDB`, then **every** bundled
289
- * database discovered in the data dirs (see {@link defaultSigDbPaths}) -- so an extra bundle dropped next to
289
+ * database discovered in the data dirs (see {@link defaultSigDbPaths}), so an extra bundle dropped next to
290
290
  * the default (e.g. a downloaded full-history one) is mounted automatically. All bundled defaults are skipped
291
291
  * when `$FLOWR_DISABLE_DEFAULT_SIGDB` is set; explicit sources are always honored.
292
292
  */
@@ -305,7 +305,7 @@ class FlowrAnalyzerPackageVersionsSigDbPlugin extends flowr_analyzer_package_ver
305
305
  loadSources(config) {
306
306
  const cfg = config ?? this.analyzerCtx?.config;
307
307
  // `solver.sigdb.enabled: false` disables the database for this analyzer only: drop any loaded sources so it
308
- // frees memory and every consumer (resolve, base-R link, queries) sees nothing -- other analyzers are untouched.
308
+ // frees memory and every consumer (resolve, base-R link, queries) sees nothing; other analyzers are untouched.
309
309
  // An absent config is the pre-analysis query path (default enabled), so only an explicit `false` disables.
310
310
  if (cfg !== undefined && !(0, config_1.isSigDbEnabled)(cfg)) {
311
311
  if (this.sources !== undefined) {
@@ -402,7 +402,7 @@ class FlowrAnalyzerPackageVersionsSigDbPlugin extends flowr_analyzer_package_ver
402
402
  const sigdb = this.analyzerCtx?.config.solver.sigdb;
403
403
  const override = sigdb?.versionOverrides?.[name];
404
404
  const selection = sigdb?.versionSelection ?? config_1.VersionSelection.Newest;
405
- const range = existing?.derivedVersion;
405
+ const range = existing?.derivedRange;
406
406
  let fallback;
407
407
  for (const src of this.loadSources()) {
408
408
  if (!src.has(name)) {
@@ -1,23 +1,40 @@
1
1
  import { type Range } from 'semver';
2
2
  import type { NamespaceInfo } from '../file-plugins/files/flowr-namespace-file';
3
3
  export type PackageType = 'package' | 'system' | 'r';
4
+ /** what a source can contribute about a package; everything else a {@link Package} exposes is derived from these */
4
5
  export type PackageOptions = {
5
- derivedVersion?: Range;
6
6
  type?: PackageType;
7
7
  dependencies?: Package[];
8
8
  namespaceInfo?: NamespaceInfo;
9
+ /** what this source declared for the package (a `DESCRIPTION` range, a lockfile pin, ...) */
9
10
  versionConstraints?: Range[];
10
11
  /** the concrete version the exports were resolved from (e.g. the package database entry), for information only */
11
12
  resolvedVersion?: string;
12
13
  };
14
+ /**
15
+ * A package as the sources describe it, accumulated with {@link addInfo}/{@link mergeInPlace}: only those may
16
+ * change it, everything else reads. Its three version views run from the rawest to the most concrete:
17
+ * - {@link versionConstraints}: what each source declared, unmerged.
18
+ * - {@link derivedRange}: their intersection, whether or not a version can satisfy it (see
19
+ * {@link hasSatisfiableVersion}, and `inferredRange` on the dependencies context for the range that is only
20
+ * handed out once it is).
21
+ * - {@link resolvedVersion}: the one concrete version the exports were read from.
22
+ */
13
23
  export declare class Package {
14
- name: string;
15
- derivedVersion?: Range;
16
- type?: PackageType;
17
- dependencies?: Package[];
18
- namespaceInfo?: NamespaceInfo;
19
- versionConstraints: Range[];
20
- resolvedVersion?: string;
24
+ readonly name: string;
25
+ private _type?;
26
+ private _dependencies?;
27
+ private _namespaceInfo?;
28
+ private _resolvedVersion?;
29
+ private readonly _versionConstraints;
30
+ /** the intersection of {@link versionConstraints}, computed on demand and dropped whenever one is added */
31
+ private _derivedRange?;
32
+ get type(): PackageType | undefined;
33
+ get dependencies(): readonly Package[] | undefined;
34
+ get namespaceInfo(): NamespaceInfo | undefined;
35
+ get resolvedVersion(): string | undefined;
36
+ get versionConstraints(): readonly Range[];
37
+ get derivedRange(): Range | undefined;
21
38
  constructor(info: {
22
39
  name: string;
23
40
  } & PackageOptions);
@@ -26,9 +43,9 @@ export declare class Package {
26
43
  has(name: string, className?: string): boolean;
27
44
  s3For(generic: string): string[];
28
45
  mergeInPlace(other: Package): void;
29
- addInfo(info: PackageOptions): void;
46
+ addInfo({ type, dependencies, namespaceInfo, versionConstraints, resolvedVersion }: PackageOptions): void;
30
47
  /** The combined (intersected) range of all recorded constraints, or `undefined` if none were given. */
31
- deriveVersion(): Range | undefined;
48
+ private deriveRange;
32
49
  /** Whether some concrete version can satisfy every recorded constraint at once. */
33
50
  hasSatisfiableVersion(): boolean;
34
51
  static parsePkgVersionRange(constraint?: string, version?: string): Range | undefined;
@@ -7,14 +7,43 @@ const flowr_namespace_file_1 = require("../file-plugins/files/flowr-namespace-fi
7
7
  const flowr_file_1 = require("../../context/flowr-file");
8
8
  const r_version_1 = require("../../../util/r-version");
9
9
  const node_id_1 = require("../../../r-bridge/lang-4.x/ast/model/processing/node-id");
10
+ /**
11
+ * A package as the sources describe it, accumulated with {@link addInfo}/{@link mergeInPlace}: only those may
12
+ * change it, everything else reads. Its three version views run from the rawest to the most concrete:
13
+ * - {@link versionConstraints}: what each source declared, unmerged.
14
+ * - {@link derivedRange}: their intersection, whether or not a version can satisfy it (see
15
+ * {@link hasSatisfiableVersion}, and `inferredRange` on the dependencies context for the range that is only
16
+ * handed out once it is).
17
+ * - {@link resolvedVersion}: the one concrete version the exports were read from.
18
+ */
10
19
  class Package {
11
20
  name;
12
- derivedVersion;
13
- type;
14
- dependencies;
15
- namespaceInfo;
16
- versionConstraints = [];
17
- resolvedVersion;
21
+ _type;
22
+ _dependencies;
23
+ _namespaceInfo;
24
+ _resolvedVersion;
25
+ _versionConstraints = [];
26
+ /** the intersection of {@link versionConstraints}, computed on demand and dropped whenever one is added */
27
+ _derivedRange;
28
+ get type() {
29
+ return this._type;
30
+ }
31
+ get dependencies() {
32
+ return this._dependencies;
33
+ }
34
+ get namespaceInfo() {
35
+ return this._namespaceInfo;
36
+ }
37
+ get resolvedVersion() {
38
+ return this._resolvedVersion;
39
+ }
40
+ get versionConstraints() {
41
+ return this._versionConstraints;
42
+ }
43
+ get derivedRange() {
44
+ this._derivedRange ??= this.deriveRange();
45
+ return this._derivedRange;
46
+ }
18
47
  constructor(info) {
19
48
  this.name = info.name;
20
49
  this.addInfo(info);
@@ -55,35 +84,31 @@ class Package {
55
84
  (0, assert_1.guard)(this.name === other.name, 'Can only merge packages with the same name');
56
85
  this.addInfo({
57
86
  type: other.type,
58
- dependencies: other.dependencies,
87
+ dependencies: other._dependencies,
59
88
  namespaceInfo: other.namespaceInfo,
60
- versionConstraints: other.versionConstraints,
89
+ versionConstraints: other._versionConstraints,
61
90
  resolvedVersion: other.resolvedVersion
62
91
  });
63
92
  }
64
- addInfo(info) {
65
- const { type, dependencies, namespaceInfo, versionConstraints, resolvedVersion } = info;
66
- this.resolvedVersion = resolvedVersion ?? this.resolvedVersion;
67
- this.type = type ?? this.type;
68
- this.dependencies = dependencies ?? this.dependencies;
69
- this.namespaceInfo = namespaceInfo ?? this.namespaceInfo;
70
- if (versionConstraints !== undefined) {
71
- for (const constraint of versionConstraints) {
72
- this.versionConstraints.push(constraint);
73
- }
74
- // sources may disagree, which `hasSatisfiableVersion` reports rather than this failing
75
- this.derivedVersion = this.deriveVersion() ?? this.derivedVersion;
93
+ addInfo({ type, dependencies, namespaceInfo, versionConstraints, resolvedVersion }) {
94
+ this._resolvedVersion = resolvedVersion ?? this._resolvedVersion;
95
+ this._type = type ?? this._type;
96
+ this._dependencies = dependencies ?? this._dependencies;
97
+ this._namespaceInfo = namespaceInfo ?? this._namespaceInfo;
98
+ if (versionConstraints !== undefined && versionConstraints.length > 0) {
99
+ this._versionConstraints.push(...versionConstraints);
100
+ this._derivedRange = undefined; // re-derived on the next read, once every source has had its say
76
101
  }
77
102
  }
78
103
  /** The combined (intersected) range of all recorded constraints, or `undefined` if none were given. */
79
- deriveVersion() {
80
- return this.versionConstraints.length > 0
81
- ? r_version_1.RRange.parse(this.versionConstraints.map(c => c.raw).join(' '))
82
- : undefined;
104
+ deriveRange() {
105
+ // sources may disagree, which `hasSatisfiableVersion` reports rather than this failing
106
+ return r_version_1.RRange.intersect(this._versionConstraints);
83
107
  }
84
108
  /** Whether some concrete version can satisfy every recorded constraint at once. */
85
109
  hasSatisfiableVersion() {
86
- return this.derivedVersion !== undefined && (0, semver_1.minVersion)(this.derivedVersion) !== null;
110
+ const range = this.derivedRange;
111
+ return range !== undefined && (0, semver_1.minVersion)(range) !== null;
87
112
  }
88
113
  static parsePkgVersionRange(constraint, version) {
89
114
  if (version) {
@@ -21,7 +21,7 @@ export interface PackageSignatureSource {
21
21
  /** the export view of a package version (defaults to its latest) */
22
22
  lookup(pkg: string, version?: string): LibraryExports | undefined;
23
23
  /**
24
- * The package that OWNS the class `className` -- an S3 class (a same-named constructor plus a registered method,
24
+ * The package that OWNS the class `className`: an S3 class (a same-named constructor plus a registered method,
25
25
  * see {@link LibraryExports.s3Classes}) or an S4 class (exported via `exportClasses`, see
26
26
  * {@link LibraryExports.s4Classes}); S3 ownership wins a tie. `undefined` if none does. Without `version`, backed
27
27
  * by a reverse index over every package's latest version, built once and cached.
@@ -72,6 +72,16 @@ export interface ShardStatus {
72
72
  * version-guessing query build on.
73
73
  */
74
74
  export declare function availableVersionEntries(src: PackageSignatureSource, pkg: string): AvailableVersion[];
75
+ /**
76
+ * The reverse index `class -> owning package` over `candidates`, at each one's latest version. S3 ownership (a
77
+ * same-named constructor plus a registered method) is a stronger signal than an S4 `exportClasses`, so S3-owned
78
+ * classes are indexed first and an S4 class only claims a name no S3 owner already took.
79
+ *
80
+ * Restricting the candidates is the targeted counterpart of {@link PackageSignatureSource.classOwner}: class names
81
+ * collide heavily across CRAN, so a whole-database answer is decided by database order, and deriving one means
82
+ * reading every package in the database.
83
+ */
84
+ export declare function classOwnerIndexFor(src: PackageSignatureSource, candidates: Iterable<string>): Map<string, string>;
75
85
  /** union view over multiple sources for the same package; routes queries to the appropriate source */
76
86
  export declare class MergedSignatureSource implements PackageSignatureSource {
77
87
  private readonly sources;
@@ -115,12 +125,6 @@ export interface OpenSyncOptions {
115
125
  export interface OpenSyncFromOptions extends SigDbOpenOptions, OpenSyncOptions {
116
126
  hash?: string;
117
127
  }
118
- /**
119
- * Fast, partial reader for a single bundle. `open()`/`openSync()` load the string dictionary + `.idx`
120
- * once (a single ranged read of the dictionary section -- no full parse), then every query seeks straight
121
- * to one package blob on demand. `open()` additionally decompresses a `.br`/`.gz` source into a
122
- * hash-keyed cache and reuses it on later startups. Implements {@link PackageSignatureSource}.
123
- */
124
128
  export declare class SigDatabase implements PackageSignatureSource {
125
129
  private closed;
126
130
  /** parsed blobs by blob index so repeated lookups skip the re-read + JSON.parse; FIFO-bounded to cap memory */
@@ -134,10 +138,16 @@ export declare class SigDatabase implements PackageSignatureSource {
134
138
  readonly content: SigDbContent | undefined;
135
139
  private readonly cranBase;
136
140
  private constructor();
141
+ /**
142
+ * Use an already-built {@link SigDb} directly, without writing or reading a file: its blobs simply start out in
143
+ * the cache. It holds exactly what a bundle carries, so every query answers as it would from disk; the
144
+ * {@link SigDbBuilder} plus this is all a test needs.
145
+ */
146
+ static fromMemory(db: SigDb): SigDatabase;
137
147
  /**
138
148
  * Open a plain, seekable `.sigs.ndjson` synchronously. Pass `index` to skip reading the `.idx`,
139
149
  * and `strings` to use an already-loaded shared dictionary instead of the file's own `d` section (for a
140
- * blob-only shard). One ranged read loads the dictionary -- no readline overhead.
150
+ * blob-only shard). One ranged read loads the dictionary, no readline overhead.
141
151
  */
142
152
  static openSync(plainFile: string, opts?: OpenSyncOptions): SigDatabase;
143
153
  /** open a `.sigs.ndjson`, `.br` or `.gz`; compressed sources are decompressed into a hash-keyed cache once */
@@ -185,7 +195,7 @@ export declare class SigDatabase implements PackageSignatureSource {
185
195
  /** close the underlying file descriptor (idempotent; safe to call more than once) */
186
196
  close(): void;
187
197
  }
188
- /** options for {@link SigDatabaseSet.openManifest} -- the base cache options plus per-shard enable/disable */
198
+ /** options for {@link SigDatabaseSet.openManifest}: the base cache options plus per-shard enable/disable */
189
199
  export interface SigDbSetOpenOptions extends SigDbOpenOptions {
190
200
  /** only load these shard ids (e.g. `['base-current','current-top']`); omit to load all */
191
201
  includeShards?: readonly string[];
@@ -220,7 +230,7 @@ export declare class SigDatabaseSet implements PackageSignatureSource {
220
230
  private static assemble;
221
231
  static openManifest(manifestFile: string, opts?: SigDbSetOpenOptions): Promise<SigDatabaseSet>;
222
232
  /**
223
- * Synchronous {@link openManifest} -- needs every shard to embed its index (the default for the bundles
233
+ * Synchronous {@link openManifest}, needing every shard to embed its index (the default for the bundles
224
234
  * flowR ships). Shards and dictionaries still decompress lazily.
225
235
  */
226
236
  static openManifestSync(manifestFile: string, opts?: SigDbSetOpenOptions): SigDatabaseSet;
@@ -228,7 +238,7 @@ export declare class SigDatabaseSet implements PackageSignatureSource {
228
238
  private readonly dictCache;
229
239
  /** load (and cache) a shared dictionary's strings, decompressing its `.br` into the cache once */
230
240
  private dictionaryStrings;
231
- /** lazily open a shard -- decompressing its `.br` (and its shared dictionary) into the cache on first access */
241
+ /** lazily open a shard, decompressing its `.br` (and its shared dictionary) into the cache on first access */
232
242
  private shard;
233
243
  /**
234
244
  * Warm the shards (and their shared dictionaries) needed for `pkgs`, or **everything** when omitted.
@@ -244,7 +254,7 @@ export declare class SigDatabaseSet implements PackageSignatureSource {
244
254
  private warmShards;
245
255
  /** the shard indices that can serve this package, preferred order; optionally requiring a specific version */
246
256
  private route;
247
- /** read (once) the blob from the shard with the most complete history -- a `full` or `history` tier if present */
257
+ /** read (once) the blob from the shard with the most complete history: a `full` or `history` tier if present */
248
258
  private historyBlob;
249
259
  has(pkg: string): boolean;
250
260
  /** whether any active shard actually carries the given version of a package (not just the package) */
@@ -254,9 +264,9 @@ export declare class SigDatabaseSet implements PackageSignatureSource {
254
264
  packageNames(): string[];
255
265
  /** the on-demand load state (opened + unpacked) of every shard in this set */
256
266
  shardStatus(): ShardStatus[];
257
- /** open (blocking) and return every shard database with its manifest ref -- used for whole-set verification */
267
+ /** open (blocking) and return every shard database with its manifest ref, for whole-set verification */
258
268
  allShards(): MountedShard[];
259
- /** load (and cache) a shared dictionary's strings by id -- for verification/inspection */
269
+ /** load (and cache) a shared dictionary's strings by id, for verification/inspection */
260
270
  sharedDictionary(id: string): string[];
261
271
  /** the first non-empty result from the shards that can serve `pkg` (in preferred order: current before full) */
262
272
  private firstOf;
@@ -270,7 +280,7 @@ export declare class SigDatabaseSet implements PackageSignatureSource {
270
280
  isBaseR(pkg: string): boolean;
271
281
  /** the R versions a base package was part of core (ascending); `undefined` if not a base package */
272
282
  coreVersions(pkg: string): RVersion[] | undefined;
273
- /** every known release of a package (version + date), ascending -- read once from the most complete shard */
283
+ /** every known release of a package (version + date), ascending, read once from the most complete shard */
274
284
  releaseDates(pkg: string): VersionRelease[];
275
285
  /** the release date of a package version (defaulting to the newest release), or `undefined` if unknown */
276
286
  releaseDate(pkg: string, version?: string): Date | undefined;
@@ -284,7 +294,7 @@ export declare class SigDatabaseSet implements PackageSignatureSource {
284
294
  }
285
295
  /**
286
296
  * Open a path-based source once, process-wide, synchronously. Returns the shared instance (opening it on the
287
- * first call), or `undefined` if the path needs async opening (a `.br`/`.gz` bundle -- use {@link getSharedSigSource}).
297
+ * first call), or `undefined` if the path needs async opening (a `.br`/`.gz` bundle, use {@link getSharedSigSource}).
288
298
  * Throws only if a sync-openable source fails to open.
289
299
  */
290
300
  export declare function getSharedSigSourceSync(source: string): PackageSignatureSource | undefined;