@eagleoutice/flowr 2.10.10 → 2.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -27
- package/cli/common/options.d.ts +2 -108
- package/cli/common/options.js +3 -27
- package/cli/common/scripts-info.d.ts +2 -123
- package/cli/common/scripts-info.js +0 -17
- package/cli/flowr-main-options.d.ts +5 -0
- package/cli/flowr-main-options.js +10 -0
- package/cli/flowr.js +2 -2
- package/cli/repl/commands/repl-commands.js +7 -6
- package/cli/repl/print-version.d.ts +3 -1
- package/cli/repl/print-version.js +21 -2
- package/cli/repl/server/connection.d.ts +2 -0
- package/cli/repl/server/connection.js +40 -31
- package/cli/script-core/summarizer-core.js +13 -32
- package/cli/wiki.d.ts +2 -1
- package/cli/wiki.js +2 -0
- package/config.d.ts +9 -0
- package/config.js +10 -0
- package/control-flow/semantic-cfg-guided-visitor.js +1 -0
- package/core/steps/pipeline/default-pipelines.d.ts +146 -146
- package/data/pkgdb/pkgdb-latest.json.br +0 -0
- package/data/pkgdb/pkgdb-tiny.json.br +0 -0
- package/dataflow/environments/append.d.ts +1 -2
- package/dataflow/environments/append.js +3 -10
- package/dataflow/environments/apply-kill.d.ts +21 -0
- package/dataflow/environments/apply-kill.js +155 -0
- package/dataflow/environments/built-in-proc-name.d.ts +2 -0
- package/dataflow/environments/built-in-proc-name.js +2 -0
- package/dataflow/environments/built-in.d.ts +2 -0
- package/dataflow/environments/built-in.js +2 -0
- package/dataflow/environments/default-builtin-config.d.ts +63 -3
- package/dataflow/environments/default-builtin-config.js +40 -8
- package/dataflow/environments/environment.d.ts +49 -32
- package/dataflow/environments/environment.js +133 -18
- package/dataflow/environments/identifier.d.ts +10 -0
- package/dataflow/environments/identifier.js +23 -0
- package/dataflow/environments/overwrite.js +2 -10
- package/dataflow/environments/resolve-by-name.d.ts +1 -1
- package/dataflow/environments/resolve-by-name.js +10 -2
- package/dataflow/environments/scoping.d.ts +9 -2
- package/dataflow/environments/scoping.js +15 -2
- package/dataflow/extractor.js +23 -2
- package/dataflow/graph/df-helper.d.ts +8 -0
- package/dataflow/graph/df-helper.js +8 -0
- package/dataflow/graph/graph.d.ts +4 -1
- package/dataflow/graph/graph.js +5 -1
- package/dataflow/info.d.ts +26 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-access.js +7 -5
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +19 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-attach.d.ts +1 -8
- package/dataflow/internal/process/functions/call/built-in/built-in-attach.js +7 -13
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.d.ts +9 -48
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +30 -47
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +17 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +6 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.d.ts +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +8 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +9 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-library.d.ts +37 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +391 -21
- package/dataflow/internal/process/functions/call/built-in/built-in-rm.d.ts +2 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +131 -48
- package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.d.ts +25 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.js +94 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +10 -3
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.d.ts +30 -0
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +279 -0
- package/dataflow/internal/process/functions/call/named-call-handling.d.ts +1 -1
- package/dataflow/internal/process/functions/call/named-call-handling.js +17 -0
- package/documentation/data/faq/faqs.js +3 -0
- package/documentation/data/interface/doc-writing-code.js +4 -80
- package/documentation/doc-util/doc-structure.js +1 -2
- package/documentation/wiki-core.js +2 -1
- package/documentation/wiki-dataflow-graph.js +35 -1
- package/documentation/wiki-interface.js +2 -2
- package/documentation/wiki-linter.js +2 -0
- package/documentation/wiki-overview.js +1 -14
- package/documentation/wiki-package-database.d.ts +9 -0
- package/documentation/wiki-package-database.js +63 -0
- package/documentation/wiki-query.js +1 -0
- package/linter/linter-rules.d.ts +23 -0
- package/linter/linter-rules.js +3 -1
- package/linter/rules/absolute-path.js +2 -1
- package/linter/rules/undefined-symbol.d.ts +39 -0
- package/linter/rules/undefined-symbol.js +80 -0
- package/package.json +4 -4
- package/project/cache/flowr-analyzer-cache.d.ts +2 -0
- package/project/cache/flowr-analyzer-cache.js +9 -1
- package/project/context/flowr-analyzer-dependencies-context.d.ts +16 -8
- package/project/context/flowr-analyzer-dependencies-context.js +39 -4
- package/project/context/flowr-analyzer-environment-context.d.ts +2 -4
- package/project/context/flowr-analyzer-environment-context.js +3 -4
- package/project/context/flowr-analyzer-files-context.d.ts +1 -0
- package/project/context/flowr-file.d.ts +2 -0
- package/project/context/flowr-file.js +2 -0
- package/project/flowr-analyzer-builder.js +3 -0
- package/project/flowr-analyzer.d.ts +2 -1
- package/project/flowr-analyzer.js +3 -1
- package/project/plugins/file-plugins/files/flowr-namespace-file.d.ts +13 -15
- package/project/plugins/file-plugins/files/flowr-namespace-file.js +36 -13
- package/project/plugins/file-plugins/flowr-analyzer-virtualenv-file-plugin.d.ts +27 -0
- package/project/plugins/file-plugins/flowr-analyzer-virtualenv-file-plugin.js +41 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-lockfile-plugin.d.ts +18 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-lockfile-plugin.js +62 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-pkgdb-plugin.d.ts +63 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-pkgdb-plugin.js +176 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-plugin.d.ts +10 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-plugin.js +6 -0
- package/project/plugins/package-version-plugins/package.d.ts +3 -0
- package/project/plugins/package-version-plugins/package.js +12 -0
- package/project/plugins/package-version-plugins/pkgdb.d.ts +133 -0
- package/project/plugins/package-version-plugins/pkgdb.js +370 -0
- package/project/plugins/plugin-registry.d.ts +4 -1
- package/project/plugins/plugin-registry.js +7 -0
- package/queries/catalog/call-context-query/call-context-query-executor.js +8 -0
- package/queries/catalog/call-context-query/call-context-query-format.d.ts +2 -0
- package/queries/catalog/call-context-query/call-context-query-format.js +1 -0
- package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +8 -0
- package/queries/catalog/dependencies-query/dependencies-query-executor.js +31 -3
- package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +3 -1
- package/queries/catalog/dependencies-query/dependencies-query-format.js +3 -2
- package/queries/catalog/dependencies-query/function-info/function-info.d.ts +1 -1
- package/queries/catalog/dependencies-query/function-info/other-path-functions.d.ts +2 -0
- package/queries/catalog/dependencies-query/function-info/other-path-functions.js +27 -0
- package/queries/catalog/dependencies-query/function-info/read-functions.js +5 -4
- package/queries/catalog/dependencies-query/function-info/visualize-functions.js +3 -1
- package/queries/catalog/linter-query/linter-query-executor.js +1 -0
- package/r-bridge/data/data.d.ts +2 -2
- package/r-bridge/data/data.js +2 -2
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.js +13 -4
- package/search/search-executor/search-enrichers.d.ts +1 -1
- package/search/search-executor/search-enrichers.js +7 -4
- package/util/mermaid/mermaid.d.ts +4 -0
- package/util/mermaid/mermaid.js +8 -1
- package/util/text/ansi.d.ts +10 -1
- package/util/text/ansi.js +17 -4
- package/util/version.js +10 -2
- package/cli/common/features.d.ts +0 -9
- package/cli/common/features.js +0 -35
- package/cli/script-core/statistics-core.d.ts +0 -6
- package/cli/script-core/statistics-core.js +0 -104
- package/cli/script-core/statistics-helper-core.d.ts +0 -6
- package/cli/script-core/statistics-helper-core.js +0 -86
- package/cli/statistics-app.d.ts +0 -11
- package/cli/statistics-app.js +0 -16
- package/cli/statistics-helper-app.d.ts +0 -11
- package/cli/statistics-helper-app.js +0 -14
- package/statistics/features/common-syntax-probability.d.ts +0 -38
- package/statistics/features/common-syntax-probability.js +0 -169
- package/statistics/features/feature.d.ts +0 -179
- package/statistics/features/feature.js +0 -38
- package/statistics/features/post-processing.d.ts +0 -18
- package/statistics/features/post-processing.js +0 -26
- package/statistics/features/supported/assignments/assignments.d.ts +0 -12
- package/statistics/features/supported/assignments/assignments.js +0 -56
- package/statistics/features/supported/assignments/post-process.d.ts +0 -6
- package/statistics/features/supported/assignments/post-process.js +0 -126
- package/statistics/features/supported/comments/comments.d.ts +0 -18
- package/statistics/features/supported/comments/comments.js +0 -143
- package/statistics/features/supported/comments/post-process.d.ts +0 -6
- package/statistics/features/supported/comments/post-process.js +0 -51
- package/statistics/features/supported/control-flow/control-flow.d.ts +0 -17
- package/statistics/features/supported/control-flow/control-flow.js +0 -69
- package/statistics/features/supported/control-flow/post-process.d.ts +0 -6
- package/statistics/features/supported/control-flow/post-process.js +0 -66
- package/statistics/features/supported/data-access/data-access.d.ts +0 -15
- package/statistics/features/supported/data-access/data-access.js +0 -122
- package/statistics/features/supported/data-access/post-process.d.ts +0 -6
- package/statistics/features/supported/data-access/post-process.js +0 -108
- package/statistics/features/supported/defined-functions/defined-functions.d.ts +0 -34
- package/statistics/features/supported/defined-functions/defined-functions.js +0 -145
- package/statistics/features/supported/defined-functions/post-process.d.ts +0 -6
- package/statistics/features/supported/defined-functions/post-process.js +0 -168
- package/statistics/features/supported/expression-list/post-process.d.ts +0 -6
- package/statistics/features/supported/expression-list/post-process.js +0 -45
- package/statistics/features/supported/expression-list/statistics-expression-list.d.ts +0 -9
- package/statistics/features/supported/expression-list/statistics-expression-list.js +0 -37
- package/statistics/features/supported/loops/loops.d.ts +0 -20
- package/statistics/features/supported/loops/loops.js +0 -81
- package/statistics/features/supported/loops/post-process.d.ts +0 -6
- package/statistics/features/supported/loops/post-process.js +0 -73
- package/statistics/features/supported/used-functions/post-process.d.ts +0 -6
- package/statistics/features/supported/used-functions/post-process.js +0 -176
- package/statistics/features/supported/used-functions/used-functions.d.ts +0 -24
- package/statistics/features/supported/used-functions/used-functions.js +0 -99
- package/statistics/features/supported/used-packages/post-process.d.ts +0 -6
- package/statistics/features/supported/used-packages/post-process.js +0 -122
- package/statistics/features/supported/used-packages/used-packages.d.ts +0 -16
- package/statistics/features/supported/used-packages/used-packages.js +0 -140
- package/statistics/features/supported/values/post-process.d.ts +0 -6
- package/statistics/features/supported/values/post-process.js +0 -73
- package/statistics/features/supported/values/values.d.ts +0 -14
- package/statistics/features/supported/values/values.js +0 -111
- package/statistics/features/supported/variables/post-process.d.ts +0 -15
- package/statistics/features/supported/variables/post-process.js +0 -126
- package/statistics/features/supported/variables/variables.d.ts +0 -15
- package/statistics/features/supported/variables/variables.js +0 -62
- package/statistics/meta-statistics.d.ts +0 -32
- package/statistics/meta-statistics.js +0 -16
- package/statistics/output/file-provider.d.ts +0 -36
- package/statistics/output/file-provider.js +0 -96
- package/statistics/output/print-stats.d.ts +0 -29
- package/statistics/output/print-stats.js +0 -81
- package/statistics/output/statistics-file.d.ts +0 -36
- package/statistics/output/statistics-file.js +0 -68
- package/statistics/statistics.d.ts +0 -29
- package/statistics/statistics.js +0 -108
- package/statistics/summarizer/auto-detect.d.ts +0 -5
- package/statistics/summarizer/auto-detect.js +0 -34
- package/statistics/summarizer/first-phase/process.d.ts +0 -6
- package/statistics/summarizer/first-phase/process.js +0 -81
- package/statistics/summarizer/post-process/clusterer.d.ts +0 -25
- package/statistics/summarizer/post-process/clusterer.js +0 -40
- package/statistics/summarizer/post-process/file-based-count.d.ts +0 -16
- package/statistics/summarizer/post-process/file-based-count.js +0 -47
- package/statistics/summarizer/post-process/histogram.d.ts +0 -57
- package/statistics/summarizer/post-process/histogram.js +0 -126
- package/statistics/summarizer/post-process/post-process-output.d.ts +0 -14
- package/statistics/summarizer/post-process/post-process-output.js +0 -102
- package/statistics/summarizer/second-phase/process.d.ts +0 -15
- package/statistics/summarizer/second-phase/process.js +0 -118
- package/statistics/summarizer/summarizer.d.ts +0 -34
- package/statistics/summarizer/summarizer.js +0 -141
package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-pkgdb-plugin.js
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.FlowrAnalyzerPackageVersionsPkgDbPlugin = exports.pkgDbLog = exports.PkgDbPluginName = void 0;
|
|
7
|
+
exports.reconstructS3Generics = reconstructS3Generics;
|
|
8
|
+
const flowr_analyzer_package_versions_plugin_1 = require("./flowr-analyzer-package-versions-plugin");
|
|
9
|
+
const semver_1 = require("semver");
|
|
10
|
+
const path_1 = __importDefault(require("path"));
|
|
11
|
+
const package_1 = require("./package");
|
|
12
|
+
const pkgdb_1 = require("./pkgdb");
|
|
13
|
+
const log_1 = require("../../../util/log");
|
|
14
|
+
/** the plugin's instance name (pass to `unregisterPlugins` to disable the default pkgdb resolver) */
|
|
15
|
+
exports.PkgDbPluginName = 'flowr-analyzer-package-versions-pkgdb-plugin';
|
|
16
|
+
exports.pkgDbLog = log_1.log.getSubLogger({ name: exports.PkgDbPluginName });
|
|
17
|
+
/** additional sources from `$FLOWR_PKGDB` (path-delimiter separated), highest priority after explicit ones */
|
|
18
|
+
function envSources() {
|
|
19
|
+
const env = typeof process !== 'undefined' ? process.env?.FLOWR_PKGDB : undefined;
|
|
20
|
+
return env ? env.split(path_1.default.delimiter).filter(s => s.length > 0) : [];
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The database flattens S3 methods into the export list, so we recover the `generic -> classes` map for
|
|
24
|
+
* dispatch: an export `generic.class` is a method when the `generic` is itself exported (e.g. `print.foo`).
|
|
25
|
+
*/
|
|
26
|
+
function reconstructS3Generics(exported) {
|
|
27
|
+
const names = new Set(exported);
|
|
28
|
+
const generics = new Map();
|
|
29
|
+
for (const name of exported) {
|
|
30
|
+
const dot = name.indexOf('.');
|
|
31
|
+
const generic = dot > 0 ? name.slice(0, dot) : undefined;
|
|
32
|
+
if (generic !== undefined && names.has(generic)) {
|
|
33
|
+
const classes = generics.get(generic) ?? [];
|
|
34
|
+
classes.push(name.slice(dot + 1));
|
|
35
|
+
generics.set(generic, classes);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return generics;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Resolves `library(pkg)` / `use(pkg, fn)` from precomputed `flowr-pkgdb` databases: the one bundled
|
|
42
|
+
* with flowR plus any extra sources (constructor args or `$FLOWR_PKGDB`). Extra sources are consulted
|
|
43
|
+
* first, so they override the bundle; packages only in the bundle still resolve. Everything is loaded
|
|
44
|
+
* lazily on the first miss (never touched if a project uses no external packages). On by default; opt
|
|
45
|
+
* out via `unregisterPlugins(PkgDbPluginName)` or `$FLOWR_DISABLE_DEFAULT_PKGDB`.
|
|
46
|
+
*
|
|
47
|
+
* A source may be an `http(s)` URL to a downloadable summary; call {@link preload} once at the
|
|
48
|
+
* analyzer boundary to fetch it, so resolution falls through to it for packages not in the bundle.
|
|
49
|
+
*/
|
|
50
|
+
class FlowrAnalyzerPackageVersionsPkgDbPlugin extends flowr_analyzer_package_versions_plugin_1.FlowrAnalyzerPackageVersionsPlugin {
|
|
51
|
+
name = exports.PkgDbPluginName;
|
|
52
|
+
description = 'Resolves library exports from precomputed flowr-pkgdb databases.';
|
|
53
|
+
version = new semver_1.SemVer('0.1.0');
|
|
54
|
+
/**
|
|
55
|
+
* Process-wide cache of parsed file databases, keyed by their source path, so a flowR session parses
|
|
56
|
+
* each file once. Parsing the bundled database is ~25ms and a fresh plugin instance is created per
|
|
57
|
+
* analyzer, so without this every analysis touching a `library()` call would re-parse the multi-MB file.
|
|
58
|
+
*/
|
|
59
|
+
static fileCache = new Map();
|
|
60
|
+
extraSources;
|
|
61
|
+
databases;
|
|
62
|
+
constructor(...sources) {
|
|
63
|
+
super();
|
|
64
|
+
this.extraSources = sources;
|
|
65
|
+
}
|
|
66
|
+
process(ctx) {
|
|
67
|
+
this.databases = undefined; // reload on (re)registration so config/source changes take effect
|
|
68
|
+
if (ctx.config.solver.pkgdb.enabled) {
|
|
69
|
+
ctx.deps.addLazyResolver((name, existing) => this.resolve(name, existing));
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/** Mount the databases up front (see `solver.pkgdb.eagerlyLoad`) instead of on the first library load. */
|
|
73
|
+
preloadDatabasesSync() {
|
|
74
|
+
this.loadDatabases();
|
|
75
|
+
}
|
|
76
|
+
/** metadata of the databases currently loaded (the synchronously available, non-URL sources) */
|
|
77
|
+
loadedDatabases() {
|
|
78
|
+
return this.loadDatabases().map(db => ({ scope: db.scope, version: db.content.version, date: db.content.date }));
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Sources in priority order: explicit constructor sources, then `$FLOWR_PKGDB`, then the bundled
|
|
82
|
+
* default. The bundled default is skipped when `$FLOWR_DISABLE_DEFAULT_PKGDB` is set (explicit
|
|
83
|
+
* sources are always honored) - the env opt-out for the shipped database.
|
|
84
|
+
*/
|
|
85
|
+
sources() {
|
|
86
|
+
const disableBundled = typeof process !== 'undefined' && process.env?.FLOWR_DISABLE_DEFAULT_PKGDB;
|
|
87
|
+
const bundled = disableBundled ? undefined : (0, pkgdb_1.defaultPkgDbPath)(); // richest bundled tier (all > latest > tiny)
|
|
88
|
+
return [...this.extraSources, ...envSources(), ...(bundled ? [bundled] : [])];
|
|
89
|
+
}
|
|
90
|
+
static isUrl(s) {
|
|
91
|
+
return typeof s === 'string' && /^https?:\/\//.test(s);
|
|
92
|
+
}
|
|
93
|
+
/** synchronously loaded databases; remote (URL) summaries are only added by {@link preload}. */
|
|
94
|
+
loadDatabases() {
|
|
95
|
+
if (this.databases === undefined) {
|
|
96
|
+
this.databases = this.sources()
|
|
97
|
+
.filter(s => !FlowrAnalyzerPackageVersionsPkgDbPlugin.isUrl(s))
|
|
98
|
+
.map(s => this.load(s))
|
|
99
|
+
.filter((d) => d !== undefined);
|
|
100
|
+
}
|
|
101
|
+
return this.databases;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Download and load every source, including remote (URL) summaries. Call this once at the
|
|
105
|
+
* analyzer boundary to let `library()` resolution fall through to additional downloaded databases
|
|
106
|
+
* (e.g. the full `all` summary or a richer `latest`). Without it, only local sources are used.
|
|
107
|
+
*/
|
|
108
|
+
async preload() {
|
|
109
|
+
const dbs = [];
|
|
110
|
+
for (const source of this.sources()) {
|
|
111
|
+
try {
|
|
112
|
+
dbs.push(FlowrAnalyzerPackageVersionsPkgDbPlugin.isUrl(source) ? await pkgdb_1.PkgDatabase.fromUrl(source) : this.mustLoad(source));
|
|
113
|
+
}
|
|
114
|
+
catch (e) {
|
|
115
|
+
exports.pkgDbLog.warn(`Could not load pkgdb source: ${e.message}`);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
this.databases = dbs;
|
|
119
|
+
}
|
|
120
|
+
load(source) {
|
|
121
|
+
try {
|
|
122
|
+
return this.mustLoad(source);
|
|
123
|
+
}
|
|
124
|
+
catch (e) {
|
|
125
|
+
exports.pkgDbLog.warn(`Could not load pkgdb source: ${e.message}`);
|
|
126
|
+
return undefined;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
mustLoad(source) {
|
|
130
|
+
if (source instanceof pkgdb_1.PkgDatabase) {
|
|
131
|
+
return source;
|
|
132
|
+
}
|
|
133
|
+
if (typeof source !== 'string') {
|
|
134
|
+
return pkgdb_1.PkgDatabase.fromObject(source);
|
|
135
|
+
}
|
|
136
|
+
return FlowrAnalyzerPackageVersionsPkgDbPlugin.loadFileCached(source);
|
|
137
|
+
}
|
|
138
|
+
/** Load a file source once per session, reusing the parsed database across analyzer instances. */
|
|
139
|
+
static loadFileCached(file) {
|
|
140
|
+
const cache = FlowrAnalyzerPackageVersionsPkgDbPlugin.fileCache;
|
|
141
|
+
let db = cache.get(file);
|
|
142
|
+
if (db === undefined) {
|
|
143
|
+
db = pkgdb_1.PkgDatabase.fromFileSync(file);
|
|
144
|
+
cache.set(file, db);
|
|
145
|
+
}
|
|
146
|
+
return db;
|
|
147
|
+
}
|
|
148
|
+
resolve(name, existing) {
|
|
149
|
+
const pinned = existing?.derivedVersion ? (0, semver_1.minVersion)(existing.derivedVersion)?.version : undefined;
|
|
150
|
+
for (const db of this.loadDatabases()) {
|
|
151
|
+
const info = db.lookup(name, pinned);
|
|
152
|
+
if (!info) {
|
|
153
|
+
continue;
|
|
154
|
+
}
|
|
155
|
+
if (pinned && info.version !== pinned) {
|
|
156
|
+
exports.pkgDbLog.warn(`project pins ${name}@${pinned} but the export database only has ${info.version}; analyzing with ${info.version}`);
|
|
157
|
+
}
|
|
158
|
+
else if (!pinned) {
|
|
159
|
+
exports.pkgDbLog.debug(`no pinned version for ${name}; using ${info.version}`);
|
|
160
|
+
}
|
|
161
|
+
const namespaceInfo = {
|
|
162
|
+
exportedSymbols: info.exported,
|
|
163
|
+
exportedFunctions: [],
|
|
164
|
+
exportS3Generics: reconstructS3Generics(info.exported),
|
|
165
|
+
exportedPatterns: [],
|
|
166
|
+
importedPackages: new Map(),
|
|
167
|
+
loadsWithSideEffects: false,
|
|
168
|
+
callable: info.exported
|
|
169
|
+
};
|
|
170
|
+
return new package_1.Package({ name, namespaceInfo });
|
|
171
|
+
}
|
|
172
|
+
return undefined;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
exports.FlowrAnalyzerPackageVersionsPkgDbPlugin = FlowrAnalyzerPackageVersionsPkgDbPlugin;
|
|
176
|
+
//# sourceMappingURL=flowr-analyzer-package-versions-pkgdb-plugin.js.map
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import { FlowrAnalyzerPlugin, PluginType } from '../flowr-analyzer-plugin';
|
|
2
|
+
/** metadata of a package database a plugin currently has loaded */
|
|
3
|
+
export interface PkgDbLoadedInfo {
|
|
4
|
+
scope: string;
|
|
5
|
+
version: number;
|
|
6
|
+
date: string;
|
|
7
|
+
}
|
|
2
8
|
/**
|
|
3
9
|
* This is the base class for all plugins that identify package and dependency versions used in the project.
|
|
4
10
|
* These plugins interplay with the {@link FlowrAnalyzerDependenciesContext} to gather information about the packages used in the project.
|
|
@@ -7,4 +13,8 @@ import { FlowrAnalyzerPlugin, PluginType } from '../flowr-analyzer-plugin';
|
|
|
7
13
|
export declare abstract class FlowrAnalyzerPackageVersionsPlugin extends FlowrAnalyzerPlugin<undefined, void> {
|
|
8
14
|
readonly type = PluginType.DependencyIdentification;
|
|
9
15
|
static defaultPlugin(): FlowrAnalyzerPackageVersionsPlugin;
|
|
16
|
+
/** metadata of the databases this plugin currently has loaded (empty for plugins without any) */
|
|
17
|
+
loadedDatabases(): PkgDbLoadedInfo[];
|
|
18
|
+
/** Eagerly parse and mount this plugin's databases up front (no-op for plugins without any). */
|
|
19
|
+
preloadDatabasesSync(): void;
|
|
10
20
|
}
|
|
@@ -13,6 +13,12 @@ class FlowrAnalyzerPackageVersionsPlugin extends flowr_analyzer_plugin_1.FlowrAn
|
|
|
13
13
|
static defaultPlugin() {
|
|
14
14
|
return new DefaultFlowrAnalyzerPackageVersionsPlugin();
|
|
15
15
|
}
|
|
16
|
+
/** metadata of the databases this plugin currently has loaded (empty for plugins without any) */
|
|
17
|
+
loadedDatabases() {
|
|
18
|
+
return [];
|
|
19
|
+
}
|
|
20
|
+
/** Eagerly parse and mount this plugin's databases up front (no-op for plugins without any). */
|
|
21
|
+
preloadDatabasesSync() { }
|
|
16
22
|
}
|
|
17
23
|
exports.FlowrAnalyzerPackageVersionsPlugin = FlowrAnalyzerPackageVersionsPlugin;
|
|
18
24
|
/**
|
|
@@ -18,6 +18,8 @@ export declare class Package {
|
|
|
18
18
|
constructor(info: {
|
|
19
19
|
name: string;
|
|
20
20
|
} & PackageOptions);
|
|
21
|
+
/** Builds a package from a raw `NAMESPACE` body and its list of callable exports. */
|
|
22
|
+
static fromConstants(name: string, namespace: string, callable: string[]): Package;
|
|
21
23
|
has(name: string, className?: string): boolean;
|
|
22
24
|
s3For(generic: string): string[];
|
|
23
25
|
mergeInPlace(other: Package): void;
|
|
@@ -25,4 +27,5 @@ export declare class Package {
|
|
|
25
27
|
getInfo(): this;
|
|
26
28
|
deriveVersion(): Range | undefined;
|
|
27
29
|
static parsePackageVersionRange(constraint?: string, version?: string): Range | undefined;
|
|
30
|
+
static funcIdentif(dependency: string, func: string): string;
|
|
28
31
|
}
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Package = void 0;
|
|
4
4
|
const assert_1 = require("../../../util/assert");
|
|
5
|
+
const flowr_namespace_file_1 = require("../file-plugins/files/flowr-namespace-file");
|
|
6
|
+
const flowr_file_1 = require("../../context/flowr-file");
|
|
5
7
|
const r_version_1 = require("../../../util/r-version");
|
|
6
8
|
class Package {
|
|
7
9
|
name;
|
|
@@ -14,6 +16,13 @@ class Package {
|
|
|
14
16
|
this.name = info.name;
|
|
15
17
|
this.addInfo(info);
|
|
16
18
|
}
|
|
19
|
+
/** Builds a package from a raw `NAMESPACE` body and its list of callable exports. */
|
|
20
|
+
static fromConstants(name, namespace, callable) {
|
|
21
|
+
return new Package({
|
|
22
|
+
name,
|
|
23
|
+
namespaceInfo: (0, flowr_namespace_file_1.setCallable)(flowr_namespace_file_1.FlowrNamespaceFile.from(new flowr_file_1.FlowrInlineTextFile('NAMESPACE', namespace)).content().current, callable)
|
|
24
|
+
});
|
|
25
|
+
}
|
|
17
26
|
has(name, className) {
|
|
18
27
|
if (!this.namespaceInfo) {
|
|
19
28
|
return false;
|
|
@@ -79,6 +88,9 @@ class Package {
|
|
|
79
88
|
return undefined;
|
|
80
89
|
}
|
|
81
90
|
}
|
|
91
|
+
static funcIdentif(dependency, func) {
|
|
92
|
+
return `${dependency}:${func}`;
|
|
93
|
+
}
|
|
82
94
|
}
|
|
83
95
|
exports.Package = Package;
|
|
84
96
|
//# sourceMappingURL=package.js.map
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
export declare const PkgDbMagic = "flowr-pkgdb";
|
|
2
|
+
export declare const PkgDbSchema = 4;
|
|
3
|
+
export declare const DefaultCranBase = "https://cran.r-project.org/src/contrib/";
|
|
4
|
+
export type PkgDbItem = number | string;
|
|
5
|
+
export type PkgDbLatestEntry = [version: string, exported: PkgDbItem[]];
|
|
6
|
+
/** one version in the `all` scope: `[version, exported, internal?, deprecated?]` of `lists` indices */
|
|
7
|
+
export type PkgDbAllVersion = [string, number] | [string, number, number] | [string, number, number, number];
|
|
8
|
+
/** `all`-scope package: `[latest, versions, nonCranVersions?]` (all arrays, no keys) */
|
|
9
|
+
export type PkgDbAllEntry = [string, PkgDbAllVersion[]] | [string, PkgDbAllVersion[], string[]];
|
|
10
|
+
/** optional definition location `[fileIndex, line]` indexing the `files` pool */
|
|
11
|
+
export type PkgDbLoc = readonly [fileIndex: number, line: number];
|
|
12
|
+
export interface PkgDbContent {
|
|
13
|
+
version: number;
|
|
14
|
+
date: string;
|
|
15
|
+
hash: string;
|
|
16
|
+
generated: number;
|
|
17
|
+
packages: number;
|
|
18
|
+
versions: number;
|
|
19
|
+
}
|
|
20
|
+
interface PkgDbCommon {
|
|
21
|
+
format: string;
|
|
22
|
+
schema: number;
|
|
23
|
+
content: PkgDbContent;
|
|
24
|
+
cranBase?: string;
|
|
25
|
+
strings: string[];
|
|
26
|
+
archived?: string[];
|
|
27
|
+
noncran?: string[];
|
|
28
|
+
}
|
|
29
|
+
export interface PkgDbLatest extends PkgDbCommon {
|
|
30
|
+
scope: 'latest';
|
|
31
|
+
pkgs: Record<string, PkgDbLatestEntry>;
|
|
32
|
+
}
|
|
33
|
+
export interface PkgDbAll extends PkgDbCommon {
|
|
34
|
+
scope: 'all';
|
|
35
|
+
lists: PkgDbItem[][];
|
|
36
|
+
pkgs: Record<string, PkgDbAllEntry>;
|
|
37
|
+
/** optional file-path pool for {@link locs} */
|
|
38
|
+
files?: string[];
|
|
39
|
+
/** optional definition locations of the latest version: `pkg -> identifier -> [fileIndex, line]` */
|
|
40
|
+
locs?: Record<string, Record<string, PkgDbLoc>>;
|
|
41
|
+
}
|
|
42
|
+
export type PkgDb = PkgDbLatest | PkgDbAll;
|
|
43
|
+
/** a definition location surfaced from the `all` scope when the database carries them */
|
|
44
|
+
export interface PkgDbDefinitionLocation {
|
|
45
|
+
file: string;
|
|
46
|
+
line: number;
|
|
47
|
+
}
|
|
48
|
+
/** the resolved identifiers of one package version */
|
|
49
|
+
export interface LibraryExports {
|
|
50
|
+
version: string;
|
|
51
|
+
exported: string[];
|
|
52
|
+
/** defined-but-not-exported identifiers (only available in the `all` scope) */
|
|
53
|
+
internal: string[];
|
|
54
|
+
deprecated: string[];
|
|
55
|
+
cran: boolean;
|
|
56
|
+
cranUrl?: string;
|
|
57
|
+
/** definition location per identifier, if the database carries them (`all` scope, latest version) */
|
|
58
|
+
locations?: ReadonlyMap<string, PkgDbDefinitionLocation>;
|
|
59
|
+
}
|
|
60
|
+
/** Reconstruct the CRAN source blob link; the newest non-archived version lives under `src/contrib`, every other under `Archive`. */
|
|
61
|
+
export declare function cranBlobUrl(cranBase: string, pkg: string, version: string, opts: {
|
|
62
|
+
latest: string;
|
|
63
|
+
archived: boolean;
|
|
64
|
+
cran: boolean;
|
|
65
|
+
}): string | undefined;
|
|
66
|
+
/** Validate the structural invariants of a decoded database, throwing a descriptive error on failure. */
|
|
67
|
+
export declare function validatePkgDb(o: unknown): asserts o is PkgDb;
|
|
68
|
+
export type PkgDbScope = 'all' | 'latest' | 'tiny';
|
|
69
|
+
/**
|
|
70
|
+
* Location of a bundled database, found by walking up from several roots (this module,
|
|
71
|
+
* `$FLOWR_PKGDB_DIR`, the working directory) across the dev (`src`) and build (`dist`) layouts. With
|
|
72
|
+
* no `scope` it returns the richest available tier (brotli, then gzip, then plain json). Node only
|
|
73
|
+
* (needs `fs`); pass `searchRoots` to override where it looks.
|
|
74
|
+
*/
|
|
75
|
+
export declare function defaultPkgDbPath(scope?: PkgDbScope, searchRoots?: readonly string[]): string | undefined;
|
|
76
|
+
/** classified identifiers of one package version, fed to {@link PkgDbBuilder} */
|
|
77
|
+
export interface VersionExports {
|
|
78
|
+
exported: readonly string[];
|
|
79
|
+
internal: readonly string[];
|
|
80
|
+
deprecated: readonly string[];
|
|
81
|
+
cran: boolean;
|
|
82
|
+
/** optional definition location per identifier: `name -> [file, line]` (emitted only in the `all` scope) */
|
|
83
|
+
locations?: ReadonlyMap<string, readonly [file: string, line: number]>;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Serializes a {@link PkgDb}. Accumulate per-version exports with {@link addPackage}/{@link addVersion},
|
|
87
|
+
* then {@link build} a scope. The multi-use string pool is computed per scope; the `latest` scope may
|
|
88
|
+
* be pruned to the most-downloaded packages. This is the counterpart of {@link PkgDatabase} (the reader).
|
|
89
|
+
*/
|
|
90
|
+
export declare class PkgDbBuilder {
|
|
91
|
+
private readonly raw;
|
|
92
|
+
private versionCount;
|
|
93
|
+
addPackage(name: string, opts: {
|
|
94
|
+
latest: string;
|
|
95
|
+
archived?: boolean;
|
|
96
|
+
downloads?: number;
|
|
97
|
+
}): void;
|
|
98
|
+
addVersion(name: string, version: string, exports: VersionExports): void;
|
|
99
|
+
private relevant;
|
|
100
|
+
private buildPool;
|
|
101
|
+
build(scope: 'latest' | 'all', meta: {
|
|
102
|
+
version: number;
|
|
103
|
+
date: string;
|
|
104
|
+
generated: number;
|
|
105
|
+
cranBase?: string;
|
|
106
|
+
minDownloads?: number;
|
|
107
|
+
topN?: number;
|
|
108
|
+
}): PkgDb;
|
|
109
|
+
}
|
|
110
|
+
export declare class PkgDatabase {
|
|
111
|
+
private readonly db;
|
|
112
|
+
private readonly archived;
|
|
113
|
+
private readonly noncran;
|
|
114
|
+
constructor(db: PkgDb);
|
|
115
|
+
get content(): PkgDbContent;
|
|
116
|
+
get scope(): 'latest' | 'all';
|
|
117
|
+
/** parse an already-loaded object (validates the schema, throwing a descriptive error on failure) */
|
|
118
|
+
static fromObject(obj: unknown): PkgDatabase;
|
|
119
|
+
/** portable async load from raw bytes (gzip auto-detected) */
|
|
120
|
+
static fromBytes(bytes: Uint8Array): Promise<PkgDatabase>;
|
|
121
|
+
/** portable async load from a URL (works in Node 18+, browser and VS Code) */
|
|
122
|
+
static fromUrl(url: string): Promise<PkgDatabase>;
|
|
123
|
+
/** synchronous load from a local file (Node only; brotli by `.br`, else gzip auto-detected, else plain) */
|
|
124
|
+
static fromFileSync(file: string): PkgDatabase;
|
|
125
|
+
has(pkg: string): boolean;
|
|
126
|
+
private decode;
|
|
127
|
+
private result;
|
|
128
|
+
/** definition locations of the latest version, if the (`all`-scope) database carries them */
|
|
129
|
+
private locations;
|
|
130
|
+
/** look up the identifiers of a package (defaulting to its latest version) */
|
|
131
|
+
lookup(pkg: string, version?: string): LibraryExports | undefined;
|
|
132
|
+
}
|
|
133
|
+
export {};
|