@eagleoutice/flowr 2.17.8 → 2.17.10
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/cli/repl/core.js +4 -0
- package/config.d.ts +11 -1
- package/config.js +45 -8
- package/control-flow/control-flow-graph.js +11 -1
- package/dataflow/environments/default-builtin-config/guards-primitive-lang.js +1 -1
- package/dataflow/environments/default-builtin-config/guards.js +6 -1
- package/dataflow/environments/default-builtin-config/index.d.ts +1 -1
- package/dataflow/environments/default-builtin-config/network-access.d.ts +1 -1
- package/dataflow/environments/default-builtin-config/network-access.js +2 -0
- package/dataflow/environments/environment.d.ts +2 -0
- package/dataflow/environments/environment.js +5 -0
- package/dataflow/environments/frame-memory.d.ts +9 -0
- package/dataflow/environments/frame-memory.js +37 -0
- package/dataflow/environments/group-generics.d.ts +2 -0
- package/dataflow/environments/group-generics.js +7 -0
- package/dataflow/environments/identifier.d.ts +2 -0
- package/dataflow/environments/identifier.js +16 -0
- package/dataflow/environments/pkg-name.d.ts +1 -0
- package/dataflow/environments/query-fn-props.d.ts +4 -0
- package/dataflow/environments/query-fn-props.js +21 -4
- package/dataflow/environments/resolve-by-name.js +5 -3
- package/dataflow/extractor.js +26 -4
- package/dataflow/fn/guards/call-contracts.js +8 -4
- package/dataflow/fn/guards/function-guards.d.ts +13 -4
- package/dataflow/fn/guards/function-guards.js +147 -52
- package/dataflow/fn/guards/guard-term.d.ts +6 -3
- package/dataflow/fn/guards/guard-term.js +12 -6
- package/dataflow/graph/graph.d.ts +2 -0
- package/dataflow/graph/graph.js +9 -5
- package/dataflow/internal/dispatch-linking.d.ts +6 -0
- package/dataflow/internal/dispatch-linking.js +25 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.d.ts +32 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +52 -21
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +28 -19
- package/dataflow/internal/process/functions/call/built-in/built-in-with.js +75 -0
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +20 -6
- package/dataflow/processor.d.ts +3 -0
- package/documentation/data/faq/faqs.js +4 -0
- package/documentation/wiki-analyzer.js +13 -2
- package/documentation/wiki-interface.js +1 -0
- package/documentation/wiki-linter.js +3 -0
- package/linter/linter-executor.js +4 -1
- package/linter/linter-format.d.ts +5 -5
- package/linter/linter-rules.d.ts +47 -13
- package/linter/linter-rules.js +3 -1
- package/linter/rules/absolute-file-paths.js +1 -1
- package/linter/rules/autoload-files.d.ts +33 -0
- package/linter/rules/autoload-files.js +94 -0
- package/linter/rules/cmd-check/description-metadata.d.ts +2 -2
- package/linter/rules/cmd-check/description-metadata.js +1 -1
- package/linter/rules/cmd-check/documentation-mismatch.d.ts +2 -2
- package/linter/rules/cmd-check/documentation-mismatch.js +1 -1
- package/linter/rules/cmd-check/file-checks.d.ts +6 -11
- package/linter/rules/cmd-check/file-checks.js +8 -3
- package/linter/rules/cmd-check/package-data.d.ts +2 -2
- package/linter/rules/cmd-check/package-data.js +1 -1
- package/linter/rules/cmd-check/package-metafiles.js +1 -1
- package/linter/rules/cmd-check/package-structure.d.ts +2 -2
- package/linter/rules/cmd-check/package-structure.js +1 -1
- package/linter/rules/cmd-check/rd-files.js +1 -1
- package/linter/rules/naming-convention.d.ts +9 -2
- package/linter/rules/process-state-in-session.js +4 -1
- package/linter/rules/software-has-license.d.ts +2 -2
- package/linter/rules/software-has-license.js +1 -2
- package/linter/rules/stop-call.d.ts +8 -3
- package/linter/rules/useless-loop.d.ts +1 -1
- package/package.json +1 -1
- package/project/cache/flowr-analyzer-cache.d.ts +3 -0
- package/project/cache/flowr-analyzer-cache.js +9 -0
- package/project/context/flowr-analyzer-context.d.ts +4 -3
- package/project/context/flowr-analyzer-context.js +18 -6
- package/project/context/flowr-analyzer-dependencies-context.d.ts +9 -0
- package/project/context/flowr-analyzer-dependencies-context.js +35 -6
- package/project/context/flowr-analyzer-environment-context.d.ts +1 -0
- package/project/context/flowr-analyzer-environment-context.js +1 -0
- package/project/context/flowr-analyzer-files-context.d.ts +4 -0
- package/project/context/flowr-analyzer-files-context.js +24 -0
- package/project/context/flowr-analyzer-functions-context.d.ts +1 -0
- package/project/context/flowr-analyzer-functions-context.js +6 -0
- package/project/context/flowr-analyzer-gas-context.d.ts +1 -0
- package/project/context/flowr-analyzer-gas-context.js +1 -0
- package/project/context/flowr-analyzer-incremental-analysis-context.d.ts +24 -0
- package/project/context/flowr-analyzer-incremental-analysis-context.js +54 -0
- package/project/context/flowr-analyzer-loading-order-context.d.ts +1 -0
- package/project/context/flowr-analyzer-loading-order-context.js +14 -0
- package/project/context/flowr-analyzer-meta-context.d.ts +1 -0
- package/project/context/flowr-analyzer-meta-context.js +11 -0
- package/project/context/flowr-file.d.ts +2 -1
- package/project/context/flowr-file.js +5 -2
- package/project/flowr-analyzer.d.ts +22 -3
- package/project/flowr-analyzer.js +36 -0
- package/project/incremental/incremental-dataflow/incremental-dataflow.d.ts +142 -0
- package/project/incremental/incremental-dataflow/incremental-dataflow.js +330 -0
- package/project/plugins/flowr-analyzer-plugin.d.ts +22 -2
- package/project/plugins/flowr-analyzer-plugin.js +16 -1
- package/project/plugins/incremental/incremental-dataflow/flowr-analyzer-incremental-dataflow-heuristic-plugin.d.ts +52 -0
- package/project/plugins/incremental/incremental-dataflow/flowr-analyzer-incremental-dataflow-heuristic-plugin.js +50 -0
- package/project/plugins/incremental/incremental-dataflow/flowr-analyzer-incremental-dataflow-update-type-plugin.d.ts +77 -0
- package/project/plugins/incremental/incremental-dataflow/flowr-analyzer-incremental-dataflow-update-type-plugin.js +151 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-plugin.d.ts +2 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-plugin.js +4 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.d.ts +1 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +3 -0
- package/project/plugins/plugin-registry.d.ts +5 -3
- package/project/plugins/plugin-registry.js +7 -2
- package/project/sigdb/decode.js +4 -1
- package/project/sigdb/dict.d.ts +7 -4
- package/project/sigdb/dict.js +20 -6
- package/project/sigdb/guarded-source.js +10 -0
- package/project/sigdb/reader.d.ts +8 -2
- package/project/sigdb/reader.js +44 -30
- package/queries/catalog/input-sources-query/simple-input-classifier.js +84 -10
- package/util/flowr-version.d.ts +1 -1
- package/util/flowr-version.js +2 -2
- package/util/objects.d.ts +14 -0
- package/util/objects.js +100 -0
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DefaultFlowrAnalyzerIncrementalDataflowUpdateTypePlugin = exports.FlowrAnalyzerIncrementalDataflowUpdateTypePlugin = exports.IncrementalUpdate = exports.IncrementalUpdateType = void 0;
|
|
4
|
+
const semver_1 = require("semver");
|
|
5
|
+
const flowr_analyzer_plugin_1 = require("../../flowr-analyzer-plugin");
|
|
6
|
+
const range_1 = require("../../../../util/range");
|
|
7
|
+
/** How the files of an analysis differ from those of the analysis before, see {@link FlowrAnalyzerIncrementalDataflowUpdateTypePlugin}. */
|
|
8
|
+
var IncrementalUpdateType;
|
|
9
|
+
(function (IncrementalUpdateType) {
|
|
10
|
+
/** Anything else, the dataflow is analyzed again from scratch. */
|
|
11
|
+
IncrementalUpdateType["Full"] = "Full";
|
|
12
|
+
/** The single file got statements appended. */
|
|
13
|
+
IncrementalUpdateType["AddedAtEnd"] = "AddedAtEnd";
|
|
14
|
+
/** The single file lost statements at its end. */
|
|
15
|
+
IncrementalUpdateType["RemovedAtEnd"] = "RemovedAtEnd";
|
|
16
|
+
/** The single file changed after its first {@link IncrementalUpdateResult#commonPrefix|commonPrefix} statements. */
|
|
17
|
+
IncrementalUpdateType["ChangedAtEnd"] = "ChangedAtEnd";
|
|
18
|
+
/** A file was added after all the files analyzed before. */
|
|
19
|
+
IncrementalUpdateType["NewFileAtEnd"] = "NewFileAtEnd";
|
|
20
|
+
/** The last file analyzed before was removed. */
|
|
21
|
+
IncrementalUpdateType["RemovedFileAtEnd"] = "RemovedFileAtEnd";
|
|
22
|
+
/** Only the source locations changed, which nodes created during the analysis copy, so this is analyzed again from the first statement that moved. */
|
|
23
|
+
IncrementalUpdateType["Location"] = "Location";
|
|
24
|
+
/** Only comments changed, which the dataflow analysis does not read. */
|
|
25
|
+
IncrementalUpdateType["Comment"] = "Comment";
|
|
26
|
+
/** Nothing changed. */
|
|
27
|
+
IncrementalUpdateType["Nothing"] = "Nothing";
|
|
28
|
+
})(IncrementalUpdateType || (exports.IncrementalUpdateType = IncrementalUpdateType = {}));
|
|
29
|
+
const UnchangedTypes = new Set([IncrementalUpdateType.Nothing, IncrementalUpdateType.Comment]);
|
|
30
|
+
/** Helper functions to ask an {@link IncrementalUpdateResult} what kind of change it is. */
|
|
31
|
+
exports.IncrementalUpdate = {
|
|
32
|
+
name: 'IncrementalUpdate',
|
|
33
|
+
/** Whether the files changed in nothing the dataflow analysis reads, i.e., at most in their comments. */
|
|
34
|
+
unchanged(update) {
|
|
35
|
+
return update.types.every(t => UnchangedTypes.has(t));
|
|
36
|
+
},
|
|
37
|
+
/** Whether `type` is the only kind of change. */
|
|
38
|
+
is(update, type) {
|
|
39
|
+
return update.types.length === 1 && update.types[0] === type;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Base class for plugins that classify how the files of an analysis changed since the analysis before,
|
|
44
|
+
* producing an {@link IncrementalUpdateResult} the incremental dataflow analysis acts on.
|
|
45
|
+
* At most one may be registered, {@link DefaultFlowrAnalyzerIncrementalDataflowUpdateTypePlugin} runs otherwise.
|
|
46
|
+
*/
|
|
47
|
+
class FlowrAnalyzerIncrementalDataflowUpdateTypePlugin extends flowr_analyzer_plugin_1.FlowrAnalyzerPlugin {
|
|
48
|
+
type = flowr_analyzer_plugin_1.PluginType.IncrementalDataflowUpdateType;
|
|
49
|
+
static defaultPlugin() {
|
|
50
|
+
return new DefaultFlowrAnalyzerIncrementalDataflowUpdateTypePlugin();
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
exports.FlowrAnalyzerIncrementalDataflowUpdateTypePlugin = FlowrAnalyzerIncrementalDataflowUpdateTypePlugin;
|
|
54
|
+
/**
|
|
55
|
+
* The default classifier, comparing the ASTs structurally.
|
|
56
|
+
* Node ids take part in the comparison, as the dataflow graph refers to the nodes by them.
|
|
57
|
+
*/
|
|
58
|
+
class DefaultFlowrAnalyzerIncrementalDataflowUpdateTypePlugin extends FlowrAnalyzerIncrementalDataflowUpdateTypePlugin {
|
|
59
|
+
name = 'default-incremental-dataflow-update-type-plugin';
|
|
60
|
+
description = 'Classifies changes by comparing the top-level statements of the analyzed files.';
|
|
61
|
+
version = new semver_1.SemVer('0.2.0');
|
|
62
|
+
process(_ctx, { previous, current }) {
|
|
63
|
+
const files = current.ast.files;
|
|
64
|
+
const shared = Math.min(previous.length, files.length);
|
|
65
|
+
for (let i = 0; i < shared; i++) {
|
|
66
|
+
if (previous[i].filePath !== files[i].filePath) {
|
|
67
|
+
return { types: [IncrementalUpdateType.Full] };
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
const differences = Array.from({ length: shared }, (_, i) => compareFiles(previous[i].root, files[i].root));
|
|
71
|
+
const unchanged = differences.every((d, i) => d.prefix === previous[i].root.children.length && d.prefix === files[i].root.children.length);
|
|
72
|
+
const moved = differences.every((d, i) => d.locations || d.prefix === previous[i].root.children.length) && differences.some(d => d.locations);
|
|
73
|
+
if (files.length === previous.length + 1 && unchanged) {
|
|
74
|
+
return { types: [IncrementalUpdateType.NewFileAtEnd], filePath: files[files.length - 1].filePath };
|
|
75
|
+
}
|
|
76
|
+
else if (files.length + 1 === previous.length && unchanged) {
|
|
77
|
+
return { types: [IncrementalUpdateType.RemovedFileAtEnd], filePath: previous[previous.length - 1].filePath };
|
|
78
|
+
}
|
|
79
|
+
else if (files.length !== previous.length) {
|
|
80
|
+
return { types: [IncrementalUpdateType.Full] };
|
|
81
|
+
}
|
|
82
|
+
if (moved) {
|
|
83
|
+
return files.length === 1 ? { types: [IncrementalUpdateType.Location], filePath: files[0].filePath, commonPrefix: differences[0].prefix } : { types: [IncrementalUpdateType.Location] };
|
|
84
|
+
}
|
|
85
|
+
else if (unchanged) {
|
|
86
|
+
return { types: [differences.some(d => d.comments) ? IncrementalUpdateType.Comment : IncrementalUpdateType.Nothing] };
|
|
87
|
+
}
|
|
88
|
+
if (files.length !== 1) {
|
|
89
|
+
return { types: [IncrementalUpdateType.Full] };
|
|
90
|
+
}
|
|
91
|
+
const [{ prefix }] = differences;
|
|
92
|
+
const before = previous[0].root.children.length;
|
|
93
|
+
const after = files[0].root.children.length;
|
|
94
|
+
const type = prefix === before ? IncrementalUpdateType.AddedAtEnd : prefix === after ? IncrementalUpdateType.RemovedAtEnd : IncrementalUpdateType.ChangedAtEnd;
|
|
95
|
+
return { types: [type], filePath: files[0].filePath, commonPrefix: prefix };
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
exports.DefaultFlowrAnalyzerIncrementalDataflowUpdateTypePlugin = DefaultFlowrAnalyzerIncrementalDataflowUpdateTypePlugin;
|
|
99
|
+
/** Keys that hold no information of their own: the parent follows from the structure, and tree-sitter ids are per parse. */
|
|
100
|
+
const IgnoredKeys = new Set(['parent', 'tsId']);
|
|
101
|
+
const LocationKeys = new Set(['location', 'fullRange']);
|
|
102
|
+
const CommentKeys = new Set(['adToks']);
|
|
103
|
+
function compareFiles(before, after) {
|
|
104
|
+
const shared = Math.min(before.children.length, after.children.length);
|
|
105
|
+
let prefix = 0;
|
|
106
|
+
let comments = !sameNode(before.info.adToks, after.info.adToks, NoKey);
|
|
107
|
+
/* a statement is the same if it is, besides its comments, as the dataflow graph keeps the locations of what it creates */
|
|
108
|
+
for (; prefix < shared; prefix++) {
|
|
109
|
+
const [a, b] = [before.children[prefix], after.children[prefix]];
|
|
110
|
+
if (sameText(a, b)) {
|
|
111
|
+
comments ||= !sameNode(a.info.adToks, b.info.adToks, NoKey);
|
|
112
|
+
}
|
|
113
|
+
else if (sameNode(a, b, key => CommentKeys.has(key))) {
|
|
114
|
+
comments = true;
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
break;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
const complete = prefix === before.children.length && prefix === after.children.length;
|
|
121
|
+
/* the statements of the prefix are the same already, so only those after it may have moved */
|
|
122
|
+
const locations = !complete && before.children.length === after.children.length
|
|
123
|
+
&& before.children.every((c, i) => i < prefix || sameNode(c, after.children[i], key => LocationKeys.has(key) || CommentKeys.has(key)));
|
|
124
|
+
return { prefix, locations, comments: complete && comments };
|
|
125
|
+
}
|
|
126
|
+
const NoKey = () => false;
|
|
127
|
+
/** Whether the two statements have the same id, range, and text, which, as the ids count the nodes before, makes them the same statement. */
|
|
128
|
+
function sameText(a, b) {
|
|
129
|
+
const [ra, rb] = [range_1.SourceRange.fromNode(a), range_1.SourceRange.fromNode(b)];
|
|
130
|
+
return a.info.id === b.info.id && a.info.fullLexeme !== undefined && a.info.fullLexeme === b.info.fullLexeme
|
|
131
|
+
&& ra !== undefined && rb !== undefined && ra.every((v, i) => v === rb[i]);
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Whether the two (sub)trees are the same, besides what `skip` names.
|
|
135
|
+
* Lexemes are compared as they are, as a change of the whitespace within them moves the locations of what follows.
|
|
136
|
+
*/
|
|
137
|
+
function sameNode(a, b, skip) {
|
|
138
|
+
if (a === b) {
|
|
139
|
+
return true;
|
|
140
|
+
}
|
|
141
|
+
else if (typeof a !== 'object' || typeof b !== 'object' || a === null || b === null) {
|
|
142
|
+
return false;
|
|
143
|
+
}
|
|
144
|
+
else if (Array.isArray(a)) {
|
|
145
|
+
return Array.isArray(b) && a.length === b.length && a.every((v, i) => sameNode(v, b[i], skip));
|
|
146
|
+
}
|
|
147
|
+
const keysA = Object.keys(a).filter(k => !IgnoredKeys.has(k) && !skip(k) && a[k] !== undefined);
|
|
148
|
+
const keysB = Object.keys(b).filter(k => !IgnoredKeys.has(k) && !skip(k) && b[k] !== undefined);
|
|
149
|
+
return keysA.length === keysB.length && keysA.every(k => sameNode(a[k], b[k], skip));
|
|
150
|
+
}
|
|
151
|
+
//# sourceMappingURL=flowr-analyzer-incremental-dataflow-update-type-plugin.js.map
|
|
@@ -23,6 +23,8 @@ export declare abstract class FlowrAnalyzerPackageVersionsPlugin extends FlowrAn
|
|
|
23
23
|
static defaultPlugin(): FlowrAnalyzerPackageVersionsPlugin;
|
|
24
24
|
/** metadata of the databases this plugin currently has loaded (empty for plugins without any) */
|
|
25
25
|
loadedDatabases(): SigDbLoadedInfo[];
|
|
26
|
+
/** Whether this plugin has a database loaded, without describing it as {@link loadedDatabases} does. */
|
|
27
|
+
hasLoadedDatabase(): boolean;
|
|
26
28
|
/** Packages known to this plugin that export `name` (empty for plugins without a database). */
|
|
27
29
|
packagesExporting(_name: BrandedIdentifier): readonly BrandedNamespace[];
|
|
28
30
|
/** The signature sources this plugin currently has loaded (empty for plugins without any). `config` lets a query resolve config-driven sources before any analysis has set the plugin's context. */
|
|
@@ -17,6 +17,10 @@ class FlowrAnalyzerPackageVersionsPlugin extends flowr_analyzer_plugin_1.FlowrAn
|
|
|
17
17
|
loadedDatabases() {
|
|
18
18
|
return [];
|
|
19
19
|
}
|
|
20
|
+
/** Whether this plugin has a database loaded, without describing it as {@link loadedDatabases} does. */
|
|
21
|
+
hasLoadedDatabase() {
|
|
22
|
+
return this.loadedDatabases().length > 0;
|
|
23
|
+
}
|
|
20
24
|
/** Packages known to this plugin that export `name` (empty for plugins without a database). */
|
|
21
25
|
packagesExporting(_name) {
|
|
22
26
|
return [];
|
package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.d.ts
CHANGED
|
@@ -69,6 +69,7 @@ export declare class FlowrAnalyzerPackageVersionsSigDbPlugin extends FlowrAnalyz
|
|
|
69
69
|
providesBaseRPackages(): boolean;
|
|
70
70
|
signatureSources(config?: FlowrConfig): readonly PackageSignatureSource[];
|
|
71
71
|
loadedDatabases(): SigDbLoadedInfo[];
|
|
72
|
+
hasLoadedDatabase(): boolean;
|
|
72
73
|
/**
|
|
73
74
|
* Packages in the loaded sources exporting `name`, self-package excluded, most downloaded first (so picking
|
|
74
75
|
* the first is the package a script most likely means); backed by the per-source memo in {@link exportOwnersBySource}, filtered here rather than there so the memo stays analyzer-independent.
|
package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js
CHANGED
|
@@ -259,6 +259,9 @@ class FlowrAnalyzerPackageVersionsSigDbPlugin extends flowr_analyzer_package_ver
|
|
|
259
259
|
loadedDatabases() {
|
|
260
260
|
return this.loadSources().map(describeLoadedDatabase);
|
|
261
261
|
}
|
|
262
|
+
hasLoadedDatabase() {
|
|
263
|
+
return this.loadSources().length > 0;
|
|
264
|
+
}
|
|
262
265
|
/**
|
|
263
266
|
* Packages in the loaded sources exporting `name`, self-package excluded, most downloaded first (so picking
|
|
264
267
|
* the first is the package a script most likely means); backed by the per-source memo in {@link exportOwnersBySource}, filtered here rather than there so the memo stays analyzer-independent.
|
|
@@ -32,8 +32,10 @@ import { FlowrAnalyzerLoadingOrderRprofilePlugin } from './loading-order-plugins
|
|
|
32
32
|
import { FlowrAnalyzerPackageVersionsLibraryPlugin } from './package-version-plugins/flowr-analyzer-package-versions-library-plugin';
|
|
33
33
|
import { FlowrAnalyzerPackageVersionsOnDemandPlugin } from './package-version-plugins/flowr-analyzer-package-versions-on-demand-plugin';
|
|
34
34
|
import { FlowrAnalyzerLoadingOrderIncludedFilesPlugin } from './loading-order-plugins/flowr-analyzer-loading-order-included-files-plugin';
|
|
35
|
+
import { DefaultFlowrAnalyzerIncrementalDataflowUpdateTypePlugin } from './incremental/incremental-dataflow/flowr-analyzer-incremental-dataflow-update-type-plugin';
|
|
36
|
+
import { AdaptiveFlowrAnalyzerIncrementalDataflowHeuristicPlugin, ConfiguredFlowrAnalyzerIncrementalDataflowHeuristicPlugin } from './incremental/incremental-dataflow/flowr-analyzer-incremental-dataflow-heuristic-plugin';
|
|
35
37
|
/** The built-in Flowr Analyzer plugins that are always available. */
|
|
36
|
-
export declare const BuiltInPlugins: [["file:description", typeof FlowrAnalyzerDescriptionFilePlugin], ["versions:description", typeof FlowrAnalyzerPackageVersionsDescriptionFilePlugin], ["versions:sigdb", typeof FlowrAnalyzerPackageVersionsSigDbPlugin], ["versions:library", typeof FlowrAnalyzerPackageVersionsLibraryPlugin], ["versions:on-demand", typeof FlowrAnalyzerPackageVersionsOnDemandPlugin], ["versions:renv", typeof FlowrAnalyzerPackageVersionsRenvPlugin], ["versions:rv", typeof FlowrAnalyzerPackageVersionsRvPlugin], ["versions:uvr", typeof FlowrAnalyzerPackageVersionsUvrPlugin], ["versions:rig", typeof FlowrAnalyzerPackageVersionsRigPlugin], ["versions:packrat", typeof FlowrAnalyzerPackageVersionsPackratPlugin], ["versions:session-info", typeof FlowrAnalyzerPackageVersionsSessionInfoPlugin], ["loading-order:description", typeof FlowrAnalyzerLoadingOrderDescriptionFilePlugin], ["loading-order:implicit-sources", typeof FlowrAnalyzerLoadingOrderImplicitSourcesPlugin], ["loading-order:rprofile", typeof FlowrAnalyzerLoadingOrderRprofilePlugin], ["loading-order:included-files", typeof FlowrAnalyzerLoadingOrderIncludedFilesPlugin], ["meta:description", typeof FlowrAnalyzerMetaDescriptionFilePlugin], ["meta:rproject", typeof FlowrAnalyzerMetaRProjectFilePlugin], ["meta:uvr", typeof FlowrAnalyzerMetaUvrManifestFilePlugin], ["meta:rig", typeof FlowrAnalyzerMetaRigProjectFilePlugin], ["meta:rig-script", typeof FlowrAnalyzerMetaRigScriptPlugin], ["file-roles:vignette", typeof FlowrAnalyzerMetaVignetteFilesPlugin], ["file-roles:test", typeof FlowrAnalyzerMetaTestFilesPlugin], ["file-roles:inst", typeof FlowrAnalyzerMetaInstFilesPlugin], ["file:rmd", typeof FlowrAnalyzerRmdFilePlugin], ["file:qmd", typeof FlowrAnalyzerQmdFilePlugin], ["file:rnw", typeof FlowrAnalyzerSweaveFilePlugin], ["file:ipynb", typeof FlowrAnalyzerJupyterFilePlugin], ["file:rout", typeof FlowrAnalyzerRSessionFilePlugin], ["file:namespace", typeof FlowrAnalyzerNamespaceFilesPlugin], ["versions:namespace", typeof FlowrAnalyzerPackageVersionsNamespaceFilePlugin], ["file:news", typeof FlowrAnalyzerNewsFilePlugin], ["file:rd-macros", typeof FlowrAnalyzerRdMacroFilePlugin], ["file:rd", typeof FlowrAnalyzerRdFilePlugin], ["file:rd-index", typeof FlowrAnalyzerRdIndexFilePlugin], ["file:rd-topics", typeof FlowrAnalyzerRdTopicIndexFilePlugin], ["file:rd-meta", typeof FlowrAnalyzerRdMetaFilePlugin], ["file:datalist", typeof FlowrAnalyzerDataListFilePlugin], ["file:sysdata", typeof FlowrAnalyzerSysdataFilePlugin], ["file:rda", typeof FlowrAnalyzerRdaFilePlugin], ["file:license", typeof FlowrAnalyzerLicenseFilePlugin], ["file:virtualenv", typeof FlowrAnalyzerVirtualEnvFilePlugin], ["file:rproject", typeof FlowrAnalyzerRProjectFilePlugin], ["file:uvr", typeof FlowrAnalyzerUvrManifestFilePlugin], ["file:rig", typeof FlowrAnalyzerRigProjectFilePlugin], ["file:rprofile", typeof FlowrAnalyzerRprofileFilePlugin], ["project-discovery:gitignore", typeof FlowrAnalyzerGitignoreProjectDiscoveryPlugin], ["project-discovery:rbuildignore", typeof FlowrAnalyzerRbuildignoreProjectDiscoveryPlugin], ["project-discovery:ignore-files", typeof FlowrAnalyzerIgnoreFileProjectDiscoveryPlugin], ["project-discovery:default", typeof FlowrAnalyzerDefaultProjectDiscoveryPlugin], ["project-discovery:full", typeof FlowrAnalyzerFullProjectDiscoveryPlugin]];
|
|
38
|
+
export declare const BuiltInPlugins: [["file:description", typeof FlowrAnalyzerDescriptionFilePlugin], ["versions:description", typeof FlowrAnalyzerPackageVersionsDescriptionFilePlugin], ["versions:sigdb", typeof FlowrAnalyzerPackageVersionsSigDbPlugin], ["versions:library", typeof FlowrAnalyzerPackageVersionsLibraryPlugin], ["versions:on-demand", typeof FlowrAnalyzerPackageVersionsOnDemandPlugin], ["versions:renv", typeof FlowrAnalyzerPackageVersionsRenvPlugin], ["versions:rv", typeof FlowrAnalyzerPackageVersionsRvPlugin], ["versions:uvr", typeof FlowrAnalyzerPackageVersionsUvrPlugin], ["versions:rig", typeof FlowrAnalyzerPackageVersionsRigPlugin], ["versions:packrat", typeof FlowrAnalyzerPackageVersionsPackratPlugin], ["versions:session-info", typeof FlowrAnalyzerPackageVersionsSessionInfoPlugin], ["loading-order:description", typeof FlowrAnalyzerLoadingOrderDescriptionFilePlugin], ["loading-order:implicit-sources", typeof FlowrAnalyzerLoadingOrderImplicitSourcesPlugin], ["loading-order:rprofile", typeof FlowrAnalyzerLoadingOrderRprofilePlugin], ["loading-order:included-files", typeof FlowrAnalyzerLoadingOrderIncludedFilesPlugin], ["meta:description", typeof FlowrAnalyzerMetaDescriptionFilePlugin], ["meta:rproject", typeof FlowrAnalyzerMetaRProjectFilePlugin], ["meta:uvr", typeof FlowrAnalyzerMetaUvrManifestFilePlugin], ["meta:rig", typeof FlowrAnalyzerMetaRigProjectFilePlugin], ["meta:rig-script", typeof FlowrAnalyzerMetaRigScriptPlugin], ["file-roles:vignette", typeof FlowrAnalyzerMetaVignetteFilesPlugin], ["file-roles:test", typeof FlowrAnalyzerMetaTestFilesPlugin], ["file-roles:inst", typeof FlowrAnalyzerMetaInstFilesPlugin], ["file:rmd", typeof FlowrAnalyzerRmdFilePlugin], ["file:qmd", typeof FlowrAnalyzerQmdFilePlugin], ["file:rnw", typeof FlowrAnalyzerSweaveFilePlugin], ["file:ipynb", typeof FlowrAnalyzerJupyterFilePlugin], ["file:rout", typeof FlowrAnalyzerRSessionFilePlugin], ["file:namespace", typeof FlowrAnalyzerNamespaceFilesPlugin], ["versions:namespace", typeof FlowrAnalyzerPackageVersionsNamespaceFilePlugin], ["file:news", typeof FlowrAnalyzerNewsFilePlugin], ["file:rd-macros", typeof FlowrAnalyzerRdMacroFilePlugin], ["file:rd", typeof FlowrAnalyzerRdFilePlugin], ["file:rd-index", typeof FlowrAnalyzerRdIndexFilePlugin], ["file:rd-topics", typeof FlowrAnalyzerRdTopicIndexFilePlugin], ["file:rd-meta", typeof FlowrAnalyzerRdMetaFilePlugin], ["file:datalist", typeof FlowrAnalyzerDataListFilePlugin], ["file:sysdata", typeof FlowrAnalyzerSysdataFilePlugin], ["file:rda", typeof FlowrAnalyzerRdaFilePlugin], ["file:license", typeof FlowrAnalyzerLicenseFilePlugin], ["file:virtualenv", typeof FlowrAnalyzerVirtualEnvFilePlugin], ["file:rproject", typeof FlowrAnalyzerRProjectFilePlugin], ["file:uvr", typeof FlowrAnalyzerUvrManifestFilePlugin], ["file:rig", typeof FlowrAnalyzerRigProjectFilePlugin], ["file:rprofile", typeof FlowrAnalyzerRprofileFilePlugin], ["project-discovery:gitignore", typeof FlowrAnalyzerGitignoreProjectDiscoveryPlugin], ["project-discovery:rbuildignore", typeof FlowrAnalyzerRbuildignoreProjectDiscoveryPlugin], ["project-discovery:ignore-files", typeof FlowrAnalyzerIgnoreFileProjectDiscoveryPlugin], ["project-discovery:default", typeof FlowrAnalyzerDefaultProjectDiscoveryPlugin], ["project-discovery:full", typeof FlowrAnalyzerFullProjectDiscoveryPlugin], ["incremental-dataflow-update-type:default", typeof DefaultFlowrAnalyzerIncrementalDataflowUpdateTypePlugin], ["incremental-dataflow-heuristic:configured", typeof ConfiguredFlowrAnalyzerIncrementalDataflowHeuristicPlugin], ["incremental-dataflow-heuristic:adaptive", typeof AdaptiveFlowrAnalyzerIncrementalDataflowHeuristicPlugin]];
|
|
37
39
|
export type BuiltInFlowrPluginName = typeof BuiltInPlugins[number][0];
|
|
38
40
|
export type BuiltInFlowrPluginArgs<N extends BuiltInFlowrPluginName> = N extends typeof BuiltInPlugins[number][0] ? ConstructorParameters<Extract<typeof BuiltInPlugins[number], [N, PluginProducer]>[1]> : never;
|
|
39
41
|
type PluginProducer = new (...args: never[]) => FlowrAnalyzerPlugin;
|
|
@@ -47,8 +49,8 @@ export declare function getPlugin(name: string, args?: unknown[]): FlowrAnalyzer
|
|
|
47
49
|
*/
|
|
48
50
|
export type PluginToRegister<T extends BuiltInFlowrPluginName | string> = FlowrAnalyzerPlugin | T | string | (T extends BuiltInFlowrPluginName ? [
|
|
49
51
|
T,
|
|
50
|
-
BuiltInFlowrPluginArgs<T
|
|
51
|
-
] : [string, unknown[]]);
|
|
52
|
+
BuiltInFlowrPluginArgs<T>?
|
|
53
|
+
] : [string, unknown[]?]);
|
|
52
54
|
/** Create a Flowr Analyzer plugin from a {@link PluginToRegister} specification. */
|
|
53
55
|
export declare function makePlugin<T extends BuiltInFlowrPluginName | string>(toRegister: PluginToRegister<T>): FlowrAnalyzerPlugin;
|
|
54
56
|
export {};
|
|
@@ -38,6 +38,8 @@ const flowr_analyzer_loading_order_rprofile_plugin_1 = require("./loading-order-
|
|
|
38
38
|
const flowr_analyzer_package_versions_library_plugin_1 = require("./package-version-plugins/flowr-analyzer-package-versions-library-plugin");
|
|
39
39
|
const flowr_analyzer_package_versions_on_demand_plugin_1 = require("./package-version-plugins/flowr-analyzer-package-versions-on-demand-plugin");
|
|
40
40
|
const flowr_analyzer_loading_order_included_files_plugin_1 = require("./loading-order-plugins/flowr-analyzer-loading-order-included-files-plugin");
|
|
41
|
+
const flowr_analyzer_incremental_dataflow_update_type_plugin_1 = require("./incremental/incremental-dataflow/flowr-analyzer-incremental-dataflow-update-type-plugin");
|
|
42
|
+
const flowr_analyzer_incremental_dataflow_heuristic_plugin_1 = require("./incremental/incremental-dataflow/flowr-analyzer-incremental-dataflow-heuristic-plugin");
|
|
41
43
|
/** The built-in Flowr Analyzer plugins that are always available. */
|
|
42
44
|
exports.BuiltInPlugins = [
|
|
43
45
|
['file:description', flowr_analyzer_description_file_plugin_1.FlowrAnalyzerDescriptionFilePlugin],
|
|
@@ -91,7 +93,10 @@ exports.BuiltInPlugins = [
|
|
|
91
93
|
['project-discovery:rbuildignore', flowr_analyzer_ignore_file_project_discovery_plugin_1.FlowrAnalyzerRbuildignoreProjectDiscoveryPlugin],
|
|
92
94
|
['project-discovery:ignore-files', flowr_analyzer_ignore_file_project_discovery_plugin_1.FlowrAnalyzerIgnoreFileProjectDiscoveryPlugin],
|
|
93
95
|
['project-discovery:default', flowr_analyzer_project_discovery_plugin_1.FlowrAnalyzerDefaultProjectDiscoveryPlugin],
|
|
94
|
-
['project-discovery:full', flowr_analyzer_project_discovery_plugin_1.FlowrAnalyzerFullProjectDiscoveryPlugin]
|
|
96
|
+
['project-discovery:full', flowr_analyzer_project_discovery_plugin_1.FlowrAnalyzerFullProjectDiscoveryPlugin],
|
|
97
|
+
['incremental-dataflow-update-type:default', flowr_analyzer_incremental_dataflow_update_type_plugin_1.DefaultFlowrAnalyzerIncrementalDataflowUpdateTypePlugin],
|
|
98
|
+
['incremental-dataflow-heuristic:configured', flowr_analyzer_incremental_dataflow_heuristic_plugin_1.ConfiguredFlowrAnalyzerIncrementalDataflowHeuristicPlugin],
|
|
99
|
+
['incremental-dataflow-heuristic:adaptive', flowr_analyzer_incremental_dataflow_heuristic_plugin_1.AdaptiveFlowrAnalyzerIncrementalDataflowHeuristicPlugin]
|
|
95
100
|
];
|
|
96
101
|
/**
|
|
97
102
|
* The registry of built-in and user-registered Flowr Analyzer plugins.
|
|
@@ -116,7 +121,7 @@ function makePlugin(toRegister) {
|
|
|
116
121
|
return toRegister;
|
|
117
122
|
}
|
|
118
123
|
if (Array.isArray(toRegister)) {
|
|
119
|
-
const [name, args] = toRegister;
|
|
124
|
+
const [name, args = []] = toRegister;
|
|
120
125
|
const plugin = getPlugin(name, args);
|
|
121
126
|
(0, assert_1.guard)(plugin !== undefined, () => `Unknown Flowr Analyzer plugin: ${name.toString()}`);
|
|
122
127
|
return plugin;
|
package/project/sigdb/decode.js
CHANGED
|
@@ -13,6 +13,7 @@ exports.deriveLibraryExports = deriveLibraryExports;
|
|
|
13
13
|
const schema_1 = require("./schema");
|
|
14
14
|
const sigdb_version_1 = require("./sigdb-version");
|
|
15
15
|
const objects_1 = require("../../util/objects");
|
|
16
|
+
const defaultmap_1 = require("../../util/collections/defaultmap");
|
|
16
17
|
const r_primitives_generated_1 = require("../../data/r-primitives.generated");
|
|
17
18
|
/**
|
|
18
19
|
* Reconstruct the CRAN source blob link which is the newest non-archived version lives under `src/contrib`,
|
|
@@ -222,6 +223,8 @@ function deriveLibraryExports(strings, blob, meta, pkg, version, cranBase = sche
|
|
|
222
223
|
const s4Classes = [];
|
|
223
224
|
const locations = new Map();
|
|
224
225
|
const reexports = new Map();
|
|
226
|
+
/* the functions of a package share a few files, so each of their names is built once */
|
|
227
|
+
const files = new defaultmap_1.DefaultMap(idx => strings.at(idx));
|
|
225
228
|
for (const i of idxs) {
|
|
226
229
|
const [nameIdx, , , bits, fileIdx, line, , reexportIdx] = blob.fns[i];
|
|
227
230
|
const name = strings.at(nameIdx);
|
|
@@ -236,7 +239,7 @@ function deriveLibraryExports(strings, blob, meta, pkg, version, cranBase = sche
|
|
|
236
239
|
s4Classes.push(name);
|
|
237
240
|
}
|
|
238
241
|
if (fileIdx >= 0) {
|
|
239
|
-
locations.set(name, { file:
|
|
242
|
+
locations.set(name, { file: files.get(fileIdx), line });
|
|
240
243
|
}
|
|
241
244
|
if (reexportIdx !== undefined) {
|
|
242
245
|
reexports.set(name, strings.at(reexportIdx));
|
package/project/sigdb/dict.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { BrandedIdentifier } from '../../dataflow/environments/identifier';
|
|
2
1
|
/**
|
|
3
2
|
* A bundle's string dictionary, held as the bytes of its names rather than as an array of strings.
|
|
4
3
|
* Split apart, a dictionary of 1.4 million names cost a slice object per name and kept the text alive
|
|
@@ -8,6 +7,8 @@ import type { BrandedIdentifier } from '../../dataflow/environments/identifier';
|
|
|
8
7
|
*/
|
|
9
8
|
/** A dictionary's names by id. Ids are positions, so {@link SigDict.at} is what `strings[id]` used to be. */
|
|
10
9
|
export declare class SigDict implements Iterable<string> {
|
|
10
|
+
/** how many groups {@link SigDict.groupOf} tells apart */
|
|
11
|
+
static readonly Groups: number;
|
|
11
12
|
/** every name in utf8, separated by newlines, so a name never carries one */
|
|
12
13
|
private readonly bytes;
|
|
13
14
|
/** where each name ends in {@link bytes}; the next one starts one past that */
|
|
@@ -25,10 +26,12 @@ export declare class SigDict implements Iterable<string> {
|
|
|
25
26
|
get length(): number;
|
|
26
27
|
/** The name with the given id, `''` for an id the dictionary does not hold. */
|
|
27
28
|
at(id: number): string;
|
|
28
|
-
/** The group the name with the given id belongs to, as {@link SigDict.
|
|
29
|
+
/** The group the name with the given id belongs to, as {@link SigDict.groupOfBytes} groups one in hand. */
|
|
29
30
|
groupOf(id: number): number;
|
|
30
|
-
/** The group
|
|
31
|
-
static
|
|
31
|
+
/** The group a name spelled `bytes` in utf8 would be in, so a lookup only compares the names that could match it. */
|
|
32
|
+
static groupOfBytes(bytes: Uint8Array): number;
|
|
33
|
+
/** Whether the name with the given id is spelled `bytes` in utf8, without building the name to compare it. */
|
|
34
|
+
spells(id: number, bytes: Uint8Array): boolean;
|
|
32
35
|
private startOf;
|
|
33
36
|
[Symbol.iterator](): Iterator<string>;
|
|
34
37
|
}
|
package/project/sigdb/dict.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SigDict = void 0;
|
|
4
2
|
/**
|
|
5
3
|
* A bundle's string dictionary, held as the bytes of its names rather than as an array of strings.
|
|
6
4
|
* Split apart, a dictionary of 1.4 million names cost a slice object per name and kept the text alive
|
|
@@ -8,8 +6,12 @@ exports.SigDict = void 0;
|
|
|
8
6
|
* `--max-old-space-size` bounds, and a name is built only when something asks for it.
|
|
9
7
|
* @module
|
|
10
8
|
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.SigDict = void 0;
|
|
11
11
|
/** A dictionary's names by id. Ids are positions, so {@link SigDict.at} is what `strings[id]` used to be. */
|
|
12
12
|
class SigDict {
|
|
13
|
+
/** how many groups {@link SigDict.groupOf} tells apart */
|
|
14
|
+
static Groups = 1 << 16;
|
|
13
15
|
/** every name in utf8, separated by newlines, so a name never carries one */
|
|
14
16
|
bytes;
|
|
15
17
|
/** where each name ends in {@link bytes}; the next one starts one past that */
|
|
@@ -64,16 +66,28 @@ class SigDict {
|
|
|
64
66
|
at(id) {
|
|
65
67
|
return id < 0 || id >= this.ends.length ? '' : this.bytes.toString('utf8', this.startOf(id), this.ends[id]);
|
|
66
68
|
}
|
|
67
|
-
/** The group the name with the given id belongs to, as {@link SigDict.
|
|
69
|
+
/** The group the name with the given id belongs to, as {@link SigDict.groupOfBytes} groups one in hand. */
|
|
68
70
|
groupOf(id) {
|
|
69
71
|
const start = this.startOf(id);
|
|
70
72
|
return group(this.ends[id] - start, this.bytes[start]);
|
|
71
73
|
}
|
|
72
|
-
/** The group
|
|
73
|
-
static
|
|
74
|
-
const bytes = Buffer.from(name, 'utf8');
|
|
74
|
+
/** The group a name spelled `bytes` in utf8 would be in, so a lookup only compares the names that could match it. */
|
|
75
|
+
static groupOfBytes(bytes) {
|
|
75
76
|
return group(bytes.length, bytes[0]);
|
|
76
77
|
}
|
|
78
|
+
/** Whether the name with the given id is spelled `bytes` in utf8, without building the name to compare it. */
|
|
79
|
+
spells(id, bytes) {
|
|
80
|
+
const start = this.startOf(id);
|
|
81
|
+
if (this.ends[id] - start !== bytes.length) {
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
85
|
+
if (this.bytes[start + i] !== bytes[i]) {
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
77
91
|
startOf(id) {
|
|
78
92
|
return id === 0 ? 0 : this.ends[id - 1] + 1;
|
|
79
93
|
}
|
|
@@ -7,6 +7,16 @@ const built_in_guards_1 = require("../../dataflow/fn/guards/built-in-guards");
|
|
|
7
7
|
* base package where the source itself records none, so a reader sees them the same way whichever source they come from.
|
|
8
8
|
*/
|
|
9
9
|
function withGuards(source) {
|
|
10
|
+
let view = guarded.get(source);
|
|
11
|
+
if (view === undefined) {
|
|
12
|
+
view = guardedView(source);
|
|
13
|
+
guarded.set(source, view);
|
|
14
|
+
}
|
|
15
|
+
return view;
|
|
16
|
+
}
|
|
17
|
+
/** the view {@link withGuards} answers with per source, as it is asked for one with every lookup */
|
|
18
|
+
const guarded = new WeakMap();
|
|
19
|
+
function guardedView(source) {
|
|
10
20
|
function add(pkg, fn) {
|
|
11
21
|
const guards = fn === undefined || fn.guards !== undefined || !source.isBaseR(pkg) ? undefined : (0, built_in_guards_1.builtInGuards)(fn.name, pkg);
|
|
12
22
|
return guards === undefined ? fn : { ...fn, guards };
|
|
@@ -143,7 +143,8 @@ export interface SigDbOpenOptions {
|
|
|
143
143
|
/** a caller-supplied index/dictionary for {@link SigDatabase.openSync} (both derived from the source otherwise) */
|
|
144
144
|
export interface OpenSyncOptions {
|
|
145
145
|
index?: SigDbIndex;
|
|
146
|
-
|
|
146
|
+
/** the dictionary, or how to load it once the first name is asked for */
|
|
147
|
+
strings?: SigDict | (() => SigDict);
|
|
147
148
|
}
|
|
148
149
|
/** {@link SigDatabase.openSyncFrom} options: cache settings plus an optional precomputed hash/index/dictionary */
|
|
149
150
|
export interface OpenSyncFromOptions extends SigDbOpenOptions, OpenSyncOptions {
|
|
@@ -199,7 +200,8 @@ export declare class SigDatabase extends HistorySource implements PackageSignatu
|
|
|
199
200
|
*/
|
|
200
201
|
private readonly outlines;
|
|
201
202
|
private readonly fd;
|
|
202
|
-
|
|
203
|
+
/** the dictionary, or how to load it: a bundle asked only for the versions it holds never needs its names */
|
|
204
|
+
private dictionary;
|
|
203
205
|
readonly index: SigDbIndex;
|
|
204
206
|
readonly content: SigDbContent | undefined;
|
|
205
207
|
private readonly cranBase;
|
|
@@ -218,6 +220,7 @@ export declare class SigDatabase extends HistorySource implements PackageSignatu
|
|
|
218
220
|
* is compressed. Pass `strings` for a blob-only shard that shares an already-loaded dictionary.
|
|
219
221
|
*/
|
|
220
222
|
static openSyncFrom(source: string, opts: OpenSyncFromOptions): SigDatabase;
|
|
223
|
+
get strings(): SigDict;
|
|
221
224
|
has(pkg: BrandedNamespace): boolean;
|
|
222
225
|
packageNames(): BrandedNamespace[];
|
|
223
226
|
/** load a single package's blob by seeking to its line (undefined if absent); cached by blob index */
|
|
@@ -311,6 +314,8 @@ export declare class SigDatabaseSet extends HistorySource implements PackageSign
|
|
|
311
314
|
/** package name to shard indices, ordered by preference (current before full) */
|
|
312
315
|
private readonly routes;
|
|
313
316
|
private readonly cacheDir?;
|
|
317
|
+
/** the latest version per package asked for, as every name resolved asks for it and parsing it costs more than the lookup; at most one per package of the set */
|
|
318
|
+
private readonly latest;
|
|
314
319
|
private constructor();
|
|
315
320
|
/** read + validate a manifest and apply the include/exclude shard filter */
|
|
316
321
|
private static prepManifest;
|
|
@@ -372,6 +377,7 @@ export declare class SigDatabaseSet extends HistorySource implements PackageSign
|
|
|
372
377
|
/** whether the latest version of the package is CRAN-archived (see {@link SigDatabase.archived}); O(1) via the hoisted metadata */
|
|
373
378
|
archived(pkg: BrandedNamespace): boolean;
|
|
374
379
|
protected recordedLatest(pkg: BrandedNamespace): string;
|
|
380
|
+
latestVersion(pkg: BrandedNamespace): RVersion | undefined;
|
|
375
381
|
/**
|
|
376
382
|
* Close every opened shard's file descriptor and drop the in-memory caches (opened shards + shared
|
|
377
383
|
* dictionaries), so the (potentially large) dictionary strings can be reclaimed by the GC. Idempotent.
|
package/project/sigdb/reader.js
CHANGED
|
@@ -38,39 +38,37 @@ function applyDictLine(json, strings) {
|
|
|
38
38
|
const { start, names } = dictLineRun(json);
|
|
39
39
|
names.split('\n').forEach((name, k) => strings[start + k] = name);
|
|
40
40
|
}
|
|
41
|
-
/**
|
|
42
|
-
* Dictionary ids grouped by first byte and byte length, kept per dictionary rather than per reader (the shards of one
|
|
43
|
-
* database read the same one). One `Int32Array` per group, ascending, so a lookup answers what `indexOf` would while
|
|
44
|
-
* comparing a few hundred names rather than the 1.4 million a scan of the whole dictionary walks.
|
|
45
|
-
*/
|
|
46
41
|
const dictionaryBuckets = new WeakMap();
|
|
42
|
+
/** Sorts the ids by their group, counting the groups first, so every id is written once to where it belongs. */
|
|
43
|
+
function bucketsOf(strings) {
|
|
44
|
+
const starts = new Int32Array(dict_1.SigDict.Groups + 1);
|
|
45
|
+
for (let i = 0; i < strings.length; i++) {
|
|
46
|
+
starts[strings.groupOf(i) + 1]++;
|
|
47
|
+
}
|
|
48
|
+
for (let group = 0; group < dict_1.SigDict.Groups; group++) {
|
|
49
|
+
starts[group + 1] += starts[group];
|
|
50
|
+
}
|
|
51
|
+
const next = starts.slice();
|
|
52
|
+
const ids = new Int32Array(strings.length);
|
|
53
|
+
for (let i = 0; i < strings.length; i++) {
|
|
54
|
+
ids[next[strings.groupOf(i)]++] = i;
|
|
55
|
+
}
|
|
56
|
+
return { ids, starts };
|
|
57
|
+
}
|
|
47
58
|
/** the id `strings.indexOf(name)` would give, through {@link dictionaryBuckets}; `-1` when the dictionary lacks it */
|
|
48
59
|
function dictionaryIdOf(strings, name) {
|
|
49
60
|
let buckets = dictionaryBuckets.get(strings);
|
|
50
61
|
if (buckets === undefined) {
|
|
51
|
-
|
|
52
|
-
lookup per entry to know where in its group the next one goes */
|
|
53
|
-
const grouped = new Map();
|
|
54
|
-
for (let i = 0; i < strings.length; i++) {
|
|
55
|
-
const key = strings.groupOf(i);
|
|
56
|
-
const group = grouped.get(key);
|
|
57
|
-
if (group === undefined) {
|
|
58
|
-
grouped.set(key, [i]);
|
|
59
|
-
}
|
|
60
|
-
else {
|
|
61
|
-
group.push(i);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
buckets = new Map();
|
|
65
|
-
for (const [key, group] of grouped) {
|
|
66
|
-
buckets.set(key, Int32Array.from(group));
|
|
67
|
-
}
|
|
62
|
+
buckets = bucketsOf(strings);
|
|
68
63
|
dictionaryBuckets.set(strings, buckets);
|
|
69
64
|
}
|
|
70
|
-
const
|
|
65
|
+
const bytes = Buffer.from(name, 'utf8');
|
|
66
|
+
const group = dict_1.SigDict.groupOfBytes(bytes);
|
|
71
67
|
/* ascending, so the first match is the one a scan from the front would have found */
|
|
72
|
-
for (
|
|
73
|
-
|
|
68
|
+
for (let at = buckets.starts[group]; at < buckets.starts[group + 1]; at++) {
|
|
69
|
+
const id = buckets.ids[at];
|
|
70
|
+
/* the bytes rule out nearly every name of the group without building it */
|
|
71
|
+
if (strings.spells(id, bytes) && strings.at(id) === name) {
|
|
74
72
|
return id;
|
|
75
73
|
}
|
|
76
74
|
}
|
|
@@ -409,14 +407,15 @@ class SigDatabase extends HistorySource {
|
|
|
409
407
|
*/
|
|
410
408
|
outlines = new Map();
|
|
411
409
|
fd;
|
|
412
|
-
|
|
410
|
+
/** the dictionary, or how to load it: a bundle asked only for the versions it holds never needs its names */
|
|
411
|
+
dictionary;
|
|
413
412
|
index;
|
|
414
413
|
content;
|
|
415
414
|
cranBase;
|
|
416
415
|
constructor(fd, strings, index, content, cranBase) {
|
|
417
416
|
super();
|
|
418
417
|
this.fd = fd;
|
|
419
|
-
this.
|
|
418
|
+
this.dictionary = strings;
|
|
420
419
|
this.index = index;
|
|
421
420
|
this.content = content;
|
|
422
421
|
this.cranBase = cranBase;
|
|
@@ -474,6 +473,12 @@ class SigDatabase extends HistorySource {
|
|
|
474
473
|
}
|
|
475
474
|
return SigDatabase.openSync(plain, { index: opts.index, strings: opts.strings });
|
|
476
475
|
}
|
|
476
|
+
get strings() {
|
|
477
|
+
if (typeof this.dictionary === 'function') {
|
|
478
|
+
this.dictionary = this.dictionary();
|
|
479
|
+
}
|
|
480
|
+
return this.dictionary;
|
|
481
|
+
}
|
|
477
482
|
has(pkg) {
|
|
478
483
|
return this.index.pkgs[pkg] !== undefined;
|
|
479
484
|
}
|
|
@@ -790,6 +795,8 @@ class SigDatabaseSet extends HistorySource {
|
|
|
790
795
|
/** package name to shard indices, ordered by preference (current before full) */
|
|
791
796
|
routes;
|
|
792
797
|
cacheDir;
|
|
798
|
+
/** the latest version per package asked for, as every name resolved asks for it and parsing it costs more than the lookup; at most one per package of the set */
|
|
799
|
+
latest = new Map();
|
|
793
800
|
constructor(manifest, baseDir, indices, routes, cacheDir) {
|
|
794
801
|
super();
|
|
795
802
|
this.manifest = manifest;
|
|
@@ -891,7 +898,8 @@ class SigDatabaseSet extends HistorySource {
|
|
|
891
898
|
return existing;
|
|
892
899
|
}
|
|
893
900
|
const ref = this.manifest.shards[i];
|
|
894
|
-
const
|
|
901
|
+
const dict = ref.dict;
|
|
902
|
+
const strings = dict ? () => this.dictionaryStrings(dict) : undefined;
|
|
895
903
|
return this.opened[i] = SigDatabase.openSyncFrom((0, decompress_1.resolveSource)(this.baseDir, ref.path), { cacheDir: this.cacheDir, hash: ref.hash, index: this.indices[i], strings });
|
|
896
904
|
}
|
|
897
905
|
/**
|
|
@@ -918,9 +926,9 @@ class SigDatabaseSet extends HistorySource {
|
|
|
918
926
|
return ref ? (0, decompress_1.ensurePlain)((0, decompress_1.resolveSource)(this.baseDir, ref.path), { cacheDir: this.cacheDir, hash: ref.hash, indexless: true, bytes: ref.byteCount }) : Promise.resolve('');
|
|
919
927
|
});
|
|
920
928
|
await Promise.all([...shardJobs, ...dictJobs]);
|
|
921
|
-
// open each shard now so later synchronous queries never block
|
|
929
|
+
// open each shard and its dictionary now so later synchronous queries never block
|
|
922
930
|
for (const i of need) {
|
|
923
|
-
this.shard(i);
|
|
931
|
+
void this.shard(i).strings;
|
|
924
932
|
}
|
|
925
933
|
}
|
|
926
934
|
/** the shard indices that can serve this package, preferred order; optionally requiring a specific version */
|
|
@@ -1027,6 +1035,12 @@ class SigDatabaseSet extends HistorySource {
|
|
|
1027
1035
|
recordedLatest(pkg) {
|
|
1028
1036
|
return this.manifest.meta?.[pkg]?.[0] ?? '';
|
|
1029
1037
|
}
|
|
1038
|
+
latestVersion(pkg) {
|
|
1039
|
+
if (!this.latest.has(pkg)) {
|
|
1040
|
+
this.latest.set(pkg, super.latestVersion(pkg));
|
|
1041
|
+
}
|
|
1042
|
+
return this.latest.get(pkg);
|
|
1043
|
+
}
|
|
1030
1044
|
/**
|
|
1031
1045
|
* Close every opened shard's file descriptor and drop the in-memory caches (opened shards + shared
|
|
1032
1046
|
* dictionaries), so the (potentially large) dictionary strings can be reclaimed by the GC. Idempotent.
|