@eagleoutice/flowr 2.13.6 → 2.13.7

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 CHANGED
@@ -43,7 +43,7 @@ It offers a wide variety of features, for example:
43
43
 
44
44
  ```shell
45
45
  $ docker run -it --rm eagleoutice/flowr # or npm run flowr
46
- flowR repl v2.13.5, R grammar v14 (tree-sitter engine)
46
+ flowR repl v2.13.6, R grammar v14 (tree-sitter engine)
47
47
  R> :query @linter "read.csv(\"/root/x.txt\")"
48
48
  ```
49
49
 
@@ -52,17 +52,17 @@ It offers a wide variety of features, for example:
52
52
 
53
53
 
54
54
  ```text
55
- Query: linter (22 ms)
55
+ Query: linter (10 ms)
56
56
  ╰ Deprecated Functions (deprecated-functions): no findings
57
57
  ╰ File Path Validity (file-path-validity):
58
58
  ╰ certain:
59
59
  ╰ Path `/root/x.txt` at 1.1-23
60
- ╰ Metadata: totalReads: 1, totalUnknown: 0, totalWritesBeforeAlways: 0, totalValid: 0, searchTimeMs: 1, processTimeMs: 1
60
+ ╰ Metadata: totalReads: 1, totalUnknown: 0, totalWritesBeforeAlways: 0, totalValid: 0, searchTimeMs: 0, processTimeMs: 1
61
61
  ╰ Seeded Randomness (seeded-randomness): no findings
62
62
  ╰ Absolute Paths (absolute-file-paths):
63
63
  ╰ certain:
64
64
  ╰ Path `/root/x.txt` at 1.1-23
65
- ╰ Metadata: totalConsidered: 1, totalUnknown: 0, searchTimeMs: 1, processTimeMs: 0
65
+ ╰ Metadata: totalConsidered: 1, totalUnknown: 0, searchTimeMs: 0, processTimeMs: 0
66
66
  ╰ Unused Definitions (unused-definitions): no findings
67
67
  ╰ Network Functions (network-functions): no findings
68
68
  ╰ Dataframe Access Validation (dataframe-access-validation): no findings
@@ -73,7 +73,7 @@ It offers a wide variety of features, for example:
73
73
  ╰ Roxygen Arguments (roxygen-arguments): no findings
74
74
  ╰ No Leaked Credentials (no-leaked-credentials): no findings
75
75
  ╰ Undefined Symbol (undefined-symbol): no findings
76
- All queries together required ≈22 ms (1ms accuracy, total 22 ms)
76
+ All queries together required ≈10 ms (1ms accuracy, total 10 ms)
77
77
  ```
78
78
 
79
79
 
@@ -95,7 +95,7 @@ It offers a wide variety of features, for example:
95
95
 
96
96
  _Results (prettified and summarized):_
97
97
 
98
- Query: **linter** (19 ms)\
98
+ Query: **linter** (14 ms)\
99
99
     ╰ **Deprecated Functions** (deprecated-functions): _no findings_\
100
100
     ╰ **File Path Validity** (file-path-validity):\
101
101
         ╰ certain:\
@@ -105,7 +105,7 @@ It offers a wide variety of features, for example:
105
105
     ╰ **Absolute Paths** (absolute-file-paths):\
106
106
         ╰ certain:\
107
107
             ╰ Path `/root/x.txt` at 1.1-23\
108
-        ╰ _Metadata_: totalConsidered: 1, totalUnknown: 0, searchTimeMs: 1, processTimeMs: 0\
108
+        ╰ _Metadata_: totalConsidered: 1, totalUnknown: 0, searchTimeMs: 0, processTimeMs: 0\
109
109
     ╰ **Unused Definitions** (unused-definitions): _no findings_\
110
110
     ╰ **Network Functions** (network-functions): _no findings_\
111
111
     ╰ **Dataframe Access Validation** (dataframe-access-validation): _no findings_\
@@ -116,11 +116,11 @@ It offers a wide variety of features, for example:
116
116
     ╰ **Roxygen Arguments** (roxygen-arguments): _no findings_\
117
117
     ╰ **No Leaked Credentials** (no-leaked-credentials): _no findings_\
118
118
     ╰ **Undefined Symbol** (undefined-symbol): _no findings_\
119
- _All queries together required ≈19 ms (1ms accuracy, total 21 ms)_
119
+ _All queries together required ≈14 ms (1ms accuracy, total 15 ms)_
120
120
 
121
121
  <details> <summary style="color:gray">Show Detailed Results as Json</summary>
122
122
 
123
- The analysis required _20.5 ms_ (including parsing and normalization and the query) within the generation environment.
123
+ The analysis required _15.0 ms_ (including parsing and normalization and the query) within the generation environment.
124
124
 
125
125
  In general, the JSON contains the Ids of the nodes in question as they are present in the normalized AST or the dataflow graph of flowR.
126
126
  Please consult the [Interface](https://github.com/flowr-analysis/flowr/wiki/Interface) wiki page for more information on how to get those.
@@ -137,8 +137,8 @@ It offers a wide variety of features, for example:
137
137
  ".meta": {
138
138
  "totalCalls": 0,
139
139
  "totalFunctionDefinitions": 0,
140
- "searchTimeMs": 3,
141
- "processTimeMs": 5
140
+ "searchTimeMs": 4,
141
+ "processTimeMs": 3
142
142
  }
143
143
  },
