@eagleoutice/flowr 2.13.16 → 2.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -31
- package/abstract-interpretation/absint-visitor.js +1 -1
- package/abstract-interpretation/data-frame/mappers/access-mapper.js +4 -4
- package/abstract-interpretation/data-frame/mappers/arguments.js +7 -4
- package/abstract-interpretation/data-frame/mappers/function-mapper.js +18 -17
- package/abstract-interpretation/data-frame/mappers/replacement-mapper.js +6 -6
- package/abstract-interpretation/data-frame/resolve-args.d.ts +9 -4
- package/abstract-interpretation/data-frame/resolve-args.js +10 -5
- package/benchmark/calibration.d.ts +12 -5
- package/benchmark/calibration.js +42 -14
- package/benchmark/slicer.d.ts +1 -1
- package/benchmark/slicer.js +5 -4
- package/benchmark/stats/size-of.js +1 -1
- package/benchmark/summarizer/first-phase/process.d.ts +2 -0
- package/benchmark/summarizer/first-phase/process.js +2 -0
- package/cli/common/options.d.ts +0 -31
- package/cli/common/options.js +1 -8
- package/cli/common/scripts-info.d.ts +0 -38
- package/cli/common/scripts-info.js +0 -8
- package/cli/repl/core.js +1 -1
- package/cli/repl/parser/slice-query-parser.js +1 -1
- package/cli/repl/print-version.js +2 -2
- package/config.d.ts +16 -0
- package/config.js +79 -0
- package/control-flow/extract-cfg.js +1 -1
- package/control-flow/semantic-cfg-guided-visitor.d.ts +1 -1
- package/control-flow/semantic-cfg-guided-visitor.js +1 -1
- package/control-flow/useless-loop.js +1 -1
- package/core/print/slice-diff-ansi.js +1 -1
- package/core/steps/pipeline/create-pipeline.js +1 -1
- package/dataflow/cluster.js +2 -2
- package/dataflow/environments/built-in-props.d.ts +8 -1
- package/dataflow/environments/built-in-props.js +18 -0
- package/dataflow/environments/built-in.d.ts +7 -1
- package/dataflow/environments/built-in.js +42 -3
- package/dataflow/environments/default-builtin-config.d.ts +442 -10
- package/dataflow/environments/default-builtin-config.js +188 -18
- package/dataflow/environments/environment.d.ts +1 -1
- package/dataflow/environments/identifier.d.ts +7 -2
- package/dataflow/environments/identifier.js +6 -1
- package/dataflow/environments/query-fn-props.js +2 -2
- package/dataflow/environments/reference-to-maybe.js +5 -5
- package/dataflow/environments/resolve-by-name.d.ts +3 -0
- package/dataflow/environments/resolve-by-name.js +30 -5
- package/dataflow/environments/resolve-helper.d.ts +6 -0
- package/dataflow/environments/resolve-helper.js +6 -0
- package/dataflow/eval/resolve/alias-tracking.d.ts +5 -0
- package/dataflow/eval/resolve/alias-tracking.js +21 -14
- package/dataflow/eval/resolve/node-value.d.ts +6 -0
- package/dataflow/eval/resolve/node-value.js +15 -9
- package/dataflow/eval/resolve/resolve-argument.js +2 -2
- package/dataflow/eval/resolve/resolve-numbers.js +2 -2
- package/dataflow/eval/resolve/resolve-operators.js +4 -3
- package/dataflow/eval/resolve/resolve-strings.js +3 -3
- package/dataflow/eval/resolve/resolve-working-directory.js +2 -1
- package/dataflow/eval/resolve/resolve.d.ts +5 -5
- package/dataflow/eval/resolve/resolve.js +10 -11
- package/dataflow/eval/values/general.d.ts +4 -1
- package/dataflow/eval/values/general.js +1 -1
- package/dataflow/extractor.js +2 -1
- package/dataflow/fn/exceptions-of-function.js +5 -4
- package/dataflow/fn/higher-order-function.js +5 -4
- package/dataflow/graph/call-graph.js +14 -14
- package/dataflow/graph/df-helper.d.ts +15 -0
- package/dataflow/graph/df-helper.js +10 -4
- package/dataflow/graph/diff-dataflow-graph.js +6 -6
- package/dataflow/graph/edge.d.ts +27 -0
- package/dataflow/graph/edge.js +33 -0
- package/dataflow/graph/graph-helper.d.ts +3 -4
- package/dataflow/graph/graph-helper.js +4 -5
- package/dataflow/graph/graph.d.ts +11 -1
- package/dataflow/graph/graph.js +16 -5
- package/dataflow/graph/vertex.d.ts +42 -6
- package/dataflow/graph/vertex.js +42 -6
- package/dataflow/internal/linker.d.ts +1 -0
- package/dataflow/internal/linker.js +11 -9
- package/dataflow/internal/process/functions/call/built-in/built-in-access.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +6 -5
- package/dataflow/internal/process/functions/call/built-in/built-in-class-generator.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +6 -7
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +7 -6
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.d.ts +1 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +19 -18
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +6 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-list.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-local.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-pipe.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-purrr-formula.js +5 -5
- package/dataflow/internal/process/functions/call/built-in/built-in-quote.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-register-hook.js +3 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +3 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +3 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +3 -3
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.d.ts +3 -1
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +15 -12
- package/dataflow/internal/process/functions/call/common.d.ts +9 -1
- package/dataflow/internal/process/functions/call/common.js +17 -6
- package/dataflow/internal/process/functions/call/deferred.js +2 -1
- package/dataflow/internal/process/functions/call/known-call-handling.d.ts +3 -1
- package/dataflow/internal/process/functions/call/known-call-handling.js +6 -3
- package/dataflow/internal/process/functions/call/named-call-handling.js +44 -12
- package/dataflow/internal/process/functions/call/nse.d.ts +33 -5
- package/dataflow/internal/process/functions/call/nse.js +113 -6
- package/dataflow/internal/process/functions/call/quoted.d.ts +5 -0
- package/dataflow/internal/process/functions/call/quoted.js +21 -9
- package/dataflow/origin/dfg-get-origin.d.ts +1 -0
- package/dataflow/origin/dfg-get-origin.js +9 -6
- package/documentation/data/faq/faqs.js +88 -88
- package/documentation/data/faq/recommended-configs.js +1 -1
- package/documentation/data/faq/wiki-faq-store.js +1 -1
- package/documentation/doc-capabilities.js +1 -1
- package/documentation/doc-readme.js +1 -1
- package/documentation/doc-util/doc-auto-gen.js +6 -2
- package/documentation/doc-util/doc-functions.js +1 -1
- package/documentation/wiki-cfg.js +2 -2
- package/documentation/wiki-create-linting-rules.js +45 -45
- package/documentation/wiki-dataflow-graph.js +17 -18
- package/documentation/wiki-linting-and-testing.js +93 -5
- package/documentation/wiki-mk/doc-maker.js +1 -1
- package/documentation/wiki-overview.js +12 -1
- package/documentation/wiki-signature-database.js +3 -0
- package/linter/rules/file-path-validity.js +1 -1
- package/linter/rules/function-finder-util.js +1 -1
- package/linter/rules/naming-convention.js +1 -1
- package/linter/rules/no-leaked-credentials.js +2 -1
- package/linter/rules/stop-with-call-arg.js +4 -4
- package/linter/rules/undefined-symbol-util.d.ts +1 -1
- package/linter/rules/undefined-symbol-util.js +5 -4
- package/linter/rules/undefined-symbol.js +3 -3
- package/linter/rules/unused-definition.js +2 -1
- package/package.json +35 -45
- package/project/context/flowr-analyzer-environment-context.d.ts +23 -0
- package/project/context/flowr-analyzer-environment-context.js +25 -0
- package/project/dependency-version-space.js +1 -2
- package/project/flowr-analyzer.js +1 -1
- package/project/plugins/file-plugins/files/flowr-rda-file.js +3 -3
- package/project/plugins/file-plugins/files/flowr-rmarkdown-file.js +2 -2
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +3 -1
- package/project/sigdb/build.js +16 -16
- package/project/sigdb/codec.d.ts +1 -1
- package/project/sigdb/codec.js +13 -13
- package/project/sigdb/decompress.d.ts +1 -1
- package/project/sigdb/decompress.js +33 -33
- package/project/sigdb/index-format.js +2 -2
- package/project/sigdb/manifest.js +21 -21
- package/project/sigdb/memory-source.d.ts +64 -0
- package/project/sigdb/memory-source.js +133 -0
- package/project/sigdb/reader.js +13 -13
- package/queries/catalog/call-context-query/call-context-query-executor.js +1 -1
- package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +2 -2
- package/queries/catalog/dependencies-query/dependencies-query-executor.js +2 -2
- package/queries/catalog/dependencies-query/dependencies-query-format.js +1 -1
- package/queries/catalog/dependencies-query/link-devices.js +2 -2
- package/queries/catalog/does-call-query/does-call-query-executor.js +2 -1
- package/queries/catalog/input-sources-query/simple-input-classifier.js +4 -4
- package/queries/catalog/location-map-query/location-map-query-format.js +1 -1
- package/queries/catalog/resolve-value-query/resolve-value-query-executor.js +2 -2
- package/queries/catalog/signature-query/signature-query-executor.d.ts +2 -0
- package/queries/catalog/signature-query/signature-query-executor.js +3 -2
- package/r-bridge/lang-4.x/ast/model/processing/node-id.js +3 -3
- package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-call.js +1 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-definition.js +1 -1
- package/r-bridge/retriever.d.ts +2 -1
- package/r-bridge/retriever.js +3 -2
- package/r-bridge/roxygen2/documentation-provider.d.ts +1 -0
- package/r-bridge/roxygen2/documentation-provider.js +1 -0
- package/r-bridge/roxygen2/roxygen-parse.d.ts +1 -1
- package/r-bridge/roxygen2/roxygen-parse.js +1 -1
- package/search/flowr-search-filters.d.ts +1 -1
- package/search/flowr-search-filters.js +2 -2
- package/search/search-executor/search-enrichers.js +4 -4
- package/search/search-executor/search-generators.js +1 -1
- package/slicing/criterion/parse.js +3 -3
- package/slicing/static/slice-call.d.ts +1 -1
- package/slicing/static/slice-call.js +2 -2
- package/slicing/static/static-slicer.js +4 -3
- package/util/assert.js +1 -1
- package/util/log.d.ts +4 -1
- package/util/log.js +15 -2
- package/util/logic.js +2 -2
- package/util/mermaid/cfg.js +1 -1
- package/util/mermaid/dfg.js +6 -6
- package/util/mermaid/mermaid.js +3 -1
- package/util/quads.js +19 -6
- package/util/schema.js +2 -2
- package/util/text/ansi.d.ts +2 -0
- package/util/text/ansi.js +8 -0
- package/util/text/name-rank.d.ts +29 -0
- package/util/text/name-rank.js +39 -0
- package/util/text/url-encoding.d.ts +15 -0
- package/util/text/url-encoding.js +59 -0
- package/util/version.js +1 -1
- package/cli/export-quads-app.d.ts +0 -7
- package/cli/export-quads-app.js +0 -44
|
@@ -18,11 +18,11 @@ exports.ensurePlainSync = ensurePlainSync;
|
|
|
18
18
|
* the cache directory. Split out of `../sigdb` so the reader there only consumes plain, seekable files. The codec
|
|
19
19
|
* is detected by extension (see `./codec`), so existing `.br` and new `.zst` bundles read transparently.
|
|
20
20
|
*/
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
const promises_1 = require("
|
|
21
|
+
const fs_1 = __importDefault(require("fs"));
|
|
22
|
+
const os_1 = __importDefault(require("os"));
|
|
23
|
+
const path_1 = __importDefault(require("path"));
|
|
24
|
+
const readline_1 = __importDefault(require("readline"));
|
|
25
|
+
const promises_1 = require("stream/promises");
|
|
26
26
|
const schema_1 = require("./schema");
|
|
27
27
|
const index_format_1 = require("./index-format");
|
|
28
28
|
const hash_1 = require("../../util/hash");
|
|
@@ -41,11 +41,11 @@ function parseHeader(text) {
|
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
function decompressStream(file) {
|
|
44
|
-
return
|
|
44
|
+
return fs_1.default.createReadStream(file).pipe((0, codec_1.createDecompressFor)(file));
|
|
45
45
|
}
|
|
46
46
|
/** a readable stream of the bundle's plain NDJSON, transparently decompressing `.gz`/`.br`/`.zst` inputs */
|
|
47
47
|
function sigDbStream(file) {
|
|
48
|
-
return (0, exports.isCompressed)(file) ? decompressStream(file) :
|
|
48
|
+
return (0, exports.isCompressed)(file) ? decompressStream(file) : fs_1.default.createReadStream(file);
|
|
49
49
|
}
|
|
50
50
|
/**
|
|
51
51
|
* Resolve a manifest-relative file to the best source this runtime can read: a plain (already seekable) file
|
|
@@ -54,13 +54,13 @@ function sigDbStream(file) {
|
|
|
54
54
|
* (it could not be decompressed), so `.br`-only bundles read on any Node. Falls back to the plain path.
|
|
55
55
|
*/
|
|
56
56
|
function resolveSource(baseDir, relPath) {
|
|
57
|
-
const plain =
|
|
58
|
-
if (
|
|
57
|
+
const plain = path_1.default.resolve(baseDir, relPath);
|
|
58
|
+
if (fs_1.default.existsSync(plain)) {
|
|
59
59
|
return plain;
|
|
60
60
|
}
|
|
61
61
|
for (const ext of (0, codec_1.readableExtsPreferred)()) {
|
|
62
62
|
const compressed = `${plain}${ext}`;
|
|
63
|
-
if (
|
|
63
|
+
if (fs_1.default.existsSync(compressed)) {
|
|
64
64
|
return compressed;
|
|
65
65
|
}
|
|
66
66
|
}
|
|
@@ -75,38 +75,38 @@ function resolveSource(baseDir, relPath) {
|
|
|
75
75
|
function sigDbCacheDir(override, create = true) {
|
|
76
76
|
const base = override
|
|
77
77
|
?? process.env.FLOWR_SIGDB_CACHE ?? process.env.FLOWR_CACHE_DIR
|
|
78
|
-
?? (process.env.XDG_CACHE_HOME ?
|
|
79
|
-
?? (process.env.LOCALAPPDATA ?
|
|
80
|
-
??
|
|
81
|
-
const dir =
|
|
78
|
+
?? (process.env.XDG_CACHE_HOME ? path_1.default.join(process.env.XDG_CACHE_HOME, 'flowr') : undefined)
|
|
79
|
+
?? (process.env.LOCALAPPDATA ? path_1.default.join(process.env.LOCALAPPDATA, 'flowr', 'cache') : undefined)
|
|
80
|
+
?? path_1.default.join(os_1.default.homedir?.() || os_1.default.tmpdir(), '.cache', 'flowr');
|
|
81
|
+
const dir = path_1.default.join(base, 'sigdb');
|
|
82
82
|
if (!create) {
|
|
83
83
|
return dir;
|
|
84
84
|
}
|
|
85
85
|
try {
|
|
86
|
-
|
|
86
|
+
fs_1.default.mkdirSync(dir, { recursive: true });
|
|
87
87
|
return dir;
|
|
88
88
|
}
|
|
89
89
|
catch {
|
|
90
|
-
const tmp =
|
|
91
|
-
|
|
90
|
+
const tmp = path_1.default.join(os_1.default.tmpdir(), 'flowr-sigdb-cache');
|
|
91
|
+
fs_1.default.mkdirSync(tmp, { recursive: true });
|
|
92
92
|
return tmp;
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
/** read the (small) header line of a possibly-compressed bundle without decompressing the whole thing */
|
|
96
96
|
async function readHeaderOf(source) {
|
|
97
97
|
if (!(0, exports.isCompressed)(source)) {
|
|
98
|
-
const fd =
|
|
98
|
+
const fd = fs_1.default.openSync(source, 'r');
|
|
99
99
|
try {
|
|
100
100
|
const buf = Buffer.allocUnsafe(65536);
|
|
101
|
-
const n =
|
|
101
|
+
const n = fs_1.default.readSync(fd, buf, 0, buf.length, 0);
|
|
102
102
|
return parseHeader(buf.toString('utf8', 0, n));
|
|
103
103
|
}
|
|
104
104
|
finally {
|
|
105
|
-
|
|
105
|
+
fs_1.default.closeSync(fd);
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
108
|
const input = decompressStream(source);
|
|
109
|
-
const rl =
|
|
109
|
+
const rl = readline_1.default.createInterface({ input, crlfDelay: Infinity });
|
|
110
110
|
try {
|
|
111
111
|
const line = (await rl[Symbol.asyncIterator]().next()).value; // just the first line (the header)
|
|
112
112
|
return line !== undefined ? JSON.parse(line) : undefined;
|
|
@@ -117,24 +117,24 @@ async function readHeaderOf(source) {
|
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
119
|
function cachePaths(hash, cacheDir) {
|
|
120
|
-
const plain =
|
|
120
|
+
const plain = path_1.default.join(sigDbCacheDir(cacheDir), `sigdb-${hash}${schema_1.SigDbExt}`);
|
|
121
121
|
return { plain, idx: `${plain}.idx` };
|
|
122
122
|
}
|
|
123
123
|
/** whether a compressed source with the given content hash has already been unpacked into its decompressed cache */
|
|
124
124
|
function isUnpacked(hash, cacheDir) {
|
|
125
|
-
return
|
|
125
|
+
return fs_1.default.existsSync(cachePaths(hash, cacheDir).plain);
|
|
126
126
|
}
|
|
127
127
|
/** materialize the `.idx` for a freshly decompressed cache file -- from the supplied index or the source's sibling */
|
|
128
128
|
function writeCacheIndex(source, idx, index) {
|
|
129
129
|
if (index) {
|
|
130
|
-
|
|
130
|
+
fs_1.default.writeFileSync(idx, JSON.stringify((0, index_format_1.encodeIndex)(index)));
|
|
131
131
|
return;
|
|
132
132
|
}
|
|
133
133
|
const srcIdx = source.replace(/\.(br|zst|gz)$/, '') + '.idx';
|
|
134
|
-
if (!
|
|
134
|
+
if (!fs_1.default.existsSync(srcIdx)) {
|
|
135
135
|
throw new Error(`missing sidecar index next to ${source} (expected ${srcIdx}), and none was supplied`);
|
|
136
136
|
}
|
|
137
|
-
|
|
137
|
+
fs_1.default.copyFileSync(srcIdx, idx);
|
|
138
138
|
}
|
|
139
139
|
/**
|
|
140
140
|
* Ensure a seekable plain `.sigs.ndjson` (+ its `.idx`) exists for `source`, decompressing a `.br`/`.zst`/`.gz`
|
|
@@ -151,12 +151,12 @@ async function ensurePlain(source, opts = {}) {
|
|
|
151
151
|
hash = content?.hash ?? new hash_1.Hash53().update(source).digest();
|
|
152
152
|
}
|
|
153
153
|
const { plain, idx } = cachePaths(hash, opts.cacheDir);
|
|
154
|
-
if (
|
|
154
|
+
if (fs_1.default.existsSync(plain) && (opts.indexless || fs_1.default.existsSync(idx))) {
|
|
155
155
|
return plain;
|
|
156
156
|
}
|
|
157
157
|
const tmp = `${plain}.${process.pid}.tmp`;
|
|
158
|
-
await (0, promises_1.pipeline)(decompressStream(source),
|
|
159
|
-
|
|
158
|
+
await (0, promises_1.pipeline)(decompressStream(source), fs_1.default.createWriteStream(tmp));
|
|
159
|
+
fs_1.default.renameSync(tmp, plain);
|
|
160
160
|
if (!opts.indexless) {
|
|
161
161
|
writeCacheIndex(source, idx, opts.index);
|
|
162
162
|
}
|
|
@@ -168,14 +168,14 @@ function ensurePlainSync(source, opts) {
|
|
|
168
168
|
return source;
|
|
169
169
|
}
|
|
170
170
|
const { plain, idx } = cachePaths(opts.hash, opts.cacheDir);
|
|
171
|
-
if (
|
|
171
|
+
if (fs_1.default.existsSync(plain) && (opts.indexless || fs_1.default.existsSync(idx))) {
|
|
172
172
|
return plain;
|
|
173
173
|
}
|
|
174
|
-
const raw =
|
|
174
|
+
const raw = fs_1.default.readFileSync(source);
|
|
175
175
|
const out = (0, codec_1.decompressSyncFor)(source, raw);
|
|
176
176
|
const tmp = `${plain}.${process.pid}.tmp`;
|
|
177
|
-
|
|
178
|
-
|
|
177
|
+
fs_1.default.writeFileSync(tmp, out);
|
|
178
|
+
fs_1.default.renameSync(tmp, plain);
|
|
179
179
|
if (!opts.indexless) {
|
|
180
180
|
writeCacheIndex(source, idx, opts.index);
|
|
181
181
|
}
|
|
@@ -11,7 +11,7 @@ exports.readSigDbIndex = readSigDbIndex;
|
|
|
11
11
|
* package routing/metadata, and its compact on-disk (wire) form. Split out of `../sigdb` so the reader/writer
|
|
12
12
|
* there does not carry the index encoding.
|
|
13
13
|
*/
|
|
14
|
-
const
|
|
14
|
+
const fs_1 = __importDefault(require("fs"));
|
|
15
15
|
/** encode an index to its compact on-disk form; omit `meta` when it is hoisted elsewhere (a manifest) */
|
|
16
16
|
function encodeIndex(i, withMeta = true) {
|
|
17
17
|
return { n: i.byteCount, d: i.dict, b: i.blobs, p: i.pkgs, ...(withMeta ? { m: i.meta } : {}) };
|
|
@@ -23,6 +23,6 @@ function decodeIndex(w, meta) {
|
|
|
23
23
|
}
|
|
24
24
|
/** read a plain bundle's sidecar `.idx` file and decode it */
|
|
25
25
|
function readSigDbIndex(plainFile) {
|
|
26
|
-
return decodeIndex(JSON.parse(
|
|
26
|
+
return decodeIndex(JSON.parse(fs_1.default.readFileSync(`${plainFile}.idx`, 'utf8')));
|
|
27
27
|
}
|
|
28
28
|
//# sourceMappingURL=index-format.js.map
|
|
@@ -14,8 +14,8 @@ exports.defaultSigDbPaths = defaultSigDbPaths;
|
|
|
14
14
|
* database), reading/writing it, and discovering the bundled manifests/bundles on flowR's search path. Split
|
|
15
15
|
* out of `../sigdb` as pure format + filesystem discovery, with no dependency on the reader/writer classes.
|
|
16
16
|
*/
|
|
17
|
-
const
|
|
18
|
-
const
|
|
17
|
+
const fs_1 = __importDefault(require("fs"));
|
|
18
|
+
const path_1 = __importDefault(require("path"));
|
|
19
19
|
const schema_1 = require("./schema");
|
|
20
20
|
const codec_1 = require("./codec");
|
|
21
21
|
const decompress_1 = require("./decompress");
|
|
@@ -23,11 +23,11 @@ exports.SigDbManifestMagic = 'flowr-sigdb-manifest';
|
|
|
23
23
|
exports.SigDbManifestSchema = 2;
|
|
24
24
|
/** write a {@link SigDbManifest} (compact JSON) plus a compressed copy per available codec (`.br` always, `.zst` when supported) beside it */
|
|
25
25
|
function writeManifest(file, manifest) {
|
|
26
|
-
|
|
26
|
+
fs_1.default.mkdirSync(path_1.default.dirname(path_1.default.resolve(file)), { recursive: true });
|
|
27
27
|
const json = JSON.stringify(manifest);
|
|
28
|
-
|
|
28
|
+
fs_1.default.writeFileSync(file, json);
|
|
29
29
|
for (const spec of (0, codec_1.writeCodecs)()) {
|
|
30
|
-
|
|
30
|
+
fs_1.default.writeFileSync(`${file}${spec.ext}`, spec.compressSync(json, { level: 11, sizeHint: json.length }));
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
/** how cheap a file is to read (lower is better); one we cannot decompress here sorts last */
|
|
@@ -44,7 +44,7 @@ function readManifestFile(manifestFile) {
|
|
|
44
44
|
return JSON.parse(readManifestText(manifestFile));
|
|
45
45
|
}
|
|
46
46
|
function readManifestText(manifestFile) {
|
|
47
|
-
const raw =
|
|
47
|
+
const raw = fs_1.default.readFileSync(manifestFile);
|
|
48
48
|
return (0, codec_1.compressedExtOf)(manifestFile) ? (0, codec_1.decompressSyncFor)(manifestFile, raw).toString('utf8') : raw.toString('utf8');
|
|
49
49
|
}
|
|
50
50
|
/**
|
|
@@ -65,14 +65,14 @@ const ManifestFilePattern = new RegExp(`\\.manifest\\.json${codec_1.CompressedEx
|
|
|
65
65
|
/** a `<name>.sigs.ndjson` bundle, in any of the codecs we can read */
|
|
66
66
|
const BundleFilePattern = new RegExp(`${schema_1.SigDbExt.replace(/\./g, '\\.')}${codec_1.CompressedExtPattern}$`);
|
|
67
67
|
function sigDbBundleDirs() {
|
|
68
|
-
if (typeof
|
|
68
|
+
if (typeof fs_1.default?.readdirSync !== 'function') {
|
|
69
69
|
return [];
|
|
70
70
|
}
|
|
71
71
|
try {
|
|
72
|
-
const bundles =
|
|
73
|
-
return
|
|
72
|
+
const bundles = path_1.default.join((0, decompress_1.sigDbCacheDir)(undefined, false), 'bundles');
|
|
73
|
+
return fs_1.default.readdirSync(bundles, { withFileTypes: true })
|
|
74
74
|
.filter(e => e.isDirectory())
|
|
75
|
-
.map(e =>
|
|
75
|
+
.map(e => path_1.default.join(bundles, e.name));
|
|
76
76
|
}
|
|
77
77
|
catch {
|
|
78
78
|
return [];
|
|
@@ -83,7 +83,7 @@ function sigDbSearchRoots(extra) {
|
|
|
83
83
|
const roots = [...(extra ?? [])];
|
|
84
84
|
const env = typeof process !== 'undefined' ? process.env?.FLOWR_SIGDB_DIR : undefined;
|
|
85
85
|
if (env) {
|
|
86
|
-
roots.push(...env.split(
|
|
86
|
+
roots.push(...env.split(path_1.default.delimiter).filter(Boolean));
|
|
87
87
|
}
|
|
88
88
|
if (typeof __dirname !== 'undefined') {
|
|
89
89
|
roots.push(__dirname);
|
|
@@ -101,7 +101,7 @@ function sigDbSearchRoots(extra) {
|
|
|
101
101
|
* bundled `base`. Node only (needs `fs`); pass `searchRoots` to override where it looks.
|
|
102
102
|
*/
|
|
103
103
|
function defaultSigDbPath(scope, searchRoots) {
|
|
104
|
-
if (typeof
|
|
104
|
+
if (typeof fs_1.default?.existsSync !== 'function') {
|
|
105
105
|
return undefined;
|
|
106
106
|
}
|
|
107
107
|
const scopes = scope ? [scope] : SigDbScopeOrder;
|
|
@@ -109,8 +109,8 @@ function defaultSigDbPath(scope, searchRoots) {
|
|
|
109
109
|
for (const sub of SigDbSubDirs) {
|
|
110
110
|
for (const s of scopes) {
|
|
111
111
|
for (const suffix of ['', ...(0, codec_1.readableExtsPreferred)()]) {
|
|
112
|
-
const candidate =
|
|
113
|
-
if (
|
|
112
|
+
const candidate = path_1.default.join(dir, sub, `${s}.manifest.json${suffix}`);
|
|
113
|
+
if (fs_1.default.existsSync(candidate)) {
|
|
114
114
|
return candidate;
|
|
115
115
|
}
|
|
116
116
|
}
|
|
@@ -124,7 +124,7 @@ function defaultSigDbPath(scope, searchRoots) {
|
|
|
124
124
|
if (hit !== undefined) {
|
|
125
125
|
return hit;
|
|
126
126
|
}
|
|
127
|
-
const parent =
|
|
127
|
+
const parent = path_1.default.dirname(dir);
|
|
128
128
|
if (parent === dir) {
|
|
129
129
|
break;
|
|
130
130
|
}
|
|
@@ -147,7 +147,7 @@ function defaultSigDbPath(scope, searchRoots) {
|
|
|
147
147
|
* shard and dictionary files a manifest already owns are skipped. Deduped by filename, first search location wins.
|
|
148
148
|
*/
|
|
149
149
|
function defaultSigDbPaths(searchRoots) {
|
|
150
|
-
if (typeof
|
|
150
|
+
if (typeof fs_1.default?.readdirSync !== 'function') {
|
|
151
151
|
return [];
|
|
152
152
|
}
|
|
153
153
|
const manifests = new Map(); // `<name>.manifest.json` (ignoring compression ext) -> first-found path
|
|
@@ -168,18 +168,18 @@ function defaultSigDbPaths(searchRoots) {
|
|
|
168
168
|
for (const sub of SigDbSubDirs) {
|
|
169
169
|
let entries;
|
|
170
170
|
try {
|
|
171
|
-
entries =
|
|
171
|
+
entries = fs_1.default.readdirSync(path_1.default.join(base, sub));
|
|
172
172
|
}
|
|
173
173
|
catch {
|
|
174
174
|
continue; // directory does not exist on this root
|
|
175
175
|
}
|
|
176
|
-
const dir =
|
|
176
|
+
const dir = path_1.default.join(base, sub);
|
|
177
177
|
for (const file of entries) {
|
|
178
178
|
if (ManifestFilePattern.test(file)) {
|
|
179
|
-
keep(manifests, (0, codec_1.stripCompressedExt)(file),
|
|
179
|
+
keep(manifests, (0, codec_1.stripCompressedExt)(file), path_1.default.join(dir, file), dir);
|
|
180
180
|
}
|
|
181
181
|
else if (BundleFilePattern.test(file) && !file.includes('.dict' + schema_1.SigDbExt)) {
|
|
182
|
-
keep(standalones, (0, codec_1.stripCompressedExt)(file),
|
|
182
|
+
keep(standalones, (0, codec_1.stripCompressedExt)(file), path_1.default.join(dir, file), dir);
|
|
183
183
|
}
|
|
184
184
|
}
|
|
185
185
|
}
|
|
@@ -187,7 +187,7 @@ function defaultSigDbPaths(searchRoots) {
|
|
|
187
187
|
for (const root of sigDbSearchRoots(searchRoots)) {
|
|
188
188
|
for (let dir = root, i = 0; i < 10; i++) {
|
|
189
189
|
scanDir(dir);
|
|
190
|
-
const parent =
|
|
190
|
+
const parent = path_1.default.dirname(dir);
|
|
191
191
|
if (parent === dir) {
|
|
192
192
|
break;
|
|
193
193
|
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { PackageSignatureSource } from './reader';
|
|
2
|
+
import type { VersionRelease } from './sigdb-version';
|
|
3
|
+
import type { LibraryExports } from './schema';
|
|
4
|
+
import type { ResolvedDependency } from './decode';
|
|
5
|
+
import { RVersion } from '../../util/r-version';
|
|
6
|
+
/**
|
|
7
|
+
* One package as {@link MemorySignatureSource} carries it: the exports are what attaching it brings, the rest
|
|
8
|
+
* is what the answers below need to stay honest. Everything but the name and the exports is optional, so a
|
|
9
|
+
* caller may ship no more than it has.
|
|
10
|
+
*/
|
|
11
|
+
export interface MemoryPackage {
|
|
12
|
+
readonly version?: string;
|
|
13
|
+
readonly exported: readonly string[];
|
|
14
|
+
readonly deprecated?: readonly string[];
|
|
15
|
+
readonly s3Classes?: readonly string[];
|
|
16
|
+
readonly s4Classes?: readonly string[];
|
|
17
|
+
readonly downloads?: number;
|
|
18
|
+
readonly deps?: readonly ResolvedDependency[];
|
|
19
|
+
/** when that version was released, which is what makes it a release rather than a label */
|
|
20
|
+
readonly released?: Date;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* A signature source held entirely in memory, for the places that cannot open a database file: a browser
|
|
24
|
+
* (the playground bundles its packages rather than reading them) and a test that wants to state a package's
|
|
25
|
+
* exports outright. It answers what a package brings into scope; the per-function view a real database
|
|
26
|
+
* decodes from its blobs is not part of what it can say, so those answers stay empty.
|
|
27
|
+
* @see {@link SigDatabase} - the file-backed source
|
|
28
|
+
*/
|
|
29
|
+
export declare class MemorySignatureSource implements PackageSignatureSource {
|
|
30
|
+
private readonly packages;
|
|
31
|
+
/** reverse index `class -> owning package`, built on first use (see {@link classOwner}) */
|
|
32
|
+
private classIndex;
|
|
33
|
+
constructor(packages: Readonly<Record<string, MemoryPackage>> | ReadonlyMap<string, MemoryPackage>);
|
|
34
|
+
has(pkg: string): boolean;
|
|
35
|
+
hasVersion(pkg: string, version: string): boolean;
|
|
36
|
+
isCranVersion(pkg: string, version: string): boolean;
|
|
37
|
+
lookup(pkg: string, version?: string): LibraryExports | undefined;
|
|
38
|
+
packagesExporting(name: string): readonly string[];
|
|
39
|
+
classOwner(className: string, version?: string): string | undefined;
|
|
40
|
+
/** no blobs to decode, so the rich per-function view has nothing to give */
|
|
41
|
+
functions(): undefined;
|
|
42
|
+
functionByName(): undefined;
|
|
43
|
+
transitiveCallees(): undefined;
|
|
44
|
+
dependencies(pkg: string, version?: string): ResolvedDependency[] | undefined;
|
|
45
|
+
packageNames(): string[];
|
|
46
|
+
isBaseR(pkg: string): boolean;
|
|
47
|
+
downloads(pkg: string): number;
|
|
48
|
+
/** the R releases a base package shipped with are a property of the database, which this source has none of */
|
|
49
|
+
coreVersions(): undefined;
|
|
50
|
+
releaseDate(pkg: string): Date | undefined;
|
|
51
|
+
releaseDates(pkg: string): VersionRelease[];
|
|
52
|
+
latestVersion(pkg: string): RVersion | undefined;
|
|
53
|
+
/** nothing is held open */
|
|
54
|
+
close(): void;
|
|
55
|
+
/** whether the package answers a lookup for `version`, which an unversioned one always does */
|
|
56
|
+
private answersFor;
|
|
57
|
+
private versionOf;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* A {@link MemorySignatureSource} from what a page can carry: `package -> [version, release date, ...exports]`.
|
|
61
|
+
* The version is what the exports were read from, so recording it is what keeps a consumer from being told
|
|
62
|
+
* the package is unknown when only its history is.
|
|
63
|
+
*/
|
|
64
|
+
export declare function memorySourceOfPackages(packages: Readonly<Record<string, readonly string[]>>): MemorySignatureSource;
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MemorySignatureSource = void 0;
|
|
4
|
+
exports.memorySourceOfPackages = memorySourceOfPackages;
|
|
5
|
+
const r_version_1 = require("../../util/r-version");
|
|
6
|
+
const reader_1 = require("./reader");
|
|
7
|
+
const r_base_packages_1 = require("../../util/r-base-packages");
|
|
8
|
+
/** what {@link LibraryExports.version} says when the source was given no version to claim */
|
|
9
|
+
const UnknownVersion = '';
|
|
10
|
+
/**
|
|
11
|
+
* A signature source held entirely in memory, for the places that cannot open a database file: a browser
|
|
12
|
+
* (the playground bundles its packages rather than reading them) and a test that wants to state a package's
|
|
13
|
+
* exports outright. It answers what a package brings into scope; the per-function view a real database
|
|
14
|
+
* decodes from its blobs is not part of what it can say, so those answers stay empty.
|
|
15
|
+
* @see {@link SigDatabase} - the file-backed source
|
|
16
|
+
*/
|
|
17
|
+
class MemorySignatureSource {
|
|
18
|
+
packages;
|
|
19
|
+
/** reverse index `class -> owning package`, built on first use (see {@link classOwner}) */
|
|
20
|
+
classIndex;
|
|
21
|
+
constructor(packages) {
|
|
22
|
+
this.packages = packages instanceof Map ? packages : new Map(Object.entries(packages));
|
|
23
|
+
}
|
|
24
|
+
has(pkg) {
|
|
25
|
+
return this.packages.has(pkg);
|
|
26
|
+
}
|
|
27
|
+
hasVersion(pkg, version) {
|
|
28
|
+
const known = this.versionOf(pkg);
|
|
29
|
+
return known !== UnknownVersion && known === version;
|
|
30
|
+
}
|
|
31
|
+
isCranVersion(pkg, version) {
|
|
32
|
+
return this.hasVersion(pkg, version);
|
|
33
|
+
}
|
|
34
|
+
lookup(pkg, version) {
|
|
35
|
+
const found = this.packages.get(pkg);
|
|
36
|
+
/* a source given no version has one answer and gives it whatever is asked for: it cannot say no */
|
|
37
|
+
if (found === undefined || !this.answersFor(pkg, version)) {
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
version: this.versionOf(pkg),
|
|
42
|
+
exported: found.exported,
|
|
43
|
+
internal: [],
|
|
44
|
+
deprecated: found.deprecated ?? [],
|
|
45
|
+
s3Classes: found.s3Classes ?? [],
|
|
46
|
+
s4Classes: found.s4Classes ?? [],
|
|
47
|
+
cran: true
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
packagesExporting(name) {
|
|
51
|
+
return [...this.packages]
|
|
52
|
+
.filter(([, p]) => p.exported.includes(name))
|
|
53
|
+
.sort(([an, a], [bn, b]) => (b.downloads ?? 0) - (a.downloads ?? 0) || an.localeCompare(bn))
|
|
54
|
+
.map(([pkg]) => pkg);
|
|
55
|
+
}
|
|
56
|
+
classOwner(className, version) {
|
|
57
|
+
if (version !== undefined) {
|
|
58
|
+
return this.packageNames().find(pkg => {
|
|
59
|
+
const lib = this.lookup(pkg, version);
|
|
60
|
+
return (lib?.s3Classes.includes(className) ?? false) || (lib?.s4Classes.includes(className) ?? false);
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
this.classIndex ??= (0, reader_1.classOwnerIndexFor)(this, this.packageNames());
|
|
64
|
+
return this.classIndex.get(className);
|
|
65
|
+
}
|
|
66
|
+
/** no blobs to decode, so the rich per-function view has nothing to give */
|
|
67
|
+
functions() {
|
|
68
|
+
return undefined;
|
|
69
|
+
}
|
|
70
|
+
functionByName() {
|
|
71
|
+
return undefined;
|
|
72
|
+
}
|
|
73
|
+
transitiveCallees() {
|
|
74
|
+
return undefined;
|
|
75
|
+
}
|
|
76
|
+
dependencies(pkg, version) {
|
|
77
|
+
const found = this.packages.get(pkg);
|
|
78
|
+
if (found === undefined || !this.answersFor(pkg, version)) {
|
|
79
|
+
return undefined;
|
|
80
|
+
}
|
|
81
|
+
return [...found.deps ?? []];
|
|
82
|
+
}
|
|
83
|
+
packageNames() {
|
|
84
|
+
return [...this.packages.keys()];
|
|
85
|
+
}
|
|
86
|
+
isBaseR(pkg) {
|
|
87
|
+
return (0, r_base_packages_1.baseRPackages)().includes(pkg);
|
|
88
|
+
}
|
|
89
|
+
downloads(pkg) {
|
|
90
|
+
return this.packages.get(pkg)?.downloads ?? 0;
|
|
91
|
+
}
|
|
92
|
+
/** the R releases a base package shipped with are a property of the database, which this source has none of */
|
|
93
|
+
coreVersions() {
|
|
94
|
+
return undefined;
|
|
95
|
+
}
|
|
96
|
+
releaseDate(pkg) {
|
|
97
|
+
return this.packages.get(pkg)?.released;
|
|
98
|
+
}
|
|
99
|
+
releaseDates(pkg) {
|
|
100
|
+
const version = this.latestVersion(pkg);
|
|
101
|
+
const date = this.releaseDate(pkg);
|
|
102
|
+
return version === undefined || date === undefined ? [] : [{ version, date }];
|
|
103
|
+
}
|
|
104
|
+
latestVersion(pkg) {
|
|
105
|
+
const known = this.versionOf(pkg);
|
|
106
|
+
return known === UnknownVersion ? undefined : r_version_1.RVersion.parse(known);
|
|
107
|
+
}
|
|
108
|
+
/** nothing is held open */
|
|
109
|
+
close() {
|
|
110
|
+
/* nothing to release */
|
|
111
|
+
}
|
|
112
|
+
/** whether the package answers a lookup for `version`, which an unversioned one always does */
|
|
113
|
+
answersFor(pkg, version) {
|
|
114
|
+
return version === undefined || this.versionOf(pkg) === UnknownVersion || this.versionOf(pkg) === version;
|
|
115
|
+
}
|
|
116
|
+
versionOf(pkg) {
|
|
117
|
+
return this.packages.get(pkg)?.version ?? UnknownVersion;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
exports.MemorySignatureSource = MemorySignatureSource;
|
|
121
|
+
/**
|
|
122
|
+
* A {@link MemorySignatureSource} from what a page can carry: `package -> [version, release date, ...exports]`.
|
|
123
|
+
* The version is what the exports were read from, so recording it is what keeps a consumer from being told
|
|
124
|
+
* the package is unknown when only its history is.
|
|
125
|
+
*/
|
|
126
|
+
function memorySourceOfPackages(packages) {
|
|
127
|
+
return new MemorySignatureSource(Object.fromEntries(Object.entries(packages).map(([pkg, [version = '', released = '', ...exported]]) => [pkg, {
|
|
128
|
+
exported,
|
|
129
|
+
version: version.length > 0 ? version : undefined,
|
|
130
|
+
released: released.length > 0 ? new Date(released) : undefined
|
|
131
|
+
}])));
|
|
132
|
+
}
|
|
133
|
+
//# sourceMappingURL=memory-source.js.map
|
package/project/sigdb/reader.js
CHANGED
|
@@ -17,9 +17,9 @@ exports.verifyShardedDatabase = verifyShardedDatabase;
|
|
|
17
17
|
* whole-bundle reading, and the post-write verification gate. This is the surface the package-version plugin
|
|
18
18
|
* uses; the format/codec/writer building blocks live in the sibling `sigdb/*` modules (imported directly).
|
|
19
19
|
*/
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
const
|
|
20
|
+
const fs_1 = __importDefault(require("fs"));
|
|
21
|
+
const path_1 = __importDefault(require("path"));
|
|
22
|
+
const readline_1 = __importDefault(require("readline"));
|
|
23
23
|
const r_version_1 = require("../../util/r-version");
|
|
24
24
|
const schema_1 = require("./schema");
|
|
25
25
|
const sigdb_version_1 = require("./sigdb-version");
|
|
@@ -52,7 +52,7 @@ function readDictSection(buf, strings) {
|
|
|
52
52
|
}
|
|
53
53
|
/** stream-read a whole bundle into a {@link SigDb} (any size; never one string). Prefer {@link SigDatabase} for partial access. */
|
|
54
54
|
async function readSignatureDb(file) {
|
|
55
|
-
const rl =
|
|
55
|
+
const rl = readline_1.default.createInterface({ input: (0, decompress_1.sigDbStream)(file), crlfDelay: Infinity });
|
|
56
56
|
let header;
|
|
57
57
|
const strings = [];
|
|
58
58
|
const blobs = [];
|
|
@@ -316,9 +316,9 @@ class SigDatabase {
|
|
|
316
316
|
throw new Error('SigDatabase.openSync needs the plain .sigs.ndjson; use open() for .br/.zst/.gz');
|
|
317
317
|
}
|
|
318
318
|
const index = opts.index ?? (0, index_format_1.readSigDbIndex)(plainFile);
|
|
319
|
-
const fd =
|
|
319
|
+
const fd = fs_1.default.openSync(plainFile, 'r');
|
|
320
320
|
const head = Buffer.allocUnsafe(Math.min(65536, index.byteCount));
|
|
321
|
-
|
|
321
|
+
fs_1.default.readSync(fd, head, 0, head.length, 0);
|
|
322
322
|
const header = (0, decompress_1.parseHeader)(head.toString('utf8'));
|
|
323
323
|
let strings = opts.strings;
|
|
324
324
|
if (!strings) {
|
|
@@ -326,7 +326,7 @@ class SigDatabase {
|
|
|
326
326
|
const [dictStart, dictBytes] = index.dict;
|
|
327
327
|
if (dictBytes > 0) {
|
|
328
328
|
const buf = Buffer.allocUnsafe(dictBytes);
|
|
329
|
-
|
|
329
|
+
fs_1.default.readSync(fd, buf, 0, dictBytes, dictStart);
|
|
330
330
|
readDictSection(buf, strings);
|
|
331
331
|
}
|
|
332
332
|
}
|
|
@@ -427,7 +427,7 @@ class SigDatabase {
|
|
|
427
427
|
/** seek to a byte range, read + decode the package blob there (no caching) */
|
|
428
428
|
readBlobAt([start, bytes]) {
|
|
429
429
|
const buf = Buffer.allocUnsafe(bytes);
|
|
430
|
-
|
|
430
|
+
fs_1.default.readSync(this.fd, buf, 0, bytes, start);
|
|
431
431
|
const [, , tuple] = JSON.parse(buf.toString('utf8'));
|
|
432
432
|
return (0, decode_1.tupleToBlob)(tuple);
|
|
433
433
|
}
|
|
@@ -592,7 +592,7 @@ class SigDatabase {
|
|
|
592
592
|
this.blobCache.clear();
|
|
593
593
|
this.classIndex = undefined;
|
|
594
594
|
if (this.fd !== NoFile) {
|
|
595
|
-
|
|
595
|
+
fs_1.default.closeSync(this.fd);
|
|
596
596
|
}
|
|
597
597
|
}
|
|
598
598
|
}
|
|
@@ -636,7 +636,7 @@ class SigDatabaseSet {
|
|
|
636
636
|
}
|
|
637
637
|
/** read + validate a manifest and apply the include/exclude shard filter */
|
|
638
638
|
static prepManifest(manifestFile, opts) {
|
|
639
|
-
const baseDir =
|
|
639
|
+
const baseDir = path_1.default.dirname(manifestFile);
|
|
640
640
|
const full = (0, manifest_1.readManifestFile)(manifestFile);
|
|
641
641
|
if (full.format !== manifest_1.SigDbManifestMagic) {
|
|
642
642
|
throw new Error(`not a ${manifest_1.SigDbManifestMagic} (got ${String(full.format)})`);
|
|
@@ -698,15 +698,15 @@ class SigDatabaseSet {
|
|
|
698
698
|
}
|
|
699
699
|
const plain = (0, decompress_1.ensurePlainSync)((0, decompress_1.resolveSource)(this.baseDir, ref.path), { cacheDir: this.cacheDir, hash: ref.hash, indexless: true });
|
|
700
700
|
const strings = [];
|
|
701
|
-
const fd =
|
|
701
|
+
const fd = fs_1.default.openSync(plain, 'r');
|
|
702
702
|
try {
|
|
703
703
|
const [start, bytes] = ref.range;
|
|
704
704
|
const buf = Buffer.allocUnsafe(bytes);
|
|
705
|
-
|
|
705
|
+
fs_1.default.readSync(fd, buf, 0, bytes, start);
|
|
706
706
|
readDictSection(buf, strings);
|
|
707
707
|
}
|
|
708
708
|
finally {
|
|
709
|
-
|
|
709
|
+
fs_1.default.closeSync(fd);
|
|
710
710
|
}
|
|
711
711
|
this.dictCache.set(dictId, strings);
|
|
712
712
|
return strings;
|
|
@@ -132,7 +132,7 @@ function retrieveAllCallAliases(nodeId, graph) {
|
|
|
132
132
|
continue;
|
|
133
133
|
}
|
|
134
134
|
const [info, outgoing] = vertex;
|
|
135
|
-
if (
|
|
135
|
+
if (!vertex_1.FunctionCallVertex.is(info)) {
|
|
136
136
|
const wantedTypes = edge_1.EdgeType.Reads | edge_1.EdgeType.DefinedBy | edge_1.EdgeType.DefinedByOnCall;
|
|
137
137
|
const x = outgoing.entries()
|
|
138
138
|
.filter(([, e]) => edge_1.DfEdge.includesType(e, wantedTypes))
|
|
@@ -10,12 +10,12 @@ const graph_1 = require("../../../dataflow/graph/graph");
|
|
|
10
10
|
const simple_visitor_1 = require("../../../control-flow/simple-visitor");
|
|
11
11
|
const vertex_1 = require("../../../dataflow/graph/vertex");
|
|
12
12
|
const edge_1 = require("../../../dataflow/graph/edge");
|
|
13
|
-
const resolve_by_name_1 = require("../../../dataflow/environments/resolve-by-name");
|
|
14
13
|
const identifier_1 = require("../../../dataflow/environments/identifier");
|
|
15
14
|
const assert_1 = require("../../../util/assert");
|
|
16
15
|
const type_1 = require("../../../r-bridge/lang-4.x/ast/model/type");
|
|
17
16
|
const cascade_action_1 = require("./cascade-action");
|
|
18
17
|
const cfg_kind_1 = require("../../../project/cfg-kind");
|
|
18
|
+
const resolve_helper_1 = require("../../../dataflow/environments/resolve-helper");
|
|
19
19
|
var CallTargets;
|
|
20
20
|
(function (CallTargets) {
|
|
21
21
|
/** call targets a function that is not defined locally in the script (e.g., the call targets a library function) */
|
|
@@ -55,7 +55,7 @@ function satisfiesCallTargets(info, graph, callTarget) {
|
|
|
55
55
|
* for performance and scoping reasons, flowR will not identify the global linkage,
|
|
56
56
|
* including any potential built-in mapping.
|
|
57
57
|
*/
|
|
58
|
-
const reResolved =
|
|
58
|
+
const reResolved = resolve_helper_1.Resolve.byName(info.name, info.environment);
|
|
59
59
|
if (reResolved?.some(t => node_id_1.NodeId.isBuiltIn(t.definedAt))) {
|
|
60
60
|
builtIn = true;
|
|
61
61
|
}
|
|
@@ -242,7 +242,7 @@ function collectValuesFromLinks(args, data, linkedIds) {
|
|
|
242
242
|
}
|
|
243
243
|
// collect this one!
|
|
244
244
|
const vertex = data.dataflow.graph.getVertex(linkedId.id);
|
|
245
|
-
if (
|
|
245
|
+
if (!vertex_1.FunctionCallVertex.is(vertex)) {
|
|
246
246
|
continue;
|
|
247
247
|
}
|
|
248
248
|
const args = (0, resolve_argument_1.getArgumentStringValue)(data.config.solver.variables, data.dataflow.graph, vertex, info.argIdx, info.argName, info.resolveValue, data.ctx);
|
|
@@ -261,7 +261,7 @@ function collectValuesFromLinks(args, data, linkedIds) {
|
|
|
261
261
|
}
|
|
262
262
|
function getFunctionsToCheck(customFunctions, functionFlag, enabled, ignoreDefaultFunctions, defaultFunctions) {
|
|
263
263
|
// "If unset or empty, all function types are searched for."
|
|
264
|
-
if (enabled !== undefined && (enabled?.length === 0 || enabled.
|
|
264
|
+
if (enabled !== undefined && (enabled?.length === 0 || !enabled.includes(functionFlag))) {
|
|
265
265
|
return [];
|
|
266
266
|
}
|
|
267
267
|
let functions = ignoreDefaultFunctions ? [] : defaultFunctions.slice();
|