@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.
Files changed (196) hide show
  1. package/README.md +31 -31
  2. package/abstract-interpretation/absint-visitor.js +1 -1
  3. package/abstract-interpretation/data-frame/mappers/access-mapper.js +4 -4
  4. package/abstract-interpretation/data-frame/mappers/arguments.js +7 -4
  5. package/abstract-interpretation/data-frame/mappers/function-mapper.js +18 -17
  6. package/abstract-interpretation/data-frame/mappers/replacement-mapper.js +6 -6
  7. package/abstract-interpretation/data-frame/resolve-args.d.ts +9 -4
  8. package/abstract-interpretation/data-frame/resolve-args.js +10 -5
  9. package/benchmark/calibration.d.ts +12 -5
  10. package/benchmark/calibration.js +42 -14
  11. package/benchmark/slicer.d.ts +1 -1
  12. package/benchmark/slicer.js +5 -4
  13. package/benchmark/stats/size-of.js +1 -1
  14. package/benchmark/summarizer/first-phase/process.d.ts +2 -0
  15. package/benchmark/summarizer/first-phase/process.js +2 -0
  16. package/cli/common/options.d.ts +0 -31
  17. package/cli/common/options.js +1 -8
  18. package/cli/common/scripts-info.d.ts +0 -38
  19. package/cli/common/scripts-info.js +0 -8
  20. package/cli/repl/core.js +1 -1
  21. package/cli/repl/parser/slice-query-parser.js +1 -1
  22. package/cli/repl/print-version.js +2 -2
  23. package/config.d.ts +16 -0
  24. package/config.js +79 -0
  25. package/control-flow/extract-cfg.js +1 -1
  26. package/control-flow/semantic-cfg-guided-visitor.d.ts +1 -1
  27. package/control-flow/semantic-cfg-guided-visitor.js +1 -1
  28. package/control-flow/useless-loop.js +1 -1
  29. package/core/print/slice-diff-ansi.js +1 -1
  30. package/core/steps/pipeline/create-pipeline.js +1 -1
  31. package/dataflow/cluster.js +2 -2
  32. package/dataflow/environments/built-in-props.d.ts +8 -1
  33. package/dataflow/environments/built-in-props.js +18 -0
  34. package/dataflow/environments/built-in.d.ts +7 -1
  35. package/dataflow/environments/built-in.js +42 -3
  36. package/dataflow/environments/default-builtin-config.d.ts +442 -10
  37. package/dataflow/environments/default-builtin-config.js +188 -18
  38. package/dataflow/environments/environment.d.ts +1 -1
  39. package/dataflow/environments/identifier.d.ts +7 -2
  40. package/dataflow/environments/identifier.js +6 -1
  41. package/dataflow/environments/query-fn-props.js +2 -2
  42. package/dataflow/environments/reference-to-maybe.js +5 -5
  43. package/dataflow/environments/resolve-by-name.d.ts +3 -0
  44. package/dataflow/environments/resolve-by-name.js +30 -5
  45. package/dataflow/environments/resolve-helper.d.ts +6 -0
  46. package/dataflow/environments/resolve-helper.js +6 -0
  47. package/dataflow/eval/resolve/alias-tracking.d.ts +5 -0
  48. package/dataflow/eval/resolve/alias-tracking.js +21 -14
  49. package/dataflow/eval/resolve/node-value.d.ts +6 -0
  50. package/dataflow/eval/resolve/node-value.js +15 -9
  51. package/dataflow/eval/resolve/resolve-argument.js +2 -2
  52. package/dataflow/eval/resolve/resolve-numbers.js +2 -2
  53. package/dataflow/eval/resolve/resolve-operators.js +4 -3
  54. package/dataflow/eval/resolve/resolve-strings.js +3 -3
  55. package/dataflow/eval/resolve/resolve-working-directory.js +2 -1
  56. package/dataflow/eval/resolve/resolve.d.ts +5 -5
  57. package/dataflow/eval/resolve/resolve.js +10 -11
  58. package/dataflow/eval/values/general.d.ts +4 -1
  59. package/dataflow/eval/values/general.js +1 -1
  60. package/dataflow/extractor.js +2 -1
  61. package/dataflow/fn/exceptions-of-function.js +5 -4
  62. package/dataflow/fn/higher-order-function.js +5 -4
  63. package/dataflow/graph/call-graph.js +14 -14
  64. package/dataflow/graph/df-helper.d.ts +15 -0
  65. package/dataflow/graph/df-helper.js +10 -4
  66. package/dataflow/graph/diff-dataflow-graph.js +6 -6
  67. package/dataflow/graph/edge.d.ts +27 -0
  68. package/dataflow/graph/edge.js +33 -0
  69. package/dataflow/graph/graph-helper.d.ts +3 -4
  70. package/dataflow/graph/graph-helper.js +4 -5
  71. package/dataflow/graph/graph.d.ts +11 -1
  72. package/dataflow/graph/graph.js +16 -5
  73. package/dataflow/graph/vertex.d.ts +42 -6
  74. package/dataflow/graph/vertex.js +42 -6
  75. package/dataflow/internal/linker.d.ts +1 -0
  76. package/dataflow/internal/linker.js +11 -9
  77. package/dataflow/internal/process/functions/call/built-in/built-in-access.js +2 -2
  78. package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +1 -1
  79. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +6 -5
  80. package/dataflow/internal/process/functions/call/built-in/built-in-class-generator.js +2 -2
  81. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +6 -7
  82. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +7 -6
  83. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.d.ts +1 -0
  84. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +19 -18
  85. package/dataflow/internal/process/functions/call/built-in/built-in-library.js +6 -1
  86. package/dataflow/internal/process/functions/call/built-in/built-in-list.js +2 -2
  87. package/dataflow/internal/process/functions/call/built-in/built-in-local.js +2 -2
  88. package/dataflow/internal/process/functions/call/built-in/built-in-pipe.js +2 -2
  89. package/dataflow/internal/process/functions/call/built-in/built-in-purrr-formula.js +5 -5
  90. package/dataflow/internal/process/functions/call/built-in/built-in-quote.js +1 -1
  91. package/dataflow/internal/process/functions/call/built-in/built-in-register-hook.js +3 -3
  92. package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +3 -3
  93. package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +2 -2
  94. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +3 -3
  95. package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +3 -3
  96. package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.d.ts +3 -1
  97. package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +15 -12
  98. package/dataflow/internal/process/functions/call/common.d.ts +9 -1
  99. package/dataflow/internal/process/functions/call/common.js +17 -6
  100. package/dataflow/internal/process/functions/call/deferred.js +2 -1
  101. package/dataflow/internal/process/functions/call/known-call-handling.d.ts +3 -1
  102. package/dataflow/internal/process/functions/call/known-call-handling.js +6 -3
  103. package/dataflow/internal/process/functions/call/named-call-handling.js +44 -12
  104. package/dataflow/internal/process/functions/call/nse.d.ts +33 -5
  105. package/dataflow/internal/process/functions/call/nse.js +113 -6
  106. package/dataflow/internal/process/functions/call/quoted.d.ts +5 -0
  107. package/dataflow/internal/process/functions/call/quoted.js +21 -9
  108. package/dataflow/origin/dfg-get-origin.d.ts +1 -0
  109. package/dataflow/origin/dfg-get-origin.js +9 -6
  110. package/documentation/data/faq/faqs.js +88 -88
  111. package/documentation/data/faq/recommended-configs.js +1 -1
  112. package/documentation/data/faq/wiki-faq-store.js +1 -1
  113. package/documentation/doc-capabilities.js +1 -1
  114. package/documentation/doc-readme.js +1 -1
  115. package/documentation/doc-util/doc-auto-gen.js +6 -2
  116. package/documentation/doc-util/doc-functions.js +1 -1
  117. package/documentation/wiki-cfg.js +2 -2
  118. package/documentation/wiki-create-linting-rules.js +45 -45
  119. package/documentation/wiki-dataflow-graph.js +17 -18
  120. package/documentation/wiki-linting-and-testing.js +93 -5
  121. package/documentation/wiki-mk/doc-maker.js +1 -1
  122. package/documentation/wiki-overview.js +12 -1
  123. package/documentation/wiki-signature-database.js +3 -0
  124. package/linter/rules/file-path-validity.js +1 -1
  125. package/linter/rules/function-finder-util.js +1 -1
  126. package/linter/rules/naming-convention.js +1 -1
  127. package/linter/rules/no-leaked-credentials.js +2 -1
  128. package/linter/rules/stop-with-call-arg.js +4 -4
  129. package/linter/rules/undefined-symbol-util.d.ts +1 -1
  130. package/linter/rules/undefined-symbol-util.js +5 -4
  131. package/linter/rules/undefined-symbol.js +3 -3
  132. package/linter/rules/unused-definition.js +2 -1
  133. package/package.json +35 -45
  134. package/project/context/flowr-analyzer-environment-context.d.ts +23 -0
  135. package/project/context/flowr-analyzer-environment-context.js +25 -0
  136. package/project/dependency-version-space.js +1 -2
  137. package/project/flowr-analyzer.js +1 -1
  138. package/project/plugins/file-plugins/files/flowr-rda-file.js +3 -3
  139. package/project/plugins/file-plugins/files/flowr-rmarkdown-file.js +2 -2
  140. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +3 -1
  141. package/project/sigdb/build.js +16 -16
  142. package/project/sigdb/codec.d.ts +1 -1
  143. package/project/sigdb/codec.js +13 -13
  144. package/project/sigdb/decompress.d.ts +1 -1
  145. package/project/sigdb/decompress.js +33 -33
  146. package/project/sigdb/index-format.js +2 -2
  147. package/project/sigdb/manifest.js +21 -21
  148. package/project/sigdb/memory-source.d.ts +64 -0
  149. package/project/sigdb/memory-source.js +133 -0
  150. package/project/sigdb/reader.js +13 -13
  151. package/queries/catalog/call-context-query/call-context-query-executor.js +1 -1
  152. package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +2 -2
  153. package/queries/catalog/dependencies-query/dependencies-query-executor.js +2 -2
  154. package/queries/catalog/dependencies-query/dependencies-query-format.js +1 -1
  155. package/queries/catalog/dependencies-query/link-devices.js +2 -2
  156. package/queries/catalog/does-call-query/does-call-query-executor.js +2 -1
  157. package/queries/catalog/input-sources-query/simple-input-classifier.js +4 -4
  158. package/queries/catalog/location-map-query/location-map-query-format.js +1 -1
  159. package/queries/catalog/resolve-value-query/resolve-value-query-executor.js +2 -2
  160. package/queries/catalog/signature-query/signature-query-executor.d.ts +2 -0
  161. package/queries/catalog/signature-query/signature-query-executor.js +3 -2
  162. package/r-bridge/lang-4.x/ast/model/processing/node-id.js +3 -3
  163. package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-call.js +1 -1
  164. package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-definition.js +1 -1
  165. package/r-bridge/retriever.d.ts +2 -1
  166. package/r-bridge/retriever.js +3 -2
  167. package/r-bridge/roxygen2/documentation-provider.d.ts +1 -0
  168. package/r-bridge/roxygen2/documentation-provider.js +1 -0
  169. package/r-bridge/roxygen2/roxygen-parse.d.ts +1 -1
  170. package/r-bridge/roxygen2/roxygen-parse.js +1 -1
  171. package/search/flowr-search-filters.d.ts +1 -1
  172. package/search/flowr-search-filters.js +2 -2
  173. package/search/search-executor/search-enrichers.js +4 -4
  174. package/search/search-executor/search-generators.js +1 -1
  175. package/slicing/criterion/parse.js +3 -3
  176. package/slicing/static/slice-call.d.ts +1 -1
  177. package/slicing/static/slice-call.js +2 -2
  178. package/slicing/static/static-slicer.js +4 -3
  179. package/util/assert.js +1 -1
  180. package/util/log.d.ts +4 -1
  181. package/util/log.js +15 -2
  182. package/util/logic.js +2 -2
  183. package/util/mermaid/cfg.js +1 -1
  184. package/util/mermaid/dfg.js +6 -6
  185. package/util/mermaid/mermaid.js +3 -1
  186. package/util/quads.js +19 -6
  187. package/util/schema.js +2 -2
  188. package/util/text/ansi.d.ts +2 -0
  189. package/util/text/ansi.js +8 -0
  190. package/util/text/name-rank.d.ts +29 -0
  191. package/util/text/name-rank.js +39 -0
  192. package/util/text/url-encoding.d.ts +15 -0
  193. package/util/text/url-encoding.js +59 -0
  194. package/util/version.js +1 -1
  195. package/cli/export-quads-app.d.ts +0 -7
  196. package/cli/export-quads-app.js +0 -44
