@eagleoutice/flowr 2.15.5 → 2.15.8
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/config.js +1 -0
- package/dataflow/environments/default-builtin-config.d.ts +57 -0
- package/dataflow/environments/default-builtin-config.js +6 -2
- package/dataflow/environments/environment.d.ts +11 -19
- package/dataflow/environments/environment.js +17 -39
- package/dataflow/environments/frame-memory.d.ts +19 -73
- package/dataflow/environments/frame-memory.js +32 -207
- package/dataflow/environments/identifier.d.ts +5 -0
- package/dataflow/internal/process/functions/call/argument/make-argument.d.ts +1 -1
- package/dataflow/internal/process/functions/call/argument/make-argument.js +17 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-string-template.js +12 -0
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +5 -19
- package/dataflow/internal/process/process-named-call.d.ts +2 -2
- package/dataflow/internal/process/process-named-call.js +3 -3
- package/documentation/wiki-setup.js +28 -3
- package/package.json +1 -1
- package/project/context/flowr-analyzer-files-context.d.ts +2 -2
- package/project/context/flowr-analyzer-files-context.js +3 -0
- package/project/sigdb/decode.d.ts +5 -4
- package/project/sigdb/decode.js +13 -18
- package/project/sigdb/dict.d.ts +35 -0
- package/project/sigdb/dict.js +97 -0
- package/project/sigdb/hash.d.ts +7 -2
- package/project/sigdb/reader.d.ts +5 -4
- package/project/sigdb/reader.js +31 -24
- package/slicing/static/fingerprint.js +6 -12
- package/util/text/playground-link.d.ts +14 -5
- package/util/text/playground-link.js +32 -8
- package/util/version.js +2 -2
package/project/sigdb/decode.js
CHANGED
|
@@ -9,11 +9,6 @@ exports.decodeDependencies = decodeDependencies;
|
|
|
9
9
|
exports.decodeClasses = decodeClasses;
|
|
10
10
|
exports.versionFnIndices = versionFnIndices;
|
|
11
11
|
exports.deriveLibraryExports = deriveLibraryExports;
|
|
12
|
-
/**
|
|
13
|
-
* Decoding a {@link PkgBlob} into the reader-facing views: the on-disk tuple form, the decoded function/
|
|
14
|
-
* dependency records, and the {@link LibraryExports} export view. Pure -- no I/O, no mutation of inputs.
|
|
15
|
-
* Split out of `../sigdb` so the reader/writer there does not carry the per-record decoding.
|
|
16
|
-
*/
|
|
17
12
|
const schema_1 = require("./schema");
|
|
18
13
|
const sigdb_version_1 = require("./sigdb-version");
|
|
19
14
|
const objects_1 = require("../../util/objects");
|
|
@@ -82,17 +77,17 @@ function decodeFunction(strings, blob, fnIdx) {
|
|
|
82
77
|
const [nameIdx, sigIdx, cgIdx, bits, fileIdx, line, topicIdx] = blob.fns[fnIdx];
|
|
83
78
|
const signature = (sigIdx >= 0 ? blob.sigs[sigIdx] : []).map(p => {
|
|
84
79
|
const [n, props, def] = Array.isArray(p) ? [p[0], p[1], p.length === 3 ? p[2] : -1] : [p, 0, -1];
|
|
85
|
-
return (0, objects_1.compactRecord)({ name: strings
|
|
80
|
+
return (0, objects_1.compactRecord)({ name: strings.at(n), props, default: def >= 0 ? strings.at(def) : undefined });
|
|
86
81
|
});
|
|
87
82
|
let callees = [];
|
|
88
83
|
if (cgIdx >= 0) {
|
|
89
84
|
let prev = 0;
|
|
90
|
-
callees = blob.cgs[cgIdx].map(d => strings
|
|
85
|
+
callees = blob.cgs[cgIdx].map(d => strings.at(prev += d));
|
|
91
86
|
}
|
|
92
87
|
return (0, objects_1.compactRecord)({
|
|
93
|
-
name: strings
|
|
94
|
-
topic: topicIdx !== undefined && topicIdx >= 0 ? strings
|
|
95
|
-
file: fileIdx >= 0 ? strings
|
|
88
|
+
name: strings.at(nameIdx),
|
|
89
|
+
topic: topicIdx !== undefined && topicIdx >= 0 ? strings.at(topicIdx) : undefined,
|
|
90
|
+
file: fileIdx >= 0 ? strings.at(fileIdx) : undefined,
|
|
96
91
|
line,
|
|
97
92
|
exported: Boolean(bits & 1 /* FnProp.Exported */),
|
|
98
93
|
props: Object.entries(schema_1.FnPropNames).filter(([m]) => bits & Number(m)).map(([, n]) => n),
|
|
@@ -106,7 +101,7 @@ function decodeDependencies(strings, blob, ver) {
|
|
|
106
101
|
if (idx === undefined) {
|
|
107
102
|
return [];
|
|
108
103
|
}
|
|
109
|
-
return blob.deps[idx].map(d => (0, objects_1.compactRecord)({ name: strings
|
|
104
|
+
return blob.deps[idx].map(d => (0, objects_1.compactRecord)({ name: strings.at(d[0]), type: d[1], constraint: d.length === 3 ? strings.at(d[2]) : undefined }));
|
|
110
105
|
}
|
|
111
106
|
/** the classes a package version declares, decoded from the blob's class pool */
|
|
112
107
|
function decodeClasses(strings, blob, ver) {
|
|
@@ -124,15 +119,15 @@ function decodeClasses(strings, blob, ver) {
|
|
|
124
119
|
}
|
|
125
120
|
const [nameIdx, system, props, supers, slots, pkgIdx] = rec;
|
|
126
121
|
out.push((0, objects_1.compactRecord)({
|
|
127
|
-
name: strings
|
|
122
|
+
name: strings.at(nameIdx),
|
|
128
123
|
system: schema_1.SigClassSystemNames[system] ?? schema_1.SigClassSystemNames[0],
|
|
129
|
-
supers: supers.map(i => strings
|
|
124
|
+
supers: supers.map(i => strings.at(i)),
|
|
130
125
|
slots: slots.map((sl) => typeof sl === 'number'
|
|
131
|
-
? { name: strings
|
|
132
|
-
: { name: strings
|
|
126
|
+
? { name: strings.at(sl) }
|
|
127
|
+
: { name: strings.at(sl[0]), type: strings.at(sl[1]) }),
|
|
133
128
|
virtual: props & 1 /* ClassProp.Virtual */ ? true : undefined,
|
|
134
129
|
union: props & 2 /* ClassProp.Union */ ? true : undefined,
|
|
135
|
-
package: pkgIdx !== undefined ? strings
|
|
130
|
+
package: pkgIdx !== undefined ? strings.at(pkgIdx) : undefined
|
|
136
131
|
}));
|
|
137
132
|
}
|
|
138
133
|
return out;
|
|
@@ -166,7 +161,7 @@ function deriveLibraryExports(strings, blob, meta, pkg, version, cranBase = sche
|
|
|
166
161
|
const locations = new Map();
|
|
167
162
|
for (const i of idxs) {
|
|
168
163
|
const [nameIdx, , , bits, fileIdx, line] = blob.fns[i];
|
|
169
|
-
const name = strings
|
|
164
|
+
const name = strings.at(nameIdx);
|
|
170
165
|
(bits & 1 /* FnProp.Exported */ ? exported : internal).push(name);
|
|
171
166
|
if (bits & 32 /* FnProp.Deprecated */) {
|
|
172
167
|
deprecated.push(name);
|
|
@@ -178,7 +173,7 @@ function deriveLibraryExports(strings, blob, meta, pkg, version, cranBase = sche
|
|
|
178
173
|
s4Classes.push(name);
|
|
179
174
|
}
|
|
180
175
|
if (fileIdx >= 0) {
|
|
181
|
-
locations.set(name, { file: strings
|
|
176
|
+
locations.set(name, { file: strings.at(fileIdx), line });
|
|
182
177
|
}
|
|
183
178
|
}
|
|
184
179
|
const cran = !blob.noncran?.includes(ver);
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A bundle's string dictionary, held as the bytes of its names rather than as an array of strings.
|
|
3
|
+
* Split apart, a dictionary of 1.4 million names cost a slice object per name and kept the text alive
|
|
4
|
+
* through them anyway; as one buffer it is off the JS heap entirely, which is what a worker's
|
|
5
|
+
* `--max-old-space-size` bounds, and a name is built only when something asks for it.
|
|
6
|
+
* @module
|
|
7
|
+
*/
|
|
8
|
+
/** A dictionary's names by id. Ids are positions, so {@link SigDict.at} is what `strings[id]` used to be. */
|
|
9
|
+
export declare class SigDict implements Iterable<string> {
|
|
10
|
+
/** every name in utf8, separated by newlines, so a name never carries one */
|
|
11
|
+
private readonly bytes;
|
|
12
|
+
/** where each name ends in {@link bytes}; the next one starts one past that */
|
|
13
|
+
private readonly ends;
|
|
14
|
+
private constructor();
|
|
15
|
+
/** The dictionary `names` spells out. */
|
|
16
|
+
static of(names: readonly string[]): SigDict;
|
|
17
|
+
/**
|
|
18
|
+
* The dictionary the given runs spell out together, each a newline-joined batch of names starting at the id
|
|
19
|
+
* it names. The runs must cover the ids from `0` without a gap, which is how a bundle writes them.
|
|
20
|
+
*/
|
|
21
|
+
static ofRuns(runs: readonly {
|
|
22
|
+
start: number;
|
|
23
|
+
names: string;
|
|
24
|
+
}[]): SigDict;
|
|
25
|
+
/** how many names it holds */
|
|
26
|
+
get length(): number;
|
|
27
|
+
/** The name with the given id, `''` for an id the dictionary does not hold. */
|
|
28
|
+
at(id: number): string;
|
|
29
|
+
/** The group the name with the given id belongs to, as {@link SigDict.keyOf} groups one in hand. */
|
|
30
|
+
groupOf(id: number): number;
|
|
31
|
+
/** The group `name` would be in, so a lookup only compares the names that could match it. */
|
|
32
|
+
static keyOf(name: string): number;
|
|
33
|
+
private startOf;
|
|
34
|
+
[Symbol.iterator](): Iterator<string>;
|
|
35
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* A bundle's string dictionary, held as the bytes of its names rather than as an array of strings.
|
|
4
|
+
* Split apart, a dictionary of 1.4 million names cost a slice object per name and kept the text alive
|
|
5
|
+
* through them anyway; as one buffer it is off the JS heap entirely, which is what a worker's
|
|
6
|
+
* `--max-old-space-size` bounds, and a name is built only when something asks for it.
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.SigDict = void 0;
|
|
11
|
+
/** the number of newline-separated pieces in `text`; `''` is one empty piece */
|
|
12
|
+
function pieces(text) {
|
|
13
|
+
let count = 1;
|
|
14
|
+
for (let at = text.indexOf('\n'); at >= 0; at = text.indexOf('\n', at + 1)) {
|
|
15
|
+
count++;
|
|
16
|
+
}
|
|
17
|
+
return count;
|
|
18
|
+
}
|
|
19
|
+
/** A dictionary's names by id. Ids are positions, so {@link SigDict.at} is what `strings[id]` used to be. */
|
|
20
|
+
class SigDict {
|
|
21
|
+
/** every name in utf8, separated by newlines, so a name never carries one */
|
|
22
|
+
bytes;
|
|
23
|
+
/** where each name ends in {@link bytes}; the next one starts one past that */
|
|
24
|
+
ends;
|
|
25
|
+
constructor(bytes, ends) {
|
|
26
|
+
this.bytes = bytes;
|
|
27
|
+
this.ends = ends;
|
|
28
|
+
}
|
|
29
|
+
/** The dictionary `names` spells out. */
|
|
30
|
+
static of(names) {
|
|
31
|
+
return SigDict.ofRuns(names.length === 0 ? [] : [{ start: 0, names: names.join('\n') }]);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The dictionary the given runs spell out together, each a newline-joined batch of names starting at the id
|
|
35
|
+
* it names. The runs must cover the ids from `0` without a gap, which is how a bundle writes them.
|
|
36
|
+
*/
|
|
37
|
+
static ofRuns(runs) {
|
|
38
|
+
if (runs.length === 0) {
|
|
39
|
+
return new SigDict(Buffer.alloc(0), new Int32Array(0));
|
|
40
|
+
}
|
|
41
|
+
const ordered = [...runs].sort((a, b) => a.start - b.start);
|
|
42
|
+
/* sized in one pass and written in the next, so no run is ever copied twice */
|
|
43
|
+
let size = ordered.length - 1, count = 0;
|
|
44
|
+
for (const run of ordered) {
|
|
45
|
+
size += Buffer.byteLength(run.names, 'utf8');
|
|
46
|
+
count += pieces(run.names);
|
|
47
|
+
}
|
|
48
|
+
const bytes = Buffer.allocUnsafe(size);
|
|
49
|
+
let at = 0;
|
|
50
|
+
for (let i = 0; i < ordered.length; i++) {
|
|
51
|
+
if (i > 0) {
|
|
52
|
+
bytes[at++] = Newline;
|
|
53
|
+
}
|
|
54
|
+
at += bytes.write(ordered[i].names, at, 'utf8');
|
|
55
|
+
}
|
|
56
|
+
const ends = new Int32Array(count);
|
|
57
|
+
for (let i = 0, from = 0; i < ends.length; i++) {
|
|
58
|
+
const newline = bytes.indexOf(Newline, from);
|
|
59
|
+
ends[i] = newline < 0 ? bytes.length : newline;
|
|
60
|
+
from = ends[i] + 1;
|
|
61
|
+
}
|
|
62
|
+
return new SigDict(bytes, ends);
|
|
63
|
+
}
|
|
64
|
+
/** how many names it holds */
|
|
65
|
+
get length() {
|
|
66
|
+
return this.ends.length;
|
|
67
|
+
}
|
|
68
|
+
/** The name with the given id, `''` for an id the dictionary does not hold. */
|
|
69
|
+
at(id) {
|
|
70
|
+
return id < 0 || id >= this.ends.length ? '' : this.bytes.toString('utf8', this.startOf(id), this.ends[id]);
|
|
71
|
+
}
|
|
72
|
+
/** The group the name with the given id belongs to, as {@link SigDict.keyOf} groups one in hand. */
|
|
73
|
+
groupOf(id) {
|
|
74
|
+
const start = this.startOf(id);
|
|
75
|
+
return group(this.ends[id] - start, this.bytes[start]);
|
|
76
|
+
}
|
|
77
|
+
/** The group `name` would be in, so a lookup only compares the names that could match it. */
|
|
78
|
+
static keyOf(name) {
|
|
79
|
+
const bytes = Buffer.from(name, 'utf8');
|
|
80
|
+
return group(bytes.length, bytes[0]);
|
|
81
|
+
}
|
|
82
|
+
startOf(id) {
|
|
83
|
+
return id === 0 ? 0 : this.ends[id - 1] + 1;
|
|
84
|
+
}
|
|
85
|
+
*[Symbol.iterator]() {
|
|
86
|
+
for (let i = 0; i < this.ends.length; i++) {
|
|
87
|
+
yield this.at(i);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
exports.SigDict = SigDict;
|
|
92
|
+
const Newline = 0x0a;
|
|
93
|
+
/** the group a name of that byte length starting with that byte belongs to; the empty name has none of its own */
|
|
94
|
+
function group(size, first) {
|
|
95
|
+
return size === 0 ? 0 : (first << 8) | Math.min(size, 255);
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=dict.js.map
|
package/project/sigdb/hash.d.ts
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import type { PkgBlob, SigDb } from './schema';
|
|
2
|
+
/** a bundle as it is hashed: the dictionary in any form that names its strings in order */
|
|
3
|
+
type Hashable = Omit<Pick<SigDb, 'strings' | 'blobs' | 'pkgs' | 'meta'>, 'strings'> & {
|
|
4
|
+
strings: Iterable<string>;
|
|
5
|
+
};
|
|
2
6
|
/** run a Hash53 over a stream of chunks (each null-terminated so boundaries can't collide) */
|
|
3
7
|
export declare function hashOf(chunks: Iterable<string>): string;
|
|
4
8
|
/** the self-contained content hash of a whole bundle (dictionary + blobs + routing/metadata) */
|
|
5
|
-
export declare function contentHash(db:
|
|
9
|
+
export declare function contentHash(db: Hashable): string;
|
|
6
10
|
/** stable hash of a shared dictionary */
|
|
7
|
-
export declare function dictionaryHash(strings:
|
|
11
|
+
export declare function dictionaryHash(strings: Iterable<string>): string;
|
|
8
12
|
/** stable hash of one shard's data (its blobs + pkgs map; the dictionary is hashed separately) */
|
|
9
13
|
export declare function shardHash(blobs: readonly PkgBlob[], pkgs: Record<string, number>): string;
|
|
14
|
+
export {};
|
|
@@ -3,6 +3,7 @@ import { type LibraryExports, type PkgBlob, type SigClassInfo, type SigDb, type
|
|
|
3
3
|
import { type VersionRelease } from './sigdb-version';
|
|
4
4
|
import { type SigDbIndex } from './index-format';
|
|
5
5
|
import { type DecodedFunction, type ResolvedDependency } from './decode';
|
|
6
|
+
import { SigDict } from './dict';
|
|
6
7
|
import { type SigDbManifest, type SigDbShardRef } from './manifest';
|
|
7
8
|
/** stream-read a whole bundle into a {@link SigDb} (any size; never one string). Prefer {@link SigDatabase} for partial access. */
|
|
8
9
|
export declare function readSignatureDb(file: string): Promise<SigDb>;
|
|
@@ -131,7 +132,7 @@ export interface SigDbOpenOptions {
|
|
|
131
132
|
/** a caller-supplied index/dictionary for {@link SigDatabase.openSync} (both derived from the source otherwise) */
|
|
132
133
|
export interface OpenSyncOptions {
|
|
133
134
|
index?: SigDbIndex;
|
|
134
|
-
strings?:
|
|
135
|
+
strings?: SigDict;
|
|
135
136
|
}
|
|
136
137
|
/** {@link SigDatabase.openSyncFrom} options: cache settings plus an optional precomputed hash/index/dictionary */
|
|
137
138
|
export interface OpenSyncFromOptions extends SigDbOpenOptions, OpenSyncOptions {
|
|
@@ -157,7 +158,7 @@ export declare class SigDatabase implements PackageSignatureSource {
|
|
|
157
158
|
/** reverse index `S3 class -> owning package`, over every package's latest version; built once (see {@link classOwner}) */
|
|
158
159
|
private classIndex;
|
|
159
160
|
private readonly fd;
|
|
160
|
-
readonly strings:
|
|
161
|
+
readonly strings: SigDict;
|
|
161
162
|
readonly index: SigDbIndex;
|
|
162
163
|
readonly content: SigDbContent | undefined;
|
|
163
164
|
private readonly cranBase;
|
|
@@ -311,8 +312,8 @@ export declare class SigDatabaseSet implements PackageSignatureSource {
|
|
|
311
312
|
shardStatus(): ShardStatus[];
|
|
312
313
|
/** open (blocking) and return every shard database with its manifest ref, for whole-set verification */
|
|
313
314
|
allShards(): MountedShard[];
|
|
314
|
-
/** load (and cache) a shared dictionary
|
|
315
|
-
sharedDictionary(id: string):
|
|
315
|
+
/** load (and cache) a shared dictionary by id, for verification/inspection */
|
|
316
|
+
sharedDictionary(id: string): SigDict;
|
|
316
317
|
/** the first non-empty result from the shards that can serve `pkg` (in preferred order: current before full) */
|
|
317
318
|
private firstOf;
|
|
318
319
|
lookup(pkg: string, version?: string): LibraryExports | undefined;
|
package/project/sigdb/reader.js
CHANGED
|
@@ -26,27 +26,29 @@ const index_format_1 = require("./index-format");
|
|
|
26
26
|
const decode_1 = require("./decode");
|
|
27
27
|
const decompress_1 = require("./decompress");
|
|
28
28
|
const codec_1 = require("./codec");
|
|
29
|
+
const dict_1 = require("./dict");
|
|
29
30
|
const hash_1 = require("./hash");
|
|
30
31
|
const manifest_1 = require("./manifest");
|
|
31
32
|
const arrays_1 = require("../../util/collections/arrays");
|
|
32
|
-
/**
|
|
33
|
-
function
|
|
33
|
+
/** the run of names one `d` line (`["d", start, payload]`, newline-blob or legacy `string[]` form) adds */
|
|
34
|
+
function dictLineRun(json) {
|
|
34
35
|
const [, start, payload] = JSON.parse(json);
|
|
35
|
-
|
|
36
|
+
return { start, names: typeof payload === 'string' ? payload : payload.join('\n') };
|
|
37
|
+
}
|
|
38
|
+
/** apply one `d` line to a plain array, for the whole-file form {@link readSigDbFile} reads */
|
|
39
|
+
function applyDictLine(json, strings) {
|
|
40
|
+
const { start, names } = dictLineRun(json);
|
|
41
|
+
const batch = names.split('\n');
|
|
36
42
|
for (let k = 0; k < batch.length; k++) {
|
|
37
43
|
strings[start + k] = batch[k];
|
|
38
44
|
}
|
|
39
45
|
}
|
|
40
46
|
/**
|
|
41
|
-
* Dictionary ids grouped by first
|
|
42
|
-
* database read the same
|
|
43
|
-
* comparing a few hundred
|
|
47
|
+
* Dictionary ids grouped by first byte and byte length, kept per dictionary rather than per reader (the shards of one
|
|
48
|
+
* database read the same one). One `Int32Array` per group, ascending, so a lookup answers what `indexOf` would while
|
|
49
|
+
* comparing a few hundred names rather than the 1.4 million a scan of the whole dictionary walks.
|
|
44
50
|
*/
|
|
45
51
|
const dictionaryBuckets = new WeakMap();
|
|
46
|
-
/** the group `name` belongs to; the empty string has none of its own, which is what `0` stands for */
|
|
47
|
-
function bucketKeyOf(name) {
|
|
48
|
-
return name.length === 0 ? 0 : (name.charCodeAt(0) << 8) | Math.min(name.length, 255);
|
|
49
|
-
}
|
|
50
52
|
/** the id `strings.indexOf(name)` would give, through {@link dictionaryBuckets}; `-1` when the dictionary lacks it */
|
|
51
53
|
function dictionaryIdOf(strings, name) {
|
|
52
54
|
let buckets = dictionaryBuckets.get(strings);
|
|
@@ -55,7 +57,7 @@ function dictionaryIdOf(strings, name) {
|
|
|
55
57
|
lookup per entry to know where in its group the next one goes */
|
|
56
58
|
const grouped = new Map();
|
|
57
59
|
for (let i = 0; i < strings.length; i++) {
|
|
58
|
-
const key =
|
|
60
|
+
const key = strings.groupOf(i);
|
|
59
61
|
const group = grouped.get(key);
|
|
60
62
|
if (group === undefined) {
|
|
61
63
|
grouped.set(key, [i]);
|
|
@@ -70,16 +72,18 @@ function dictionaryIdOf(strings, name) {
|
|
|
70
72
|
}
|
|
71
73
|
dictionaryBuckets.set(strings, buckets);
|
|
72
74
|
}
|
|
73
|
-
const bucket = buckets.get(
|
|
75
|
+
const bucket = buckets.get(dict_1.SigDict.keyOf(name));
|
|
74
76
|
/* ascending, so the first match is the one a scan from the front would have found */
|
|
75
77
|
for (const id of bucket ?? []) {
|
|
76
|
-
if (strings
|
|
78
|
+
if (strings.at(id) === name) {
|
|
77
79
|
return id;
|
|
78
80
|
}
|
|
79
81
|
}
|
|
80
82
|
return -1;
|
|
81
83
|
}
|
|
82
|
-
|
|
84
|
+
/** the dictionary a bundle's `d` lines spell out */
|
|
85
|
+
function readDictSection(buf) {
|
|
86
|
+
const runs = [];
|
|
83
87
|
let off = 0;
|
|
84
88
|
while (off < buf.length) {
|
|
85
89
|
let nl = buf.indexOf(0x0a, off);
|
|
@@ -87,10 +91,11 @@ function readDictSection(buf, strings) {
|
|
|
87
91
|
nl = buf.length;
|
|
88
92
|
}
|
|
89
93
|
if (nl > off) {
|
|
90
|
-
|
|
94
|
+
runs.push(dictLineRun(buf.toString('utf8', off, nl)));
|
|
91
95
|
}
|
|
92
96
|
off = nl + 1;
|
|
93
97
|
}
|
|
98
|
+
return dict_1.SigDict.ofRuns(runs);
|
|
94
99
|
}
|
|
95
100
|
/** stream-read a whole bundle into a {@link SigDb} (any size; never one string). Prefer {@link SigDatabase} for partial access. */
|
|
96
101
|
async function readSignatureDb(file) {
|
|
@@ -393,7 +398,7 @@ class SigDatabase {
|
|
|
393
398
|
/** Use an already-built {@link SigDb} directly, no file involved: its blobs start out in the cache, so a test needs only {@link SigDbBuilder} plus this. */
|
|
394
399
|
static fromMemory(db) {
|
|
395
400
|
const index = { byteCount: 0, dict: [0, 0], blobs: [], pkgs: db.pkgs, meta: db.meta };
|
|
396
|
-
const source = new SigDatabase(NoFile, db.strings, index, db.content, db.cranBase ?? schema_1.DefaultCranBase);
|
|
401
|
+
const source = new SigDatabase(NoFile, dict_1.SigDict.of(db.strings), index, db.content, db.cranBase ?? schema_1.DefaultCranBase);
|
|
397
402
|
db.blobs.forEach((blob, i) => source.blobCache.set(i, { blob }));
|
|
398
403
|
return source;
|
|
399
404
|
}
|
|
@@ -411,13 +416,15 @@ class SigDatabase {
|
|
|
411
416
|
fs_1.default.readSync(fd, head, 0, head.length, 0);
|
|
412
417
|
const header = (0, decompress_1.parseHeader)(head.toString('utf8'));
|
|
413
418
|
let strings = opts.strings;
|
|
414
|
-
if (
|
|
415
|
-
strings = [];
|
|
419
|
+
if (strings === undefined) {
|
|
416
420
|
const [dictStart, dictBytes] = index.dict;
|
|
417
421
|
if (dictBytes > 0) {
|
|
418
422
|
const buf = Buffer.allocUnsafe(dictBytes);
|
|
419
423
|
fs_1.default.readSync(fd, buf, 0, dictBytes, dictStart);
|
|
420
|
-
readDictSection(buf
|
|
424
|
+
strings = readDictSection(buf);
|
|
425
|
+
}
|
|
426
|
+
else {
|
|
427
|
+
strings = dict_1.SigDict.of([]);
|
|
421
428
|
}
|
|
422
429
|
}
|
|
423
430
|
const cranBase = header?.cranBase ?? schema_1.DefaultCranBase;
|
|
@@ -554,7 +561,7 @@ class SigDatabase {
|
|
|
554
561
|
}
|
|
555
562
|
sourceOf(pkg, version) {
|
|
556
563
|
const idx = this.blob(pkg)?.sources?.[version];
|
|
557
|
-
return idx === undefined ? undefined : this.strings
|
|
564
|
+
return idx === undefined ? undefined : this.strings.at(idx);
|
|
558
565
|
}
|
|
559
566
|
/** `{ blob, meta }` for `pkg` when this bundle carries both, `undefined` otherwise; the shared prologue of most per-package queries below. */
|
|
560
567
|
blobMeta(pkg) {
|
|
@@ -646,7 +653,7 @@ class SigDatabase {
|
|
|
646
653
|
if (r.fns.byName === undefined) {
|
|
647
654
|
const byName = new Map();
|
|
648
655
|
for (const i of r.fns.idxs) {
|
|
649
|
-
const fn = this.strings
|
|
656
|
+
const fn = this.strings.at(r.blob.fns[i][0]);
|
|
650
657
|
// first record wins, as the linear scan did
|
|
651
658
|
if (!byName.has(fn)) {
|
|
652
659
|
byName.set(fn, i);
|
|
@@ -821,13 +828,13 @@ class SigDatabaseSet {
|
|
|
821
828
|
throw new Error(`manifest references unknown dictionary '${dictId}'`);
|
|
822
829
|
}
|
|
823
830
|
const plain = (0, decompress_1.ensurePlainSync)((0, decompress_1.resolveSource)(this.baseDir, ref.path), { cacheDir: this.cacheDir, hash: ref.hash, indexless: true });
|
|
824
|
-
|
|
831
|
+
let strings;
|
|
825
832
|
const fd = fs_1.default.openSync(plain, 'r');
|
|
826
833
|
try {
|
|
827
834
|
const [start, bytes] = ref.range;
|
|
828
835
|
const buf = Buffer.allocUnsafe(bytes);
|
|
829
836
|
fs_1.default.readSync(fd, buf, 0, bytes, start);
|
|
830
|
-
readDictSection(buf
|
|
837
|
+
strings = readDictSection(buf);
|
|
831
838
|
}
|
|
832
839
|
finally {
|
|
833
840
|
fs_1.default.closeSync(fd);
|
|
@@ -943,7 +950,7 @@ class SigDatabaseSet {
|
|
|
943
950
|
allShards() {
|
|
944
951
|
return this.manifest.shards.map((ref, i) => ({ ref, db: this.shard(i) }));
|
|
945
952
|
}
|
|
946
|
-
/** load (and cache) a shared dictionary
|
|
953
|
+
/** load (and cache) a shared dictionary by id, for verification/inspection */
|
|
947
954
|
sharedDictionary(id) {
|
|
948
955
|
return this.dictionaryStrings(id);
|
|
949
956
|
}
|
|
@@ -15,11 +15,10 @@ const HashOptions = {
|
|
|
15
15
|
ignoreUnknown: true,
|
|
16
16
|
replacer: (v) => (0, environment_1.isDefaultBuiltInEnvironment)(v) ? undefined : v
|
|
17
17
|
};
|
|
18
|
-
/* definitions,
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* set is what costs. */
|
|
18
|
+
/* definitions, bindings, and frames are shared across the environments a slice builds, and a definition may hold
|
|
19
|
+
* a whole environment of its own (`envState`), so each is hashed once instead of on every fingerprint. Bindings
|
|
20
|
+
* are keyed apart from the frame because cloning shares them until one side writes (see {@link Environment#clone}):
|
|
21
|
+
* the graph holds many frames per distinct set of bindings, and hashing that set is what costs. */
|
|
23
22
|
const definitionHashes = new WeakMap();
|
|
24
23
|
const memoryHashes = new WeakMap();
|
|
25
24
|
const frameHashes = new WeakMap();
|
|
@@ -32,12 +31,7 @@ function definitionHash(definition) {
|
|
|
32
31
|
return hash;
|
|
33
32
|
}
|
|
34
33
|
function memoryHash(memory) {
|
|
35
|
-
let
|
|
36
|
-
if (byVersion === undefined) {
|
|
37
|
-
byVersion = new Map();
|
|
38
|
-
memoryHashes.set(memory.frame, byVersion);
|
|
39
|
-
}
|
|
40
|
-
let hash = byVersion.get(memory.version);
|
|
34
|
+
let hash = memoryHashes.get(memory);
|
|
41
35
|
if (hash === undefined) {
|
|
42
36
|
const entries = [];
|
|
43
37
|
for (const [name, definitions] of memory) {
|
|
@@ -45,7 +39,7 @@ function memoryHash(memory) {
|
|
|
45
39
|
}
|
|
46
40
|
entries.sort();
|
|
47
41
|
hash = (0, object_hash_1.default)(entries, HashOptions);
|
|
48
|
-
|
|
42
|
+
memoryHashes.set(memory, hash);
|
|
49
43
|
}
|
|
50
44
|
return hash;
|
|
51
45
|
}
|
|
@@ -103,11 +103,20 @@ export declare const Playground: {
|
|
|
103
103
|
*/
|
|
104
104
|
link(this: void, parts: PlaygroundLinkParts): string;
|
|
105
105
|
/**
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
106
|
+
* The configuration keys as one field. A key is `a.b.c=<json>`, and the json is brackets, braces and quotes
|
|
107
|
+
* that a fragment does not carry, so it travels packed like the script rather than as a run of `%5B`.
|
|
108
|
+
*/
|
|
109
|
+
packConfig(this: void, config: readonly string[]): string;
|
|
110
|
+
/** The keys back out of that field, which older links wrote out plainly and which is read either way. */
|
|
111
|
+
unpackConfig(this: void, field: string | null | undefined): string[];
|
|
112
|
+
/**
|
|
113
|
+
* Everything a fragment does not carry as itself is escaped, so a configuration's brackets, braces and
|
|
114
|
+
* quotes travel as `%5B`, `%7B` and `%22` rather than as characters a chat client, a markdown reader or
|
|
115
|
+
* a terminal cuts the address at. What is left is what {@link FragmentSafe} lists: a fragment is not a
|
|
116
|
+
* query, so `,`, `:` and `;` stand in it as they are and keep a link readable. `&` and `+` are escaped
|
|
117
|
+
* beyond that, the first because it separates the fields here and the second because a reader takes it
|
|
118
|
+
* for a space. A link is also made not to end on punctuation, because that is where a chat client stops
|
|
119
|
+
* reading it.
|
|
111
120
|
*/
|
|
112
121
|
hash(this: void, fields: readonly (readonly [string, string])[]): string;
|
|
113
122
|
/**
|
|
@@ -23,6 +23,12 @@ const FoundMarkPattern = /^(lint|dep):[^@,]+(@\d+)?$/;
|
|
|
23
23
|
const MaxExpandedRange = 500;
|
|
24
24
|
/** the longest link the page still opens, and the longest a chat client hands on in one piece */
|
|
25
25
|
const MaxSharedLink = 4000;
|
|
26
|
+
/**
|
|
27
|
+
* What a fragment carries unescaped: the unreserved characters plus the sub-delimiters a link is still read
|
|
28
|
+
* with, minus `&` and `+`, which mean something of their own here. The `u` flag keeps a character outside the
|
|
29
|
+
* basic plane one match, so escaping never splits a surrogate pair.
|
|
30
|
+
*/
|
|
31
|
+
const FragmentSafe = /[^A-Za-z0-9\-._~!$'()*,;:@/?=]/gu;
|
|
26
32
|
/**
|
|
27
33
|
* The helper object associated with {@link PlaygroundMark}, which makes it easy to check a mark and to
|
|
28
34
|
* keep a list of them as short as a link should be.
|
|
@@ -104,7 +110,7 @@ exports.Playground = {
|
|
|
104
110
|
fields.push(['c', (0, url_encoding_1.packForUrl)(code)]);
|
|
105
111
|
}
|
|
106
112
|
if (config.length > 0) {
|
|
107
|
-
fields.push(['k',
|
|
113
|
+
fields.push(['k', exports.Playground.packConfig(config)]);
|
|
108
114
|
}
|
|
109
115
|
const kept = exports.PlaygroundMark.compress(marks);
|
|
110
116
|
if (kept.length > 0) {
|
|
@@ -135,18 +141,36 @@ exports.Playground = {
|
|
|
135
141
|
return hash.length > 0 ? `${base}#${hash}` : base;
|
|
136
142
|
},
|
|
137
143
|
/**
|
|
138
|
-
*
|
|
139
|
-
*
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
144
|
+
* The configuration keys as one field. A key is `a.b.c=<json>`, and the json is brackets, braces and quotes
|
|
145
|
+
* that a fragment does not carry, so it travels packed like the script rather than as a run of `%5B`.
|
|
146
|
+
*/
|
|
147
|
+
packConfig(config) {
|
|
148
|
+
return (0, url_encoding_1.packForUrl)(config.join(';'));
|
|
149
|
+
},
|
|
150
|
+
/** The keys back out of that field, which older links wrote out plainly and which is read either way. */
|
|
151
|
+
unpackConfig(field) {
|
|
152
|
+
if (!field) {
|
|
153
|
+
return [];
|
|
154
|
+
}
|
|
155
|
+
/* a key carries its `=`, and neither packing produces one, so what has one was written before they did */
|
|
156
|
+
const text = field.includes('=') ? field : (0, url_encoding_1.unpackFromUrl)(field) ?? '';
|
|
157
|
+
return text.split(';').filter(key => key.length > 0);
|
|
158
|
+
},
|
|
159
|
+
/**
|
|
160
|
+
* Everything a fragment does not carry as itself is escaped, so a configuration's brackets, braces and
|
|
161
|
+
* quotes travel as `%5B`, `%7B` and `%22` rather than as characters a chat client, a markdown reader or
|
|
162
|
+
* a terminal cuts the address at. What is left is what {@link FragmentSafe} lists: a fragment is not a
|
|
163
|
+
* query, so `,`, `:` and `;` stand in it as they are and keep a link readable. `&` and `+` are escaped
|
|
164
|
+
* beyond that, the first because it separates the fields here and the second because a reader takes it
|
|
165
|
+
* for a space. A link is also made not to end on punctuation, because that is where a chat client stops
|
|
166
|
+
* reading it.
|
|
143
167
|
*/
|
|
144
168
|
hash(fields) {
|
|
145
169
|
const hash = fields
|
|
146
170
|
.filter(([, value]) => value.length > 0)
|
|
147
|
-
.map(([key, value]) => `${key}=${value.replace(
|
|
171
|
+
.map(([key, value]) => `${key}=${value.replace(FragmentSafe, character => encodeURIComponent(character))}`)
|
|
148
172
|
.join('&');
|
|
149
|
-
return hash.replace(/[.,:;
|
|
173
|
+
return hash.replace(/[.,:;')]$/, character => encodeURIComponent(character));
|
|
150
174
|
},
|
|
151
175
|
/**
|
|
152
176
|
* Where a criterion points in the given code, as the `<line>:<column>` the page opens the cursor on.
|
package/util/version.js
CHANGED
|
@@ -42,9 +42,9 @@ const assert_1 = require("./assert");
|
|
|
42
42
|
const sigdb_download_1 = require("../project/sigdb/sigdb-download");
|
|
43
43
|
const doc_files_1 = require("../documentation/doc-util/doc-files");
|
|
44
44
|
// this is automatically replaced with the current version by release-it
|
|
45
|
-
const version = '2.15.
|
|
45
|
+
const version = '2.15.8';
|
|
46
46
|
// this is automatically replaced with the release date by release-it (regex-bumper, see package.json)
|
|
47
|
-
const versionDate = '2026-08-
|
|
47
|
+
const versionDate = '2026-08-27T16:01:04Z';
|
|
48
48
|
/**
|
|
49
49
|
* Retrieves the current flowR version as a new {@link SemVer} object.
|
|
50
50
|
*/
|