@eagleoutice/flowr 1.4.2 → 1.5.1

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 (223) hide show
  1. package/core/print/slice-diff-ansi.js +7 -7
  2. package/core/steps.d.ts +352 -11
  3. package/core/steps.js +4 -4
  4. package/index.d.ts +0 -2
  5. package/index.js +0 -2
  6. package/package.json +76 -216
  7. package/util/{summarizer/summarizer.d.ts → summarizer.d.ts} +15 -1
  8. package/util/summarizer.js +37 -0
  9. package/util/version.d.ts +2 -0
  10. package/util/version.js +11 -0
  11. package/benchmark/index.d.ts +0 -3
  12. package/benchmark/index.js +0 -20
  13. package/benchmark/slicer.d.ts +0 -98
  14. package/benchmark/slicer.js +0 -213
  15. package/benchmark/stats/index.d.ts +0 -10
  16. package/benchmark/stats/index.js +0 -27
  17. package/benchmark/stats/print.d.ts +0 -7
  18. package/benchmark/stats/print.js +0 -155
  19. package/benchmark/stats/stats.d.ts +0 -40
  20. package/benchmark/stats/stats.js +0 -6
  21. package/benchmark/stopwatch.d.ts +0 -35
  22. package/benchmark/stopwatch.js +0 -79
  23. package/cli/benchmark-app.d.ts +0 -10
  24. package/cli/benchmark-app.js +0 -67
  25. package/cli/benchmark-helper-app.d.ts +0 -9
  26. package/cli/benchmark-helper-app.js +0 -69
  27. package/cli/common/features.d.ts +0 -3
  28. package/cli/common/features.js +0 -30
  29. package/cli/common/index.d.ts +0 -2
  30. package/cli/common/index.js +0 -19
  31. package/cli/common/options.d.ts +0 -20
  32. package/cli/common/options.js +0 -85
  33. package/cli/common/script.d.ts +0 -21
  34. package/cli/common/script.js +0 -61
  35. package/cli/common/scripts-info.d.ts +0 -25
  36. package/cli/common/scripts-info.js +0 -83
  37. package/cli/export-quads-app.d.ts +0 -7
  38. package/cli/export-quads-app.js +0 -42
  39. package/cli/repl/commands/cfg.d.ts +0 -3
  40. package/cli/repl/commands/cfg.js +0 -37
  41. package/cli/repl/commands/commands.d.ts +0 -13
  42. package/cli/repl/commands/commands.js +0 -142
  43. package/cli/repl/commands/dataflow.d.ts +0 -3
  44. package/cli/repl/commands/dataflow.js +0 -34
  45. package/cli/repl/commands/execute.d.ts +0 -4
  46. package/cli/repl/commands/execute.js +0 -27
  47. package/cli/repl/commands/index.d.ts +0 -2
  48. package/cli/repl/commands/index.js +0 -19
  49. package/cli/repl/commands/main.d.ts +0 -39
  50. package/cli/repl/commands/main.js +0 -14
  51. package/cli/repl/commands/normalize.d.ts +0 -3
  52. package/cli/repl/commands/normalize.js +0 -34
  53. package/cli/repl/commands/parse.d.ts +0 -2
  54. package/cli/repl/commands/parse.js +0 -109
  55. package/cli/repl/commands/quit.d.ts +0 -2
  56. package/cli/repl/commands/quit.js +0 -15
  57. package/cli/repl/commands/version.d.ts +0 -16
  58. package/cli/repl/commands/version.js +0 -33
  59. package/cli/repl/core.d.ts +0 -41
  60. package/cli/repl/core.js +0 -172
  61. package/cli/repl/execute.d.ts +0 -28
  62. package/cli/repl/execute.js +0 -79
  63. package/cli/repl/index.d.ts +0 -5
  64. package/cli/repl/index.js +0 -22
  65. package/cli/repl/prompt.d.ts +0 -2
  66. package/cli/repl/prompt.js +0 -9
  67. package/cli/repl/server/connection.d.ts +0 -21
  68. package/cli/repl/server/connection.js +0 -213
  69. package/cli/repl/server/messages/analysis.d.ts +0 -71
  70. package/cli/repl/server/messages/analysis.js +0 -21
  71. package/cli/repl/server/messages/error.d.ts +0 -11
  72. package/cli/repl/server/messages/error.js +0 -3
  73. package/cli/repl/server/messages/hello.d.ts +0 -20
  74. package/cli/repl/server/messages/hello.js +0 -3
  75. package/cli/repl/server/messages/index.d.ts +0 -1
  76. package/cli/repl/server/messages/index.js +0 -3
  77. package/cli/repl/server/messages/messages.d.ts +0 -35
  78. package/cli/repl/server/messages/messages.js +0 -40
  79. package/cli/repl/server/messages/repl.d.ts +0 -33
  80. package/cli/repl/server/messages/repl.js +0 -37
  81. package/cli/repl/server/messages/slice.d.ts +0 -25
  82. package/cli/repl/server/messages/slice.js +0 -37
  83. package/cli/repl/server/net.d.ts +0 -49
  84. package/cli/repl/server/net.js +0 -63
  85. package/cli/repl/server/send.d.ts +0 -4
  86. package/cli/repl/server/send.js +0 -18
  87. package/cli/repl/server/server.d.ts +0 -20
  88. package/cli/repl/server/server.js +0 -66
  89. package/cli/repl/server/validate.d.ts +0 -15
  90. package/cli/repl/server/validate.js +0 -34
  91. package/cli/slicer-app.d.ts +0 -11
  92. package/cli/slicer-app.js +0 -81
  93. package/cli/statistics-app.d.ts +0 -11
  94. package/cli/statistics-app.js +0 -98
  95. package/cli/statistics-helper-app.d.ts +0 -11
  96. package/cli/statistics-helper-app.js +0 -82
  97. package/cli/summarizer-app.d.ts +0 -18
  98. package/cli/summarizer-app.js +0 -66
  99. package/flowr.d.ts +0 -29
  100. package/flowr.js +0 -142
  101. package/statistics/features/common-syntax-probability.d.ts +0 -31
  102. package/statistics/features/common-syntax-probability.js +0 -156
  103. package/statistics/features/feature.d.ts +0 -175
  104. package/statistics/features/feature.js +0 -30
  105. package/statistics/features/index.d.ts +0 -1
  106. package/statistics/features/index.js +0 -18
  107. package/statistics/features/post-processing.d.ts +0 -12
  108. package/statistics/features/post-processing.js +0 -21
  109. package/statistics/features/supported/assignments/assignments.d.ts +0 -11
  110. package/statistics/features/supported/assignments/assignments.js +0 -53
  111. package/statistics/features/supported/assignments/index.d.ts +0 -1
  112. package/statistics/features/supported/assignments/index.js +0 -6
  113. package/statistics/features/supported/assignments/post-process.d.ts +0 -3
  114. package/statistics/features/supported/assignments/post-process.js +0 -125
  115. package/statistics/features/supported/comments/comments.d.ts +0 -18
  116. package/statistics/features/supported/comments/comments.js +0 -133
  117. package/statistics/features/supported/comments/index.d.ts +0 -1
  118. package/statistics/features/supported/comments/index.js +0 -6
  119. package/statistics/features/supported/comments/post-process.d.ts +0 -3
  120. package/statistics/features/supported/comments/post-process.js +0 -50
  121. package/statistics/features/supported/control-flow/control-flow.d.ts +0 -17
  122. package/statistics/features/supported/control-flow/control-flow.js +0 -67
  123. package/statistics/features/supported/control-flow/index.d.ts +0 -1
  124. package/statistics/features/supported/control-flow/index.js +0 -6
  125. package/statistics/features/supported/control-flow/post-process.d.ts +0 -3
  126. package/statistics/features/supported/control-flow/post-process.js +0 -65
  127. package/statistics/features/supported/data-access/data-access.d.ts +0 -15
  128. package/statistics/features/supported/data-access/data-access.js +0 -118
  129. package/statistics/features/supported/data-access/index.d.ts +0 -1
  130. package/statistics/features/supported/data-access/index.js +0 -6
  131. package/statistics/features/supported/data-access/post-process.d.ts +0 -3
  132. package/statistics/features/supported/data-access/post-process.js +0 -107
  133. package/statistics/features/supported/defined-functions/defined-functions.d.ts +0 -35
  134. package/statistics/features/supported/defined-functions/defined-functions.js +0 -139
  135. package/statistics/features/supported/defined-functions/index.d.ts +0 -1
  136. package/statistics/features/supported/defined-functions/index.js +0 -6
  137. package/statistics/features/supported/defined-functions/post-process.d.ts +0 -6
  138. package/statistics/features/supported/defined-functions/post-process.js +0 -177
  139. package/statistics/features/supported/expression-list/expression-list.d.ts +0 -9
  140. package/statistics/features/supported/expression-list/expression-list.js +0 -36
  141. package/statistics/features/supported/expression-list/index.d.ts +0 -1
  142. package/statistics/features/supported/expression-list/index.js +0 -6
  143. package/statistics/features/supported/expression-list/post-process.d.ts +0 -3
  144. package/statistics/features/supported/expression-list/post-process.js +0 -44
  145. package/statistics/features/supported/index.d.ts +0 -10
  146. package/statistics/features/supported/index.js +0 -27
  147. package/statistics/features/supported/loops/index.d.ts +0 -1
  148. package/statistics/features/supported/loops/index.js +0 -6
  149. package/statistics/features/supported/loops/loops.d.ts +0 -20
  150. package/statistics/features/supported/loops/loops.js +0 -79
  151. package/statistics/features/supported/loops/post-process.d.ts +0 -3
  152. package/statistics/features/supported/loops/post-process.js +0 -72
  153. package/statistics/features/supported/used-functions/index.d.ts +0 -1
  154. package/statistics/features/supported/used-functions/index.js +0 -6
  155. package/statistics/features/supported/used-functions/post-process.d.ts +0 -6
  156. package/statistics/features/supported/used-functions/post-process.js +0 -179
  157. package/statistics/features/supported/used-functions/used-functions.d.ts +0 -24
  158. package/statistics/features/supported/used-functions/used-functions.js +0 -95
  159. package/statistics/features/supported/used-packages/index.d.ts +0 -1
  160. package/statistics/features/supported/used-packages/index.js +0 -6
  161. package/statistics/features/supported/used-packages/post-process.d.ts +0 -3
  162. package/statistics/features/supported/used-packages/post-process.js +0 -121
  163. package/statistics/features/supported/used-packages/used-packages.d.ts +0 -16
  164. package/statistics/features/supported/used-packages/used-packages.js +0 -130
  165. package/statistics/features/supported/values/index.d.ts +0 -1
  166. package/statistics/features/supported/values/index.js +0 -6
  167. package/statistics/features/supported/values/post-process.d.ts +0 -3
  168. package/statistics/features/supported/values/post-process.js +0 -72
  169. package/statistics/features/supported/values/values.d.ts +0 -14
  170. package/statistics/features/supported/values/values.js +0 -101
  171. package/statistics/features/supported/variables/index.d.ts +0 -1
  172. package/statistics/features/supported/variables/index.js +0 -6
  173. package/statistics/features/supported/variables/post-process.d.ts +0 -9
  174. package/statistics/features/supported/variables/post-process.js +0 -122
  175. package/statistics/features/supported/variables/variables.d.ts +0 -15
  176. package/statistics/features/supported/variables/variables.js +0 -70
  177. package/statistics/index.d.ts +0 -6
  178. package/statistics/index.js +0 -24
  179. package/statistics/meta-statistics.d.ts +0 -33
  180. package/statistics/meta-statistics.js +0 -17
  181. package/statistics/output/file-provider.d.ts +0 -37
  182. package/statistics/output/file-provider.js +0 -97
  183. package/statistics/output/index.d.ts +0 -4
  184. package/statistics/output/index.js +0 -21
  185. package/statistics/output/print-stats.d.ts +0 -17
  186. package/statistics/output/print-stats.js +0 -69
  187. package/statistics/output/statistics-file.d.ts +0 -37
  188. package/statistics/output/statistics-file.js +0 -69
  189. package/statistics/statistics.d.ts +0 -24
  190. package/statistics/statistics.js +0 -108
  191. package/util/summarizer/auto-detect.d.ts +0 -2
  192. package/util/summarizer/auto-detect.js +0 -32
  193. package/util/summarizer/benchmark/data.d.ts +0 -66
  194. package/util/summarizer/benchmark/data.js +0 -13
  195. package/util/summarizer/benchmark/first-phase/input.d.ts +0 -3
  196. package/util/summarizer/benchmark/first-phase/input.js +0 -75
  197. package/util/summarizer/benchmark/first-phase/process.d.ts +0 -11
  198. package/util/summarizer/benchmark/first-phase/process.js +0 -217
  199. package/util/summarizer/benchmark/second-phase/graph.d.ts +0 -2
  200. package/util/summarizer/benchmark/second-phase/graph.js +0 -54
  201. package/util/summarizer/benchmark/second-phase/process.d.ts +0 -6
  202. package/util/summarizer/benchmark/second-phase/process.js +0 -126
  203. package/util/summarizer/benchmark/summarizer.d.ts +0 -31
  204. package/util/summarizer/benchmark/summarizer.js +0 -58
  205. package/util/summarizer/statistics/first-phase/process.d.ts +0 -6
  206. package/util/summarizer/statistics/first-phase/process.js +0 -81
  207. package/util/summarizer/statistics/post-process/clusterer.d.ts +0 -26
  208. package/util/summarizer/statistics/post-process/clusterer.js +0 -43
  209. package/util/summarizer/statistics/post-process/file-based-count.d.ts +0 -17
  210. package/util/summarizer/statistics/post-process/file-based-count.js +0 -49
  211. package/util/summarizer/statistics/post-process/histogram.d.ts +0 -59
  212. package/util/summarizer/statistics/post-process/histogram.js +0 -128
  213. package/util/summarizer/statistics/post-process/index.d.ts +0 -4
  214. package/util/summarizer/statistics/post-process/index.js +0 -21
  215. package/util/summarizer/statistics/post-process/post-process-output.d.ts +0 -16
  216. package/util/summarizer/statistics/post-process/post-process-output.js +0 -103
  217. package/util/summarizer/statistics/second-phase/process.d.ts +0 -11
  218. package/util/summarizer/statistics/second-phase/process.js +0 -117
  219. package/util/summarizer/statistics/summarizer.d.ts +0 -35
  220. package/util/summarizer/statistics/summarizer.js +0 -135
  221. package/util/summarizer/summarizer.js +0 -13
  222. /package/{statistics/output → util}/ansi.d.ts +0 -0
  223. /package/{statistics/output → util}/ansi.js +0 -0