package/util/quads.js CHANGED
@@ -13,13 +13,25 @@ exports.defaultQuadIdGenerator = defaultQuadIdGenerator;
13
13
  exports.defaultQuadIgnoreIf = defaultQuadIgnoreIf;
14
14
  exports.serialize2quads = serialize2quads;
15
15
  exports.graph2quads = graph2quads;
16
- const n3_1 = require("n3");
17
- const namedNode = (v) => n3_1.DataFactory.namedNode(v);
18
- const quad = (s, p, o, g) => n3_1.DataFactory.quad(s, p, o, g);
16
+ /**
17
+ * The `n3` module, or a clear error if the optional dependency is missing.
18
+ * Install it to serialize quads (`npm i n3`), everything else works without it.
19
+ */
20
+ function n3() {
21
+ try {
22
+ // eslint-disable-next-line @typescript-eslint/no-require-imports -- optional dependency, resolved only when quads are requested
23
+ return require('n3');
24
+ }
25
+ catch {
26
+ throw new Error('quad serialization needs the optional `n3` dependency, install it with `npm i n3`');
27
+ }
28
+ }
29
+ const namedNode = (v) => n3().DataFactory.namedNode(v);
30
+ const quad = (s, p, o, g) => n3().DataFactory.quad(s, p, o, g);
19
31
  const objects_1 = require("./objects");
