@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
|
@@ -19,6 +19,7 @@ const built_in_props_1 = require("../../dataflow/environments/built-in-props");
|
|
|
19
19
|
const default_builtin_config_1 = require("../../dataflow/environments/default-builtin-config");
|
|
20
20
|
const r_function_call_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
21
21
|
const r_function_definition_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-definition");
|
|
22
|
+
const graph_1 = require("../../dataflow/graph/graph");
|
|
22
23
|
/**
|
|
23
24
|
* The dots parameter is a special parameter and must never be reported as an unused definition.
|
|
24
25
|
*/
|
|
@@ -154,7 +155,7 @@ function buildQuickFix(variable, dfg, ast) {
|
|
|
154
155
|
}
|
|
155
156
|
const definedBys = getDefinitionArguments(variable.info.id, dfg);
|
|
156
157
|
const hasImportantArgs = definedBys.some(d => dfg.unknownSideEffects.has(d))
|
|
157
|
-
|| definedBys.flatMap(e => Array.from(dfg.outgoingEdges(e) ??
|
|
158
|
+
|| definedBys.flatMap(e => Array.from(dfg.outgoingEdges(e) ?? graph_1.NoEdges))
|
|
158
159
|
.some(([target, e]) => {
|
|
159
160
|
return edge_1.DfEdge.includesType(e, InterestingEdgesTargets) || dfg.unknownSideEffects.has(target);
|
|
160
161
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eagleoutice/flowr",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.14.0",
|
|
4
4
|
"description": "Static Dataflow Analyzer and Program Slicer for the R Programming Language",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=22"
|
|
@@ -16,49 +16,46 @@
|
|
|
16
16
|
},
|
|
17
17
|
"scripts": {
|
|
18
18
|
"setup:dev": "npm ci && ts-node --transpile-only scripts/setup-dev.ts",
|
|
19
|
-
"main": "npm run build:bundle-flowr && node dist/src/cli/flowr.min.js",
|
|
20
19
|
"flowr": "npm run main --",
|
|
21
20
|
"flowr:dev": "npm run sync:sigdb && npm run gen:base-packages && npm run main-dev --",
|
|
21
|
+
"main": "npm run build:bundle-flowr && node dist/src/cli/flowr.min.js",
|
|
22
22
|
"main-dev": "node -r ts-node/register --watch src/cli/flowr.ts",
|
|
23
|
-
"publish-library": "cp .npmignore package.json README.md LICENSE dist/src/ && cd dist/src && npm publish --access public",
|
|
24
|
-
"release": "npx release-it --ci",
|
|
25
23
|
"slicer": "ts-node src/cli/slicer-app.ts",
|
|
24
|
+
"benchmark": "npm run build:dev && node dist/src/cli/benchmark-app.js",
|
|
26
25
|
"benchmark-helper": "ts-node src/cli/benchmark-helper-app.ts",
|
|
27
|
-
"benchmark": "npm run build-dev && node dist/src/cli/benchmark-app.js",
|
|
28
26
|
"summarizer": "ts-node src/cli/summarizer-app.ts",
|
|
29
|
-
"benchmark:test-counts": "ts-node --transpile-only scripts/test-label-counts.ts",
|
|
30
|
-
"benchmark:compact": "ts-node --transpile-only scripts/compact-benchmark-data.ts",
|
|
31
|
-
"export-quads": "ts-node src/cli/export-quads-app.ts",
|
|
32
|
-
"capabilities-markdown": "ts-node src/documentation/doc-capabilities.ts",
|
|
33
|
-
"wiki": "ts-node src/cli/wiki.ts",
|
|
34
|
-
"wiki:watch": "node -r ts-node/register --watch src/cli/wiki.ts --keep-alive",
|
|
35
27
|
"build": "npm run gen:base-packages && tsc --project . && npm run build:copy-data",
|
|
28
|
+
"build:dev": "npm run build && npm run build:copy-wasm",
|
|
29
|
+
"build:bundle-flowr": "npm run build && esbuild --bundle dist/src/cli/flowr.js --platform=node --tree-shaking=true --minify --external:clipboardy --target=node22 --outfile=dist/src/cli/flowr.min.js && npm run build:copy-wasm",
|
|
30
|
+
"build:copy-data": "ts-node --transpile-only scripts/sigdb-copy.ts",
|
|
31
|
+
"build:copy-wasm": "mkdir -p dist/node_modules/@davisvaughan/tree-sitter-r/ && mkdir -p dist/node_modules/web-tree-sitter && cp node_modules/@davisvaughan/tree-sitter-r/tree-sitter-r.wasm dist/node_modules/@davisvaughan/tree-sitter-r/ && cp node_modules/web-tree-sitter/tree-sitter.wasm dist/node_modules/web-tree-sitter/",
|
|
36
32
|
"gen:base-packages": "ts-node --transpile-only scripts/gen-base-packages.ts",
|
|
37
|
-
"
|
|
38
|
-
"check:generic-labels": "ts-node --transpile-only scripts/check-generic-labels.ts",
|
|
33
|
+
"gen:landing": "ts-node --transpile-only scripts/gen-landing.ts && ts-node --transpile-only scripts/gen-sigdb-index.ts && ts-node --transpile-only scripts/gen-playground.ts",
|
|
39
34
|
"gen:sigdb-remote": "ts-node --transpile-only scripts/sigdb-remote.ts",
|
|
35
|
+
"sync:sigdb": "ts-node --transpile-only scripts/sigdb-sync.ts",
|
|
40
36
|
"publish:sigdb": "ts-node scripts/publish-sigdb.ts",
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"build:copy-wasm": "mkdir -p dist/node_modules/@davisvaughan/tree-sitter-r/ && mkdir -p dist/node_modules/web-tree-sitter && cp node_modules/@davisvaughan/tree-sitter-r/tree-sitter-r.wasm dist/node_modules/@davisvaughan/tree-sitter-r/ && cp node_modules/web-tree-sitter/tree-sitter.wasm dist/node_modules/web-tree-sitter/",
|
|
37
|
+
"wiki": "ts-node src/cli/wiki.ts",
|
|
38
|
+
"wiki:watch": "node -r ts-node/register --watch src/cli/wiki.ts --keep-alive",
|
|
39
|
+
"doc": "node --max-old-space-size=8192 node_modules/typedoc/dist/cli.js",
|
|
45
40
|
"typecheck": "tsc --noEmit --project .",
|
|
46
|
-
"lint-local": "npm run typecheck && npx eslint --version && npx eslint src/ test/ scripts/ --concurrency=auto --cache --cache-location node_modules/.cache/eslint-local --rule \"no-warning-comments: off\"",
|
|
47
41
|
"lint": "npm run license-compat -- --summary && npm run typecheck && npx eslint --version && npx eslint src/ test/ scripts/ --concurrency=auto --cache --cache-location node_modules/.cache/eslint",
|
|
42
|
+
"lint-local": "npm run typecheck && npx eslint --version && npx eslint src/ test/ scripts/ --concurrency=auto --cache --cache-location node_modules/.cache/eslint-local --rule \"no-warning-comments: off\"",
|
|
48
43
|
"license-compat": "license-checker-rseidelsohn --onlyAllow 'MIT;MPL-2.0;MIT OR X11;GPLv2;LGPL;GNUGPL;ISC;Apache-2.0;FreeBSD;BSD-2-Clause;clearbsd;ModifiedBSD;BSD-3-Clause;Python-2.0;Unlicense;WTFPL;BlueOak-1.0.0;CC-BY-4.0;CC-BY-3.0;CC0-1.0;0BSD' --clarificationsFile license-clarifications.json",
|
|
49
|
-
"
|
|
44
|
+
"check:generic-labels": "ts-node --transpile-only scripts/check-generic-labels.ts",
|
|
45
|
+
"detect-circular-deps": "npx madge --extensions ts,tsx --circular src/",
|
|
46
|
+
"checkup": "ts-node scripts/checkup-parallel.ts",
|
|
50
47
|
"test": "vitest --exclude \"test/system-tests/**\" --config test/vitest.config.mts",
|
|
48
|
+
"test:full": "npm run test:coverage -- --no-watch --reporter=default --reporter=json --outputFile.json=coverage/flowr-test-results.json -- --make-summary --test-installation",
|
|
49
|
+
"test:coverage": "npm run test -- --coverage",
|
|
51
50
|
"test:verbose": "FLOWR_VERBOSE=true vitest --exclude \"test/system-tests/**\" --config test/vitest.config.mts",
|
|
52
51
|
"test:system": "vitest --dir test/system-tests --config test/system-tests/vitest.config.mts",
|
|
53
|
-
"test:coverage": "npm run test -- --coverage",
|
|
54
|
-
"test:full": "npm run test-full",
|
|
55
52
|
"test:bench": "vitest bench --config test/vitest.config.mts",
|
|
56
|
-
"test
|
|
57
|
-
"performance-test": "func() { cd test/performance/ && bash run-all-suites.sh \"$@\"; }; func",
|
|
58
|
-
"test:performance": "npm run performance-test --",
|
|
53
|
+
"test:performance": "func() { cd test/performance/ && bash run-all-suites.sh \"$@\"; }; func",
|
|
59
54
|
"test:docker": "func() { b() { docker build ${1:+--network=$1} -t flowr-docker-test -f \"$2\" .; }; r() { docker run --rm ${1:+--network=$1} flowr-docker-test --version; }; for df in scripts/Dockerfile scripts/Dockerfile-NoR; do echo \"=== building $df ===\"; b '' \"$df\" || { echo '(retrying with --network=host: bridge networking unavailable)'; b host \"$df\"; } || return 1; echo \"=== smoke-testing $df ===\"; r '' || r host || return 1; done; }; func",
|
|
60
|
-
"
|
|
61
|
-
"
|
|
55
|
+
"benchmark:test-counts": "ts-node --transpile-only scripts/test-label-counts.ts",
|
|
56
|
+
"benchmark:compact": "ts-node --transpile-only scripts/compact-benchmark-data.ts",
|
|
57
|
+
"publish-library": "cp .npmignore package.json README.md LICENSE dist/src/ && cd dist/src && npm publish --access public",
|
|
58
|
+
"release": "npx release-it --ci"
|
|
62
59
|
},
|
|
63
60
|
"keywords": [
|
|
64
61
|
"static code analysis",
|
|
@@ -161,9 +158,9 @@
|
|
|
161
158
|
"hooks": {
|
|
162
159
|
"before:init": [
|
|
163
160
|
"npm run lint",
|
|
164
|
-
"npm run test
|
|
161
|
+
"npm run test:full"
|
|
165
162
|
],
|
|
166
|
-
"after:bump": "npm run build
|
|
163
|
+
"after:bump": "npm run build:dev",
|
|
167
164
|
"after:git:release": "echo After git push, before github release",
|
|
168
165
|
"after:release": "echo Successfully released ${name} v${version} to ${repo.repository}."
|
|
169
166
|
},
|
|
@@ -186,11 +183,11 @@
|
|
|
186
183
|
}
|
|
187
184
|
},
|
|
188
185
|
"devDependencies": {
|
|
186
|
+
"@codemirror/legacy-modes": "^6.5.3",
|
|
189
187
|
"@commitlint/cli": "^20.5.0",
|
|
190
188
|
"@commitlint/config-angular": "^20.5.0",
|
|
191
|
-
"@eagleoutice/eslint-config-flowr": "^2.
|
|
189
|
+
"@eagleoutice/eslint-config-flowr": "^2.1.1",
|
|
192
190
|
"@j-ulrich/release-it-regex-bumper": "^5.4.0",
|
|
193
|
-
"@stylistic/eslint-plugin": "^5.10.0",
|
|
194
191
|
"@types/command-line-args": "^5.2.3",
|
|
195
192
|
"@types/command-line-usage": "^5.0.4",
|
|
196
193
|
"@types/commonmark": "^0.27.10",
|
|
@@ -203,18 +200,13 @@
|
|
|
203
200
|
"@types/semver": "^7.7.0",
|
|
204
201
|
"@types/tmp": "^0.2.6",
|
|
205
202
|
"@types/ws": "^8.18.1",
|
|
206
|
-
"@typescript-eslint/eslint-plugin": "^8.40.0",
|
|
207
|
-
"@typescript-eslint/parser": "^8.65.0",
|
|
208
203
|
"@vitest/coverage-v8": "^4.1.8",
|
|
204
|
+
"codemirror": "^6.0.2",
|
|
209
205
|
"esbuild": "^0.28.1",
|
|
210
206
|
"eslint": "^10.8.0",
|
|
211
|
-
"eslint-plugin-check-file": "^3.3.2",
|
|
212
|
-
"eslint-plugin-import-x": "^4.17.1",
|
|
213
|
-
"eslint-plugin-jsdoc": "^62.9.0",
|
|
214
|
-
"eslint-plugin-tsdoc": "^0.5.2",
|
|
215
|
-
"eslint-plugin-unused-imports": "^4.4.1",
|
|
216
207
|
"license-checker-rseidelsohn": "^4.4.2",
|
|
217
208
|
"release-it": "^20.0.0",
|
|
209
|
+
"seedrandom": "^3.0.5",
|
|
218
210
|
"ts-node": "^10.9.2",
|
|
219
211
|
"typedoc": "^0.28.17",
|
|
220
212
|
"typedoc-plugin-missing-exports": "^4.1.2",
|
|
@@ -227,32 +219,25 @@
|
|
|
227
219
|
"@jupyterlab/nbformat": "^4.5.4",
|
|
228
220
|
"@xmldom/xmldom": "^0.9.7",
|
|
229
221
|
"bzip2": "^0.1.1",
|
|
230
|
-
"clipboardy": "^4.0.0",
|
|
231
222
|
"command-line-args": "^6.0.1",
|
|
232
223
|
"command-line-usage": "^7.0.3",
|
|
233
224
|
"commonmark": "^0.31.2",
|
|
234
225
|
"dagre": "^0.8.5",
|
|
235
|
-
"diff": "^8.0.3",
|
|
236
226
|
"gray-matter": "^4.0.3",
|
|
237
227
|
"ignore": "^5.3.2",
|
|
238
228
|
"joi": "^18.0.1",
|
|
239
229
|
"lz-string": "^1.5.0",
|
|
240
230
|
"n-readlines": "^3.4.1",
|
|
241
|
-
"n3": "^1.26.0",
|
|
242
231
|
"object-hash": "^3.0.0",
|
|
243
232
|
"object-path": "^0.11.8",
|
|
244
233
|
"object-sizeof": "^2.6.5",
|
|
245
|
-
"rotating-file-stream": "^3.2.8",
|
|
246
|
-
"seedrandom": "^3.0.5",
|
|
247
234
|
"semver": "^7.7.4",
|
|
248
235
|
"smol-toml": "^1.7.0",
|
|
249
|
-
"tar": "^7.4.3",
|
|
250
236
|
"tmp": "^0.2.3",
|
|
251
237
|
"ts-essentials": "^10.1.1",
|
|
252
238
|
"tslog": "^4.10.2",
|
|
253
239
|
"web-tree-sitter": "^0.24.7",
|
|
254
|
-
"ws": "^8.18.0"
|
|
255
|
-
"xpath-ts2": "^1.4.2"
|
|
240
|
+
"ws": "^8.18.0"
|
|
256
241
|
},
|
|
257
242
|
"allowScripts": {
|
|
258
243
|
"@davisvaughan/tree-sitter-r@1.2.0": true,
|
|
@@ -260,5 +245,10 @@
|
|
|
260
245
|
"esbuild@0.28.1": true,
|
|
261
246
|
"plantuml-pipe@1.6.0": true,
|
|
262
247
|
"unrs-resolver@1.12.2": true
|
|
248
|
+
},
|
|
249
|
+
"optionalDependencies": {
|
|
250
|
+
"clipboardy": "^4.0.0",
|
|
251
|
+
"n3": "^1.26.0",
|
|
252
|
+
"rotating-file-stream": "^3.2.8"
|
|
263
253
|
}
|
|
264
254
|
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type { FlowrAnalyzerContext } from './flowr-analyzer-context';
|
|
2
2
|
import type { IEnvironment, REnvironmentInformation } from '../../dataflow/environments/environment';
|
|
3
3
|
import type { DeepReadonly } from 'ts-essentials';
|
|
4
|
+
import type { IdentifierDefinition } from '../../dataflow/environments/identifier';
|
|
5
|
+
import { Identifier } from '../../dataflow/environments/identifier';
|
|
6
|
+
import type { BuiltInIdentifierDefinition } from '../../dataflow/environments/built-in';
|
|
4
7
|
import type { Fingerprint } from '../../slicing/static/fingerprint';
|
|
5
8
|
/**
|
|
6
9
|
* Read-only interface to the {@link FlowrAnalyzerEnvironmentContext}.
|
|
@@ -10,6 +13,21 @@ export interface ReadOnlyFlowrAnalyzerEnvironmentContext {
|
|
|
10
13
|
* Get the built-in environment used during analysis.
|
|
11
14
|
*/
|
|
12
15
|
get builtInEnvironment(): DeepReadonly<IEnvironment>;
|
|
16
|
+
/**
|
|
17
|
+
* Every built-in definition flowR carries for `name`, matched by its plain name.
|
|
18
|
+
*/
|
|
19
|
+
builtInDefinitionsOf(name: Identifier): readonly IdentifierDefinition[];
|
|
20
|
+
/**
|
|
21
|
+
* The built-in function flowR defines for `name`, respecting its namespace: `dplyr::filter` picks
|
|
22
|
+
* flowR's `dplyr` definition rather than whatever else is registered under `filter`.
|
|
23
|
+
*/
|
|
24
|
+
builtInFunctionOf(name: Identifier): BuiltInIdentifierDefinition | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* Whether flowR carries definitions of its own for package `pkg`, i.e. whether it knows what attaching
|
|
27
|
+
* that package brings even when no signature database resolves it. Built once and kept, as the built-in
|
|
28
|
+
* environment does not change during an analysis.
|
|
29
|
+
*/
|
|
30
|
+
knowsPackage(pkg: string): boolean;
|
|
13
31
|
/**
|
|
14
32
|
* Get the empty built-in environment used during analysis.
|
|
15
33
|
* The empty built-in environment only contains primitive definitions.
|
|
@@ -40,9 +58,14 @@ export declare class FlowrAnalyzerEnvironmentContext implements ReadOnlyFlowrAna
|
|
|
40
58
|
private readonly builtInEnv;
|
|
41
59
|
private readonly emptyBuiltInEnv;
|
|
42
60
|
private builtInEnvFingerprint;
|
|
61
|
+
/** the packages {@link knowsPackage} answers for, collected from the built-in environment on first use */
|
|
62
|
+
private knownPackages;
|
|
43
63
|
constructor(ctx: FlowrAnalyzerContext);
|
|
44
64
|
get builtInEnvironment(): DeepReadonly<IEnvironment>;
|
|
45
65
|
get emptyBuiltInEnvironment(): DeepReadonly<IEnvironment>;
|
|
66
|
+
builtInDefinitionsOf(name: Identifier): readonly IdentifierDefinition[];
|
|
67
|
+
knowsPackage(pkg: string): boolean;
|
|
68
|
+
builtInFunctionOf(name: Identifier): BuiltInIdentifierDefinition | undefined;
|
|
46
69
|
makeCleanEnv(): REnvironmentInformation;
|
|
47
70
|
getCleanEnvFingerprint(): Fingerprint;
|
|
48
71
|
makeCleanEnvWithEmptyBuiltIns(): REnvironmentInformation;
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.FlowrAnalyzerEnvironmentContext = void 0;
|
|
4
4
|
const environment_1 = require("../../dataflow/environments/environment");
|
|
5
5
|
const built_in_config_1 = require("../../dataflow/environments/built-in-config");
|
|
6
|
+
const identifier_1 = require("../../dataflow/environments/identifier");
|
|
6
7
|
const fingerprint_1 = require("../../slicing/static/fingerprint");
|
|
7
8
|
/**
|
|
8
9
|
* Provides the built-in environment, created from the {@link FlowrAnalyzerContext} configuration.
|
|
@@ -12,6 +13,8 @@ class FlowrAnalyzerEnvironmentContext {
|
|
|
12
13
|
builtInEnv;
|
|
13
14
|
emptyBuiltInEnv;
|
|
14
15
|
builtInEnvFingerprint;
|
|
16
|
+
/** the packages {@link knowsPackage} answers for, collected from the built-in environment on first use */
|
|
17
|
+
knownPackages;
|
|
15
18
|
constructor(ctx) {
|
|
16
19
|
const builtInsConfig = ctx.config.semantics.environment.overwriteBuiltIns;
|
|
17
20
|
const builtIns = (0, built_in_config_1.getBuiltInDefinitions)(builtInsConfig.definitions, builtInsConfig.loadDefaults);
|
|
@@ -26,6 +29,28 @@ class FlowrAnalyzerEnvironmentContext {
|
|
|
26
29
|
get emptyBuiltInEnvironment() {
|
|
27
30
|
return this.emptyBuiltInEnv;
|
|
28
31
|
}
|
|
32
|
+
builtInDefinitionsOf(name) {
|
|
33
|
+
return this.builtInEnv.memory.get(identifier_1.Identifier.getName(name)) ?? [];
|
|
34
|
+
}
|
|
35
|
+
knowsPackage(pkg) {
|
|
36
|
+
if (this.knownPackages === undefined) {
|
|
37
|
+
this.knownPackages = new Set();
|
|
38
|
+
for (const [, definitions] of this.builtInEnv.memory) {
|
|
39
|
+
for (const definition of definitions) {
|
|
40
|
+
const namespace = definition.name === undefined ? undefined : identifier_1.Identifier.getNamespace(definition.name);
|
|
41
|
+
if (namespace !== undefined) {
|
|
42
|
+
this.knownPackages.add(String(namespace));
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return this.knownPackages.has(pkg);
|
|
48
|
+
}
|
|
49
|
+
builtInFunctionOf(name) {
|
|
50
|
+
const namespace = identifier_1.Identifier.getNamespace(name);
|
|
51
|
+
return this.builtInDefinitionsOf(name).find((d) => d.type === identifier_1.ReferenceType.BuiltInFunction && typeof d.processor === 'function'
|
|
52
|
+
&& (namespace === undefined || (d.name !== undefined && identifier_1.Identifier.getNamespace(d.name) === namespace)));
|
|
53
|
+
}
|
|
29
54
|
makeCleanEnv() {
|
|
30
55
|
return {
|
|
31
56
|
current: new environment_1.Environment(this.builtInEnv).asGlobal(),
|
|
@@ -36,7 +36,6 @@ const identifier_1 = require("../dataflow/environments/identifier");
|
|
|
36
36
|
const vertex_1 = require("../dataflow/graph/vertex");
|
|
37
37
|
const graph_1 = require("../dataflow/graph/graph");
|
|
38
38
|
const df_helper_1 = require("../dataflow/graph/df-helper");
|
|
39
|
-
const dfg_get_origin_1 = require("../dataflow/origin/dfg-get-origin");
|
|
40
39
|
const r_base_packages_1 = require("../util/r-base-packages");
|
|
41
40
|
const undefined_symbol_util_1 = require("../linter/rules/undefined-symbol-util");
|
|
42
41
|
const type_1 = require("../r-bridge/lang-4.x/ast/model/type");
|
|
@@ -271,7 +270,7 @@ function collectOrphanUsage(graph, deps, usage, isKnown, options = {}) {
|
|
|
271
270
|
const name = identifier_1.Identifier.getName(vertex.name);
|
|
272
271
|
// a call bound to a real definition (local, parameter, closure, or import) *is* that definition, not a package
|
|
273
272
|
// export; only an unresolved or builtin-modeled call can be an orphan (flowR models e.g. `ggplot` as a builtin)
|
|
274
|
-
if (
|
|
273
|
+
if (df_helper_1.Dataflow.origin(graph, id)?.some(o => o.type === 2 /* OriginType.FunctionCallOrigin */) === true) {
|
|
275
274
|
continue;
|
|
276
275
|
}
|
|
277
276
|
// a bare name from a default-attached base package (or a base primitive) is defined without a library() call
|
|
@@ -85,7 +85,7 @@ class FlowrAnalyzer {
|
|
|
85
85
|
addRequest(...request) {
|
|
86
86
|
for (const r of request) {
|
|
87
87
|
if (typeof r === 'string') {
|
|
88
|
-
const trimmed = r.
|
|
88
|
+
const trimmed = r.slice(retriever_1.fileProtocol.length);
|
|
89
89
|
if (r.startsWith(retriever_1.fileProtocol) && !(0, files_1.isFilePath)(trimmed)) {
|
|
90
90
|
this.addAnalysisRequest({ request: 'project', content: trimmed });
|
|
91
91
|
}
|
|
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.RDAParser = exports.SerializationFormat = exports.SexpType = exports.SerializationTypeTag = exports.CompressionType = exports.FlowrRDAFile = void 0;
|
|
7
7
|
const flowr_file_1 = require("../../../context/flowr-file");
|
|
8
|
-
const
|
|
8
|
+
const fs_1 = __importDefault(require("fs"));
|
|
9
9
|
const r_fun_tab_1 = require("./r-fun-tab");
|
|
10
10
|
const shell_executor_1 = require("../../../../r-bridge/shell-executor");
|
|
11
11
|
/**
|
|
@@ -204,7 +204,7 @@ class RDAParser {
|
|
|
204
204
|
* @returns List of found {@link RObjectData} or `null` if the file is empty.
|
|
205
205
|
*/
|
|
206
206
|
parse() {
|
|
207
|
-
const fileContent =
|
|
207
|
+
const fileContent = fs_1.default.readFileSync(this.file.path());
|
|
208
208
|
const compressionType = this.detectCompression(fileContent);
|
|
209
209
|
this.buffer = this.decompress(fileContent, compressionType);
|
|
210
210
|
const result = this.deserialize2();
|
|
@@ -273,7 +273,7 @@ class RDAParser {
|
|
|
273
273
|
switch (compressionType) {
|
|
274
274
|
case CompressionType.CompGz: {
|
|
275
275
|
// eslint-disable-next-line @typescript-eslint/no-require-imports,@typescript-eslint/no-unsafe-assignment
|
|
276
|
-
const zlib = require('
|
|
276
|
+
const zlib = require('zlib');
|
|
277
277
|
try {
|
|
278
278
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
|
|
279
279
|
buffer = zlib.gunzipSync(fileContent);
|
|
@@ -247,14 +247,14 @@ const OptionsRegex = /([\w_.-]*)\s*[:=]\s*["']?([^,"']*)/g;
|
|
|
247
247
|
function parseCodeBlockOptions(header, content) {
|
|
248
248
|
const headerOpts = header.length === 3 // '{r}' => header.length=3 (no options in header)
|
|
249
249
|
? ''
|
|
250
|
-
: header.
|
|
250
|
+
: header.slice(3, -1).trim();
|
|
251
251
|
const cellLines = [];
|
|
252
252
|
for (const line of content.split('\n')) {
|
|
253
253
|
if (!line.trim().startsWith('#|')) {
|
|
254
254
|
break;
|
|
255
255
|
}
|
|
256
256
|
// keep the indentation, yaml block scalars rely on it
|
|
257
|
-
cellLines.push(line.trim().
|
|
257
|
+
cellLines.push(line.trim().slice(2).replace(/^ /, ''));
|
|
258
258
|
}
|
|
259
259
|
const options = parseOptionString(headerOpts);
|
|
260
260
|
for (const [key, value] of parseCellOptions(cellLines)) {
|
package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js
CHANGED
|
@@ -558,7 +558,9 @@ class FlowrAnalyzerPackageVersionsSigDbPlugin extends flowr_analyzer_package_ver
|
|
|
558
558
|
loadsWithSideEffects: false,
|
|
559
559
|
callable: exported
|
|
560
560
|
};
|
|
561
|
-
|
|
561
|
+
/* a source may know the exports without knowing which release they are from, and then the package
|
|
562
|
+
carries no version rather than a made-up one */
|
|
563
|
+
return new package_1.Package({ name, namespaceInfo, resolvedVersion: info.version || undefined });
|
|
562
564
|
}
|
|
563
565
|
}
|
|
564
566
|
exports.FlowrAnalyzerPackageVersionsSigDbPlugin = FlowrAnalyzerPackageVersionsSigDbPlugin;
|
package/project/sigdb/build.js
CHANGED
|
@@ -15,9 +15,9 @@ exports.writeShardedDatabase = writeShardedDatabase;
|
|
|
15
15
|
* dictionary, blob-only shards, and the sharded {@link SigDbManifest}). Split out of `../sigdb` so the reader
|
|
16
16
|
* there is not weighed down by the (build-time only) encoder; imports only sibling format/codec modules.
|
|
17
17
|
*/
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
const
|
|
18
|
+
const fs_1 = __importDefault(require("fs"));
|
|
19
|
+
const path_1 = __importDefault(require("path"));
|
|
20
|
+
const events_1 = require("events");
|
|
21
21
|
const schema_1 = require("./schema");
|
|
22
22
|
const r_version_1 = require("../../util/r-version");
|
|
23
23
|
const decode_1 = require("./decode");
|
|
@@ -496,10 +496,10 @@ class LineWriter {
|
|
|
496
496
|
byteOff = 0;
|
|
497
497
|
constructor(plain, compress) {
|
|
498
498
|
noteZstdSupport();
|
|
499
|
-
|
|
500
|
-
this.plainOut =
|
|
499
|
+
fs_1.default.mkdirSync(path_1.default.dirname(path_1.default.resolve(plain)), { recursive: true });
|
|
500
|
+
this.plainOut = fs_1.default.createWriteStream(plain);
|
|
501
501
|
for (const spec of (0, codec_1.writeCodecs)()) {
|
|
502
|
-
const file =
|
|
502
|
+
const file = fs_1.default.createWriteStream(`${plain}${spec.ext}`);
|
|
503
503
|
const stream = spec.createCompress(codecOptions(spec, compress));
|
|
504
504
|
stream.pipe(file);
|
|
505
505
|
this.sinks.push({ stream, file });
|
|
@@ -509,11 +509,11 @@ class LineWriter {
|
|
|
509
509
|
const chunk = text + '\n';
|
|
510
510
|
const back = [];
|
|
511
511
|
if (!this.plainOut.write(chunk)) {
|
|
512
|
-
back.push((0,
|
|
512
|
+
back.push((0, events_1.once)(this.plainOut, 'drain'));
|
|
513
513
|
}
|
|
514
514
|
for (const { stream } of this.sinks) {
|
|
515
515
|
if (!stream.write(chunk)) {
|
|
516
|
-
back.push((0,
|
|
516
|
+
back.push((0, events_1.once)(stream, 'drain'));
|
|
517
517
|
}
|
|
518
518
|
}
|
|
519
519
|
if (back.length > 0) {
|
|
@@ -526,7 +526,7 @@ class LineWriter {
|
|
|
526
526
|
for (const { stream } of this.sinks) {
|
|
527
527
|
stream.end();
|
|
528
528
|
}
|
|
529
|
-
await Promise.all([(0,
|
|
529
|
+
await Promise.all([(0, events_1.once)(this.plainOut, 'close'), ...this.sinks.map(s => (0, events_1.once)(s.file, 'close'))]);
|
|
530
530
|
}
|
|
531
531
|
}
|
|
532
532
|
/** Write `<outBase>.sigs.ndjson` (+ `.br`, `.zst` when supported, `.idx`) -- a single self-contained bundle (its own dictionary). */
|
|
@@ -556,7 +556,7 @@ async function writeSignatureDb(outBase, db, compress = {}) {
|
|
|
556
556
|
}
|
|
557
557
|
await w.close();
|
|
558
558
|
const index = { byteCount: w.byteOff, dict, blobs, pkgs: db.pkgs, meta: db.meta };
|
|
559
|
-
|
|
559
|
+
fs_1.default.writeFileSync(`${plain}.idx`, JSON.stringify((0, index_format_1.encodeIndex)(index)));
|
|
560
560
|
return index;
|
|
561
561
|
}
|
|
562
562
|
/** the extension of a standalone shared-dictionary file */
|
|
@@ -572,7 +572,7 @@ async function writeDictionary(outBase, id, strings, compress = {}) {
|
|
|
572
572
|
}
|
|
573
573
|
const range = [start, w.byteOff - start];
|
|
574
574
|
await w.close();
|
|
575
|
-
return { id, path: `${
|
|
575
|
+
return { id, path: `${path_1.default.basename(outBase)}${exports.SigDbDictExt}`, hash: (0, hash_1.dictionaryHash)(strings), range, byteCount: w.byteOff, strings: strings.length };
|
|
576
576
|
}
|
|
577
577
|
/** Write one blob-only shard (references a shared dictionary) to `<outBase>.<id>.sigs.ndjson` (+ `.br`/`.zst`). */
|
|
578
578
|
async function writeShardBundle(outBase, shard, cranBase, compress = {}) {
|
|
@@ -604,7 +604,7 @@ async function writeShardBundle(outBase, shard, cranBase, compress = {}) {
|
|
|
604
604
|
async function writeShardedDatabase(outBase, db, manifestFile, opts = {}) {
|
|
605
605
|
const compress = { level: opts.level, brotliQuality: opts.brotliQuality, brotliLgwin: opts.brotliLgwin };
|
|
606
606
|
const exts = (0, codec_1.writeCodecs)().map(c => c.ext); // every compressed variant produced (`.br` always, `.zst` when supported)
|
|
607
|
-
const base =
|
|
607
|
+
const base = path_1.default.basename(outBase);
|
|
608
608
|
const dictRef = await writeDictionary(outBase, 'shared', db.strings, compress);
|
|
609
609
|
const shardRefs = [];
|
|
610
610
|
for (const s of db.shards) {
|
|
@@ -624,14 +624,14 @@ async function writeShardedDatabase(outBase, db, manifestFile, opts = {}) {
|
|
|
624
624
|
(0, manifest_1.writeManifest)(manifestFile, manifest);
|
|
625
625
|
if (opts.pack) {
|
|
626
626
|
// a self-contained folder to copy into flowR: every compressed variant of the dictionary + shards + the (index-embedding) manifest
|
|
627
|
-
|
|
627
|
+
fs_1.default.mkdirSync(opts.pack, { recursive: true });
|
|
628
628
|
for (const ext of exts) {
|
|
629
|
-
|
|
629
|
+
fs_1.default.copyFileSync(`${outBase}${exports.SigDbDictExt}${ext}`, path_1.default.join(opts.pack, `${dictRef.path}${ext}`));
|
|
630
630
|
for (const ref of shardRefs) {
|
|
631
|
-
|
|
631
|
+
fs_1.default.copyFileSync(`${outBase}.${ref.id}${schema_1.SigDbExt}${ext}`, path_1.default.join(opts.pack, `${ref.path}${ext}`));
|
|
632
632
|
}
|
|
633
633
|
}
|
|
634
|
-
(0, manifest_1.writeManifest)(
|
|
634
|
+
(0, manifest_1.writeManifest)(path_1.default.join(opts.pack, `${base}.manifest.json`), manifest);
|
|
635
635
|
}
|
|
636
636
|
return manifest;
|
|
637
637
|
}
|
package/project/sigdb/codec.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Transform } from '
|
|
1
|
+
import type { Transform } from 'stream';
|
|
2
2
|
/** whether the running Node exposes the `node:zlib` zstd API (Node 22.15+ / 23.8+) */
|
|
3
3
|
export declare function zstdSupported(): boolean;
|
|
4
4
|
/** on-disk compression codec for a sigdb bundle */
|
package/project/sigdb/codec.js
CHANGED
|
@@ -21,8 +21,8 @@ exports.decompressSyncFor = decompressSyncFor;
|
|
|
21
21
|
* including the older Node bundled in the VS Code extension host. Only the outer compression changes -- the
|
|
22
22
|
* ranged reads and `.idx` seek logic operate on the decompressed plain NDJSON and are codec-agnostic.
|
|
23
23
|
*/
|
|
24
|
-
const
|
|
25
|
-
const zstd =
|
|
24
|
+
const zlib_1 = __importDefault(require("zlib"));
|
|
25
|
+
const zstd = zlib_1.default;
|
|
26
26
|
/** whether the running Node exposes the `node:zlib` zstd API (Node 22.15+ / 23.8+) */
|
|
27
27
|
function zstdSupported() {
|
|
28
28
|
return typeof zstd.zstdCompressSync === 'function' && typeof zstd.createZstdDecompress === 'function';
|
|
@@ -53,16 +53,16 @@ function stripCompressedExt(name) {
|
|
|
53
53
|
/** regex alternation matching an optional trailing compressed extension, e.g. `(?:\.br|\.zst|\.gz)?` */
|
|
54
54
|
exports.CompressedExtPattern = `(?:${exports.CompressedExts.map(e => e.replace(/\./g, '\\.')).join('|')})?`;
|
|
55
55
|
// reading large-window brotli requires opting in; every `.br` flowR writes uses large windows, so this is always safe
|
|
56
|
-
const BrotliDecodeParams = { params: { [
|
|
56
|
+
const BrotliDecodeParams = { params: { [zlib_1.default.constants.BROTLI_DECODER_PARAM_LARGE_WINDOW]: 1 } };
|
|
57
57
|
function brotliParams(opts) {
|
|
58
58
|
const lgwin = opts.lgwin ?? 30;
|
|
59
59
|
const params = {
|
|
60
|
-
[
|
|
61
|
-
[
|
|
62
|
-
[
|
|
60
|
+
[zlib_1.default.constants.BROTLI_PARAM_QUALITY]: opts.level ?? 11,
|
|
61
|
+
[zlib_1.default.constants.BROTLI_PARAM_LGWIN]: lgwin,
|
|
62
|
+
[zlib_1.default.constants.BROTLI_PARAM_LARGE_WINDOW]: lgwin > 24 ? 1 : 0
|
|
63
63
|
};
|
|
64
64
|
if (opts.sizeHint !== undefined) {
|
|
65
|
-
params[
|
|
65
|
+
params[zlib_1.default.constants.BROTLI_PARAM_SIZE_HINT] = opts.sizeHint;
|
|
66
66
|
}
|
|
67
67
|
return params;
|
|
68
68
|
}
|
|
@@ -72,8 +72,8 @@ function zstdParams(opts) {
|
|
|
72
72
|
exports.BrotliCodec = {
|
|
73
73
|
codec: 'brotli',
|
|
74
74
|
ext: '.br',
|
|
75
|
-
compressSync: (buf, opts = {}) =>
|
|
76
|
-
createCompress: (opts = {}) =>
|
|
75
|
+
compressSync: (buf, opts = {}) => zlib_1.default.brotliCompressSync(buf, { params: brotliParams(opts) }),
|
|
76
|
+
createCompress: (opts = {}) => zlib_1.default.createBrotliCompress({ params: brotliParams(opts) })
|
|
77
77
|
};
|
|
78
78
|
exports.ZstdCodec = {
|
|
79
79
|
codec: 'zstd',
|
|
@@ -105,9 +105,9 @@ function createDecompressFor(file) {
|
|
|
105
105
|
return requireZstd().createZstdDecompress();
|
|
106
106
|
}
|
|
107
107
|
if (file.endsWith('.gz')) {
|
|
108
|
-
return
|
|
108
|
+
return zlib_1.default.createGunzip();
|
|
109
109
|
}
|
|
110
|
-
return
|
|
110
|
+
return zlib_1.default.createBrotliDecompress(BrotliDecodeParams);
|
|
111
111
|
}
|
|
112
112
|
/** synchronously decompress a compressed buffer, choosing the codec by the source's extension */
|
|
113
113
|
function decompressSyncFor(file, raw) {
|
|
@@ -115,8 +115,8 @@ function decompressSyncFor(file, raw) {
|
|
|
115
115
|
return requireZstd().zstdDecompressSync(raw);
|
|
116
116
|
}
|
|
117
117
|
if (file.endsWith('.gz')) {
|
|
118
|
-
return
|
|
118
|
+
return zlib_1.default.gunzipSync(raw);
|
|
119
119
|
}
|
|
120
|
-
return
|
|
120
|
+
return zlib_1.default.brotliDecompressSync(raw, BrotliDecodeParams);
|
|
121
121
|
}
|
|
122
122
|
//# sourceMappingURL=codec.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Readable } from '
|
|
1
|
+
import type { Readable } from 'stream';
|
|
2
2
|
import { type SigDbIndex } from './index-format';
|
|
3
3
|
/** whether a bundle path is a compressed (`.br`/`.zst`/`.gz`) source that must be decompressed to be seekable */
|
|
4
4
|
export declare const isCompressed: (f: string) => boolean;
|