144
144
  "file-path-validity": {
@@ -172,8 +172,8 @@ It offers a wide variety of features, for example:
172
172
  "callsWithAssignmentProducers": 0,
173
173
  "callsWithNonConstantProducers": 0,
174
174
  "callsWithOtherBranchProducers": 0,
175
- "searchTimeMs": 2,
176
- "processTimeMs": 0
175
+ "searchTimeMs": 0,
176
+ "processTimeMs": 1
177
177
  }
178
178
  },
179
179
  "absolute-file-paths": {
@@ -192,7 +192,7 @@ It offers a wide variety of features, for example:
192
192
  ".meta": {
193
193
  "totalConsidered": 1,
194
194
  "totalUnknown": 0,
195
- "searchTimeMs": 1,
195
+ "searchTimeMs": 0,
196
196
  "processTimeMs": 0
197
197
  }
198
198
  },
@@ -226,7 +226,7 @@ It offers a wide variety of features, for example:
226
226
  "dead-code": {
227
227
  "results": [],
228
228
  ".meta": {
229
- "searchTimeMs": 1,
229
+ "searchTimeMs": 0,
230
230
  "processTimeMs": 0
231
231
  }
232
232
  },
@@ -256,7 +256,7 @@ It offers a wide variety of features, for example:
256
256
  "roxygen-arguments": {
257
257
  "results": [],
258
258
  ".meta": {
259
- "searchTimeMs": 0,
259
+ "searchTimeMs": 1,
260
260
  "processTimeMs": 0
261
261
  }
262
262
  },
@@ -281,16 +281,16 @@ It offers a wide variety of features, for example:
281
281
  "subscript": 0
282
282
  },
283
283
  "searchTimeMs": 0,
284
- "processTimeMs": 3
284
+ "processTimeMs": 1
285
285
  }
286
286
  }
287
287
  },
288
288
  ".meta": {
289
- "timing": 19
289
+ "timing": 14
290
290
  }
291
291
  },
292
292
  ".meta": {
293
- "timing": 19
293
+ "timing": 14
294
294
  }
295
295
  }
296
296
  ```
@@ -354,7 +354,7 @@ It offers a wide variety of features, for example:
354
354
 
355
355
  ```shell
356
356
  $ docker run -it --rm eagleoutice/flowr # or npm run flowr
357
- flowR repl v2.13.5, R grammar v14 (tree-sitter engine)
357
+ flowR repl v2.13.6, R grammar v14 (tree-sitter engine)
358
358
  R> :query @static-slice (11@sum) file://test/testfiles/example.R
359
359
  ```
360
360
 
@@ -368,7 +368,7 @@ It offers a wide variety of features, for example:
368
368
  N <- 10
369
369
  for(i in 1:(N-1)) sum <- sum + i + w
370
370
  sum
371
- All queries together required ≈7 ms (1ms accuracy, total 8 ms)
371
+ All queries together required ≈5 ms (1ms accuracy, total 6 ms)
372
372
  ```
373
373
 
374
374
 
@@ -383,7 +383,7 @@ It offers a wide variety of features, for example:
383
383
  </details>
384
384
 
385
385
  * 🚀 **fast call-graph, data-, and control-flow graphs**\