20
32
  const assert_1 = require("./assert");
21
33
  const defaultmap_1 = require("./collections/defaultmap");
22
- const literal = (v, n) => n3_1.DataFactory.literal(v, n);
34
+ const literal = (v, n) => n3().DataFactory.literal(v, n);
23
35
  const log_1 = require("./log");
24
36
  const domain = 'https://uni-ulm.de/r-ast/';
25
37
  /**
@@ -46,7 +58,8 @@ exports.DefaultQuadSerializationConfiguration = {
46
58
  function retrieveContext(context, obj) {
47
59
  return typeof context === 'string' ? context : context(obj);
48
60
  }
49
- const writer = new n3_1.Writer({ format: 'N-Quads' });
61
+ let cachedWriter;
62
+ const writer = () => cachedWriter ??= new (n3().Writer)({ format: 'N-Quads' });
50
63
  /**
51
64
  * Serializes the given object or array to rdf quads.
52
65
  * @param obj - The object to serialize (must be a Record and no array etc.)
@@ -61,7 +74,7 @@ function serialize2quads(obj, config) {
61
74
  store = new Set();
62
75
  const quads = [];
63
76
  serializeObject(obj, quads, useConfig);
64
- return writer.quadsToString(quads);
77
+ return writer().quadsToString(quads);
65
78
  }
66
79
  /**
67
80
  * Serializes the given directed graph to rdf quads.
package/util/schema.js CHANGED
@@ -75,7 +75,7 @@ function firstUnknownSchemaSegment(description, path) {
75
75
  const pattern = patternObject(node);
76
76
  if (pattern !== undefined) {
77
77
  if (pattern.keyValids !== undefined && !pattern.keyValids.includes(path[i])) {
78
- return { segment: path[i], available: pattern.keyValids.map(v => String(v)), at: path.slice(0, i) };
78
+ return { segment: path[i], available: pattern.keyValids.map(String), at: path.slice(0, i) };
79
79
  }
80
80
  node = pattern.value;
81
81
  continue;
@@ -110,7 +110,7 @@ function descriptionPathKeys(description, path) {
110
110
  }
111
111
  const keys = Object.keys((node.keys ?? {}));
112
112
  // a `.pattern()` object declares no keys, but a `.valid(...)` key schema restricts them to a known set
113
- const valids = patternObject(node)?.keyValids?.map(v => String(v)) ?? [];
113
+ const valids = patternObject(node)?.keyValids?.map(String) ?? [];
114
114
  return [...keys, ...valids.filter(v => !keys.includes(v))];
115
115
  }
116
116
  /** every settable path in a schema description, intermediate objects included */