package/cli/repl/core.js DELETED
@@ -1,172 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.loadReplHistory = exports.repl = exports.replProcessAnswer = exports.DEFAULT_REPL_READLINE_CONFIGURATION = exports.replCompleter = void 0;
30
- /**
31
- * Basically a helper file to allow the main 'flowr' script (located in the source root) to provide its repl
32
- *
33
- * @module
34
- */
35
- const r_bridge_1 = require("../../r-bridge");
36
- const statistics_1 = require("../../statistics");
37
- const prompt_1 = require("./prompt");
38
- const commands_1 = require("./commands");
39
- const readline = __importStar(require("readline"));
40
- const args_1 = require("../../util/args");
41
- const execute_1 = require("./commands/execute");
42
- const os_1 = __importDefault(require("os"));
43
- const path_1 = __importDefault(require("path"));
44
- const fs_1 = __importDefault(require("fs"));
45
- const common_1 = require("../common");
46
- let _replCompleterKeywords = undefined;
47
- function replCompleterKeywords() {
48
- if (_replCompleterKeywords === undefined) {
49
- _replCompleterKeywords = Array.from((0, commands_1.getCommandNames)(), s => `:${s}`);
50
- }
51
- return _replCompleterKeywords;
52
- }
53
- const defaultHistoryFile = path_1.default.join(os_1.default.tmpdir(), '.flowrhistory');
54
- /**
55
- * Used by the repl to provide automatic completions for a given (partial) input line
56
- */
57
- function replCompleter(line) {
58
- const splitLine = (0, args_1.splitAtEscapeSensitive)(line);
59
- // did we just type a space (and are starting a new arg right now)?
60
- const startingNewArg = line.endsWith(' ');
61
- // if we typed a command fully already, autocomplete the arguments
62
- if (splitLine.length > 1 || startingNewArg) {
63
- const commandNameColon = replCompleterKeywords().find(k => splitLine[0] === k);
64
- if (commandNameColon) {
65
- const completions = [];
66
- const commandName = commandNameColon.slice(1);
67
- if ((0, commands_1.getCommand)(commandName)?.script === true) {
68
- // autocomplete script arguments
69
- const options = common_1.scripts[commandName].options;
70
- completions.push(...(0, common_1.getValidOptionsForCompletion)(options, splitLine).map(o => `${o} `));
71
- }
72
- else {
73
- // autocomplete command arguments (specifically, autocomplete the file:// protocol)
74
- completions.push(r_bridge_1.fileProtocol);
75
- }
76
- // add an empty option so that it doesn't autocomplete the only defined option immediately
77
- completions.push(' ');
78
- const currentArg = startingNewArg ? '' : splitLine[splitLine.length - 1];
79
- return [completions.filter(a => a.startsWith(currentArg)), currentArg];
80
- }
81
- }
82
- // if no command is already typed, just return all commands that match
83
- return [replCompleterKeywords().filter(k => k.startsWith(line)).map(k => `${k} `), line];
84
- }
85
- exports.replCompleter = replCompleter;
86
- exports.DEFAULT_REPL_READLINE_CONFIGURATION = {
87
- input: process.stdin,
88
- output: process.stdout,
89
- tabSize: 4,
90
- terminal: true,
91
- history: loadReplHistory(defaultHistoryFile),
92
- removeHistoryDuplicates: true,
93
- completer: replCompleter
94
- };
95
- async function replProcessStatement(output, statement, shell) {
96
- if (statement.startsWith(':')) {
97
- const command = statement.slice(1).split(' ')[0].toLowerCase();
98
- const processor = (0, commands_1.getCommand)(command);
99
- if (processor) {
100
- try {
101
- await processor.fn(output, shell, statement.slice(command.length + 2).trim());
102
- }
103
- catch (e) {
104
- console.log(`${(0, statistics_1.bold)(`Failed to execute command ${command}`)}: ${e?.message}. Using the ${(0, statistics_1.bold)('--verbose')} flag on startup may provide additional information.`);
105
- }
106
- }
107
- else {
108
- console.log(`the command '${command}' is unknown, try ${(0, statistics_1.bold)(':help')} for more information`);
109
- }
110
- }
111
- else {
112
- await (0, execute_1.executeRShellCommand)(output, shell, statement);
113
- }
114
- }
115
- /**
116
- * This function interprets the given `expr` as a REPL command (see {@link repl} for more on the semantics).
117
- *
118
- * @param output - Defines two methods that every function in the repl uses to output its data.
119
- * @param expr - The expression to process.
120
- * @param shell - The {@link RShell} to use (see {@link repl}).
121
- */
122
- async function replProcessAnswer(output, expr, shell) {
123
- const statements = (0, args_1.splitAtEscapeSensitive)(expr, false, ';');
124
- for (const statement of statements) {
125
- await replProcessStatement(output, statement, shell);
126
- }
127
- }
128
- exports.replProcessAnswer = replProcessAnswer;
129
- /**
130
- * Provides a never-ending repl (read-evaluate-print loop) processor that can be used to interact with a {@link RShell} as well as all flowR scripts.
131
- *
132
- * The repl allows for two kinds of inputs:
133
- * - Starting with a colon `:`, indicating a command (probe `:help`, and refer to {@link commands}) </li>
134
- * - Starting with anything else, indicating default R code to be directly executed. If you kill the underlying shell, that is on you! </li>
135
- *
136
- * @param shell - The shell to use, if you do not pass one it will automatically create a new one with the `revive` option set to 'always'
137
- * @param rl - A potentially customized readline interface to be used for the repl to *read* from the user, we write the output with the {@link ReplOutput | `output` } interface.
138
- * If you want to provide a custom one but use the same `completer`, refer to {@link replCompleter}.
139
- * For the default arguments, see {@link DEFAULT_REPL_READLINE_CONFIGURATION}.
140
- * @param output - Defines two methods that every function in the repl uses to output its data.
141
- * @param historyFile - The file to use for persisting the repl's history. Passing undefined causes history not to be saved.
142
- *
143
- * For the execution, this function makes use of {@link replProcessAnswer}
144
- *
145
- */
146
- async function repl(shell = new r_bridge_1.RShell({ revive: 'always' }), rl = readline.createInterface(exports.DEFAULT_REPL_READLINE_CONFIGURATION), output = commands_1.standardReplOutput, historyFile = defaultHistoryFile) {
147
- if (historyFile) {
148
- rl.on('history', h => fs_1.default.writeFileSync(historyFile, h.join('\n'), { encoding: 'utf-8' }));
149
- }
150
- // the incredible repl :D, we kill it with ':quit'
151
- // eslint-disable-next-line no-constant-condition,@typescript-eslint/no-unnecessary-condition
152
- while (true) {
153
- await new Promise((resolve, reject) => {
154
- rl.question((0, prompt_1.prompt)(), answer => {
155
- rl.pause();
156
- replProcessAnswer(output, answer, shell).then(() => {
157
- rl.resume();
158
- resolve();
159
- }).catch(reject);
160
- });
161
- });
162
- }
163
- }
164
- exports.repl = repl;
165
- function loadReplHistory(historyFile) {
166
- if (!fs_1.default.existsSync(historyFile)) {
167
- return undefined;
168
- }
169
- return fs_1.default.readFileSync(historyFile, { encoding: 'utf-8' }).split('\n');
170
- }
171
- exports.loadReplHistory = loadReplHistory;
172
- //# sourceMappingURL=core.js.map
@@ -1,28 +0,0 @@
1
- /// <reference types="node" />
2
- import type { Readable, Writable } from 'stream';
3
- type Stdio = [stdin: Writable | null, stdout: Readable | null, stderr: Readable | null, extra: Writable | Readable | null | undefined, extra: Writable | Readable | null | undefined];
4
- export type StdioProcessor = (stdio: Stdio) => void;
5
- /**
6
- * Simply captures the output of the script executed by {@link waitOnScript}.
7
- *
8
- * @param stdio - The standard io tuple provided by {@link waitOnScript}
9
- * @param onStdOutLine - The callback is executed each time we receive a new line from the standard output channel.
10
- * @param onStdErrLine - The callback is executed each time we receive a new line from the standard error channel.
11
- */
12
- export declare function stdioCaptureProcessor(stdio: Stdio, onStdOutLine: (msg: string) => void, onStdErrLine: (msg: string) => void): void;
13
- /**
14
- * Run the given module with the presented arguments, and wait for it to exit.
15
- *
16
- * @param module - The (flowR) module that you want to use for the fork.
17
- * It is probably best to use {@link __dirname} so you can specify the module relative to your
18
- * current one.
19
- * @param args - The arguments you want to start your process with.
20
- * @param io - If you omit this argument, the in-, out- and error-channels of the script execution
21
- * will be automatically forwarded to the respective in-, out- and error-channels of your process.
22
- * However, by defining `io` you essentially gain full control on what should happen
23
- * with these streams. For a simple capturing processor, for example if you want to collect
24
- * the output of the script, see {@link stdioCaptureProcessor}.
25
- * @param exitOnError - If set to `true`, the process will exit with the exit code of the script.
26
- */
27
- export declare function waitOnScript(module: string, args: string[], io?: StdioProcessor, exitOnError?: boolean): Promise<void>;
28
- export {};
@@ -1,79 +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
- exports.waitOnScript = exports.stdioCaptureProcessor = void 0;
7
- const log_1 = require("../../util/log");
8
- const child_process_1 = __importDefault(require("child_process"));
9
- const readline_1 = __importDefault(require("readline"));
10
- const assert_1 = require("../../util/assert");
11
- /**
12
- * Simply captures the output of the script executed by {@link waitOnScript}.
13
- *
14
- * @param stdio - The standard io tuple provided by {@link waitOnScript}
15
- * @param onStdOutLine - The callback is executed each time we receive a new line from the standard output channel.
16
- * @param onStdErrLine - The callback is executed each time we receive a new line from the standard error channel.
17
- */
18
- function stdioCaptureProcessor(stdio, onStdOutLine, onStdErrLine) {
19
- (0, assert_1.guard)(stdio[1] !== null, 'no stdout given in stdio!');
20
- const outRl = readline_1.default.createInterface({
21
- input: stdio[1],
22
- terminal: false
23
- });
24
- (0, assert_1.guard)(stdio[2] !== null, 'no stderr given in stdio!');
25
- const errRl = readline_1.default.createInterface({
26
- input: stdio[2],
27
- terminal: false
28
- });
29
- outRl.on('line', onStdOutLine);
30
- errRl.on('line', onStdErrLine);
31
- }
32
- exports.stdioCaptureProcessor = stdioCaptureProcessor;
33
- /**
34
- * Run the given module with the presented arguments, and wait for it to exit.
35
- *
36
- * @param module - The (flowR) module that you want to use for the fork.
37
- * It is probably best to use {@link __dirname} so you can specify the module relative to your
38
- * current one.
39
- * @param args - The arguments you want to start your process with.
40
- * @param io - If you omit this argument, the in-, out- and error-channels of the script execution
41
- * will be automatically forwarded to the respective in-, out- and error-channels of your process.
42
- * However, by defining `io` you essentially gain full control on what should happen
43
- * with these streams. For a simple capturing processor, for example if you want to collect
44
- * the output of the script, see {@link stdioCaptureProcessor}.
45
- * @param exitOnError - If set to `true`, the process will exit with the exit code of the script.
46
- */
47
- async function waitOnScript(module, args, io, exitOnError = false) {
48
- log_1.log.info(`starting script ${module} with args ${JSON.stringify(args)}`);
49
- const child = child_process_1.default.fork(module, args, {
50
- silent: io !== undefined
51
- });
52
- if (io !== undefined) {
53
- io(child.stdio);
54
- }
55
- child.on('exit', (code, signal) => {
56
- if (code) {
57
- console.error(`Script ${module} exited with code ${String(code)} and signal ${JSON.stringify(signal)}`);
58
- if (exitOnError) {
59
- process.exit(code);
60
- }
61
- }
62
- });
63
- child.on('error', err => {
64
- console.error(`Script ${module} signaled error ${JSON.stringify(err)}`);
65
- if (exitOnError) {
66
- process.exit(1);
67
- }
68
- });
69
- await new Promise((resolve, reject) => child.on('exit', code => {
70
- if (exitOnError && code) {
71
- reject(new Error(`Script ${module} exited with code ${String(code)}`));
72
- }
73
- else {
74
- resolve();
75
- }
76
- }));
77
- }
78
- exports.waitOnScript = waitOnScript;
79
- //# sourceMappingURL=execute.js.map
@@ -1,5 +0,0 @@
1
- export * from './server/messages/messages';
2
- export * from './core';
3
- export * from './prompt';
4
- export * from './server/messages/messages';
5
- export * from './execute';
package/cli/repl/index.js DELETED
@@ -1,22 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./server/messages/messages"), exports);
18
- __exportStar(require("./core"), exports);
19
- __exportStar(require("./prompt"), exports);
20
- __exportStar(require("./server/messages/messages"), exports);
21
- __exportStar(require("./execute"), exports);
22
- //# sourceMappingURL=index.js.map
@@ -1,2 +0,0 @@
1
- export declare const rawPrompt = "R>";
2
- export declare const prompt: () => string;
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.prompt = exports.rawPrompt = void 0;
4
- const statistics_1 = require("../../statistics");
5
- exports.rawPrompt = 'R>';
6
- // is a function as the 'formatter' is configured only after the cli options have been read
7
- const prompt = () => `${statistics_1.formatter.format(exports.rawPrompt, { color: 6 /* Colors.Cyan */, effect: statistics_1.ColorEffect.Foreground })} `;
8
- exports.prompt = prompt;
9
- //# sourceMappingURL=prompt.js.map
@@ -1,21 +0,0 @@
1
- import type { RShell } from '../../../r-bridge';
2
- import type { Socket } from './net';
3
- /**
4
- * Each connection handles a single client, answering to its requests.
5
- * There is no need to construct this class manually, {@link FlowRServer} will do it for you.
6
- */
7
- export declare class FlowRServerConnection {
8
- private readonly socket;
9
- private readonly shell;
10
- private readonly name;
11
- private readonly logger;
12
- private readonly fileMap;
13
- constructor(socket: Socket, name: string, shell: RShell);
14
- private currentMessageBuffer;
15
- private handleData;
16
- private handleFileAnalysisRequest;
17
- private sendFileAnalysisResponse;
18
- private createSteppingSlicerForRequest;
19
- private handleSliceRequest;
20
- private handleRepl;
21
- }
@@ -1,213 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FlowRServerConnection = void 0;
4
- const core_1 = require("../../../core");
5
- const send_1 = require("./send");
6
- const validate_1 = require("./validate");
7
- const analysis_1 = require("./messages/analysis");
8
- const slice_1 = require("./messages/slice");
9
- const server_1 = require("./server");
10
- const repl_1 = require("./messages/repl");
11
- const core_2 = require("../core");
12
- const statistics_1 = require("../../../statistics");
13
- const cfg_1 = require("../../../util/cfg/cfg");
14
- const quads_1 = require("../../../util/quads");
15
- /**
16
- * Each connection handles a single client, answering to its requests.
17
- * There is no need to construct this class manually, {@link FlowRServer} will do it for you.
18
- */
19
- class FlowRServerConnection {
20
- socket;
21
- shell;
22
- name;
23
- logger;
24
- // maps token to information
25
- fileMap = new Map();
26
- // we do not have to ensure synchronized shell-access as we are always running synchronized
27
- constructor(socket, name, shell) {
28
- this.socket = socket;
29
- this.shell = shell;
30
- this.name = name;
31
- this.logger = server_1.serverLog.getSubLogger({ name });
32
- this.socket.on('data', data => this.handleData(String(data)));
33
- this.socket.on('error', e => this.logger.error(`[${this.name}] Error while handling connection: ${String(e)}`));
34
- }
35
- currentMessageBuffer = '';
36
- handleData(message) {
37
- if (!message.endsWith('\n')) {
38
- this.currentMessageBuffer += message;
39
- this.logger.trace(`[${this.name}] Received partial message. Buffering ${this.currentMessageBuffer.length}.`);
40
- return;
41
- }
42
- message = this.currentMessageBuffer + message;
43
- if (this.logger.settings.minLevel >= 2 /* LogLevel.Debug */) {
44
- this.logger.debug(`[${this.name}] Received message: ${message}`);
45
- }
46
- this.currentMessageBuffer = '';
47
- const request = (0, validate_1.validateBaseMessageFormat)(message);
48
- if (request.type === 'error') {
49
- (0, validate_1.answerForValidationError)(this.socket, request);
50
- return;
51
- }
52
- switch (request.message.type) {
53
- case 'request-file-analysis':
54
- this.handleFileAnalysisRequest(request.message);
55
- break;
56
- case 'request-slice':
57
- this.handleSliceRequest(request.message);
58
- break;
59
- case 'request-repl-execution':
60
- this.handleRepl(request.message);
61
- break;
62
- default:
63
- (0, send_1.sendMessage)(this.socket, {
64
- id: request.message.id,
65
- type: 'error',
66
- fatal: true,
67
- reason: `The message type ${JSON.stringify(request.message.type ?? 'undefined')} is not supported.`
68
- });
69
- this.socket.end();
70
- }
71
- }
72
- handleFileAnalysisRequest(base) {
73
- const requestResult = (0, validate_1.validateMessage)(base, analysis_1.requestAnalysisMessage);
74
- if (requestResult.type === 'error') {
75
- (0, validate_1.answerForValidationError)(this.socket, requestResult, base.id);
76
- return;
77
- }
78
- const message = requestResult.message;
79
- this.logger.info(`[${this.name}] Received file analysis request for ${message.filename ?? 'unknown file'}${message.filetoken ? ' with token: ' + message.filetoken : ''}`);
80
- if (message.filetoken && this.fileMap.has(message.filetoken)) {
81
- this.logger.warn(`File token ${message.filetoken} already exists. Overwriting.`);
82
- }
83
- const slicer = this.createSteppingSlicerForRequest(message);
84
- void slicer.allRemainingSteps(false).then(async (results) => await this.sendFileAnalysisResponse(results, message))
85
- .catch(e => {
86
- this.logger.error(`[${this.name}] Error while analyzing file ${message.filename ?? 'unknown file'}: ${String(e)}`);
87
- (0, send_1.sendMessage)(this.socket, {
88
- id: message.id,
89
- type: 'error',
90
- fatal: false,
91
- reason: `Error while analyzing file ${message.filename ?? 'unknown file'}: ${String(e)}`
92
- });
93
- });
94
- }
95
- async sendFileAnalysisResponse(results, message) {
96
- let cfg = undefined;
97
- if (message.cfg) {
98
- cfg = (0, cfg_1.extractCFG)(results.normalize);
99
- }
100
- const config = () => ({ context: message.filename ?? 'unknown', getId: (0, quads_1.defaultQuadIdGenerator)() });
101
- if (message.format === 'n-quads') {
102
- (0, send_1.sendMessage)(this.socket, {
103
- type: 'response-file-analysis',
104
- format: 'n-quads',
105
- id: message.id,
106
- cfg: cfg ? (0, cfg_1.cfg2quads)(cfg, config()) : undefined,
107
- results: {
108
- parse: await (0, core_1.printStepResult)('parse', results.parse, 5 /* StepOutputFormat.RdfQuads */, config()),
109
- normalize: await (0, core_1.printStepResult)('normalize', results.normalize, 5 /* StepOutputFormat.RdfQuads */, config()),
110
- dataflow: await (0, core_1.printStepResult)('dataflow', results.dataflow, 5 /* StepOutputFormat.RdfQuads */, config())
111
- }
112
- });
113
- }
114
- else {
115
- (0, send_1.sendMessage)(this.socket, {
116
- type: 'response-file-analysis',
117
- format: 'json',
118
- id: message.id,
119
- cfg,
120
- results: {
121
- ...results,
122
- normalize: {
123
- ...results.normalize,
124
- idMap: undefined
125
- }
126
- }
127
- });
128
- }
129
- }
130
- createSteppingSlicerForRequest(message) {
131
- const slicer = new core_1.SteppingSlicer({
132
- stepOfInterest: core_1.LAST_STEP,
133
- shell: this.shell,
134
- // we have to make sure, that the content is not interpreted as a file path if it starts with 'file://' therefore, we do it manually
135
- request: {
136
- request: message.content === undefined ? 'file' : 'text',
137
- content: message.content ?? message.filepath
138
- },
139
- criterion: [] // currently unknown
140
- });
141
- if (message.filetoken) {
142
- this.logger.info(`Storing file token ${message.filetoken}`);
143
- this.fileMap.set(message.filetoken, {
144
- filename: message.filename,
145
- slicer
146
- });
147
- }
148
- return slicer;
149
- }
150
- handleSliceRequest(base) {
151
- const requestResult = (0, validate_1.validateMessage)(base, slice_1.requestSliceMessage);
152
- if (requestResult.type === 'error') {
153
- (0, validate_1.answerForValidationError)(this.socket, requestResult, base.id);
154
- return;
155
- }
156
- const request = requestResult.message;
157
- this.logger.info(`[${request.filetoken}] Received slice request with criteria ${JSON.stringify(request.criterion)}`);
158
- const fileInformation = this.fileMap.get(request.filetoken);
159
- if (!fileInformation) {
160
- (0, send_1.sendMessage)(this.socket, {
161
- id: request.id,
162
- type: 'error',
163
- fatal: false,
164
- reason: `The file token ${request.filetoken} has never been analyzed.`
165
- });
166
- return;
167
- }
168
- fileInformation.slicer.updateCriterion(request.criterion);
169
- void fileInformation.slicer.allRemainingSteps(true).then(results => {
170
- (0, send_1.sendMessage)(this.socket, {
171
- type: 'response-slice',
172
- id: request.id,
173
- results: Object.fromEntries(Object.entries(results).filter(([k,]) => Object.hasOwn(core_1.STEPS_PER_SLICE, k)))
174
- });
175
- }).catch(e => {
176
- this.logger.error(`[${this.name}] Error while analyzing file for token ${request.filetoken}: ${String(e)}`);
177
- (0, send_1.sendMessage)(this.socket, {
178
- id: request.id,
179
- type: 'error',
180
- fatal: false,
181
- reason: `Error while analyzing file for token ${request.filetoken}: ${String(e)}`
182
- });
183
- });
184
- }
185
- handleRepl(base) {
186
- const requestResult = (0, validate_1.validateMessage)(base, repl_1.requestExecuteReplExpressionMessage);
187
- if (requestResult.type === 'error') {
188
- (0, validate_1.answerForValidationError)(this.socket, requestResult, base.id);
189
- return;
190
- }
191
- const request = requestResult.message;
192
- const out = (stream, msg) => {
193
- (0, send_1.sendMessage)(this.socket, {
194
- type: 'response-repl-execution',
195
- id: request.id,
196
- result: msg,
197
- stream
198
- });
199
- };
200
- void (0, core_2.replProcessAnswer)({
201
- formatter: request.ansi ? statistics_1.ansiFormatter : statistics_1.voidFormatter,
202
- stdout: msg => out('stdout', msg),
203
- stderr: msg => out('stderr', msg)
204
- }, request.expression, this.shell).then(() => {
205
- (0, send_1.sendMessage)(this.socket, {
206
- type: 'end-repl-execution',
207
- id: request.id
208
- });
209
- });
210
- }
211
- }
212
- exports.FlowRServerConnection = FlowRServerConnection;
213
- //# sourceMappingURL=connection.js.map
@@ -1,71 +0,0 @@
1
- import type { IdMessageBase, MessageDefinition } from './messages';
2
- import type { LAST_PER_FILE_STEP, StepResults } from '../../../../core';
3
- import type { ControlFlowInformation } from '../../../../util/cfg/cfg';
4
- /**
5
- * Send by the client to request an analysis of a given file.
6
- * Answered by either an {@link FlowrErrorMessage} or a {@link FileAnalysisResponseMessageJson}.
7
- */
8
- export interface FileAnalysisRequestMessage extends IdMessageBase {
9
- type: 'request-file-analysis';
10
- /**
11
- * This is a unique token that you assign to subsequently slice the respective files.
12
- * If you pass the same token multiple times, previous results will be overwritten.
13
- *
14
- * If you do not pass a file token, the server will _not_ store the results!
15
- */
16
- filetoken?: string;
17
- /**
18
- * A human-readable file name. If you present a `filepath` or read from a file this should be straightforward.
19
- * However, the name is only for debugging and bears no semantic meaning.
20
- */
21
- filename?: string;
22
- /** The contents of the file, or an R expression itself (like `1 + 1`), give either this or the `filepath`. */
23
- content?: string;
24
- /** The filepath on the local machine, accessible to flowR, or simply. Give either this or the `content` */
25
- filepath?: string;
26
- /** Can be used to additionally extract the {@link ControlFlowInformation} of the file, which is not exposed (and not fully calculated) by default. */
27
- cfg?: boolean;
28
- /** Controls the serialization of the `results` (and the {@link ControlFlowGraph} if the corresponding flag is set). If missing, we assume _json_. */
29
- format?: 'json' | 'n-quads';
30
- }
31
- export declare const requestAnalysisMessage: MessageDefinition<FileAnalysisRequestMessage>;
32
- /**
33
- * Answer for a successful {@link FileAnalysisRequestMessage}.
34
- * It contains the results of the analysis in JSON format (guided by {@link FileAnalysisRequestMessage#format}).
35
- *
36
- * The `idMap` of the normalization step (see {@link NormalizedAst}) is not serialized as it would essentially
37
- * repeat the complete normalized AST.
38
- *
39
- * @note The serialization of maps and sets is controlled by the {@link jsonReplacer} as part of {@link sendMessage}.
40
- *
41
- * @see FileAnalysisResponseMessageNQuads
42
- */
43
- export interface FileAnalysisResponseMessageJson extends IdMessageBase {
44
- type: 'response-file-analysis';
45
- format: 'json';
46
- /**
47
- * See the {@link SteppingSlicer} and {@link StepResults} for details on the results.
48
- */
49
- results: StepResults<typeof LAST_PER_FILE_STEP>;
50
- /**
51
- * Only if the {@link FileAnalysisRequestMessage} contained a `cfg: true` this will contain the {@link ControlFlowInformation} of the file.
52
- */
53
- cfg?: ControlFlowInformation;
54
- }
55
- /**
56
- * Similar to {@link FileAnalysisResponseMessageJson} but using n-quads as serialization format.
57
- */
58
- export interface FileAnalysisResponseMessageNQuads extends IdMessageBase {
59
- type: 'response-file-analysis';
60
- format: 'n-quads';
61
- /**
62
- * @see FileAnalysisResponseMessageJson#results
63
- */
64
- results: {
65
- [K in keyof StepResults<typeof LAST_PER_FILE_STEP>]: string;
66
- };
67
- /**
68
- * @see FileAnalysisResponseMessageJson#cfg
69
- */
70
- cfg?: string;
71
- }
@@ -1,21 +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
- exports.requestAnalysisMessage = void 0;
7
- const joi_1 = __importDefault(require("joi"));
8
- exports.requestAnalysisMessage = {
9
- type: 'request-file-analysis',
10
- schema: joi_1.default.object({
11
- type: joi_1.default.string().valid('request-file-analysis').required(),
12
- id: joi_1.default.string().optional(),
13
- filetoken: joi_1.default.string().optional(),
14
- filename: joi_1.default.string().optional(),
15
- content: joi_1.default.string().optional(),
16
- filepath: joi_1.default.string().optional(),
17
- cfg: joi_1.default.boolean().optional(),
18
- format: joi_1.default.string().valid('json', 'n-quads').optional()
19
- }).xor('content', 'filepath')
20
- };
21
- //# sourceMappingURL=analysis.js.map
@@ -1,11 +0,0 @@
1
- import type { IdMessageBase } from './messages';
2
- /**
3
- * Sent in case of any error (e.g., if the analysis fails, or the message contains syntax errors).
4
- */
5
- export interface FlowrErrorMessage extends IdMessageBase {
6
- type: 'error';
7
- /** if fatal, the connection will be partially closed afterward */
8
- fatal: boolean;
9
- /** the human-readable reason for the error */
10
- reason: string;
11
- }