386
- Within just [<i><span title="This measurement is automatically fetched from the latest benchmark!">105.1 ms</span></i> (as of Jul 29, 2026)](https://flowr-analysis.github.io/flowr/wiki/stats/benchmark),
386
+ Within just [<i><span title="This measurement is automatically fetched from the latest benchmark!">100.6 ms</span></i> (as of Jul 31, 2026)](https://flowr-analysis.github.io/flowr/wiki/stats/benchmark),
387
387
  _flowR_ can analyze the data- and control-flow of the average real-world R&nbsp;script. See the [benchmarks](https://flowr-analysis.github.io/flowr/wiki/stats/benchmark) for more information,
388
388
  and consult the [wiki pages](https://github.com/flowr-analysis/flowr/wiki/dataflow-graph) for more details on the [dataflow graphs](https://github.com/flowr-analysis/flowr/wiki/dataflow-graph) as well as [call graphs](https://github.com/flowr-analysis/flowr/wiki/dataflow-graph#perspectives-cg).
389
389
 
@@ -419,7 +419,7 @@ It offers a wide variety of features, for example:
419
419
 
420
420
  ```shell
421
421
  $ docker run -it --rm eagleoutice/flowr # or npm run flowr
422
- flowR repl v2.13.5, R grammar v14 (tree-sitter engine)
422
+ flowR repl v2.13.6, R grammar v14 (tree-sitter engine)
423
423
  R> :dataflow* test/testfiles/example.R
424
424
  ```
425
425
 
@@ -692,7 +692,7 @@ It offers a wide variety of features, for example:
692
692
  ```
693
693
 
694
694
 
695
- (The analysis required _3.5 ms_ (including parse and normalize, using the [tree-sitter](https://github.com/flowr-analysis/flowr/wiki/Engines) engine) within the generation environment. No [signature database](https://github.com/flowr-analysis/flowr/wiki/Signature-Database) is mounted for these generated graphs, so `library()` calls attach no package exports; base-R names are still qualified via the generated base-package store (e.g. `acf` as `stats::acf`).)
695
+ (The analysis required _3.0 ms_ (including parse and normalize, using the [tree-sitter](https://github.com/flowr-analysis/flowr/wiki/Engines) engine) within the generation environment. No [signature database](https://github.com/flowr-analysis/flowr/wiki/Signature-Database) is mounted for these generated graphs, so `library()` calls attach no package exports; base-R names are still qualified via the generated base-package store (e.g. `acf` as `stats::acf`).)
696
696
 
697
697
 
698
698
 
package/config.d.ts CHANGED
@@ -193,7 +193,7 @@ export interface FlowrConfig extends MergeableRecord {
193
193
  shinyEntryFiles?: string[];
194
194
  /** Regex source evidencing shiny usage in an entry file. */
195
195
  shinyUsagePattern?: string;
196
- /** File extensions marking a notebook (default `ipynb`, `rmd`, `qmd`, `rnw`). */
196
+ /** File extensions marking a notebook (default `ipynb`, `rmd`, `rmarkdown`, `qmd`, `rnw`). */
197
197
  notebookExtensions?: string[];
198
198
  };
199
199
  };
package/config.js CHANGED
@@ -109,6 +109,7 @@ exports.FlowrDefaultPlugins = [
109
109
  'loading-order:description',
110
110
  'loading-order:implicit-sources',
111
111
  'loading-order:rprofile',
112
+ 'loading-order:included-files',
112
113
  'meta:description',
113
114
  'meta:rproject',
114
115
  'meta:uvr',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eagleoutice/flowr",
3
- "version": "2.13.6",
3
+ "version": "2.13.7",
4
4
  "description": "Static Dataflow Analyzer and Program Slicer for the R Programming Language",
5
5
  "types": "dist/src/index.d.ts",
6
6
  "repository": {
@@ -11,7 +11,7 @@ const shinyEntryFiles = new Set(['app.r', 'ui.r', 'server.r', 'global.r']);
11
11
  /** default evidence that a file is part of a shiny app (a load of the shiny stack or a call to one of its entry points) */
12
12
  const shinyUsage = /(?:library|require|requireNamespace|loadNamespace)\s*\(\s*['"]?(?:shiny|bslib|shinydashboard|shinyMobile|golem|flexdashboard)\b|\b(?:shinyApp|shinyServer|shinyUI|runApp|fluidPage|fluidRow|navbarPage|bootstrapPage|fillPage|dashboardPage|page_fluid|page_sidebar|page_navbar|pageWithSidebar)\s*\(/;
13
13
  /** default extensions marking a notebook / literate document */
14
- const notebookExtension = /\.(ipynb|rmd|qmd|rnw)$/;
14
+ const notebookExtension = /\.(ipynb|rmd|rmarkdown|qmd|rnw)$/;
15
15
  /** Resolve {@link ClassificationConfig} into {@link ResolvedClassifyOptions}, using the built-in defaults for unset fields. */
16
16
  function resolveClassifyOptions(cfg) {
17
17
  return {
@@ -75,6 +75,12 @@ export declare class FlowrAnalyzerLoadingOrderContext extends AbstractFlowrAnaly
75
75
  * existing orders instead of competing with them like {@link addGuess} would.
76
76
  */
77
77
  prependToOrder(requests: readonly RParseRequest[]): void;
78
+ /**
79
+ * Drop `requests` from every order known so far. Use this for files another file already
80
+ * contains (e.g. the target of an Rmd `child` chunk), as it refines the existing orders instead
81
+ * of competing with them like {@link addGuess} would.
82
+ */
83
+ removeFromOrder(requests: readonly RParseRequest[]): void;
78
84
  currentGuesses(): readonly (readonly RParseRequest[])[];
79
85
  currentKnownOrder(): readonly RParseRequest[] | undefined;
80
86
  peekLoadingOrder(): readonly RParseRequest[] | undefined;
@@ -96,6 +96,27 @@ class FlowrAnalyzerLoadingOrderContext extends abstract_flowr_analyzer_context_1
96
96
  this.addGuess(front(this.unordered));
97
97
  }
98
98
  }
99
+ /**
100
+ * Drop `requests` from every order known so far. Use this for files another file already
101
+ * contains (e.g. the target of an Rmd `child` chunk), as it refines the existing orders instead
102
+ * of competing with them like {@link addGuess} would.
103
+ */
104
+ removeFromOrder(requests) {
105
+ if (requests.length === 0) {
106
+ return;
107
+ }
108
+ const drop = new Set(requests);
109
+ const without = (order) => order.filter(r => !drop.has(r));
110
+ if (this.knownOrder) {
111
+ this.knownOrder = without(this.knownOrder);
112
+ }
113
+ for (let i = 0; i < this.guesses.length; i++) {
114
+ this.guesses[i] = without(this.guesses[i]);
115
+ }
116
+ if (!this.knownOrder && this.guesses.length === 0) {
117
+ this.addGuess(without(this.unordered));
118
+ }
119
+ }
99
120
  currentGuesses() {
100
121
  return this.guesses;
101
122
  }
@@ -11,6 +11,7 @@ export declare class FlowrRMarkdownFile extends FlowrFile {
11
11
  private mergedCode?;
12
12
  private readonly wrapped;
13
13
  private readonly context;
14
+ private readonly included;
14
15
  /**
15
16
  * Prefer the static {@link FlowrRMarkdownFile.from} method
16
17
  * @param file - the file to load as R Markdown
@@ -30,6 +31,8 @@ export declare class FlowrRMarkdownFile extends FlowrFile {
30
31
  * Postprocess blocks with options like child='other.Rmd'
31
32
  */
32
33
  private postProcessCodeBlocks;
34
+ /** The paths this document splices into itself, only known once the content is loaded */
35
+ get includedFiles(): readonly string[];
33
36
  static from(file: FlowrFileProvider<string> | FlowrRMarkdownFile, ctx: FlowrAnalyzerContext): FlowrRMarkdownFile;
34
37
  }
35
38
  export type CodeBlockOptions = Map<string, string>;
@@ -46,6 +49,18 @@ export interface RmdInfo {
46
49
  blocks: CodeBlock[];
47
50
  options: object;
48
51
  }
52
+ /**
53
+ * Checks whether a code block is evaluated when the document is knitted (i.e. not `eval=FALSE`),
54
+ * falling back to the document-wide default of {@link globalChunkOptions} if the chunk says nothing
55
+ */
56
+ export declare function isExecutableCell(block: CodeBlock, defaults: CodeBlockOptions): boolean;
57
+ /** Checks whether knitr keeps going when the chunk raises an error (i.e. `error=TRUE`) */
58
+ export declare function continuesAfterError(block: CodeBlock, defaults: CodeBlockOptions): boolean;
59
+ /**
60
+ * The chunk option defaults of the document, which quarto collects under `execute:` in the
61
+ * frontmatter and rmarkdown under `knitr: opts_chunk:`
62
+ */
63
+ export declare function globalChunkOptions(frontmatter: object): CodeBlockOptions;
49
64
  /**
50
65
  * Parse the contents of a RMarkdown file into complete code and blocks
51
66
  * @param raw - the raw file content
@@ -4,6 +4,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.FlowrRMarkdownFile = void 0;
7
+ exports.isExecutableCell = isExecutableCell;
8
+ exports.continuesAfterError = continuesAfterError;
9
+ exports.globalChunkOptions = globalChunkOptions;
7
10
  exports.parseRMarkdownFile = parseRMarkdownFile;
8
11
  exports.isRCodeBlock = isRCodeBlock;
9
12
  exports.restoreBlocksWithoutMd = restoreBlocksWithoutMd;
@@ -23,6 +26,7 @@ class FlowrRMarkdownFile extends flowr_file_1.FlowrFile {
23
26
  mergedCode;
24
27
  wrapped;
25
28
  context;
29
+ included = [];
26
30
  /**
27
31
  * Prefer the static {@link FlowrRMarkdownFile.from} method
28
32
  * @param file - the file to load as R Markdown
@@ -43,10 +47,8 @@ class FlowrRMarkdownFile extends flowr_file_1.FlowrFile {
43
47
  return this.data;
44
48
  }
45
49
  get executableCells() {
46
- return this.rmd.blocks.filter(b => {
47
- const opt = b.options.get('eval');
48
- return opt !== 'F' && opt !== 'FALSE';
49
- });
50
+ const defaults = globalChunkOptions(this.rmd.options);
51
+ return this.rmd.blocks.filter(b => isExecutableCell(b, defaults));
50
52
  }
51
53
  /**
52
54
  * Loads and parses the content of the wrapped file.
@@ -56,7 +58,8 @@ class FlowrRMarkdownFile extends flowr_file_1.FlowrFile {
56
58
  const raw = this.wrapped.content();
57
59
  this.data = parseRMarkdownFile(raw);
58
60
  this.postProcessCodeBlocks();
59
- this.mergedCode = restoreBlocksWithoutMd(this.data.blocks, countNewlines(raw));
61
+ const defaults = globalChunkOptions(this.data.options);
62
+ this.mergedCode = restoreBlocksWithoutMd(this.executableCells.map(b => continuesAfterError(b, defaults) ? { ...b, code: wrapErrorTolerant(b.code) } : b), countNewlines(raw));
60
63
  (0, assert_1.guard)(this.mergedCode !== undefined);
61
64
  return this.mergedCode;
62
65
  }
@@ -80,12 +83,11 @@ class FlowrRMarkdownFile extends flowr_file_1.FlowrFile {
80
83
  if (childPath.length > 1) {
81
84
  log_1.log.warn(`Found more than one path for child '${childOpt}' in rmd file '${this.path()}'. Only using the first path: '${childPath[0]}'`);
82
85
  }
83
- this.context.files.resolveRequest({
84
- request: 'file',
85
- content: childPath[0]
86
- });
87
- const rawChildFile = this.context.files.getFileByPath(childPath[0]);
86
+ // register but do not request, the content is spliced in here
87
+ const rawChildFile = (this.context.files.getFileByPath(childPath[0])
88
+ ?? this.context.files.addFile(childPath[0]));
88
89
  if (rawChildFile !== undefined) {
90
+ this.included.push(childPath[0]);
89
91
  block.code = FlowrRMarkdownFile.from(rawChildFile, this.context).content().toString();
90
92
  }
91
93
  else {
@@ -93,11 +95,55 @@ class FlowrRMarkdownFile extends flowr_file_1.FlowrFile {
93
95
  }
94
96
  }
95
97
  }
98
+ /** The paths this document splices into itself, only known once the content is loaded */
99
+ get includedFiles() {
100
+ (0, assert_1.guard)(this.rmd !== undefined);
101
+ return this.included;
102
+ }
96
103
  static from(file, ctx) {
97
104
  return file instanceof FlowrRMarkdownFile ? file : new FlowrRMarkdownFile(file, ctx);
98
105
  }
99
106
  }
100
107
  exports.FlowrRMarkdownFile = FlowrRMarkdownFile;
108
+ /* knitr accepts R literals (`FALSE`, `F`), quarto yaml options accept `false` */
109
+ const NonExecutableEvalValues = new Set(['F', 'FALSE', 'false', 'False']);
110
+ /**
111
+ * Checks whether a code block is evaluated when the document is knitted (i.e. not `eval=FALSE`),
112
+ * falling back to the document-wide default of {@link globalChunkOptions} if the chunk says nothing
113
+ */
114
+ function isExecutableCell(block, defaults) {
115
+ const opt = block.options.get('eval') ?? defaults.get('eval');
116
+ return opt === undefined || !NonExecutableEvalValues.has(opt);
117
+ }
118
+ const ErrorTolerantValues = new Set(['T', 'TRUE', 'true', 'True']);
119
+ /** Checks whether knitr keeps going when the chunk raises an error (i.e. `error=TRUE`) */
120
+ function continuesAfterError(block, defaults) {
121
+ const opt = block.options.get('error') ?? defaults.get('error');
122
+ return opt !== undefined && ErrorTolerantValues.has(opt);
123
+ }
124
+ /** As `error=TRUE` keeps knitting, the chunk must not cut the document short. Adds no lines, so all following positions hold. */
125
+ function wrapErrorTolerant(code) {
126
+ return `tryCatch({${code}}, error = function(e) NULL)`;
127
+ }
128
+ /**
129
+ * The chunk option defaults of the document, which quarto collects under `execute:` in the
130
+ * frontmatter and rmarkdown under `knitr: opts_chunk:`
131
+ */
132
+ function globalChunkOptions(frontmatter) {
133
+ const knitr = frontmatter.knitr;
134
+ const options = new Map();
135
+ for (const source of [frontmatter.execute, knitr?.opts_chunk]) {
136
+ if (typeof source !== 'object' || source === null) {
137
+ continue;
138
+ }
139
+ for (const [key, value] of Object.entries(source)) {
140
+ if (value !== null && typeof value !== 'object') {
141
+ options.set(key, String(value));
142
+ }
143
+ }
144
+ }
145
+ return options;
146
+ }
101
147
  /**
102
148
  * Parse the contents of a RMarkdown file into complete code and blocks
103
149
  * @param raw - the raw file content
@@ -137,11 +183,31 @@ function parseRMarkdownFile(raw) {
137
183
  startpos: { line: node.sourcepos[0][0] + 1, col: 0 }
138
184
  });
139
185
  }
186
+ blocks.push(...parseIncludeShortcodes(raw));
187
+ blocks.sort((a, b) => a.startpos.line - b.startpos.line);
140
188
  return {
141
189
  blocks: blocks,
142
190
  options: frontmatter?.data ?? {}
143
191
  };
144
192
  }
193
+ const IncludeShortcodeRegex = /{{<\s*include\s+["']?(.+?)["']?\s*>}}/;
194
+ /** Collects quarto's `{{< include other.qmd >}}` as blocks carrying a `child`, resolved like knitr's option */
195
+ function parseIncludeShortcodes(raw) {
196
+ const blocks = [];
197
+ const lines = raw.split(LineRegex);
198
+ for (let i = 0; i < lines.length; i++) {
199
+ const match = IncludeShortcodeRegex.exec(lines[i]);
200
+ if (match) {
201
+ blocks.push({
202
+ code: '',
203
+ options: new Map([['child', match[1]]]),
204
+ header: '',
205
+ startpos: { line: i + 1, col: 0 }
206
+ });
207
+ }
208
+ }
209
+ return blocks;
210
+ }
145
211
  // We need the [\s,] part, otherwise {rust} would also match
146
212
  const RTagRegex = /{[rR](?:[\s,][^}]*)?}/;
147
213
  /**
@@ -179,23 +245,54 @@ const OptionsRegex = /([\w_.-]*)\s*[:=]\s*["']?([^,"']*)/g;
179
245
  * Parses the options of an R code block from its header and content
180
246
  */
181
247
  function parseCodeBlockOptions(header, content) {
182
- let opts = header.length === 3 // '{r}' => header.length=3 (no options in header)
248
+ const headerOpts = header.length === 3 // '{r}' => header.length=3 (no options in header)
183
249
  ? ''
184
250
  : header.substring(3, header.length - 1).trim();
185
- const lines = content.split('\n');
186
- for (const line of lines) {
251
+ const cellLines = [];
252
+ for (const line of content.split('\n')) {
187
253
  if (!line.trim().startsWith('#|')) {
188
254
  break;
189
255
  }
190
- const opt = line.substring(2).trim();
191
- opts += opts.length === 0 ? opt : `, ${opt}`;
256
+ // keep the indentation, yaml block scalars rely on it
257
+ cellLines.push(line.trim().substring(2).replace(/^ /, ''));
258
+ }
259
+ const options = parseOptionString(headerOpts);
260
+ for (const [key, value] of parseCellOptions(cellLines)) {
261
+ options.set(key, value);
192
262
  }
263
+ return options;
264
+ }
265
+ /** Parses knitr's `key=value` option syntax as used in the chunk header */
266
+ function parseOptionString(opts) {
193
267
  const parsedOptions = new Map();
194
268
  for (const match of opts.matchAll(OptionsRegex)) {
195
269
  if (match[1] && match[2] !== undefined) { // key must not be empty, but value can be empty string for example
196
- parsedOptions.set(match[1], match[2]);
270
+ parsedOptions.set(match[1], match[2].trim());
197
271
  }
198
272
  }
199
273
  return parsedOptions;
200
274
  }
275
+ /** Parses the `#|` options quarto writes as yaml, falling back to knitr's `key=value` syntax */
276
+ function parseCellOptions(lines) {
277
+ if (lines.length === 0) {
278
+ return new Map();
279
+ }
280
+ try {
281
+ const parsed = (0, gray_matter_1.default)(`---\n${lines.join('\n')}\n---\n`).data;
282
+ // a bare scalar is knitr's `key=value` syntax, not yaml
283
+ if (typeof parsed === 'object' && parsed !== null && !Array.isArray(parsed) && Object.keys(parsed).length > 0) {
284
+ const options = new Map();
285
+ for (const [key, value] of Object.entries(parsed)) {
286
+ if (value !== null && typeof value !== 'object') {
287
+ options.set(key, String(value));
288
+ }
289
+ }
290
+ return options;
291
+ }
292
+ }
293
+ catch (e) {
294
+ log_1.log.warn(`Failed to parse cell options as yaml, falling back to the header syntax. Error was: ${JSON.stringify(e)}`);
295
+ }
296
+ return parseOptionString(lines.join(', '));
297
+ }
201
298
  //# sourceMappingURL=flowr-rmarkdown-file.js.map
@@ -5,7 +5,8 @@ const semver_1 = require("semver");
5
5
  const flowr_analyzer_file_plugin_1 = require("../flowr-analyzer-file-plugin");
6
6
  const flowr_rmarkdown_file_1 = require("../files/flowr-rmarkdown-file");
7
7
  const built_in_source_1 = require("../../../../dataflow/internal/process/functions/call/built-in/built-in-source");
8
- exports.RmdPattern = /\.rmd$/i;
8
+ /* `.Rmarkdown` is the knitr-only variant used by blogdown and quarto */
9
+ exports.RmdPattern = /\.(rmd|rmarkdown)$/i;
9
10
  /**
10
11
  * The plugin provides support for R Markdown (`.rmd`) files
11
12
  */
@@ -0,0 +1,15 @@
1
+ import { SemVer } from 'semver';
2
+ import { FlowrAnalyzerLoadingOrderPlugin } from './flowr-analyzer-loading-order-plugin';
3
+ import type { FlowrAnalyzerContext } from '../../context/flowr-analyzer-context';
4
+ /**
5
+ * Drops the files an R Markdown document splices into itself ({@link FlowrRMarkdownFile#includedFiles})
6
+ * from the loading order, as the including document already carries their content.
7
+ *
8
+ * This refines the orders the other loading-order plugins produced, so register it after them.
9
+ */
10
+ export declare class FlowrAnalyzerLoadingOrderIncludedFilesPlugin extends FlowrAnalyzerLoadingOrderPlugin {
11
+ readonly name = "flowr-analyzer-loading-order-included-files-plugin";
12
+ readonly description = "Drops files that another document includes from the loading order.";
13
+ readonly version: SemVer;
14
+ process(ctx: FlowrAnalyzerContext): void;
15
+ }
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FlowrAnalyzerLoadingOrderIncludedFilesPlugin = void 0;
4
+ const semver_1 = require("semver");
5
+ const flowr_analyzer_loading_order_plugin_1 = require("./flowr-analyzer-loading-order-plugin");
6
+ const flowr_rmarkdown_file_1 = require("../file-plugins/files/flowr-rmarkdown-file");
7
+ /**
8
+ * Drops the files an R Markdown document splices into itself ({@link FlowrRMarkdownFile#includedFiles})
9
+ * from the loading order, as the including document already carries their content.
10
+ *
11
+ * This refines the orders the other loading-order plugins produced, so register it after them.
12
+ */
13
+ class FlowrAnalyzerLoadingOrderIncludedFilesPlugin extends flowr_analyzer_loading_order_plugin_1.FlowrAnalyzerLoadingOrderPlugin {
14
+ name = 'flowr-analyzer-loading-order-included-files-plugin';
15
+ description = 'Drops files that another document includes from the loading order.';
16
+ version = new semver_1.SemVer('0.1.0');
17
+ process(ctx) {
18
+ const files = ctx.files.loadingOrder.getUnorderedRequests()
19
+ .filter((r) => r.request === 'file');
20
+ const included = new Set();
21
+ for (const request of files) {
22
+ const file = ctx.files.resolveFile(request.content);
23
+ if (file instanceof flowr_rmarkdown_file_1.FlowrRMarkdownFile) {
24
+ for (const path of file.includedFiles) {
25
+ included.add(path);
26
+ }
27
+ }
28
+ }
29
+ ctx.files.loadingOrder.removeFromOrder(files.filter(r => included.has(r.content)));
30
+ }
31
+ }
32
+ exports.FlowrAnalyzerLoadingOrderIncludedFilesPlugin = FlowrAnalyzerLoadingOrderIncludedFilesPlugin;
33
+ //# sourceMappingURL=flowr-analyzer-loading-order-included-files-plugin.js.map
@@ -26,10 +26,11 @@ import { FlowrAnalyzerGitignoreProjectDiscoveryPlugin, FlowrAnalyzerIgnoreFilePr
26
26
  import { FlowrAnalyzerDefaultProjectDiscoveryPlugin, FlowrAnalyzerFullProjectDiscoveryPlugin } from './project-discovery/flowr-analyzer-project-discovery-plugin';
27
27
  import { FlowrAnalyzerRprofileFilePlugin } from './file-plugins/flowr-analyzer-rprofile-file-plugin';
28
28
  import { FlowrAnalyzerLoadingOrderRprofilePlugin } from './loading-order-plugins/flowr-analyzer-loading-order-rprofile-plugin';
29
+ import { FlowrAnalyzerLoadingOrderIncludedFilesPlugin } from './loading-order-plugins/flowr-analyzer-loading-order-included-files-plugin';
29
30
  /**
30
31
  * The built-in Flowr Analyzer plugins that are always available.
31
32
  */
32
- export declare const BuiltInPlugins: [["file:description", typeof FlowrAnalyzerDescriptionFilePlugin], ["versions:description", typeof FlowrAnalyzerPackageVersionsDescriptionFilePlugin], ["versions:sigdb", typeof FlowrAnalyzerPackageVersionsSigDbPlugin], ["versions:renv", typeof FlowrAnalyzerPackageVersionsRenvPlugin], ["versions:rv", typeof FlowrAnalyzerPackageVersionsRvPlugin], ["versions:uvr", typeof FlowrAnalyzerPackageVersionsUvrPlugin], ["versions:packrat", typeof FlowrAnalyzerPackageVersionsPackratPlugin], ["versions:session-info", typeof FlowrAnalyzerPackageVersionsSessionInfoPlugin], ["loading-order:description", typeof FlowrAnalyzerLoadingOrderDescriptionFilePlugin], ["loading-order:implicit-sources", typeof FlowrAnalyzerLoadingOrderImplicitSourcesPlugin], ["loading-order:rprofile", typeof FlowrAnalyzerLoadingOrderRprofilePlugin], ["meta:description", typeof FlowrAnalyzerMetaDescriptionFilePlugin], ["meta:rproject", typeof FlowrAnalyzerMetaRProjectFilePlugin], ["meta:uvr", typeof FlowrAnalyzerMetaUvrManifestFilePlugin], ["file-roles:vignette", typeof FlowrAnalyzerMetaVignetteFilesPlugin], ["file-roles:test", typeof FlowrAnalyzerMetaTestFilesPlugin], ["file-roles:inst", typeof FlowrAnalyzerMetaInstFilesPlugin], ["file:rmd", typeof FlowrAnalyzerRmdFilePlugin], ["file:qmd", typeof FlowrAnalyzerQmdFilePlugin], ["file:rnw", typeof FlowrAnalyzerSweaveFilePlugin], ["file:ipynb", typeof FlowrAnalyzerJupyterFilePlugin], ["file:namespace", typeof FlowrAnalyzerNamespaceFilesPlugin], ["versions:namespace", typeof FlowrAnalyzerPackageVersionsNamespaceFilePlugin], ["file:news", typeof FlowrAnalyzerNewsFilePlugin], ["file:rda", typeof FlowrAnalyzerRdaFilePlugin], ["file:license", typeof FlowrAnalyzerLicenseFilePlugin], ["file:virtualenv", typeof FlowrAnalyzerVirtualEnvFilePlugin], ["file:rproject", typeof FlowrAnalyzerRProjectFilePlugin], ["file:uvr", typeof FlowrAnalyzerUvrManifestFilePlugin], ["file:rprofile", typeof FlowrAnalyzerRprofileFilePlugin], ["project-discovery:gitignore", typeof FlowrAnalyzerGitignoreProjectDiscoveryPlugin], ["project-discovery:rbuildignore", typeof FlowrAnalyzerRbuildignoreProjectDiscoveryPlugin], ["project-discovery:ignore-files", typeof FlowrAnalyzerIgnoreFileProjectDiscoveryPlugin], ["project-discovery:default", typeof FlowrAnalyzerDefaultProjectDiscoveryPlugin], ["project-discovery:full", typeof FlowrAnalyzerFullProjectDiscoveryPlugin]];
33
+ export declare const BuiltInPlugins: [["file:description", typeof FlowrAnalyzerDescriptionFilePlugin], ["versions:description", typeof FlowrAnalyzerPackageVersionsDescriptionFilePlugin], ["versions:sigdb", typeof FlowrAnalyzerPackageVersionsSigDbPlugin], ["versions:renv", typeof FlowrAnalyzerPackageVersionsRenvPlugin], ["versions:rv", typeof FlowrAnalyzerPackageVersionsRvPlugin], ["versions:uvr", typeof FlowrAnalyzerPackageVersionsUvrPlugin], ["versions:packrat", typeof FlowrAnalyzerPackageVersionsPackratPlugin], ["versions:session-info", typeof FlowrAnalyzerPackageVersionsSessionInfoPlugin], ["loading-order:description", typeof FlowrAnalyzerLoadingOrderDescriptionFilePlugin], ["loading-order:implicit-sources", typeof FlowrAnalyzerLoadingOrderImplicitSourcesPlugin], ["loading-order:rprofile", typeof FlowrAnalyzerLoadingOrderRprofilePlugin], ["loading-order:included-files", typeof FlowrAnalyzerLoadingOrderIncludedFilesPlugin], ["meta:description", typeof FlowrAnalyzerMetaDescriptionFilePlugin], ["meta:rproject", typeof FlowrAnalyzerMetaRProjectFilePlugin], ["meta:uvr", typeof FlowrAnalyzerMetaUvrManifestFilePlugin], ["file-roles:vignette", typeof FlowrAnalyzerMetaVignetteFilesPlugin], ["file-roles:test", typeof FlowrAnalyzerMetaTestFilesPlugin], ["file-roles:inst", typeof FlowrAnalyzerMetaInstFilesPlugin], ["file:rmd", typeof FlowrAnalyzerRmdFilePlugin], ["file:qmd", typeof FlowrAnalyzerQmdFilePlugin], ["file:rnw", typeof FlowrAnalyzerSweaveFilePlugin], ["file:ipynb", typeof FlowrAnalyzerJupyterFilePlugin], ["file:namespace", typeof FlowrAnalyzerNamespaceFilesPlugin], ["versions:namespace", typeof FlowrAnalyzerPackageVersionsNamespaceFilePlugin], ["file:news", typeof FlowrAnalyzerNewsFilePlugin], ["file:rda", typeof FlowrAnalyzerRdaFilePlugin], ["file:license", typeof FlowrAnalyzerLicenseFilePlugin], ["file:virtualenv", typeof FlowrAnalyzerVirtualEnvFilePlugin], ["file:rproject", typeof FlowrAnalyzerRProjectFilePlugin], ["file:uvr", typeof FlowrAnalyzerUvrManifestFilePlugin], ["file:rprofile", typeof FlowrAnalyzerRprofileFilePlugin], ["project-discovery:gitignore", typeof FlowrAnalyzerGitignoreProjectDiscoveryPlugin], ["project-discovery:rbuildignore", typeof FlowrAnalyzerRbuildignoreProjectDiscoveryPlugin], ["project-discovery:ignore-files", typeof FlowrAnalyzerIgnoreFileProjectDiscoveryPlugin], ["project-discovery:default", typeof FlowrAnalyzerDefaultProjectDiscoveryPlugin], ["project-discovery:full", typeof FlowrAnalyzerFullProjectDiscoveryPlugin]];
33
34
  export type BuiltInFlowrPluginName = typeof BuiltInPlugins[number][0];
34
35
  export type BuiltInFlowrPluginArgs<N extends BuiltInFlowrPluginName> = N extends typeof BuiltInPlugins[number][0] ? ConstructorParameters<Extract<typeof BuiltInPlugins[number], [N, PluginProducer]>[1]> : never;
35
36
  type PluginProducer = new (...args: never[]) => FlowrAnalyzerPlugin;
@@ -32,6 +32,7 @@ const flowr_analyzer_ignore_file_project_discovery_plugin_1 = require("./project
32
32
  const flowr_analyzer_project_discovery_plugin_1 = require("./project-discovery/flowr-analyzer-project-discovery-plugin");
33
33
  const flowr_analyzer_rprofile_file_plugin_1 = require("./file-plugins/flowr-analyzer-rprofile-file-plugin");
34
34
  const flowr_analyzer_loading_order_rprofile_plugin_1 = require("./loading-order-plugins/flowr-analyzer-loading-order-rprofile-plugin");
35
+ const flowr_analyzer_loading_order_included_files_plugin_1 = require("./loading-order-plugins/flowr-analyzer-loading-order-included-files-plugin");
35
36
  /**
36
37
  * The built-in Flowr Analyzer plugins that are always available.
37
38
  */
@@ -47,6 +48,7 @@ exports.BuiltInPlugins = [
47
48
  ['loading-order:description', flowr_analyzer_loading_order_description_file_plugin_1.FlowrAnalyzerLoadingOrderDescriptionFilePlugin],
48
49
  ['loading-order:implicit-sources', flowr_analyzer_loading_order_implicit_sources_plugin_1.FlowrAnalyzerLoadingOrderImplicitSourcesPlugin],
49
50
  ['loading-order:rprofile', flowr_analyzer_loading_order_rprofile_plugin_1.FlowrAnalyzerLoadingOrderRprofilePlugin],
51
+ ['loading-order:included-files', flowr_analyzer_loading_order_included_files_plugin_1.FlowrAnalyzerLoadingOrderIncludedFilesPlugin],
50
52
  ['meta:description', flowr_analyzer_meta_description_file_plugin_1.FlowrAnalyzerMetaDescriptionFilePlugin],
51
53
  ['meta:rproject', flowr_analyzer_meta_manifest_file_plugin_1.FlowrAnalyzerMetaRProjectFilePlugin],
52
54
  ['meta:uvr', flowr_analyzer_meta_manifest_file_plugin_1.FlowrAnalyzerMetaUvrManifestFilePlugin],
@@ -30,7 +30,7 @@ class FlowrAnalyzerProjectDiscoveryPlugin extends flowr_analyzer_plugin_1.FlowrA
30
30
  }
31
31
  exports.FlowrAnalyzerProjectDiscoveryPlugin = FlowrAnalyzerProjectDiscoveryPlugin;
32
32
  // `.Rprofile`/`Rprofile.site` carry no extension but are plain R sources
33
- exports.discoverRSourcesRegex = /(\.(r|rmd|ipynb|qmd|rnw)|(^|[\\/])\.?Rprofile(\.site)?)$/i;
33
+ exports.discoverRSourcesRegex = /(\.(r|rmd|rmarkdown|ipynb|qmd|rnw)|(^|[\\/])\.?Rprofile(\.site)?)$/i;
34
34
  // matched against the posix path relative to the project root
35
35
  exports.ignorePathsWith = /(^|\/)(\.git|\.svn|\.hg|node_modules|__pycache__|\.Rproj\.user|\.uvr|Rtmp[^/]*|(packrat|renv|rv)\/(lib|library|src|staging|sandbox|bundles)[^/]*)(\/|$)/i;
36
36
  exports.excludeRequestsForPaths = /vignettes?|tests?|revdep|inst|data/i;
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.6';
45
+ const version = '2.13.7';
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
  /**