@@ -63,6 +63,8 @@ export declare function faint(s: string, f?: OutputFormatter, options?: FormatOp
63
63
  */
64
64
  export declare function ansiInfo(s: string, f?: OutputFormatter): string;
65
65
  export declare const escape = "\u001B[";
66
+ /** The text without any colouring, for wherever an escape sequence would only show up as `[0m`. */
67
+ export declare function stripAnsi(text: string): string;
66
68
  /** best-effort, env-based OSC 8 hyperlink support (`FORCE_HYPERLINK`/`NO_HYPERLINK` override; unknown terminals are treated as unsupported) */
67
69
  export declare function supportsHyperlinks(): boolean;
68
70
  export declare const ansiFormatter: {
package/util/text/ansi.js CHANGED
@@ -6,6 +6,7 @@ exports.bold = bold;
6
6
  exports.color = color;
7
7
  exports.faint = faint;
8
8
  exports.ansiInfo = ansiInfo;
9
+ exports.stripAnsi = stripAnsi;
9
10
  exports.supportsHyperlinks = supportsHyperlinks;
10
11
  exports.setFormatter = setFormatter;
11
12
  // noinspection JSUnusedGlobalSymbols
@@ -90,6 +91,13 @@ function ansiInfo(s, f = exports.formatter) {
90
91
  return f.format(s, { color: 7 /* Colors.White */, effect: ColorEffect.Foreground, style: 3 /* FontStyles.Italic */ });
91
92
  }
92
93
  exports.escape = '\x1b[';
94
+ /** every {@link escape} sequence, so a place that cannot colour (a browser, a log file) can drop them */
95
+ // eslint-disable-next-line no-control-regex -- the escape character is what an escape sequence starts with
96
+ const AnsiSequence = /\x1b\[[\d;]*m/g;
97
+ /** The text without any colouring, for wherever an escape sequence would only show up as `[0m`. */
98
+ function stripAnsi(text) {
99
+ return text.replaceAll(AnsiSequence, '');
100
+ }
93
101
  const colorSuffix = 'm';
94
102
  let hyperlinkSupport;
95
103
  /** best-effort, env-based OSC 8 hyperlink support (`FORCE_HYPERLINK`/`NO_HYPERLINK` override; unknown terminals are treated as unsupported) */
@@ -0,0 +1,29 @@
1
+ /**
2
+ * What a reader most likely meant when typing a name: a well-used package first, base R ahead of CRAN, and
3
+ * the things one rarely reaches for last, which are S3 methods, `%operators%` and names starting with a dot.
4
+ *
5
+ * The signature browser and the playground's completion both offer names out of the same database, so they
6
+ * order them with the same {@link rankName}, and what one of them learns the other one knows.
7
+ */
8
+ export interface NameRankInput {
9
+ /** the name being offered */
10
+ readonly name: string;
11
+ /** what was typed, empty when nothing was */
12
+ readonly needle: string;
13
+ /** how far down the fuzzy match sits, `0` being the closest; `0` when nothing was typed */
14
+ readonly rank?: number;
15
+ /** how often the owning package was downloaded, `0` when unknown */
16
+ readonly downloads?: number;
17
+ /** the owning package ships with R */
18
+ readonly baseR?: boolean;
19
+ /** the owning package is `base` itself */
20
+ readonly base?: boolean;
21
+ /** flowR carries a definition of its own for the name, so it is one people actually call */
22
+ readonly known?: boolean;
23
+ /** the name is an S3 method, like `print.foo` */
24
+ readonly s3?: boolean;
25
+ /** the name holds a value rather than a function */
26
+ readonly variable?: boolean;
27
+ }
28
+ /** The points {@link NameRankInput} earns, higher being offered first. */
29
+ export declare function rankName(of: NameRankInput): number;
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.rankName = rankName;
4
+ /**
5
+ * Every rule beyond the match itself, as `points` and when they apply. A list rather than a run of
6
+ * conditions, so a rule can be read, weighed against its neighbours, or added without touching the rest.
7
+ */
8
+ const Adjustments = [
9
+ /* what was typed, exactly, always comes first; the same spelling in another case comes next */
10
+ [1200, ({ name, needle }) => name === needle],
11
+ [900, ({ name, needle }) => name !== needle && name.toLowerCase() === needle.toLowerCase()],
12
+ /* a real function from base R is what a reader usually means; a lone symbol almost never is */
13
+ [40, ({ name, baseR }) => baseR === true && name.length >= 3],
14
+ [-20, ({ variable }) => variable === true],
15
+ [-40, ({ name }) => name.length < 3],
16
+ /* `names<-` is the replacement form of `names`, and nobody reaches for it first */
17
+ [-35, ({ name }) => name.endsWith('<-')],
18
+ [-45, ({ name, needle }) => name.includes('.') && !needle.includes('.')],
19
+ /* `base` itself before the packages that merely ship with R */
20
+ [20, ({ base }) => base === true],
21
+ /* a name flowR recognises outranks a closer spelling it knows nothing about: typing `plot` should
22
+ offer `ggplot` before `plotH`, because one of them is a function people actually call */
23
+ [500, ({ known }) => known === true],
24
+ [-30, ({ s3 }) => s3 === true],
25
+ /* operators, punctuation and SHOUTING names are rarely what someone is looking for */
26
+ [-60, ({ name }) => /^%.*%$/.test(name) || /^[^\w.]/.test(name)],
27
+ [-30, ({ name, needle }) => name === name.toUpperCase() && /[A-Z]/.test(name) && name !== needle],
28
+ [-400, ({ name }) => name.startsWith('.')]
29
+ ];
30
+ /** The points {@link NameRankInput} earns, higher being offered first. */
31
+ function rankName(of) {
32
+ const { name, needle, rank = 0, downloads = 0 } = of;
33
+ /* how well it matches comes first, then how short it is; popularity only settles what is left.
34
+ Length only matters against something typed: with an empty box it would rank `AIC` above `mean` */
35
+ const match = -rank * 150 - (needle ? name.length * 12 : 0)
36
+ + Math.min(Math.log10(downloads + 10), 8) * (needle ? 4 : 12);
37
+ return Adjustments.reduce((points, [worth, when]) => when(of) ? points + worth : points, match);
38
+ }
39
+ //# sourceMappingURL=name-rank.js.map
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Base64 for the pages flowR ships, which run in a browser and therefore have `btoa`/`atob` rather than
3
+ * node's `Buffer`. The url-safe pair is what lets the playground keep a script in its own address, so a
4
+ * link is the example.
5
+ */
6
+ /** bytes as base64 */
7
+ export declare function toBase64(bytes: Uint8Array): string;
8
+ /** text as base64 in the alphabet a url carries without escaping anything, padding dropped */
9
+ export declare function toBase64Url(text: string): string;
10
+ /** the inverse of {@link toBase64Url}, `undefined` for anything that is not what it produced */
11
+ export declare function fromBase64Url(text: string): string | undefined;
12
+ /** Text as short as it goes while staying a url: compressed when that helps, plain base64 when it does not. */
13
+ export declare function packForUrl(text: string): string;
14
+ /** The inverse of {@link packForUrl}, `undefined` for anything it did not produce. */
15
+ export declare function unpackFromUrl(payload: string): string | undefined;
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.toBase64 = toBase64;
4
+ exports.toBase64Url = toBase64Url;
5
+ exports.fromBase64Url = fromBase64Url;
6
+ exports.packForUrl = packForUrl;
7
+ exports.unpackFromUrl = unpackFromUrl;
8
+ const lz_string_1 = require("lz-string");
9
+ /**
10
+ * Base64 for the pages flowR ships, which run in a browser and therefore have `btoa`/`atob` rather than
11
+ * node's `Buffer`. The url-safe pair is what lets the playground keep a script in its own address, so a
12
+ * link is the example.
13
+ */
14
+ /** bytes as base64 */
15
+ function toBase64(bytes) {
16
+ let binary = '';
17
+ for (const byte of bytes) {
18
+ binary += String.fromCharCode(byte);
19
+ }
20
+ return btoa(binary);
21
+ }
22
+ /** text as base64 in the alphabet a url carries without escaping anything, padding dropped */
23
+ function toBase64Url(text) {
24
+ return toBase64(new TextEncoder().encode(text)).replaceAll('+', '-').replaceAll('/', '_').replace(/=+$/, '');
25
+ }
26
+ /** the inverse of {@link toBase64Url}, `undefined` for anything that is not what it produced */
27
+ function fromBase64Url(text) {
28
+ try {
29
+ const binary = atob(text.replaceAll('-', '+').replaceAll('_', '/'));
30
+ return new TextDecoder('utf-8', { fatal: true }).decode(Uint8Array.from(binary, character => character.charCodeAt(0)));
31
+ }
32
+ catch {
33
+ return undefined; /* a link someone edited by hand */
34
+ }
35
+ }
36
+ /** Text as short as it goes while staying a url: compressed when that helps, plain base64 when it does not. */
37
+ function packForUrl(text) {
38
+ const plain = toBase64Url(text);
39
+ if (text.length === 0) {
40
+ return "t" /* Packing.Plain */ + plain;
41
+ }
42
+ const compressed = (0, lz_string_1.compressToEncodedURIComponent)(text);
43
+ return compressed.length < plain.length ? "z" /* Packing.Compressed */ + compressed : "t" /* Packing.Plain */ + plain;
44
+ }
45
+ /** The inverse of {@link packForUrl}, `undefined` for anything it did not produce. */
46
+ function unpackFromUrl(payload) {
47
+ const rest = payload.slice(1);
48
+ try {
49
+ switch (payload[0]) {
50
+ case "z" /* Packing.Compressed */: return (0, lz_string_1.decompressFromEncodedURIComponent)(rest) ?? undefined;
51
+ case "t" /* Packing.Plain */: return fromBase64Url(rest);
52
+ default: return undefined;
53
+ }
54
+ }
55
+ catch {
56
+ return undefined; /* a link someone edited by hand */
57
+ }
58
+ }
59
+ //# sourceMappingURL=url-encoding.js.map
package/util/version.js CHANGED
@@ -42,7 +42,7 @@ 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.13.16';
45
+ const version = '2.14.0';
46
46
  // this is automatically replaced with the release date by release-it (regex-bumper, see package.json)
47
47
  const versionDate = '2026-07-15T07:13:44Z';
48
48
  /**
@@ -1,7 +0,0 @@
1
- export interface QuadsCliOptions {
2
- verbose: boolean;
3
- help: boolean;
4
- input: string[];
5
- limit: number;
6
- output: string | undefined;
7
- }
@@ -1,44 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const fs_1 = __importDefault(require("fs"));
7
- const quads_1 = require("../util/quads");
8
- const log_1 = require("../util/log");
9
- const files_1 = require("../util/files");
10
- const script_1 = require("./common/script");
11
- const shell_1 = require("../r-bridge/shell");
12
- const retriever_1 = require("../r-bridge/retriever");
13
- const config_1 = require("../config");
14
- const options = (0, script_1.processCommandLineArgs)('export-quads', [], {
15
- subtitle: 'Generate RDF N-Quads from the AST of a given R script',
16
- examples: [
17
- '{bold -i} {italic example.R} {bold --output} {italic "example.quads"}',
18
- '{bold --help}'
19
- ]
20
- });
21
- const shell = new shell_1.RShell(config_1.FlowrConfig.getForEngine(config_1.FlowrConfig.fromFile(), 'r-shell'));
22
- async function writeQuadForSingleFile(request, output) {
23
- const normalized = await (0, retriever_1.retrieveNormalizedAstFromRCode)(request, shell);
24
- const serialized = (0, quads_1.serialize2quads)(normalized.ast.files[0].root, { context: request.content });
25
- log_1.log.info(`Appending quads to ${output}`);
26
- fs_1.default.appendFileSync(output, serialized);
27
- }
28
- async function getQuads() {
29
- const output = options.output ?? 'out.quads';
30
- let skipped = 0;
31
- for await (const request of (0, files_1.allRFilesFrom)(options.input, options.limit)) {
32
- try {
33
- await writeQuadForSingleFile(request, output);
34
- }
35
- catch (e) {
36
- log_1.log.error(`[Skipped] Error while processing ${request.content}: ${e.message} (${e.stack ?? ''})`);
37
- skipped++;
38
- }
39
- }
40
- console.log(`Skipped ${skipped} files`);
41
- shell.close();
42
- }
43
- void getQuads();
44
- //# sourceMappingURL=export-quads-app.js.map