Add comprehensive development roadmap via GitHub Issues

Created 10 detailed GitHub issues covering:
- Project activation and management UI (#1-2)
- Worker node coordination and visualization (#3-4)
- Automated GitHub repository scanning (#5)
- Intelligent model-to-issue matching (#6)
- Multi-model task execution system (#7)
- N8N workflow integration (#8)
- Hive-Bzzz P2P bridge (#9)
- Peer assistance protocol (#10)

Each issue includes detailed specifications, acceptance criteria,
technical implementation notes, and dependency mapping.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
anthonyrawlins
2025-07-12 19:41:01 +10:00
parent 9a6a06da89
commit e89f2f4b7b
4980 changed files with 1501266 additions and 57 deletions

13
frontend/node_modules/recast/.editorconfig generated vendored Normal file
View File

@@ -0,0 +1,13 @@
[*]
insert_final_newline = true
[{package.json}]
indent_style = space
indent_size = 2
[{*.js, *.ts}]
indent_style = space
indent_size = 2
trim_trailing_whitespace = true
end_of_line = lf
charset = utf-8

16
frontend/node_modules/recast/.eslintrc.js generated vendored Normal file
View File

@@ -0,0 +1,16 @@
module.exports = {
parser: "@typescript-eslint/parser",
parserOptions: {
ecmaVersion: 6,
sourceType: "module",
ecmaFeatures: {
jsx: true,
},
},
rules: {
"no-var": "error",
"no-case-declarations": "error",
"no-fallthrough": "error",
},
ignorePatterns: ["test/data"],
};

9
frontend/node_modules/recast/.github/dependabot.yml generated vendored Normal file
View File

@@ -0,0 +1,9 @@
# Please see the documentation for all configuration options:
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
version: 2
updates:
- package-ecosystem: "npm" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "daily"

View File

@@ -0,0 +1,30 @@
name: CI
on:
push:
branches: [master]
pull_request:
branches: [master]
jobs:
test:
name: Test on node ${{ matrix.node_version }} and ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
node_version: ["12.x", "14.x", "16.x", "18.x", "19.x", "20.x"]
os: [ubuntu-latest]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node_version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node_version }}
- name: npm install, build and test
run: |
npm install
npm run build --if-present
npm run format:check
npm test

9
frontend/node_modules/recast/.prettierignore generated vendored Normal file
View File

@@ -0,0 +1,9 @@
*.d.ts
test/data/
/example
# output files
/main.js
/lib/**/*.js
/parsers/**/*.js
/test/**/*.js

16
frontend/node_modules/recast/.prettierrc.js generated vendored Normal file
View File

@@ -0,0 +1,16 @@
module.exports = {
printWidth: 80,
trailingComma: "all",
singleQuote: false,
overrides: [
{
files: "*.md",
options: {
printWidth: 60,
// Don't reformat code examples in README
embeddedLanguageFormatting: "off",
},
},
],
};

20
frontend/node_modules/recast/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,20 @@
Copyright (c) 2012 Ben Newman <bn@cs.stanford.edu>
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

221
frontend/node_modules/recast/README.md generated vendored Normal file
View File

@@ -0,0 +1,221 @@
# recast, _v_. ![CI](https://github.com/benjamn/recast/workflows/CI/badge.svg) [![Join the chat at https://gitter.im/benjamn/recast](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/benjamn/recast?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
1. to give (a metal object) a different form by melting it down and reshaping it.
1. to form, fashion, or arrange again.
1. to remodel or reconstruct (a literary work, document, sentence, etc.).
1. to supply (a theater or opera work) with a new cast.
## Installation
From npm:
npm install recast
From GitHub:
cd path/to/node_modules
git clone git://github.com/benjamn/recast.git
cd recast
npm install .
## Import style
Recast is designed to be imported using **named** imports:
```js
import { parse, print } from "recast";
console.log(print(parse(source)).code);
import * as recast from "recast";
console.log(recast.print(recast.parse(source)).code);
```
If you're using CommonJS:
```js
const { parse, print } = require("recast");
console.log(print(parse(source)).code);
const recast = require("recast");
console.log(recast.print(recast.parse(source)).code);
```
## Usage
Recast exposes two essential interfaces, one for parsing JavaScript code (`require("recast").parse`) and the other for reprinting modified syntax trees (`require("recast").print`).
Here's a simple but non-trivial example of how you might use `.parse` and `.print`:
```js
import * as recast from "recast";
// Let's turn this function declaration into a variable declaration.
const code = [
"function add(a, b) {",
" return a +",
" // Weird formatting, huh?",
" b;",
"}"
].join("\n");
// Parse the code using an interface similar to require("esprima").parse.
const ast = recast.parse(code);
```
Now do _whatever_ you want to `ast`. Really, anything at all!
See [ast-types](https://github.com/benjamn/ast-types) (especially the [def/core.ts](https://github.com/benjamn/ast-types/blob/master/src/def/core.ts)) module for a thorough overview of the `ast` API.
```js
// Grab a reference to the function declaration we just parsed.
const add = ast.program.body[0];
// Make sure it's a FunctionDeclaration (optional).
const n = recast.types.namedTypes;
n.FunctionDeclaration.assert(add);
// If you choose to use recast.builders to construct new AST nodes, all builder
// arguments will be dynamically type-checked against the Mozilla Parser API.
const b = recast.types.builders;
// This kind of manipulation should seem familiar if you've used Esprima or the
// Mozilla Parser API before.
ast.program.body[0] = b.variableDeclaration("var", [
b.variableDeclarator(add.id, b.functionExpression(
null, // Anonymize the function expression.
add.params,
add.body
))
]);
// Just for fun, because addition is commutative:
add.params.push(add.params.shift());
```
When you finish manipulating the AST, let `recast.print` work its magic:
```js
const output = recast.print(ast).code;
```
The `output` string now looks exactly like this, weird formatting and all:
```js
var add = function(b, a) {
return a +
// Weird formatting, huh?
b;
}
```
The magic of Recast is that it reprints only those parts of the syntax tree that you modify. In other words, the following identity is guaranteed:
```js
recast.print(recast.parse(source)).code === source
```
Whenever Recast cannot reprint a modified node using the original source code, it falls back to using a generic pretty printer. So the worst that can happen is that your changes trigger some harmless reformatting of your code.
If you really don't care about preserving the original formatting, you can access the pretty printer directly:
```js
var output = recast.prettyPrint(ast, { tabWidth: 2 }).code;
```
And here's the exact `output`:
```js
var add = function(b, a) {
return a + b;
}
```
Note that the weird formatting was discarded, yet the behavior and abstract structure of the code remain the same.
## Using a different parser
By default, Recast uses the [Esprima JavaScript parser](https://www.npmjs.com/package/esprima) when you call `recast.parse(code)`. While Esprima supports almost all modern ECMAScript syntax, you may want to use a different parser to enable TypeScript or Flow syntax, or just because you want to match other compilation tools you might be using.
In order to get any benefits from Recast's conservative pretty-printing, **it is very important that you continue to call `recast.parse`** (rather than parsing the AST yourself using a different parser), and simply instruct `recast.parse` to use a different parser:
```js
const acornAst = recast.parse(source, {
parser: require("acorn")
});
```
Why is this so important? When you call `recast.parse`, it makes a shadow copy of the AST before returning it to you, giving every copied AST node a reference back to the original through a special `.original` property. This information is what enables `recast.print` to detect where the AST has been modified, so that it can preserve formatting for parts of the AST that were not modified.
Any `parser` object that supports a `parser.parse(source)` method will work here; however, if your parser requires additional options, you can always implement your own `parse` method that invokes your parser with custom options:
```js
const acornAst = recast.parse(source, {
parser: {
parse(source) {
return require("acorn").parse(source, {
// additional options
});
}
}
});
```
To take some of the guesswork out of configuring common parsers, Recast provides [several preconfigured parsers](https://github.com/benjamn/recast/tree/master/parsers), so you can parse TypeScript (for example) without worrying about the configuration details:
```js
const tsAst = recast.parse(source, {
parser: require("recast/parsers/typescript")
});
```
**Note:** Some of these parsers import npm packages that Recast does not directly depend upon, so please be aware you may have to run `npm install @babel/parser` to use the `typescript`, `flow`, or `babel` parsers, or `npm install acorn` to use the `acorn` parser. Only Esprima is installed by default when Recast is installed.
After calling `recast.parse`, if you're going to transform the AST, make sure that the `.original` property is preserved. With Babel, for instance, if you call `transformFromAST`, you must pass `cloneInputAst: false` in its options. ([More detail](https://github.com/babel/babel/issues/12882)).
## Source maps
One of the coolest consequences of tracking and reusing original source code during reprinting is that it's pretty easy to generate a high-resolution mapping between the original code and the generated code—completely automatically!
With every `slice`, `join`, and re-`indent`-ation, the reprinting process maintains exact knowledge of which character sequences are original, and where in the original source they came from.
All you have to think about is how to manipulate the syntax tree, and Recast will give you a [source map](https://github.com/mozilla/source-map) in exchange for specifying the names of your source file(s) and the desired name of the map:
```js
var result = recast.print(transform(recast.parse(source, {
sourceFileName: "source.js"
})), {
sourceMapName: "source.min.js"
});
console.log(result.code); // Resulting string of code.
console.log(result.map); // JSON source map.
var SourceMapConsumer = require("source-map").SourceMapConsumer;
var smc = new SourceMapConsumer(result.map);
console.log(smc.originalPositionFor({
line: 3,
column: 15
})); // { source: 'source.js',
// line: 2,
// column: 10,
// name: null }
```
Note that you are free to mix and match syntax trees parsed from different source files, and the resulting source map will automatically keep track of the separate file origins for you.
Note also that the source maps generated by Recast are character-by-character maps, so meaningful identifier names are not recorded at this time. This approach leads to higher-resolution debugging in modern browsers, at the expense of somewhat larger map sizes. Striking the perfect balance here is an area for future exploration, but such improvements will not require any breaking changes to the interface demonstrated above.
## Options
All Recast API functions take second parameter with configuration options, documented in
[options.ts](https://github.com/benjamn/recast/blob/master/lib/options.ts)
## Motivation
The more code you have, the harder it becomes to make big, sweeping changes quickly and confidently. Even if you trust yourself not to make too many mistakes, and no matter how proficient you are with your text editor, changing tens of thousands of lines of code takes precious, non-refundable time.
Is there a better way? Not always! When a task requires you to alter the semantics of many different pieces of code in subtly different ways, your brain inevitably becomes the bottleneck, and there is little hope of completely automating the process. Your best bet is to plan carefully, buckle down, and get it right the first time. Love it or loathe it, that's the way programming goes sometimes.
What I hope to eliminate are the brain-wasting tasks, the tasks that are bottlenecked by keystrokes, the tasks that can be expressed as operations on the _syntactic structure_ of your code. Specifically, my goal is to make it possible for you to run your code through a parser, manipulate the abstract syntax tree directly, subject only to the constraints of your imagination, and then automatically translate those modifications back into source code, without upsetting the formatting of unmodified code.
And here's the best part: when you're done running a Recast script, if you're not completely satisfied with the results, blow them away with `git reset --hard`, tweak the script, and just run it again. Change your mind as many times as you like. Instead of typing yourself into a nasty case of [RSI](http://en.wikipedia.org/wiki/Repetitive_strain_injury), gaze upon your new wells of free time and ask yourself: what next?

44
frontend/node_modules/recast/example/add-braces generated vendored Executable file
View File

@@ -0,0 +1,44 @@
#!/usr/bin/env node
var recast = require("recast");
var types = recast.types;
var n = types.namedTypes;
var b = types.builders;
require("recast").run(function(ast, callback) {
recast.visit(ast, {
visitIfStatement: function(path) {
var stmt = path.node;
stmt.consequent = fix(stmt.consequent);
var alt = stmt.alternate;
if (!n.IfStatement.check(alt)) {
stmt.alternate = fix(alt);
}
this.traverse(path);
},
visitWhileStatement: visitLoop,
visitForStatement: visitLoop,
visitForInStatement: visitLoop
});
callback(ast);
});
function visitLoop(path) {
var loop = path.node;
loop.body = fix(loop.body);
this.traverse(path);
}
function fix(clause) {
if (clause) {
if (!n.BlockStatement.check(clause)) {
clause = b.blockStatement([clause]);
}
}
return clause;
}

17
frontend/node_modules/recast/example/generic-identity generated vendored Executable file
View File

@@ -0,0 +1,17 @@
#!/usr/bin/env node
// This script should reprint the contents of the given file without
// reusing the original source, but with identical AST structure.
var recast = require("recast");
recast.run(function(ast, callback) {
recast.visit(ast, {
visitNode: function(path) {
this.traverse(path);
path.node.original = null;
}
});
callback(ast);
});

8
frontend/node_modules/recast/example/identity generated vendored Executable file
View File

@@ -0,0 +1,8 @@
#!/usr/bin/env node
// This script should echo the contents of the given file without
// modification.
require("recast").run(function(ast, callback) {
callback(ast);
});

84
frontend/node_modules/recast/example/to-while generated vendored Executable file
View File

@@ -0,0 +1,84 @@
#!/usr/bin/env node
// This script converts for and do-while loops into equivalent while loops.
// Note that for-in statements are left unmodified, as they do not have a
// simple analogy to while loops. Also note that labeled continue statements
// are not correctly handled at this point, and will trigger an assertion
// failure if encountered.
var assert = require("assert");
var recast = require("recast");
var types = recast.types;
var n = types.namedTypes;
var b = types.builders;
recast.run(function(ast, callback) {
recast.visit(ast, {
visitForStatement: function(path) {
var fst = path.node;
path.replace(
fst.init,
b.whileStatement(
fst.test,
insertBeforeLoopback(fst, fst.update)
)
);
this.traverse(path);
},
visitDoWhileStatement: function(path) {
var dwst = path.node;
return b.whileStatement(
b.literal(true),
insertBeforeLoopback(
dwst,
b.ifStatement(
dwst.test,
b.breakStatement()
)
)
);
}
});
callback(ast);
});
function insertBeforeLoopback(loop, toInsert) {
var body = loop.body;
if (!n.Statement.check(toInsert)) {
toInsert = b.expressionStatement(toInsert);
}
if (n.BlockStatement.check(body)) {
body.body.push(toInsert);
} else {
body = b.blockStatement([body, toInsert]);
loop.body = body;
}
recast.visit(body, {
visitContinueStatement: function(path) {
var cst = path.node;
assert.equal(
cst.label, null,
"Labeled continue statements are not yet supported."
);
path.replace(toInsert, path.node);
return false;
},
// Do not descend into nested loops.
visitWhileStatement: function() {},
visitForStatement: function() {},
visitForInStatement: function() {},
visitDoWhileStatement: function() {}
});
return body;
}

2
frontend/node_modules/recast/lib/comments.d.ts generated vendored Normal file
View File

@@ -0,0 +1,2 @@
export declare function attach(comments: any[], ast: any, lines: any): void;
export declare function printComments(path: any, print: any): any;

313
frontend/node_modules/recast/lib/comments.js generated vendored Normal file
View File

@@ -0,0 +1,313 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.printComments = exports.attach = void 0;
var tslib_1 = require("tslib");
var tiny_invariant_1 = tslib_1.__importDefault(require("tiny-invariant"));
var types = tslib_1.__importStar(require("ast-types"));
var n = types.namedTypes;
var isArray = types.builtInTypes.array;
var isObject = types.builtInTypes.object;
var lines_1 = require("./lines");
var util_1 = require("./util");
var childNodesCache = new WeakMap();
// TODO Move a non-caching implementation of this function into ast-types,
// and implement a caching wrapper function here.
function getSortedChildNodes(node, lines, resultArray) {
if (!node) {
return resultArray;
}
// The .loc checks below are sensitive to some of the problems that
// are fixed by this utility function. Specifically, if it decides to
// set node.loc to null, indicating that the node's .loc information
// is unreliable, then we don't want to add node to the resultArray.
(0, util_1.fixFaultyLocations)(node, lines);
if (resultArray) {
if (n.Node.check(node) && n.SourceLocation.check(node.loc)) {
// This reverse insertion sort almost always takes constant
// time because we almost always (maybe always?) append the
// nodes in order anyway.
var i = resultArray.length - 1;
for (; i >= 0; --i) {
var child = resultArray[i];
if (child &&
child.loc &&
(0, util_1.comparePos)(child.loc.end, node.loc.start) <= 0) {
break;
}
}
resultArray.splice(i + 1, 0, node);
return resultArray;
}
}
else {
var childNodes = childNodesCache.get(node);
if (childNodes) {
return childNodes;
}
}
var names;
if (isArray.check(node)) {
names = Object.keys(node);
}
else if (isObject.check(node)) {
names = types.getFieldNames(node);
}
else {
return resultArray;
}
if (!resultArray) {
childNodesCache.set(node, (resultArray = []));
}
for (var i = 0, nameCount = names.length; i < nameCount; ++i) {
getSortedChildNodes(node[names[i]], lines, resultArray);
}
return resultArray;
}
// As efficiently as possible, decorate the comment object with
// .precedingNode, .enclosingNode, and/or .followingNode properties, at
// least one of which is guaranteed to be defined.
function decorateComment(node, comment, lines) {
var childNodes = getSortedChildNodes(node, lines);
// Time to dust off the old binary search robes and wizard hat.
var left = 0;
var right = childNodes && childNodes.length;
var precedingNode;
var followingNode;
while (typeof right === "number" && left < right) {
var middle = (left + right) >> 1;
var child = childNodes[middle];
if ((0, util_1.comparePos)(child.loc.start, comment.loc.start) <= 0 &&
(0, util_1.comparePos)(comment.loc.end, child.loc.end) <= 0) {
// The comment is completely contained by this child node.
decorateComment((comment.enclosingNode = child), comment, lines);
return; // Abandon the binary search at this level.
}
if ((0, util_1.comparePos)(child.loc.end, comment.loc.start) <= 0) {
// This child node falls completely before the comment.
// Because we will never consider this node or any nodes
// before it again, this node must be the closest preceding
// node we have encountered so far.
precedingNode = child;
left = middle + 1;
continue;
}
if ((0, util_1.comparePos)(comment.loc.end, child.loc.start) <= 0) {
// This child node falls completely after the comment.
// Because we will never consider this node or any nodes after
// it again, this node must be the closest following node we
// have encountered so far.
followingNode = child;
right = middle;
continue;
}
throw new Error("Comment location overlaps with node location");
}
if (precedingNode) {
comment.precedingNode = precedingNode;
}
if (followingNode) {
comment.followingNode = followingNode;
}
}
function attach(comments, ast, lines) {
if (!isArray.check(comments)) {
return;
}
var tiesToBreak = [];
comments.forEach(function (comment) {
comment.loc.lines = lines;
decorateComment(ast, comment, lines);
var pn = comment.precedingNode;
var en = comment.enclosingNode;
var fn = comment.followingNode;
if (pn && fn) {
var tieCount = tiesToBreak.length;
if (tieCount > 0) {
var lastTie = tiesToBreak[tieCount - 1];
(0, tiny_invariant_1.default)((lastTie.precedingNode === comment.precedingNode) ===
(lastTie.followingNode === comment.followingNode));
if (lastTie.followingNode !== comment.followingNode) {
breakTies(tiesToBreak, lines);
}
}
tiesToBreak.push(comment);
}
else if (pn) {
// No contest: we have a trailing comment.
breakTies(tiesToBreak, lines);
addTrailingComment(pn, comment);
}
else if (fn) {
// No contest: we have a leading comment.
breakTies(tiesToBreak, lines);
addLeadingComment(fn, comment);
}
else if (en) {
// The enclosing node has no child nodes at all, so what we
// have here is a dangling comment, e.g. [/* crickets */].
breakTies(tiesToBreak, lines);
addDanglingComment(en, comment);
}
else {
throw new Error("AST contains no nodes at all?");
}
});
breakTies(tiesToBreak, lines);
comments.forEach(function (comment) {
// These node references were useful for breaking ties, but we
// don't need them anymore, and they create cycles in the AST that
// may lead to infinite recursion if we don't delete them here.
delete comment.precedingNode;
delete comment.enclosingNode;
delete comment.followingNode;
});
}
exports.attach = attach;
function breakTies(tiesToBreak, lines) {
var tieCount = tiesToBreak.length;
if (tieCount === 0) {
return;
}
var pn = tiesToBreak[0].precedingNode;
var fn = tiesToBreak[0].followingNode;
var gapEndPos = fn.loc.start;
// Iterate backwards through tiesToBreak, examining the gaps
// between the tied comments. In order to qualify as leading, a
// comment must be separated from fn by an unbroken series of
// whitespace-only gaps (or other comments).
var indexOfFirstLeadingComment = tieCount;
var comment;
for (; indexOfFirstLeadingComment > 0; --indexOfFirstLeadingComment) {
comment = tiesToBreak[indexOfFirstLeadingComment - 1];
(0, tiny_invariant_1.default)(comment.precedingNode === pn);
(0, tiny_invariant_1.default)(comment.followingNode === fn);
var gap = lines.sliceString(comment.loc.end, gapEndPos);
if (/\S/.test(gap)) {
// The gap string contained something other than whitespace.
break;
}
gapEndPos = comment.loc.start;
}
while (indexOfFirstLeadingComment <= tieCount &&
(comment = tiesToBreak[indexOfFirstLeadingComment]) &&
// If the comment is a //-style comment and indented more
// deeply than the node itself, reconsider it as trailing.
(comment.type === "Line" || comment.type === "CommentLine") &&
comment.loc.start.column > fn.loc.start.column) {
++indexOfFirstLeadingComment;
}
if (indexOfFirstLeadingComment) {
var enclosingNode = tiesToBreak[indexOfFirstLeadingComment - 1].enclosingNode;
if ((enclosingNode === null || enclosingNode === void 0 ? void 0 : enclosingNode.type) === "CallExpression") {
--indexOfFirstLeadingComment;
}
}
tiesToBreak.forEach(function (comment, i) {
if (i < indexOfFirstLeadingComment) {
addTrailingComment(pn, comment);
}
else {
addLeadingComment(fn, comment);
}
});
tiesToBreak.length = 0;
}
function addCommentHelper(node, comment) {
var comments = node.comments || (node.comments = []);
comments.push(comment);
}
function addLeadingComment(node, comment) {
comment.leading = true;
comment.trailing = false;
addCommentHelper(node, comment);
}
function addDanglingComment(node, comment) {
comment.leading = false;
comment.trailing = false;
addCommentHelper(node, comment);
}
function addTrailingComment(node, comment) {
comment.leading = false;
comment.trailing = true;
addCommentHelper(node, comment);
}
function printLeadingComment(commentPath, print) {
var comment = commentPath.getValue();
n.Comment.assert(comment);
var loc = comment.loc;
var lines = loc && loc.lines;
var parts = [print(commentPath)];
if (comment.trailing) {
// When we print trailing comments as leading comments, we don't
// want to bring any trailing spaces along.
parts.push("\n");
}
else if (lines instanceof lines_1.Lines) {
var trailingSpace = lines.slice(loc.end, lines.skipSpaces(loc.end) || lines.lastPos());
if (trailingSpace.length === 1) {
// If the trailing space contains no newlines, then we want to
// preserve it exactly as we found it.
parts.push(trailingSpace);
}
else {
// If the trailing space contains newlines, then replace it
// with just that many newlines, with all other spaces removed.
parts.push(new Array(trailingSpace.length).join("\n"));
}
}
else {
parts.push("\n");
}
return (0, lines_1.concat)(parts);
}
function printTrailingComment(commentPath, print) {
var comment = commentPath.getValue(commentPath);
n.Comment.assert(comment);
var loc = comment.loc;
var lines = loc && loc.lines;
var parts = [];
if (lines instanceof lines_1.Lines) {
var fromPos = lines.skipSpaces(loc.start, true) || lines.firstPos();
var leadingSpace = lines.slice(fromPos, loc.start);
if (leadingSpace.length === 1) {
// If the leading space contains no newlines, then we want to
// preserve it exactly as we found it.
parts.push(leadingSpace);
}
else {
// If the leading space contains newlines, then replace it
// with just that many newlines, sans all other spaces.
parts.push(new Array(leadingSpace.length).join("\n"));
}
}
parts.push(print(commentPath));
return (0, lines_1.concat)(parts);
}
function printComments(path, print) {
var value = path.getValue();
var innerLines = print(path);
var comments = n.Node.check(value) && types.getFieldValue(value, "comments");
if (!comments || comments.length === 0) {
return innerLines;
}
var leadingParts = [];
var trailingParts = [innerLines];
path.each(function (commentPath) {
var comment = commentPath.getValue();
var leading = types.getFieldValue(comment, "leading");
var trailing = types.getFieldValue(comment, "trailing");
if (leading ||
(trailing &&
!(n.Statement.check(value) ||
comment.type === "Block" ||
comment.type === "CommentBlock"))) {
leadingParts.push(printLeadingComment(commentPath, print));
}
else if (trailing) {
trailingParts.push(printTrailingComment(commentPath, print));
}
}, "comments");
leadingParts.push.apply(leadingParts, trailingParts);
return (0, lines_1.concat)(leadingParts);
}
exports.printComments = printComments;

25
frontend/node_modules/recast/lib/fast-path.d.ts generated vendored Normal file
View File

@@ -0,0 +1,25 @@
interface FastPathType {
stack: any[];
copy(): any;
getName(): any;
getValue(): any;
valueIsDuplicate(): any;
getNode(count?: number): any;
getParentNode(count?: number): any;
getRootValue(): any;
call(callback: any, ...names: any[]): any;
each(callback: any, ...names: any[]): any;
map(callback: any, ...names: any[]): any;
hasParens(): any;
getPrevToken(node: any): any;
getNextToken(node: any): any;
needsParens(assumeExpressionContext?: boolean): any;
canBeFirstInStatement(): any;
firstInStatement(): any;
}
interface FastPathConstructor {
new (value: any): FastPathType;
from(obj: any): any;
}
declare const FastPath: FastPathConstructor;
export default FastPath;

541
frontend/node_modules/recast/lib/fast-path.js generated vendored Normal file
View File

@@ -0,0 +1,541 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var tiny_invariant_1 = tslib_1.__importDefault(require("tiny-invariant"));
var types = tslib_1.__importStar(require("ast-types"));
var util = tslib_1.__importStar(require("./util"));
var n = types.namedTypes;
var isArray = types.builtInTypes.array;
var isNumber = types.builtInTypes.number;
var PRECEDENCE = {};
[
["??"],
["||"],
["&&"],
["|"],
["^"],
["&"],
["==", "===", "!=", "!=="],
["<", ">", "<=", ">=", "in", "instanceof"],
[">>", "<<", ">>>"],
["+", "-"],
["*", "/", "%"],
["**"],
].forEach(function (tier, i) {
tier.forEach(function (op) {
PRECEDENCE[op] = i;
});
});
var FastPath = function FastPath(value) {
(0, tiny_invariant_1.default)(this instanceof FastPath);
this.stack = [value];
};
var FPp = FastPath.prototype;
// Static convenience function for coercing a value to a FastPath.
FastPath.from = function (obj) {
if (obj instanceof FastPath) {
// Return a defensive copy of any existing FastPath instances.
return obj.copy();
}
if (obj instanceof types.NodePath) {
// For backwards compatibility, unroll NodePath instances into
// lightweight FastPath [..., name, value] stacks.
var copy = Object.create(FastPath.prototype);
var stack = [obj.value];
for (var pp = void 0; (pp = obj.parentPath); obj = pp)
stack.push(obj.name, pp.value);
copy.stack = stack.reverse();
return copy;
}
// Otherwise use obj as the value of the new FastPath instance.
return new FastPath(obj);
};
FPp.copy = function copy() {
var copy = Object.create(FastPath.prototype);
copy.stack = this.stack.slice(0);
return copy;
};
// The name of the current property is always the penultimate element of
// this.stack, and always a String.
FPp.getName = function getName() {
var s = this.stack;
var len = s.length;
if (len > 1) {
return s[len - 2];
}
// Since the name is always a string, null is a safe sentinel value to
// return if we do not know the name of the (root) value.
return null;
};
// The value of the current property is always the final element of
// this.stack.
FPp.getValue = function getValue() {
var s = this.stack;
return s[s.length - 1];
};
FPp.valueIsDuplicate = function () {
var s = this.stack;
var valueIndex = s.length - 1;
return s.lastIndexOf(s[valueIndex], valueIndex - 1) >= 0;
};
function getNodeHelper(path, count) {
var s = path.stack;
for (var i = s.length - 1; i >= 0; i -= 2) {
var value = s[i];
if (n.Node.check(value) && --count < 0) {
return value;
}
}
return null;
}
FPp.getNode = function getNode(count) {
if (count === void 0) { count = 0; }
return getNodeHelper(this, ~~count);
};
FPp.getParentNode = function getParentNode(count) {
if (count === void 0) { count = 0; }
return getNodeHelper(this, ~~count + 1);
};
// The length of the stack can be either even or odd, depending on whether
// or not we have a name for the root value. The difference between the
// index of the root value and the index of the final value is always
// even, though, which allows us to return the root value in constant time
// (i.e. without iterating backwards through the stack).
FPp.getRootValue = function getRootValue() {
var s = this.stack;
if (s.length % 2 === 0) {
return s[1];
}
return s[0];
};
// Temporarily push properties named by string arguments given after the
// callback function onto this.stack, then call the callback with a
// reference to this (modified) FastPath object. Note that the stack will
// be restored to its original state after the callback is finished, so it
// is probably a mistake to retain a reference to the path.
FPp.call = function call(callback /*, name1, name2, ... */) {
var s = this.stack;
var origLen = s.length;
var value = s[origLen - 1];
var argc = arguments.length;
for (var i = 1; i < argc; ++i) {
var name = arguments[i];
value = value[name];
s.push(name, value);
}
var result = callback(this);
s.length = origLen;
return result;
};
// Similar to FastPath.prototype.call, except that the value obtained by
// accessing this.getValue()[name1][name2]... should be array-like. The
// callback will be called with a reference to this path object for each
// element of the array.
FPp.each = function each(callback /*, name1, name2, ... */) {
var s = this.stack;
var origLen = s.length;
var value = s[origLen - 1];
var argc = arguments.length;
for (var i = 1; i < argc; ++i) {
var name = arguments[i];
value = value[name];
s.push(name, value);
}
for (var i = 0; i < value.length; ++i) {
if (i in value) {
s.push(i, value[i]);
// If the callback needs to know the value of i, call
// path.getName(), assuming path is the parameter name.
callback(this);
s.length -= 2;
}
}
s.length = origLen;
};
// Similar to FastPath.prototype.each, except that the results of the
// callback function invocations are stored in an array and returned at
// the end of the iteration.
FPp.map = function map(callback /*, name1, name2, ... */) {
var s = this.stack;
var origLen = s.length;
var value = s[origLen - 1];
var argc = arguments.length;
for (var i = 1; i < argc; ++i) {
var name = arguments[i];
value = value[name];
s.push(name, value);
}
var result = new Array(value.length);
for (var i = 0; i < value.length; ++i) {
if (i in value) {
s.push(i, value[i]);
result[i] = callback(this, i);
s.length -= 2;
}
}
s.length = origLen;
return result;
};
// Returns true if the node at the tip of the path is wrapped with
// parentheses, OR if the only reason the node needed parentheses was that
// it couldn't be the first expression in the enclosing statement (see
// FastPath#canBeFirstInStatement), and it has an opening `(` character.
// For example, the FunctionExpression in `(function(){}())` appears to
// need parentheses only because it's the first expression in the AST, but
// since it happens to be preceded by a `(` (which is not apparent from
// the AST but can be determined using FastPath#getPrevToken), there is no
// ambiguity about how to parse it, so it counts as having parentheses,
// even though it is not immediately followed by a `)`.
FPp.hasParens = function () {
var node = this.getNode();
var prevToken = this.getPrevToken(node);
if (!prevToken) {
return false;
}
var nextToken = this.getNextToken(node);
if (!nextToken) {
return false;
}
if (prevToken.value === "(") {
if (nextToken.value === ")") {
// If the node preceded by a `(` token and followed by a `)` token,
// then of course it has parentheses.
return true;
}
// If this is one of the few Expression types that can't come first in
// the enclosing statement because of parsing ambiguities (namely,
// FunctionExpression, ObjectExpression, and ClassExpression) and
// this.firstInStatement() returns true, and the node would not need
// parentheses in an expression context because this.needsParens(true)
// returns false, then it just needs an opening parenthesis to resolve
// the parsing ambiguity that made it appear to need parentheses.
var justNeedsOpeningParen = !this.canBeFirstInStatement() &&
this.firstInStatement() &&
!this.needsParens(true);
if (justNeedsOpeningParen) {
return true;
}
}
return false;
};
FPp.getPrevToken = function (node) {
node = node || this.getNode();
var loc = node && node.loc;
var tokens = loc && loc.tokens;
if (tokens && loc.start.token > 0) {
var token = tokens[loc.start.token - 1];
if (token) {
// Do not return tokens that fall outside the root subtree.
var rootLoc = this.getRootValue().loc;
if (util.comparePos(rootLoc.start, token.loc.start) <= 0) {
return token;
}
}
}
return null;
};
FPp.getNextToken = function (node) {
node = node || this.getNode();
var loc = node && node.loc;
var tokens = loc && loc.tokens;
if (tokens && loc.end.token < tokens.length) {
var token = tokens[loc.end.token];
if (token) {
// Do not return tokens that fall outside the root subtree.
var rootLoc = this.getRootValue().loc;
if (util.comparePos(token.loc.end, rootLoc.end) <= 0) {
return token;
}
}
}
return null;
};
// Inspired by require("ast-types").NodePath.prototype.needsParens, but
// more efficient because we're iterating backwards through a stack.
FPp.needsParens = function (assumeExpressionContext) {
var node = this.getNode();
// This needs to come before `if (!parent) { return false }` because
// an object destructuring assignment requires parens for
// correctness even when it's the topmost expression.
if (node.type === "AssignmentExpression" &&
node.left.type === "ObjectPattern") {
return true;
}
var parent = this.getParentNode();
var name = this.getName();
// If the value of this path is some child of a Node and not a Node
// itself, then it doesn't need parentheses. Only Node objects (in fact,
// only Expression nodes) need parentheses.
if (this.getValue() !== node) {
return false;
}
// Only statements don't need parentheses.
if (n.Statement.check(node)) {
return false;
}
// Identifiers never need parentheses.
if (node.type === "Identifier") {
return false;
}
if (parent && parent.type === "ParenthesizedExpression") {
return false;
}
if (node.extra && node.extra.parenthesized) {
return true;
}
if (!parent)
return false;
// Wrap e.g. `-1` in parentheses inside `(-1) ** 2`.
if (node.type === "UnaryExpression" &&
parent.type === "BinaryExpression" &&
name === "left" &&
parent.left === node &&
parent.operator === "**") {
return true;
}
switch (node.type) {
case "UnaryExpression":
case "SpreadElement":
case "SpreadProperty":
return (parent.type === "MemberExpression" &&
name === "object" &&
parent.object === node);
case "BinaryExpression":
case "LogicalExpression":
switch (parent.type) {
case "CallExpression":
return name === "callee" && parent.callee === node;
case "UnaryExpression":
case "SpreadElement":
case "SpreadProperty":
return true;
case "MemberExpression":
return name === "object" && parent.object === node;
case "BinaryExpression":
case "LogicalExpression": {
var po = parent.operator;
var pp = PRECEDENCE[po];
var no = node.operator;
var np = PRECEDENCE[no];
if (pp > np) {
return true;
}
if (pp === np && name === "right") {
(0, tiny_invariant_1.default)(parent.right === node);
return true;
}
break;
}
default:
return false;
}
break;
case "SequenceExpression":
switch (parent.type) {
case "ReturnStatement":
return false;
case "ForStatement":
// Although parentheses wouldn't hurt around sequence expressions in
// the head of for loops, traditional style dictates that e.g. i++,
// j++ should not be wrapped with parentheses.
return false;
case "ExpressionStatement":
return name !== "expression";
default:
// Otherwise err on the side of overparenthesization, adding
// explicit exceptions above if this proves overzealous.
return true;
}
case "OptionalIndexedAccessType":
return node.optional && parent.type === "IndexedAccessType";
case "IntersectionTypeAnnotation":
case "UnionTypeAnnotation":
return parent.type === "NullableTypeAnnotation";
case "Literal":
return (parent.type === "MemberExpression" &&
isNumber.check(node.value) &&
name === "object" &&
parent.object === node);
// Babel 6 Literal split
case "NumericLiteral":
return (parent.type === "MemberExpression" &&
name === "object" &&
parent.object === node);
case "YieldExpression":
case "AwaitExpression":
case "AssignmentExpression":
case "ConditionalExpression":
switch (parent.type) {
case "UnaryExpression":
case "SpreadElement":
case "SpreadProperty":
case "BinaryExpression":
case "LogicalExpression":
return true;
case "CallExpression":
case "NewExpression":
return name === "callee" && parent.callee === node;
case "ConditionalExpression":
return name === "test" && parent.test === node;
case "MemberExpression":
return name === "object" && parent.object === node;
default:
return false;
}
case "ArrowFunctionExpression":
if (n.CallExpression.check(parent) &&
name === "callee" &&
parent.callee === node) {
return true;
}
if (n.MemberExpression.check(parent) &&
name === "object" &&
parent.object === node) {
return true;
}
if (n.TSAsExpression &&
n.TSAsExpression.check(parent) &&
name === "expression" &&
parent.expression === node) {
return true;
}
return isBinary(parent);
case "ObjectExpression":
if (parent.type === "ArrowFunctionExpression" &&
name === "body" &&
parent.body === node) {
return true;
}
break;
case "TSAsExpression":
if (parent.type === "ArrowFunctionExpression" &&
name === "body" &&
parent.body === node &&
node.expression.type === "ObjectExpression") {
return true;
}
break;
case "CallExpression":
if (name === "declaration" &&
n.ExportDefaultDeclaration.check(parent) &&
n.FunctionExpression.check(node.callee)) {
return true;
}
}
if (parent.type === "NewExpression" &&
name === "callee" &&
parent.callee === node) {
return containsCallExpression(node);
}
if (assumeExpressionContext !== true &&
!this.canBeFirstInStatement() &&
this.firstInStatement()) {
return true;
}
return false;
};
function isBinary(node) {
return n.BinaryExpression.check(node) || n.LogicalExpression.check(node);
}
// @ts-ignore 'isUnaryLike' is declared but its value is never read. [6133]
function isUnaryLike(node) {
return (n.UnaryExpression.check(node) ||
// I considered making SpreadElement and SpreadProperty subtypes of
// UnaryExpression, but they're not really Expression nodes.
(n.SpreadElement && n.SpreadElement.check(node)) ||
(n.SpreadProperty && n.SpreadProperty.check(node)));
}
function containsCallExpression(node) {
if (n.CallExpression.check(node)) {
return true;
}
if (isArray.check(node)) {
return node.some(containsCallExpression);
}
if (n.Node.check(node)) {
return types.someField(node, function (_name, child) {
return containsCallExpression(child);
});
}
return false;
}
FPp.canBeFirstInStatement = function () {
var node = this.getNode();
if (n.FunctionExpression.check(node)) {
return false;
}
if (n.ObjectExpression.check(node)) {
return false;
}
if (n.ClassExpression.check(node)) {
return false;
}
return true;
};
FPp.firstInStatement = function () {
var s = this.stack;
var parentName, parent;
var childName, child;
for (var i = s.length - 1; i >= 0; i -= 2) {
if (n.Node.check(s[i])) {
childName = parentName;
child = parent;
parentName = s[i - 1];
parent = s[i];
}
if (!parent || !child) {
continue;
}
if (n.BlockStatement.check(parent) &&
parentName === "body" &&
childName === 0) {
(0, tiny_invariant_1.default)(parent.body[0] === child);
return true;
}
if (n.ExpressionStatement.check(parent) && childName === "expression") {
(0, tiny_invariant_1.default)(parent.expression === child);
return true;
}
if (n.AssignmentExpression.check(parent) && childName === "left") {
(0, tiny_invariant_1.default)(parent.left === child);
return true;
}
if (n.ArrowFunctionExpression.check(parent) && childName === "body") {
(0, tiny_invariant_1.default)(parent.body === child);
return true;
}
// s[i + 1] and s[i + 2] represent the array between the parent
// SequenceExpression node and its child nodes
if (n.SequenceExpression.check(parent) &&
s[i + 1] === "expressions" &&
childName === 0) {
(0, tiny_invariant_1.default)(parent.expressions[0] === child);
continue;
}
if (n.CallExpression.check(parent) && childName === "callee") {
(0, tiny_invariant_1.default)(parent.callee === child);
continue;
}
if (n.MemberExpression.check(parent) && childName === "object") {
(0, tiny_invariant_1.default)(parent.object === child);
continue;
}
if (n.ConditionalExpression.check(parent) && childName === "test") {
(0, tiny_invariant_1.default)(parent.test === child);
continue;
}
if (isBinary(parent) && childName === "left") {
(0, tiny_invariant_1.default)(parent.left === child);
continue;
}
if (n.UnaryExpression.check(parent) &&
!parent.prefix &&
childName === "argument") {
(0, tiny_invariant_1.default)(parent.argument === child);
continue;
}
return false;
}
return true;
};
exports.default = FastPath;

62
frontend/node_modules/recast/lib/lines.d.ts generated vendored Normal file
View File

@@ -0,0 +1,62 @@
import { Options } from "./options";
import { namedTypes } from "ast-types";
type Pos = namedTypes.Position;
type LineInfo = {
readonly line: string;
readonly indent: number;
readonly locked: boolean;
readonly sliceStart: number;
readonly sliceEnd: number;
};
export declare class Lines {
private infos;
readonly length: number;
readonly name: string | null;
private mappings;
private cachedSourceMap;
private cachedTabWidth;
constructor(infos: LineInfo[], sourceFileName?: string | null);
toString(options?: Options): string;
getSourceMap(sourceMapName: string, sourceRoot?: string): any;
bootstrapCharAt(pos: Pos): string;
charAt(pos: Pos): string;
stripMargin(width: number, skipFirstLine: boolean): Lines;
indent(by: number): Lines;
indentTail(by: number): Lines;
lockIndentTail(): Lines;
getIndentAt(line: number): number;
guessTabWidth(): number;
startsWithComment(): boolean;
isOnlyWhitespace(): boolean;
isPrecededOnlyByWhitespace(pos: Pos): boolean;
getLineLength(line: number): number;
nextPos(pos: Pos, skipSpaces?: boolean): boolean;
prevPos(pos: Pos, skipSpaces?: boolean): boolean;
firstPos(): {
line: number;
column: number;
};
lastPos(): {
line: number;
column: number;
};
skipSpaces(pos: Pos, backward?: boolean, modifyInPlace?: boolean): namedTypes.Position | null;
trimLeft(): Lines;
trimRight(): Lines;
trim(): Lines;
eachPos(callback: (pos: Pos) => any, startPos?: Pos, skipSpaces?: boolean): void;
bootstrapSlice(start: Pos, end: Pos): Lines;
slice(start?: Pos, end?: Pos): Lines;
bootstrapSliceString(start: Pos, end: Pos, options?: Options): string;
sliceString(start?: Pos, end?: Pos, options?: Options): string;
isEmpty(): boolean;
join(elements: (string | Lines)[]): Lines;
concat(...args: (string | Lines)[]): Lines;
}
export declare function countSpaces(spaces: string, tabWidth?: number): number;
/**
* @param {Object} options - Options object that configures printing.
*/
export declare function fromString(string: string | Lines, options?: Options): Lines;
export declare function concat(elements: (string | Lines)[]): Lines;
export {};

654
frontend/node_modules/recast/lib/lines.js generated vendored Normal file
View File

@@ -0,0 +1,654 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.concat = exports.fromString = exports.countSpaces = exports.Lines = void 0;
var tslib_1 = require("tslib");
var tiny_invariant_1 = tslib_1.__importDefault(require("tiny-invariant"));
var source_map_1 = tslib_1.__importDefault(require("source-map"));
var options_1 = require("./options");
var util_1 = require("./util");
var mapping_1 = tslib_1.__importDefault(require("./mapping"));
var Lines = /** @class */ (function () {
function Lines(infos, sourceFileName) {
if (sourceFileName === void 0) { sourceFileName = null; }
this.infos = infos;
this.mappings = [];
this.cachedSourceMap = null;
this.cachedTabWidth = void 0;
(0, tiny_invariant_1.default)(infos.length > 0);
this.length = infos.length;
this.name = sourceFileName || null;
if (this.name) {
this.mappings.push(new mapping_1.default(this, {
start: this.firstPos(),
end: this.lastPos(),
}));
}
}
Lines.prototype.toString = function (options) {
return this.sliceString(this.firstPos(), this.lastPos(), options);
};
Lines.prototype.getSourceMap = function (sourceMapName, sourceRoot) {
if (!sourceMapName) {
// Although we could make up a name or generate an anonymous
// source map, instead we assume that any consumer who does not
// provide a name does not actually want a source map.
return null;
}
var targetLines = this;
function updateJSON(json) {
json = json || {};
json.file = sourceMapName;
if (sourceRoot) {
json.sourceRoot = sourceRoot;
}
return json;
}
if (targetLines.cachedSourceMap) {
// Since Lines objects are immutable, we can reuse any source map
// that was previously generated. Nevertheless, we return a new
// JSON object here to protect the cached source map from outside
// modification.
return updateJSON(targetLines.cachedSourceMap.toJSON());
}
var smg = new source_map_1.default.SourceMapGenerator(updateJSON());
var sourcesToContents = {};
targetLines.mappings.forEach(function (mapping) {
var sourceCursor = mapping.sourceLines.skipSpaces(mapping.sourceLoc.start) ||
mapping.sourceLines.lastPos();
var targetCursor = targetLines.skipSpaces(mapping.targetLoc.start) ||
targetLines.lastPos();
while ((0, util_1.comparePos)(sourceCursor, mapping.sourceLoc.end) < 0 &&
(0, util_1.comparePos)(targetCursor, mapping.targetLoc.end) < 0) {
var sourceChar = mapping.sourceLines.charAt(sourceCursor);
var targetChar = targetLines.charAt(targetCursor);
(0, tiny_invariant_1.default)(sourceChar === targetChar);
var sourceName = mapping.sourceLines.name;
// Add mappings one character at a time for maximum resolution.
smg.addMapping({
source: sourceName,
original: { line: sourceCursor.line, column: sourceCursor.column },
generated: { line: targetCursor.line, column: targetCursor.column },
});
if (!hasOwn.call(sourcesToContents, sourceName)) {
var sourceContent = mapping.sourceLines.toString();
smg.setSourceContent(sourceName, sourceContent);
sourcesToContents[sourceName] = sourceContent;
}
targetLines.nextPos(targetCursor, true);
mapping.sourceLines.nextPos(sourceCursor, true);
}
});
targetLines.cachedSourceMap = smg;
return smg.toJSON();
};
Lines.prototype.bootstrapCharAt = function (pos) {
(0, tiny_invariant_1.default)(typeof pos === "object");
(0, tiny_invariant_1.default)(typeof pos.line === "number");
(0, tiny_invariant_1.default)(typeof pos.column === "number");
var line = pos.line, column = pos.column, strings = this.toString().split(lineTerminatorSeqExp), string = strings[line - 1];
if (typeof string === "undefined")
return "";
if (column === string.length && line < strings.length)
return "\n";
if (column >= string.length)
return "";
return string.charAt(column);
};
Lines.prototype.charAt = function (pos) {
(0, tiny_invariant_1.default)(typeof pos === "object");
(0, tiny_invariant_1.default)(typeof pos.line === "number");
(0, tiny_invariant_1.default)(typeof pos.column === "number");
var line = pos.line, column = pos.column, secret = this, infos = secret.infos, info = infos[line - 1], c = column;
if (typeof info === "undefined" || c < 0)
return "";
var indent = this.getIndentAt(line);
if (c < indent)
return " ";
c += info.sliceStart - indent;
if (c === info.sliceEnd && line < this.length)
return "\n";
if (c >= info.sliceEnd)
return "";
return info.line.charAt(c);
};
Lines.prototype.stripMargin = function (width, skipFirstLine) {
if (width === 0)
return this;
(0, tiny_invariant_1.default)(width > 0, "negative margin: " + width);
if (skipFirstLine && this.length === 1)
return this;
var lines = new Lines(this.infos.map(function (info, i) {
if (info.line && (i > 0 || !skipFirstLine)) {
info = tslib_1.__assign(tslib_1.__assign({}, info), { indent: Math.max(0, info.indent - width) });
}
return info;
}));
if (this.mappings.length > 0) {
var newMappings_1 = lines.mappings;
(0, tiny_invariant_1.default)(newMappings_1.length === 0);
this.mappings.forEach(function (mapping) {
newMappings_1.push(mapping.indent(width, skipFirstLine, true));
});
}
return lines;
};
Lines.prototype.indent = function (by) {
if (by === 0) {
return this;
}
var lines = new Lines(this.infos.map(function (info) {
if (info.line && !info.locked) {
info = tslib_1.__assign(tslib_1.__assign({}, info), { indent: info.indent + by });
}
return info;
}));
if (this.mappings.length > 0) {
var newMappings_2 = lines.mappings;
(0, tiny_invariant_1.default)(newMappings_2.length === 0);
this.mappings.forEach(function (mapping) {
newMappings_2.push(mapping.indent(by));
});
}
return lines;
};
Lines.prototype.indentTail = function (by) {
if (by === 0) {
return this;
}
if (this.length < 2) {
return this;
}
var lines = new Lines(this.infos.map(function (info, i) {
if (i > 0 && info.line && !info.locked) {
info = tslib_1.__assign(tslib_1.__assign({}, info), { indent: info.indent + by });
}
return info;
}));
if (this.mappings.length > 0) {
var newMappings_3 = lines.mappings;
(0, tiny_invariant_1.default)(newMappings_3.length === 0);
this.mappings.forEach(function (mapping) {
newMappings_3.push(mapping.indent(by, true));
});
}
return lines;
};
Lines.prototype.lockIndentTail = function () {
if (this.length < 2) {
return this;
}
return new Lines(this.infos.map(function (info, i) { return (tslib_1.__assign(tslib_1.__assign({}, info), { locked: i > 0 })); }));
};
Lines.prototype.getIndentAt = function (line) {
(0, tiny_invariant_1.default)(line >= 1, "no line " + line + " (line numbers start from 1)");
return Math.max(this.infos[line - 1].indent, 0);
};
Lines.prototype.guessTabWidth = function () {
if (typeof this.cachedTabWidth === "number") {
return this.cachedTabWidth;
}
var counts = []; // Sparse array.
var lastIndent = 0;
for (var line = 1, last = this.length; line <= last; ++line) {
var info = this.infos[line - 1];
var sliced = info.line.slice(info.sliceStart, info.sliceEnd);
// Whitespace-only lines don't tell us much about the likely tab
// width of this code.
if (isOnlyWhitespace(sliced)) {
continue;
}
var diff = Math.abs(info.indent - lastIndent);
counts[diff] = ~~counts[diff] + 1;
lastIndent = info.indent;
}
var maxCount = -1;
var result = 2;
for (var tabWidth = 1; tabWidth < counts.length; tabWidth += 1) {
if (hasOwn.call(counts, tabWidth) && counts[tabWidth] > maxCount) {
maxCount = counts[tabWidth];
result = tabWidth;
}
}
return (this.cachedTabWidth = result);
};
// Determine if the list of lines has a first line that starts with a //
// or /* comment. If this is the case, the code may need to be wrapped in
// parens to avoid ASI issues.
Lines.prototype.startsWithComment = function () {
if (this.infos.length === 0) {
return false;
}
var firstLineInfo = this.infos[0], sliceStart = firstLineInfo.sliceStart, sliceEnd = firstLineInfo.sliceEnd, firstLine = firstLineInfo.line.slice(sliceStart, sliceEnd).trim();
return (firstLine.length === 0 ||
firstLine.slice(0, 2) === "//" ||
firstLine.slice(0, 2) === "/*");
};
Lines.prototype.isOnlyWhitespace = function () {
return isOnlyWhitespace(this.toString());
};
Lines.prototype.isPrecededOnlyByWhitespace = function (pos) {
var info = this.infos[pos.line - 1];
var indent = Math.max(info.indent, 0);
var diff = pos.column - indent;
if (diff <= 0) {
// If pos.column does not exceed the indentation amount, then
// there must be only whitespace before it.
return true;
}
var start = info.sliceStart;
var end = Math.min(start + diff, info.sliceEnd);
var prefix = info.line.slice(start, end);
return isOnlyWhitespace(prefix);
};
Lines.prototype.getLineLength = function (line) {
var info = this.infos[line - 1];
return this.getIndentAt(line) + info.sliceEnd - info.sliceStart;
};
Lines.prototype.nextPos = function (pos, skipSpaces) {
if (skipSpaces === void 0) { skipSpaces = false; }
var l = Math.max(pos.line, 0), c = Math.max(pos.column, 0);
if (c < this.getLineLength(l)) {
pos.column += 1;
return skipSpaces ? !!this.skipSpaces(pos, false, true) : true;
}
if (l < this.length) {
pos.line += 1;
pos.column = 0;
return skipSpaces ? !!this.skipSpaces(pos, false, true) : true;
}
return false;
};
Lines.prototype.prevPos = function (pos, skipSpaces) {
if (skipSpaces === void 0) { skipSpaces = false; }
var l = pos.line, c = pos.column;
if (c < 1) {
l -= 1;
if (l < 1)
return false;
c = this.getLineLength(l);
}
else {
c = Math.min(c - 1, this.getLineLength(l));
}
pos.line = l;
pos.column = c;
return skipSpaces ? !!this.skipSpaces(pos, true, true) : true;
};
Lines.prototype.firstPos = function () {
// Trivial, but provided for completeness.
return { line: 1, column: 0 };
};
Lines.prototype.lastPos = function () {
return {
line: this.length,
column: this.getLineLength(this.length),
};
};
Lines.prototype.skipSpaces = function (pos, backward, modifyInPlace) {
if (backward === void 0) { backward = false; }
if (modifyInPlace === void 0) { modifyInPlace = false; }
if (pos) {
pos = modifyInPlace
? pos
: {
line: pos.line,
column: pos.column,
};
}
else if (backward) {
pos = this.lastPos();
}
else {
pos = this.firstPos();
}
if (backward) {
while (this.prevPos(pos)) {
if (!isOnlyWhitespace(this.charAt(pos)) && this.nextPos(pos)) {
return pos;
}
}
return null;
}
else {
while (isOnlyWhitespace(this.charAt(pos))) {
if (!this.nextPos(pos)) {
return null;
}
}
return pos;
}
};
Lines.prototype.trimLeft = function () {
var pos = this.skipSpaces(this.firstPos(), false, true);
return pos ? this.slice(pos) : emptyLines;
};
Lines.prototype.trimRight = function () {
var pos = this.skipSpaces(this.lastPos(), true, true);
return pos ? this.slice(this.firstPos(), pos) : emptyLines;
};
Lines.prototype.trim = function () {
var start = this.skipSpaces(this.firstPos(), false, true);
if (start === null) {
return emptyLines;
}
var end = this.skipSpaces(this.lastPos(), true, true);
if (end === null) {
return emptyLines;
}
return this.slice(start, end);
};
Lines.prototype.eachPos = function (callback, startPos, skipSpaces) {
if (startPos === void 0) { startPos = this.firstPos(); }
if (skipSpaces === void 0) { skipSpaces = false; }
var pos = this.firstPos();
if (startPos) {
(pos.line = startPos.line), (pos.column = startPos.column);
}
if (skipSpaces && !this.skipSpaces(pos, false, true)) {
return; // Encountered nothing but spaces.
}
do
callback.call(this, pos);
while (this.nextPos(pos, skipSpaces));
};
Lines.prototype.bootstrapSlice = function (start, end) {
var strings = this.toString()
.split(lineTerminatorSeqExp)
.slice(start.line - 1, end.line);
if (strings.length > 0) {
strings.push(strings.pop().slice(0, end.column));
strings[0] = strings[0].slice(start.column);
}
return fromString(strings.join("\n"));
};
Lines.prototype.slice = function (start, end) {
if (!end) {
if (!start) {
// The client seems to want a copy of this Lines object, but
// Lines objects are immutable, so it's perfectly adequate to
// return the same object.
return this;
}
// Slice to the end if no end position was provided.
end = this.lastPos();
}
if (!start) {
throw new Error("cannot slice with end but not start");
}
var sliced = this.infos.slice(start.line - 1, end.line);
if (start.line === end.line) {
sliced[0] = sliceInfo(sliced[0], start.column, end.column);
}
else {
(0, tiny_invariant_1.default)(start.line < end.line);
sliced[0] = sliceInfo(sliced[0], start.column);
sliced.push(sliceInfo(sliced.pop(), 0, end.column));
}
var lines = new Lines(sliced);
if (this.mappings.length > 0) {
var newMappings_4 = lines.mappings;
(0, tiny_invariant_1.default)(newMappings_4.length === 0);
this.mappings.forEach(function (mapping) {
var sliced = mapping.slice(this, start, end);
if (sliced) {
newMappings_4.push(sliced);
}
}, this);
}
return lines;
};
Lines.prototype.bootstrapSliceString = function (start, end, options) {
return this.slice(start, end).toString(options);
};
Lines.prototype.sliceString = function (start, end, options) {
if (start === void 0) { start = this.firstPos(); }
if (end === void 0) { end = this.lastPos(); }
var _a = (0, options_1.normalize)(options), tabWidth = _a.tabWidth, useTabs = _a.useTabs, reuseWhitespace = _a.reuseWhitespace, lineTerminator = _a.lineTerminator;
var parts = [];
for (var line = start.line; line <= end.line; ++line) {
var info = this.infos[line - 1];
if (line === start.line) {
if (line === end.line) {
info = sliceInfo(info, start.column, end.column);
}
else {
info = sliceInfo(info, start.column);
}
}
else if (line === end.line) {
info = sliceInfo(info, 0, end.column);
}
var indent = Math.max(info.indent, 0);
var before_1 = info.line.slice(0, info.sliceStart);
if (reuseWhitespace &&
isOnlyWhitespace(before_1) &&
countSpaces(before_1, tabWidth) === indent) {
// Reuse original spaces if the indentation is correct.
parts.push(info.line.slice(0, info.sliceEnd));
continue;
}
var tabs = 0;
var spaces = indent;
if (useTabs) {
tabs = Math.floor(indent / tabWidth);
spaces -= tabs * tabWidth;
}
var result = "";
if (tabs > 0) {
result += new Array(tabs + 1).join("\t");
}
if (spaces > 0) {
result += new Array(spaces + 1).join(" ");
}
result += info.line.slice(info.sliceStart, info.sliceEnd);
parts.push(result);
}
return parts.join(lineTerminator);
};
Lines.prototype.isEmpty = function () {
return this.length < 2 && this.getLineLength(1) < 1;
};
Lines.prototype.join = function (elements) {
var separator = this;
var infos = [];
var mappings = [];
var prevInfo;
function appendLines(linesOrNull) {
if (linesOrNull === null) {
return;
}
if (prevInfo) {
var info = linesOrNull.infos[0];
var indent = new Array(info.indent + 1).join(" ");
var prevLine_1 = infos.length;
var prevColumn_1 = Math.max(prevInfo.indent, 0) +
prevInfo.sliceEnd -
prevInfo.sliceStart;
prevInfo.line =
prevInfo.line.slice(0, prevInfo.sliceEnd) +
indent +
info.line.slice(info.sliceStart, info.sliceEnd);
// If any part of a line is indentation-locked, the whole line
// will be indentation-locked.
prevInfo.locked = prevInfo.locked || info.locked;
prevInfo.sliceEnd = prevInfo.line.length;
if (linesOrNull.mappings.length > 0) {
linesOrNull.mappings.forEach(function (mapping) {
mappings.push(mapping.add(prevLine_1, prevColumn_1));
});
}
}
else if (linesOrNull.mappings.length > 0) {
mappings.push.apply(mappings, linesOrNull.mappings);
}
linesOrNull.infos.forEach(function (info, i) {
if (!prevInfo || i > 0) {
prevInfo = tslib_1.__assign({}, info);
infos.push(prevInfo);
}
});
}
function appendWithSeparator(linesOrNull, i) {
if (i > 0)
appendLines(separator);
appendLines(linesOrNull);
}
elements
.map(function (elem) {
var lines = fromString(elem);
if (lines.isEmpty())
return null;
return lines;
})
.forEach(function (linesOrNull, i) {
if (separator.isEmpty()) {
appendLines(linesOrNull);
}
else {
appendWithSeparator(linesOrNull, i);
}
});
if (infos.length < 1)
return emptyLines;
var lines = new Lines(infos);
lines.mappings = mappings;
return lines;
};
Lines.prototype.concat = function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
var list = [this];
list.push.apply(list, args);
(0, tiny_invariant_1.default)(list.length === args.length + 1);
return emptyLines.join(list);
};
return Lines;
}());
exports.Lines = Lines;
var fromStringCache = {};
var hasOwn = fromStringCache.hasOwnProperty;
var maxCacheKeyLen = 10;
function countSpaces(spaces, tabWidth) {
var count = 0;
var len = spaces.length;
for (var i = 0; i < len; ++i) {
switch (spaces.charCodeAt(i)) {
case 9: {
// '\t'
(0, tiny_invariant_1.default)(typeof tabWidth === "number");
(0, tiny_invariant_1.default)(tabWidth > 0);
var next = Math.ceil(count / tabWidth) * tabWidth;
if (next === count) {
count += tabWidth;
}
else {
count = next;
}
break;
}
case 11: // '\v'
case 12: // '\f'
case 13: // '\r'
case 0xfeff: // zero-width non-breaking space
// These characters contribute nothing to indentation.
break;
case 32: // ' '
default:
// Treat all other whitespace like ' '.
count += 1;
break;
}
}
return count;
}
exports.countSpaces = countSpaces;
var leadingSpaceExp = /^\s*/;
// As specified here: http://www.ecma-international.org/ecma-262/6.0/#sec-line-terminators
var lineTerminatorSeqExp = /\u000D\u000A|\u000D(?!\u000A)|\u000A|\u2028|\u2029/;
/**
* @param {Object} options - Options object that configures printing.
*/
function fromString(string, options) {
if (string instanceof Lines)
return string;
string += "";
var tabWidth = options && options.tabWidth;
var tabless = string.indexOf("\t") < 0;
var cacheable = !options && tabless && string.length <= maxCacheKeyLen;
(0, tiny_invariant_1.default)(tabWidth || tabless, "No tab width specified but encountered tabs in string\n" + string);
if (cacheable && hasOwn.call(fromStringCache, string))
return fromStringCache[string];
var lines = new Lines(string.split(lineTerminatorSeqExp).map(function (line) {
// TODO: handle null exec result
var spaces = leadingSpaceExp.exec(line)[0];
return {
line: line,
indent: countSpaces(spaces, tabWidth),
// Boolean indicating whether this line can be reindented.
locked: false,
sliceStart: spaces.length,
sliceEnd: line.length,
};
}), (0, options_1.normalize)(options).sourceFileName);
if (cacheable)
fromStringCache[string] = lines;
return lines;
}
exports.fromString = fromString;
function isOnlyWhitespace(string) {
return !/\S/.test(string);
}
function sliceInfo(info, startCol, endCol) {
var sliceStart = info.sliceStart;
var sliceEnd = info.sliceEnd;
var indent = Math.max(info.indent, 0);
var lineLength = indent + sliceEnd - sliceStart;
if (typeof endCol === "undefined") {
endCol = lineLength;
}
startCol = Math.max(startCol, 0);
endCol = Math.min(endCol, lineLength);
endCol = Math.max(endCol, startCol);
if (endCol < indent) {
indent = endCol;
sliceEnd = sliceStart;
}
else {
sliceEnd -= lineLength - endCol;
}
lineLength = endCol;
lineLength -= startCol;
if (startCol < indent) {
indent -= startCol;
}
else {
startCol -= indent;
indent = 0;
sliceStart += startCol;
}
(0, tiny_invariant_1.default)(indent >= 0);
(0, tiny_invariant_1.default)(sliceStart <= sliceEnd);
(0, tiny_invariant_1.default)(lineLength === indent + sliceEnd - sliceStart);
if (info.indent === indent &&
info.sliceStart === sliceStart &&
info.sliceEnd === sliceEnd) {
return info;
}
return {
line: info.line,
indent: indent,
// A destructive slice always unlocks indentation.
locked: false,
sliceStart: sliceStart,
sliceEnd: sliceEnd,
};
}
function concat(elements) {
return emptyLines.join(elements);
}
exports.concat = concat;
// The emptyLines object needs to be created all the way down here so that
// Lines.prototype will be fully populated.
var emptyLines = fromString("");

15
frontend/node_modules/recast/lib/mapping.d.ts generated vendored Normal file
View File

@@ -0,0 +1,15 @@
import { namedTypes } from "ast-types";
import { Lines } from "./lines";
type Pos = namedTypes.Position;
type Loc = namedTypes.SourceLocation;
export default class Mapping {
sourceLines: Lines;
sourceLoc: Loc;
targetLoc: Loc;
constructor(sourceLines: Lines, sourceLoc: Loc, targetLoc?: Loc);
slice(lines: Lines, start: Pos, end?: Pos): Mapping | null;
add(line: number, column: number): Mapping;
subtract(line: number, column: number): Mapping;
indent(by: number, skipFirstLine?: boolean, noNegativeColumns?: boolean): Mapping;
}
export {};

197
frontend/node_modules/recast/lib/mapping.js generated vendored Normal file
View File

@@ -0,0 +1,197 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var tiny_invariant_1 = tslib_1.__importDefault(require("tiny-invariant"));
var util_1 = require("./util");
var Mapping = /** @class */ (function () {
function Mapping(sourceLines, sourceLoc, targetLoc) {
if (targetLoc === void 0) { targetLoc = sourceLoc; }
this.sourceLines = sourceLines;
this.sourceLoc = sourceLoc;
this.targetLoc = targetLoc;
}
Mapping.prototype.slice = function (lines, start, end) {
if (end === void 0) { end = lines.lastPos(); }
var sourceLines = this.sourceLines;
var sourceLoc = this.sourceLoc;
var targetLoc = this.targetLoc;
function skip(name) {
var sourceFromPos = sourceLoc[name];
var targetFromPos = targetLoc[name];
var targetToPos = start;
if (name === "end") {
targetToPos = end;
}
else {
(0, tiny_invariant_1.default)(name === "start");
}
return skipChars(sourceLines, sourceFromPos, lines, targetFromPos, targetToPos);
}
if ((0, util_1.comparePos)(start, targetLoc.start) <= 0) {
if ((0, util_1.comparePos)(targetLoc.end, end) <= 0) {
targetLoc = {
start: subtractPos(targetLoc.start, start.line, start.column),
end: subtractPos(targetLoc.end, start.line, start.column),
};
// The sourceLoc can stay the same because the contents of the
// targetLoc have not changed.
}
else if ((0, util_1.comparePos)(end, targetLoc.start) <= 0) {
return null;
}
else {
sourceLoc = {
start: sourceLoc.start,
end: skip("end"),
};
targetLoc = {
start: subtractPos(targetLoc.start, start.line, start.column),
end: subtractPos(end, start.line, start.column),
};
}
}
else {
if ((0, util_1.comparePos)(targetLoc.end, start) <= 0) {
return null;
}
if ((0, util_1.comparePos)(targetLoc.end, end) <= 0) {
sourceLoc = {
start: skip("start"),
end: sourceLoc.end,
};
targetLoc = {
// Same as subtractPos(start, start.line, start.column):
start: { line: 1, column: 0 },
end: subtractPos(targetLoc.end, start.line, start.column),
};
}
else {
sourceLoc = {
start: skip("start"),
end: skip("end"),
};
targetLoc = {
// Same as subtractPos(start, start.line, start.column):
start: { line: 1, column: 0 },
end: subtractPos(end, start.line, start.column),
};
}
}
return new Mapping(this.sourceLines, sourceLoc, targetLoc);
};
Mapping.prototype.add = function (line, column) {
return new Mapping(this.sourceLines, this.sourceLoc, {
start: addPos(this.targetLoc.start, line, column),
end: addPos(this.targetLoc.end, line, column),
});
};
Mapping.prototype.subtract = function (line, column) {
return new Mapping(this.sourceLines, this.sourceLoc, {
start: subtractPos(this.targetLoc.start, line, column),
end: subtractPos(this.targetLoc.end, line, column),
});
};
Mapping.prototype.indent = function (by, skipFirstLine, noNegativeColumns) {
if (skipFirstLine === void 0) { skipFirstLine = false; }
if (noNegativeColumns === void 0) { noNegativeColumns = false; }
if (by === 0) {
return this;
}
var targetLoc = this.targetLoc;
var startLine = targetLoc.start.line;
var endLine = targetLoc.end.line;
if (skipFirstLine && startLine === 1 && endLine === 1) {
return this;
}
targetLoc = {
start: targetLoc.start,
end: targetLoc.end,
};
if (!skipFirstLine || startLine > 1) {
var startColumn = targetLoc.start.column + by;
targetLoc.start = {
line: startLine,
column: noNegativeColumns ? Math.max(0, startColumn) : startColumn,
};
}
if (!skipFirstLine || endLine > 1) {
var endColumn = targetLoc.end.column + by;
targetLoc.end = {
line: endLine,
column: noNegativeColumns ? Math.max(0, endColumn) : endColumn,
};
}
return new Mapping(this.sourceLines, this.sourceLoc, targetLoc);
};
return Mapping;
}());
exports.default = Mapping;
function addPos(toPos, line, column) {
return {
line: toPos.line + line - 1,
column: toPos.line === 1 ? toPos.column + column : toPos.column,
};
}
function subtractPos(fromPos, line, column) {
return {
line: fromPos.line - line + 1,
column: fromPos.line === line ? fromPos.column - column : fromPos.column,
};
}
function skipChars(sourceLines, sourceFromPos, targetLines, targetFromPos, targetToPos) {
var targetComparison = (0, util_1.comparePos)(targetFromPos, targetToPos);
if (targetComparison === 0) {
// Trivial case: no characters to skip.
return sourceFromPos;
}
var sourceCursor, targetCursor;
if (targetComparison < 0) {
// Skipping forward.
sourceCursor =
sourceLines.skipSpaces(sourceFromPos) || sourceLines.lastPos();
targetCursor =
targetLines.skipSpaces(targetFromPos) || targetLines.lastPos();
var lineDiff = targetToPos.line - targetCursor.line;
sourceCursor.line += lineDiff;
targetCursor.line += lineDiff;
if (lineDiff > 0) {
// If jumping to later lines, reset columns to the beginnings
// of those lines.
sourceCursor.column = 0;
targetCursor.column = 0;
}
else {
(0, tiny_invariant_1.default)(lineDiff === 0);
}
while ((0, util_1.comparePos)(targetCursor, targetToPos) < 0 &&
targetLines.nextPos(targetCursor, true)) {
(0, tiny_invariant_1.default)(sourceLines.nextPos(sourceCursor, true));
(0, tiny_invariant_1.default)(sourceLines.charAt(sourceCursor) === targetLines.charAt(targetCursor));
}
}
else {
// Skipping backward.
sourceCursor =
sourceLines.skipSpaces(sourceFromPos, true) || sourceLines.firstPos();
targetCursor =
targetLines.skipSpaces(targetFromPos, true) || targetLines.firstPos();
var lineDiff = targetToPos.line - targetCursor.line;
sourceCursor.line += lineDiff;
targetCursor.line += lineDiff;
if (lineDiff < 0) {
// If jumping to earlier lines, reset columns to the ends of
// those lines.
sourceCursor.column = sourceLines.getLineLength(sourceCursor.line);
targetCursor.column = targetLines.getLineLength(targetCursor.line);
}
else {
(0, tiny_invariant_1.default)(lineDiff === 0);
}
while ((0, util_1.comparePos)(targetToPos, targetCursor) < 0 &&
targetLines.prevPos(targetCursor, true)) {
(0, tiny_invariant_1.default)(sourceLines.prevPos(sourceCursor, true));
(0, tiny_invariant_1.default)(sourceLines.charAt(sourceCursor) === targetLines.charAt(targetCursor));
}
}
return sourceCursor;
}

147
frontend/node_modules/recast/lib/options.d.ts generated vendored Normal file
View File

@@ -0,0 +1,147 @@
/**
* All Recast API functions take second parameter with configuration options,
* documented in options.js
*/
export interface Options extends DeprecatedOptions {
/**
* If you want to use a different branch of esprima, or any other module
* that supports a .parse function, pass that module object to
* recast.parse as options.parser (legacy synonym: options.esprima).
* @default require("recast/parsers/esprima")
*/
parser?: any;
/**
* Number of spaces the pretty-printer should use per tab for
* indentation. If you do not pass this option explicitly, it will be
* (quite reliably!) inferred from the original code.
* @default 4
*/
tabWidth?: number;
/**
* If you really want the pretty-printer to use tabs instead of spaces,
* make this option true.
* @default false
*/
useTabs?: boolean;
/**
* The reprinting code leaves leading whitespace untouched unless it has
* to reindent a line, or you pass false for this option.
* @default true
*/
reuseWhitespace?: boolean;
/**
* Override this option to use a different line terminator, e.g. \r\n.
* @default require("os").EOL || "\n"
*/
lineTerminator?: string;
/**
* Some of the pretty-printer code (such as that for printing function
* parameter lists) makes a valiant attempt to prevent really long
* lines. You can adjust the limit by changing this option; however,
* there is no guarantee that line length will fit inside this limit.
* @default 74
*/
wrapColumn?: number;
/**
* Pass a string as options.sourceFileName to recast.parse to tell the
* reprinter to keep track of reused code so that it can construct a
* source map automatically.
* @default null
*/
sourceFileName?: string | null;
/**
* Pass a string as options.sourceMapName to recast.print, and (provided
* you passed options.sourceFileName earlier) the PrintResult of
* recast.print will have a .map property for the generated source map.
* @default null
*/
sourceMapName?: string | null;
/**
* If provided, this option will be passed along to the source map
* generator as a root directory for relative source file paths.
* @default null
*/
sourceRoot?: string | null;
/**
* If you provide a source map that was generated from a previous call
* to recast.print as options.inputSourceMap, the old source map will be
* composed with the new source map.
* @default null
*/
inputSourceMap?: string | null;
/**
* If you want esprima to generate .range information (recast only uses
* .loc internally), pass true for this option.
* @default false
*/
range?: boolean;
/**
* If you want esprima not to throw exceptions when it encounters
* non-fatal errors, keep this option true.
* @default true
*/
tolerant?: boolean;
/**
* If you want to override the quotes used in string literals, specify
* either "single", "double", or "auto" here ("auto" will select the one
* which results in the shorter literal) Otherwise, use double quotes.
* @default null
*/
quote?: "single" | "double" | "auto" | null;
/**
* Controls the printing of trailing commas in object literals, array
* expressions and function parameters.
*
* This option could either be:
* * Boolean - enable/disable in all contexts (objects, arrays and function params).
* * Object - enable/disable per context.
*
* Example:
* trailingComma: {
* objects: true,
* arrays: true,
* parameters: false,
* }
*
* @default false
*/
trailingComma?: boolean;
/**
* Controls the printing of spaces inside array brackets.
* See: http://eslint.org/docs/rules/array-bracket-spacing
* @default false
*/
arrayBracketSpacing?: boolean;
/**
* Controls the printing of spaces inside object literals,
* destructuring assignments, and import/export specifiers.
* See: http://eslint.org/docs/rules/object-curly-spacing
* @default true
*/
objectCurlySpacing?: boolean;
/**
* If you want parenthesis to wrap single-argument arrow function
* parameter lists, pass true for this option.
* @default false
*/
arrowParensAlways?: boolean;
/**
* There are 2 supported syntaxes (`,` and `;`) in Flow Object Types;
* The use of commas is in line with the more popular style and matches
* how objects are defined in JS, making it a bit more natural to write.
* @default true
*/
flowObjectCommas?: boolean;
/**
* Whether to return an array of .tokens on the root AST node.
* @default true
*/
tokens?: boolean;
}
interface DeprecatedOptions {
/** @deprecated */
esprima?: any;
}
export type NormalizedOptions = Required<Omit<Options, keyof DeprecatedOptions>>;
export declare function normalize(opts?: Options): NormalizedOptions;
export {};

55
frontend/node_modules/recast/lib/options.js generated vendored Normal file
View File

@@ -0,0 +1,55 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.normalize = void 0;
var util_1 = require("./util");
var defaults = {
parser: require("../parsers/esprima"),
tabWidth: 4,
useTabs: false,
reuseWhitespace: true,
lineTerminator: (0, util_1.getLineTerminator)(),
wrapColumn: 74,
sourceFileName: null,
sourceMapName: null,
sourceRoot: null,
inputSourceMap: null,
range: false,
tolerant: true,
quote: null,
trailingComma: false,
arrayBracketSpacing: false,
objectCurlySpacing: true,
arrowParensAlways: false,
flowObjectCommas: true,
tokens: true,
};
var hasOwn = defaults.hasOwnProperty;
// Copy options and fill in default values.
function normalize(opts) {
var options = opts || defaults;
function get(key) {
return hasOwn.call(options, key) ? options[key] : defaults[key];
}
return {
tabWidth: +get("tabWidth"),
useTabs: !!get("useTabs"),
reuseWhitespace: !!get("reuseWhitespace"),
lineTerminator: get("lineTerminator"),
wrapColumn: Math.max(get("wrapColumn"), 0),
sourceFileName: get("sourceFileName"),
sourceMapName: get("sourceMapName"),
sourceRoot: get("sourceRoot"),
inputSourceMap: get("inputSourceMap"),
parser: get("esprima") || get("parser"),
range: get("range"),
tolerant: get("tolerant"),
quote: get("quote"),
trailingComma: get("trailingComma"),
arrayBracketSpacing: get("arrayBracketSpacing"),
objectCurlySpacing: get("objectCurlySpacing"),
arrowParensAlways: get("arrowParensAlways"),
flowObjectCommas: get("flowObjectCommas"),
tokens: !!get("tokens"),
};
}
exports.normalize = normalize;

2
frontend/node_modules/recast/lib/parser.d.ts generated vendored Normal file
View File

@@ -0,0 +1,2 @@
import { Options } from "./options";
export declare function parse(source: string, options?: Partial<Options>): any;

250
frontend/node_modules/recast/lib/parser.js generated vendored Normal file
View File

@@ -0,0 +1,250 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.parse = void 0;
var tslib_1 = require("tslib");
var tiny_invariant_1 = tslib_1.__importDefault(require("tiny-invariant"));
var types = tslib_1.__importStar(require("ast-types"));
var b = types.builders;
var isObject = types.builtInTypes.object;
var isArray = types.builtInTypes.array;
var options_1 = require("./options");
var lines_1 = require("./lines");
var comments_1 = require("./comments");
var util = tslib_1.__importStar(require("./util"));
function parse(source, options) {
options = (0, options_1.normalize)(options);
var lines = (0, lines_1.fromString)(source, options);
var sourceWithoutTabs = lines.toString({
tabWidth: options.tabWidth,
reuseWhitespace: false,
useTabs: false,
});
var comments = [];
var ast = options.parser.parse(sourceWithoutTabs, {
jsx: true,
loc: true,
locations: true,
range: options.range,
comment: true,
onComment: comments,
tolerant: util.getOption(options, "tolerant", true),
ecmaVersion: 6,
sourceType: util.getOption(options, "sourceType", "module"),
});
// Use ast.tokens if possible, and otherwise fall back to the Esprima
// tokenizer. All the preconfigured ../parsers/* expose ast.tokens
// automatically, but custom parsers might need additional configuration
// to avoid this fallback.
var tokens = Array.isArray(ast.tokens)
? ast.tokens
: require("esprima").tokenize(sourceWithoutTabs, {
loc: true,
});
// We will reattach the tokens array to the file object below.
delete ast.tokens;
// Make sure every token has a token.value string.
tokens.forEach(function (token) {
if (typeof token.value !== "string") {
token.value = lines.sliceString(token.loc.start, token.loc.end);
}
});
if (Array.isArray(ast.comments)) {
comments = ast.comments;
delete ast.comments;
}
if (ast.loc) {
// If the source was empty, some parsers give loc.{start,end}.line
// values of 0, instead of the minimum of 1.
util.fixFaultyLocations(ast, lines);
}
else {
ast.loc = {
start: lines.firstPos(),
end: lines.lastPos(),
};
}
ast.loc.lines = lines;
ast.loc.indent = 0;
var file;
var program;
if (ast.type === "Program") {
program = ast;
// In order to ensure we reprint leading and trailing program
// comments, wrap the original Program node with a File node. Only
// ESTree parsers (Acorn and Esprima) return a Program as the root AST
// node. Most other (Babylon-like) parsers return a File.
file = b.file(ast, options.sourceFileName || null);
file.loc = {
start: lines.firstPos(),
end: lines.lastPos(),
lines: lines,
indent: 0,
};
}
else if (ast.type === "File") {
file = ast;
program = file.program;
}
// Expose file.tokens unless the caller passed false for options.tokens.
if (options.tokens) {
file.tokens = tokens;
}
// Expand the Program's .loc to include all comments (not just those
// attached to the Program node, as its children may have comments as
// well), since sometimes program.loc.{start,end} will coincide with the
// .loc.{start,end} of the first and last *statements*, mistakenly
// excluding comments that fall outside that region.
var trueProgramLoc = util.getTrueLoc({
type: program.type,
loc: program.loc,
body: [],
comments: comments,
}, lines);
program.loc.start = trueProgramLoc.start;
program.loc.end = trueProgramLoc.end;
// Passing file.program here instead of just file means that initial
// comments will be attached to program.body[0] instead of program.
(0, comments_1.attach)(comments, program.body.length ? file.program : file, lines);
// Return a copy of the original AST so that any changes made may be
// compared to the original.
return new TreeCopier(lines, tokens).copy(file);
}
exports.parse = parse;
var TreeCopier = function TreeCopier(lines, tokens) {
(0, tiny_invariant_1.default)(this instanceof TreeCopier);
this.lines = lines;
this.tokens = tokens;
this.startTokenIndex = 0;
this.endTokenIndex = tokens.length;
this.indent = 0;
this.seen = new Map();
};
var TCp = TreeCopier.prototype;
TCp.copy = function (node) {
if (this.seen.has(node)) {
return this.seen.get(node);
}
if (isArray.check(node)) {
var copy_1 = new Array(node.length);
this.seen.set(node, copy_1);
node.forEach(function (item, i) {
copy_1[i] = this.copy(item);
}, this);
return copy_1;
}
if (!isObject.check(node)) {
return node;
}
util.fixFaultyLocations(node, this.lines);
var copy = Object.create(Object.getPrototypeOf(node), {
original: {
// Provide a link from the copy to the original.
value: node,
configurable: false,
enumerable: false,
writable: true,
},
});
this.seen.set(node, copy);
var loc = node.loc;
var oldIndent = this.indent;
var newIndent = oldIndent;
var oldStartTokenIndex = this.startTokenIndex;
var oldEndTokenIndex = this.endTokenIndex;
if (loc) {
// When node is a comment, we set node.loc.indent to
// node.loc.start.column so that, when/if we print the comment by
// itself, we can strip that much whitespace from the left margin of
// the comment. This only really matters for multiline Block comments,
// but it doesn't hurt for Line comments.
if (node.type === "Block" ||
node.type === "Line" ||
node.type === "CommentBlock" ||
node.type === "CommentLine" ||
this.lines.isPrecededOnlyByWhitespace(loc.start)) {
newIndent = this.indent = loc.start.column;
}
// Every node.loc has a reference to the original source lines as well
// as a complete list of source tokens.
loc.lines = this.lines;
loc.tokens = this.tokens;
loc.indent = newIndent;
// Set loc.start.token and loc.end.token such that
// loc.tokens.slice(loc.start.token, loc.end.token) returns a list of
// all the tokens that make up this node.
this.findTokenRange(loc);
}
var keys = Object.keys(node);
var keyCount = keys.length;
for (var i = 0; i < keyCount; ++i) {
var key = keys[i];
if (key === "loc") {
copy[key] = node[key];
}
else if (key === "tokens" && node.type === "File") {
// Preserve file.tokens (uncopied) in case client code cares about
// it, even though Recast ignores it when reprinting.
copy[key] = node[key];
}
else {
copy[key] = this.copy(node[key]);
}
}
this.indent = oldIndent;
this.startTokenIndex = oldStartTokenIndex;
this.endTokenIndex = oldEndTokenIndex;
return copy;
};
// If we didn't have any idea where in loc.tokens to look for tokens
// contained by this loc, a binary search would be appropriate, but
// because we maintain this.startTokenIndex and this.endTokenIndex as we
// traverse the AST, we only need to make small (linear) adjustments to
// those indexes with each recursive iteration.
TCp.findTokenRange = function (loc) {
// In the unlikely event that loc.tokens[this.startTokenIndex] starts
// *after* loc.start, we need to rewind this.startTokenIndex first.
while (this.startTokenIndex > 0) {
var token = loc.tokens[this.startTokenIndex];
if (util.comparePos(loc.start, token.loc.start) < 0) {
--this.startTokenIndex;
}
else
break;
}
// In the unlikely event that loc.tokens[this.endTokenIndex - 1] ends
// *before* loc.end, we need to fast-forward this.endTokenIndex first.
while (this.endTokenIndex < loc.tokens.length) {
var token = loc.tokens[this.endTokenIndex];
if (util.comparePos(token.loc.end, loc.end) < 0) {
++this.endTokenIndex;
}
else
break;
}
// Increment this.startTokenIndex until we've found the first token
// contained by this node.
while (this.startTokenIndex < this.endTokenIndex) {
var token = loc.tokens[this.startTokenIndex];
if (util.comparePos(token.loc.start, loc.start) < 0) {
++this.startTokenIndex;
}
else
break;
}
// Index into loc.tokens of the first token within this node.
loc.start.token = this.startTokenIndex;
// Decrement this.endTokenIndex until we've found the first token after
// this node (not contained by the node).
while (this.endTokenIndex > this.startTokenIndex) {
var token = loc.tokens[this.endTokenIndex - 1];
if (util.comparePos(loc.end, token.loc.end) < 0) {
--this.endTokenIndex;
}
else
break;
}
// Index into loc.tokens of the first token *after* this node.
// If loc.start.token === loc.end.token, the node contains no tokens,
// and the index is that of the next token following this node.
loc.end.token = this.endTokenIndex;
};

12
frontend/node_modules/recast/lib/patcher.d.ts generated vendored Normal file
View File

@@ -0,0 +1,12 @@
interface PatcherType {
replace(loc: any, lines: any): any;
get(loc?: any): any;
tryToReprintComments(newNode: any, oldNode: any, print: any): any;
deleteComments(node: any): any;
}
interface PatcherConstructor {
new (lines: any): PatcherType;
}
declare const Patcher: PatcherConstructor;
export { Patcher };
export declare function getReprinter(path: any): ((print: any) => any) | undefined;

386
frontend/node_modules/recast/lib/patcher.js generated vendored Normal file
View File

@@ -0,0 +1,386 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getReprinter = exports.Patcher = void 0;
var tslib_1 = require("tslib");
var tiny_invariant_1 = tslib_1.__importDefault(require("tiny-invariant"));
var linesModule = tslib_1.__importStar(require("./lines"));
var types = tslib_1.__importStar(require("ast-types"));
var Printable = types.namedTypes.Printable;
var Expression = types.namedTypes.Expression;
var ReturnStatement = types.namedTypes.ReturnStatement;
var SourceLocation = types.namedTypes.SourceLocation;
var util_1 = require("./util");
var fast_path_1 = tslib_1.__importDefault(require("./fast-path"));
var isObject = types.builtInTypes.object;
var isArray = types.builtInTypes.array;
var isString = types.builtInTypes.string;
var riskyAdjoiningCharExp = /[0-9a-z_$]/i;
var Patcher = function Patcher(lines) {
(0, tiny_invariant_1.default)(this instanceof Patcher);
(0, tiny_invariant_1.default)(lines instanceof linesModule.Lines);
var self = this, replacements = [];
self.replace = function (loc, lines) {
if (isString.check(lines))
lines = linesModule.fromString(lines);
replacements.push({
lines: lines,
start: loc.start,
end: loc.end,
});
};
self.get = function (loc) {
// If no location is provided, return the complete Lines object.
loc = loc || {
start: { line: 1, column: 0 },
end: { line: lines.length, column: lines.getLineLength(lines.length) },
};
var sliceFrom = loc.start, toConcat = [];
function pushSlice(from, to) {
(0, tiny_invariant_1.default)((0, util_1.comparePos)(from, to) <= 0);
toConcat.push(lines.slice(from, to));
}
replacements
.sort(function (a, b) { return (0, util_1.comparePos)(a.start, b.start); })
.forEach(function (rep) {
if ((0, util_1.comparePos)(sliceFrom, rep.start) > 0) {
// Ignore nested replacement ranges.
}
else {
pushSlice(sliceFrom, rep.start);
toConcat.push(rep.lines);
sliceFrom = rep.end;
}
});
pushSlice(sliceFrom, loc.end);
return linesModule.concat(toConcat);
};
};
exports.Patcher = Patcher;
var Pp = Patcher.prototype;
Pp.tryToReprintComments = function (newNode, oldNode, print) {
var patcher = this;
if (!newNode.comments && !oldNode.comments) {
// We were (vacuously) able to reprint all the comments!
return true;
}
var newPath = fast_path_1.default.from(newNode);
var oldPath = fast_path_1.default.from(oldNode);
newPath.stack.push("comments", getSurroundingComments(newNode));
oldPath.stack.push("comments", getSurroundingComments(oldNode));
var reprints = [];
var ableToReprintComments = findArrayReprints(newPath, oldPath, reprints);
// No need to pop anything from newPath.stack or oldPath.stack, since
// newPath and oldPath are fresh local variables.
if (ableToReprintComments && reprints.length > 0) {
reprints.forEach(function (reprint) {
var oldComment = reprint.oldPath.getValue();
(0, tiny_invariant_1.default)(oldComment.leading || oldComment.trailing);
patcher.replace(oldComment.loc,
// Comments can't have .comments, so it doesn't matter whether we
// print with comments or without.
print(reprint.newPath).indentTail(oldComment.loc.indent));
});
}
return ableToReprintComments;
};
// Get all comments that are either leading or trailing, ignoring any
// comments that occur inside node.loc. Returns an empty array for nodes
// with no leading or trailing comments.
function getSurroundingComments(node) {
var result = [];
if (node.comments && node.comments.length > 0) {
node.comments.forEach(function (comment) {
if (comment.leading || comment.trailing) {
result.push(comment);
}
});
}
return result;
}
Pp.deleteComments = function (node) {
if (!node.comments) {
return;
}
var patcher = this;
node.comments.forEach(function (comment) {
if (comment.leading) {
// Delete leading comments along with any trailing whitespace they
// might have.
patcher.replace({
start: comment.loc.start,
end: node.loc.lines.skipSpaces(comment.loc.end, false, false),
}, "");
}
else if (comment.trailing) {
// Delete trailing comments along with any leading whitespace they
// might have.
patcher.replace({
start: node.loc.lines.skipSpaces(comment.loc.start, true, false),
end: comment.loc.end,
}, "");
}
});
};
function getReprinter(path) {
(0, tiny_invariant_1.default)(path instanceof fast_path_1.default);
// Make sure that this path refers specifically to a Node, rather than
// some non-Node subproperty of a Node.
var node = path.getValue();
if (!Printable.check(node))
return;
var orig = node.original;
var origLoc = orig && orig.loc;
var lines = origLoc && origLoc.lines;
var reprints = [];
if (!lines || !findReprints(path, reprints))
return;
return function (print) {
var patcher = new Patcher(lines);
reprints.forEach(function (reprint) {
var newNode = reprint.newPath.getValue();
var oldNode = reprint.oldPath.getValue();
SourceLocation.assert(oldNode.loc, true);
var needToPrintNewPathWithComments = !patcher.tryToReprintComments(newNode, oldNode, print);
if (needToPrintNewPathWithComments) {
// Since we were not able to preserve all leading/trailing
// comments, we delete oldNode's comments, print newPath with
// comments, and then patch the resulting lines where oldNode used
// to be.
patcher.deleteComments(oldNode);
}
var newLines = print(reprint.newPath, {
includeComments: needToPrintNewPathWithComments,
// If the oldNode we're replacing already had parentheses, we may
// not need to print the new node with any extra parentheses,
// because the existing parentheses will suffice. However, if the
// newNode has a different type than the oldNode, let the printer
// decide if reprint.newPath needs parentheses, as usual.
avoidRootParens: oldNode.type === newNode.type && reprint.oldPath.hasParens(),
}).indentTail(oldNode.loc.indent);
var nls = needsLeadingSpace(lines, oldNode.loc, newLines);
var nts = needsTrailingSpace(lines, oldNode.loc, newLines);
// If we try to replace the argument of a ReturnStatement like
// return"asdf" with e.g. a literal null expression, we run the risk
// of ending up with returnnull, so we need to add an extra leading
// space in situations where that might happen. Likewise for
// "asdf"in obj. See #170.
if (nls || nts) {
var newParts = [];
nls && newParts.push(" ");
newParts.push(newLines);
nts && newParts.push(" ");
newLines = linesModule.concat(newParts);
}
patcher.replace(oldNode.loc, newLines);
});
// Recall that origLoc is the .loc of an ancestor node that is
// guaranteed to contain all the reprinted nodes and comments.
var patchedLines = patcher.get(origLoc).indentTail(-orig.loc.indent);
if (path.needsParens()) {
return linesModule.concat(["(", patchedLines, ")"]);
}
return patchedLines;
};
}
exports.getReprinter = getReprinter;
// If the last character before oldLoc and the first character of newLines
// are both identifier characters, they must be separated by a space,
// otherwise they will most likely get fused together into a single token.
function needsLeadingSpace(oldLines, oldLoc, newLines) {
var posBeforeOldLoc = (0, util_1.copyPos)(oldLoc.start);
// The character just before the location occupied by oldNode.
var charBeforeOldLoc = oldLines.prevPos(posBeforeOldLoc) && oldLines.charAt(posBeforeOldLoc);
// First character of the reprinted node.
var newFirstChar = newLines.charAt(newLines.firstPos());
return (charBeforeOldLoc &&
riskyAdjoiningCharExp.test(charBeforeOldLoc) &&
newFirstChar &&
riskyAdjoiningCharExp.test(newFirstChar));
}
// If the last character of newLines and the first character after oldLoc
// are both identifier characters, they must be separated by a space,
// otherwise they will most likely get fused together into a single token.
function needsTrailingSpace(oldLines, oldLoc, newLines) {
// The character just after the location occupied by oldNode.
var charAfterOldLoc = oldLines.charAt(oldLoc.end);
var newLastPos = newLines.lastPos();
// Last character of the reprinted node.
var newLastChar = newLines.prevPos(newLastPos) && newLines.charAt(newLastPos);
return (newLastChar &&
riskyAdjoiningCharExp.test(newLastChar) &&
charAfterOldLoc &&
riskyAdjoiningCharExp.test(charAfterOldLoc));
}
function findReprints(newPath, reprints) {
var newNode = newPath.getValue();
Printable.assert(newNode);
var oldNode = newNode.original;
Printable.assert(oldNode);
(0, tiny_invariant_1.default)(reprints.length === 0);
if (newNode.type !== oldNode.type) {
return false;
}
var oldPath = new fast_path_1.default(oldNode);
var canReprint = findChildReprints(newPath, oldPath, reprints);
if (!canReprint) {
// Make absolutely sure the calling code does not attempt to reprint
// any nodes.
reprints.length = 0;
}
return canReprint;
}
function findAnyReprints(newPath, oldPath, reprints) {
var newNode = newPath.getValue();
var oldNode = oldPath.getValue();
if (newNode === oldNode)
return true;
if (isArray.check(newNode))
return findArrayReprints(newPath, oldPath, reprints);
if (isObject.check(newNode))
return findObjectReprints(newPath, oldPath, reprints);
return false;
}
function findArrayReprints(newPath, oldPath, reprints) {
var newNode = newPath.getValue();
var oldNode = oldPath.getValue();
if (newNode === oldNode ||
newPath.valueIsDuplicate() ||
oldPath.valueIsDuplicate()) {
return true;
}
isArray.assert(newNode);
var len = newNode.length;
if (!(isArray.check(oldNode) && oldNode.length === len))
return false;
for (var i = 0; i < len; ++i) {
newPath.stack.push(i, newNode[i]);
oldPath.stack.push(i, oldNode[i]);
var canReprint = findAnyReprints(newPath, oldPath, reprints);
newPath.stack.length -= 2;
oldPath.stack.length -= 2;
if (!canReprint) {
return false;
}
}
return true;
}
function findObjectReprints(newPath, oldPath, reprints) {
var newNode = newPath.getValue();
isObject.assert(newNode);
if (newNode.original === null) {
// If newNode.original node was set to null, reprint the node.
return false;
}
var oldNode = oldPath.getValue();
if (!isObject.check(oldNode))
return false;
if (newNode === oldNode ||
newPath.valueIsDuplicate() ||
oldPath.valueIsDuplicate()) {
return true;
}
if (Printable.check(newNode)) {
if (!Printable.check(oldNode)) {
return false;
}
var newParentNode = newPath.getParentNode();
var oldParentNode = oldPath.getParentNode();
if (oldParentNode !== null &&
oldParentNode.type === "FunctionTypeAnnotation" &&
newParentNode !== null &&
newParentNode.type === "FunctionTypeAnnotation") {
var oldNeedsParens = oldParentNode.params.length !== 1 || !!oldParentNode.params[0].name;
var newNeedParens = newParentNode.params.length !== 1 || !!newParentNode.params[0].name;
if (!oldNeedsParens && newNeedParens) {
return false;
}
}
// Here we need to decide whether the reprinted code for newNode is
// appropriate for patching into the location of oldNode.
if (newNode.type === oldNode.type) {
var childReprints = [];
if (findChildReprints(newPath, oldPath, childReprints)) {
reprints.push.apply(reprints, childReprints);
}
else if (oldNode.loc) {
// If we have no .loc information for oldNode, then we won't be
// able to reprint it.
reprints.push({
oldPath: oldPath.copy(),
newPath: newPath.copy(),
});
}
else {
return false;
}
return true;
}
if (Expression.check(newNode) &&
Expression.check(oldNode) &&
// If we have no .loc information for oldNode, then we won't be
// able to reprint it.
oldNode.loc) {
// If both nodes are subtypes of Expression, then we should be able
// to fill the location occupied by the old node with code printed
// for the new node with no ill consequences.
reprints.push({
oldPath: oldPath.copy(),
newPath: newPath.copy(),
});
return true;
}
// The nodes have different types, and at least one of the types is
// not a subtype of the Expression type, so we cannot safely assume
// the nodes are syntactically interchangeable.
return false;
}
return findChildReprints(newPath, oldPath, reprints);
}
function findChildReprints(newPath, oldPath, reprints) {
var newNode = newPath.getValue();
var oldNode = oldPath.getValue();
isObject.assert(newNode);
isObject.assert(oldNode);
if (newNode.original === null) {
// If newNode.original node was set to null, reprint the node.
return false;
}
// If this node needs parentheses and will not be wrapped with
// parentheses when reprinted, then return false to skip reprinting and
// let it be printed generically.
if (newPath.needsParens() && !oldPath.hasParens()) {
return false;
}
var keys = (0, util_1.getUnionOfKeys)(oldNode, newNode);
if (oldNode.type === "File" || newNode.type === "File") {
// Don't bother traversing file.tokens, an often very large array
// returned by Babylon, and useless for our purposes.
delete keys.tokens;
}
// Don't bother traversing .loc objects looking for reprintable nodes.
delete keys.loc;
var originalReprintCount = reprints.length;
for (var k in keys) {
if (k.charAt(0) === "_") {
// Ignore "private" AST properties added by e.g. Babel plugins and
// parsers like Babylon.
continue;
}
newPath.stack.push(k, types.getFieldValue(newNode, k));
oldPath.stack.push(k, types.getFieldValue(oldNode, k));
var canReprint = findAnyReprints(newPath, oldPath, reprints);
newPath.stack.length -= 2;
oldPath.stack.length -= 2;
if (!canReprint) {
return false;
}
}
// Return statements might end up running into ASI issues due to
// comments inserted deep within the tree, so reprint them if anything
// changed within them.
if (ReturnStatement.check(newPath.getNode()) &&
reprints.length > originalReprintCount) {
return false;
}
return true;
}

14
frontend/node_modules/recast/lib/printer.d.ts generated vendored Normal file
View File

@@ -0,0 +1,14 @@
export interface PrintResultType {
code: string;
map?: any;
toString(): string;
}
interface PrinterType {
print(ast: any): PrintResultType;
printGenerically(ast: any): PrintResultType;
}
interface PrinterConstructor {
new (config?: any): PrinterType;
}
declare const Printer: PrinterConstructor;
export { Printer };

2406
frontend/node_modules/recast/lib/printer.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

18
frontend/node_modules/recast/lib/util.d.ts generated vendored Normal file
View File

@@ -0,0 +1,18 @@
export declare function getLineTerminator(): any;
export declare function isBrowser(): boolean;
export declare function getOption(options: any, key: any, defaultValue: any): any;
export declare function getUnionOfKeys(...args: any[]): any;
export declare function comparePos(pos1: any, pos2: any): number;
export declare function copyPos(pos: any): {
line: any;
column: any;
};
export declare function composeSourceMaps(formerMap: any, latterMap: any): any;
export declare function getTrueLoc(node: any, lines: any): {
start: any;
end: any;
} | null;
export declare function fixFaultyLocations(node: any, lines: any): void;
export declare function isExportDeclaration(node: any): boolean;
export declare function getParentExportDeclaration(path: any): any;
export declare function isTrailingCommaEnabled(options: any, context: any): boolean;

331
frontend/node_modules/recast/lib/util.js generated vendored Normal file
View File

@@ -0,0 +1,331 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isTrailingCommaEnabled = exports.getParentExportDeclaration = exports.isExportDeclaration = exports.fixFaultyLocations = exports.getTrueLoc = exports.composeSourceMaps = exports.copyPos = exports.comparePos = exports.getUnionOfKeys = exports.getOption = exports.isBrowser = exports.getLineTerminator = void 0;
var tslib_1 = require("tslib");
var tiny_invariant_1 = tslib_1.__importDefault(require("tiny-invariant"));
var types = tslib_1.__importStar(require("ast-types"));
var n = types.namedTypes;
var source_map_1 = tslib_1.__importDefault(require("source-map"));
var SourceMapConsumer = source_map_1.default.SourceMapConsumer;
var SourceMapGenerator = source_map_1.default.SourceMapGenerator;
var hasOwn = Object.prototype.hasOwnProperty;
function getLineTerminator() {
return isBrowser() ? "\n" : require("os").EOL || "\n";
}
exports.getLineTerminator = getLineTerminator;
function isBrowser() {
return (typeof window !== "undefined" && typeof window.document !== "undefined");
}
exports.isBrowser = isBrowser;
function getOption(options, key, defaultValue) {
if (options && hasOwn.call(options, key)) {
return options[key];
}
return defaultValue;
}
exports.getOption = getOption;
function getUnionOfKeys() {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
var result = {};
var argc = args.length;
for (var i = 0; i < argc; ++i) {
var keys = Object.keys(args[i]);
var keyCount = keys.length;
for (var j = 0; j < keyCount; ++j) {
result[keys[j]] = true;
}
}
return result;
}
exports.getUnionOfKeys = getUnionOfKeys;
function comparePos(pos1, pos2) {
return pos1.line - pos2.line || pos1.column - pos2.column;
}
exports.comparePos = comparePos;
function copyPos(pos) {
return {
line: pos.line,
column: pos.column,
};
}
exports.copyPos = copyPos;
function composeSourceMaps(formerMap, latterMap) {
if (formerMap) {
if (!latterMap) {
return formerMap;
}
}
else {
return latterMap || null;
}
var smcFormer = new SourceMapConsumer(formerMap);
var smcLatter = new SourceMapConsumer(latterMap);
var smg = new SourceMapGenerator({
file: latterMap.file,
sourceRoot: latterMap.sourceRoot,
});
var sourcesToContents = {};
smcLatter.eachMapping(function (mapping) {
var origPos = smcFormer.originalPositionFor({
line: mapping.originalLine,
column: mapping.originalColumn,
});
var sourceName = origPos.source;
if (sourceName === null) {
return;
}
smg.addMapping({
source: sourceName,
original: copyPos(origPos),
generated: {
line: mapping.generatedLine,
column: mapping.generatedColumn,
},
name: mapping.name,
});
var sourceContent = smcFormer.sourceContentFor(sourceName);
if (sourceContent && !hasOwn.call(sourcesToContents, sourceName)) {
sourcesToContents[sourceName] = sourceContent;
smg.setSourceContent(sourceName, sourceContent);
}
});
return smg.toJSON();
}
exports.composeSourceMaps = composeSourceMaps;
function getTrueLoc(node, lines) {
// It's possible that node is newly-created (not parsed by Esprima),
// in which case it probably won't have a .loc property (or an
// .original property for that matter). That's fine; we'll just
// pretty-print it as usual.
if (!node.loc) {
return null;
}
var result = {
start: node.loc.start,
end: node.loc.end,
};
function include(node) {
expandLoc(result, node.loc);
}
// If the node is an export declaration and its .declaration has any
// decorators, their locations might contribute to the true start/end
// positions of the export declaration node.
if (node.declaration &&
node.declaration.decorators &&
isExportDeclaration(node)) {
node.declaration.decorators.forEach(include);
}
if (comparePos(result.start, result.end) < 0) {
// Trim leading whitespace.
result.start = copyPos(result.start);
lines.skipSpaces(result.start, false, true);
if (comparePos(result.start, result.end) < 0) {
// Trim trailing whitespace, if the end location is not already the
// same as the start location.
result.end = copyPos(result.end);
lines.skipSpaces(result.end, true, true);
}
}
// If the node has any comments, their locations might contribute to
// the true start/end positions of the node.
if (node.comments) {
node.comments.forEach(include);
}
return result;
}
exports.getTrueLoc = getTrueLoc;
function expandLoc(parentLoc, childLoc) {
if (parentLoc && childLoc) {
if (comparePos(childLoc.start, parentLoc.start) < 0) {
parentLoc.start = childLoc.start;
}
if (comparePos(parentLoc.end, childLoc.end) < 0) {
parentLoc.end = childLoc.end;
}
}
}
function fixFaultyLocations(node, lines) {
var loc = node.loc;
if (loc) {
if (loc.start.line < 1) {
loc.start.line = 1;
}
if (loc.end.line < 1) {
loc.end.line = 1;
}
}
if (node.type === "File") {
// Babylon returns File nodes whose .loc.{start,end} do not include
// leading or trailing whitespace.
loc.start = lines.firstPos();
loc.end = lines.lastPos();
}
fixForLoopHead(node, lines);
fixTemplateLiteral(node, lines);
if (loc && node.decorators) {
// Expand the .loc of the node responsible for printing the decorators
// (here, the decorated node) so that it includes node.decorators.
node.decorators.forEach(function (decorator) {
expandLoc(loc, decorator.loc);
});
}
else if (node.declaration && isExportDeclaration(node)) {
// Nullify .loc information for the child declaration so that we never
// try to reprint it without also reprinting the export declaration.
node.declaration.loc = null;
// Expand the .loc of the node responsible for printing the decorators
// (here, the export declaration) so that it includes node.decorators.
var decorators = node.declaration.decorators;
if (decorators) {
decorators.forEach(function (decorator) {
expandLoc(loc, decorator.loc);
});
}
}
else if ((n.MethodDefinition && n.MethodDefinition.check(node)) ||
(n.Property.check(node) && (node.method || node.shorthand))) {
// If the node is a MethodDefinition or a .method or .shorthand
// Property, then the location information stored in
// node.value.loc is very likely untrustworthy (just the {body}
// part of a method, or nothing in the case of shorthand
// properties), so we null out that information to prevent
// accidental reuse of bogus source code during reprinting.
node.value.loc = null;
if (n.FunctionExpression.check(node.value)) {
// FunctionExpression method values should be anonymous,
// because their .id fields are ignored anyway.
node.value.id = null;
}
}
else if (node.type === "ObjectTypeProperty") {
var loc_1 = node.loc;
var end = loc_1 && loc_1.end;
if (end) {
end = copyPos(end);
if (lines.prevPos(end) && lines.charAt(end) === ",") {
// Some parsers accidentally include trailing commas in the
// .loc.end information for ObjectTypeProperty nodes.
if ((end = lines.skipSpaces(end, true, true))) {
loc_1.end = end;
}
}
}
}
}
exports.fixFaultyLocations = fixFaultyLocations;
function fixForLoopHead(node, lines) {
if (node.type !== "ForStatement") {
return;
}
function fix(child) {
var loc = child && child.loc;
var start = loc && loc.start;
var end = loc && copyPos(loc.end);
while (start && end && comparePos(start, end) < 0) {
lines.prevPos(end);
if (lines.charAt(end) === ";") {
// Update child.loc.end to *exclude* the ';' character.
loc.end.line = end.line;
loc.end.column = end.column;
}
else {
break;
}
}
}
fix(node.init);
fix(node.test);
fix(node.update);
}
function fixTemplateLiteral(node, lines) {
if (node.type !== "TemplateLiteral") {
return;
}
if (node.quasis.length === 0) {
// If there are no quasi elements, then there is nothing to fix.
return;
}
// node.loc is not present when using export default with a template literal
if (node.loc) {
// First we need to exclude the opening ` from the .loc of the first
// quasi element, in case the parser accidentally decided to include it.
var afterLeftBackTickPos = copyPos(node.loc.start);
(0, tiny_invariant_1.default)(lines.charAt(afterLeftBackTickPos) === "`");
(0, tiny_invariant_1.default)(lines.nextPos(afterLeftBackTickPos));
var firstQuasi = node.quasis[0];
if (comparePos(firstQuasi.loc.start, afterLeftBackTickPos) < 0) {
firstQuasi.loc.start = afterLeftBackTickPos;
}
// Next we need to exclude the closing ` from the .loc of the last quasi
// element, in case the parser accidentally decided to include it.
var rightBackTickPos = copyPos(node.loc.end);
(0, tiny_invariant_1.default)(lines.prevPos(rightBackTickPos));
(0, tiny_invariant_1.default)(lines.charAt(rightBackTickPos) === "`");
var lastQuasi = node.quasis[node.quasis.length - 1];
if (comparePos(rightBackTickPos, lastQuasi.loc.end) < 0) {
lastQuasi.loc.end = rightBackTickPos;
}
}
// Now we need to exclude ${ and } characters from the .loc's of all
// quasi elements, since some parsers accidentally include them.
node.expressions.forEach(function (expr, i) {
// Rewind from expr.loc.start over any whitespace and the ${ that
// precedes the expression. The position of the $ should be the same
// as the .loc.end of the preceding quasi element, but some parsers
// accidentally include the ${ in the .loc of the quasi element.
var dollarCurlyPos = lines.skipSpaces(expr.loc.start, true, false);
if (lines.prevPos(dollarCurlyPos) &&
lines.charAt(dollarCurlyPos) === "{" &&
lines.prevPos(dollarCurlyPos) &&
lines.charAt(dollarCurlyPos) === "$") {
var quasiBefore = node.quasis[i];
if (comparePos(dollarCurlyPos, quasiBefore.loc.end) < 0) {
quasiBefore.loc.end = dollarCurlyPos;
}
}
// Likewise, some parsers accidentally include the } that follows
// the expression in the .loc of the following quasi element.
var rightCurlyPos = lines.skipSpaces(expr.loc.end, false, false);
if (lines.charAt(rightCurlyPos) === "}") {
(0, tiny_invariant_1.default)(lines.nextPos(rightCurlyPos));
// Now rightCurlyPos is technically the position just after the }.
var quasiAfter = node.quasis[i + 1];
if (comparePos(quasiAfter.loc.start, rightCurlyPos) < 0) {
quasiAfter.loc.start = rightCurlyPos;
}
}
});
}
function isExportDeclaration(node) {
if (node)
switch (node.type) {
case "ExportDeclaration":
case "ExportDefaultDeclaration":
case "ExportDefaultSpecifier":
case "DeclareExportDeclaration":
case "ExportNamedDeclaration":
case "ExportAllDeclaration":
return true;
}
return false;
}
exports.isExportDeclaration = isExportDeclaration;
function getParentExportDeclaration(path) {
var parentNode = path.getParentNode();
if (path.getName() === "declaration" && isExportDeclaration(parentNode)) {
return parentNode;
}
return null;
}
exports.getParentExportDeclaration = getParentExportDeclaration;
function isTrailingCommaEnabled(options, context) {
var trailingComma = options.trailingComma;
if (typeof trailingComma === "object") {
return !!trailingComma[context];
}
return !!trailingComma;
}
exports.isTrailingCommaEnabled = isTrailingCommaEnabled;

50
frontend/node_modules/recast/main.d.ts generated vendored Normal file
View File

@@ -0,0 +1,50 @@
import * as types from "ast-types";
import { parse } from "./lib/parser";
import { Options } from "./lib/options";
export {
/**
* Parse a string of code into an augmented syntax tree suitable for
* arbitrary modification and reprinting.
*/
parse,
/**
* Convenient shorthand for the ast-types package.
*/
types, };
/**
* Traverse and potentially modify an abstract syntax tree using a
* convenient visitor syntax:
*
* recast.visit(ast, {
* names: [],
* visitIdentifier: function(path) {
* var node = path.value;
* this.visitor.names.push(node.name);
* this.traverse(path);
* }
* });
*/
export { visit } from "ast-types";
/**
* Options shared between parsing and printing.
*/
export { Options } from "./lib/options";
/**
* Reprint a modified syntax tree using as much of the original source
* code as possible.
*/
export declare function print(node: types.ASTNode, options?: Options): import("./lib/printer").PrintResultType;
/**
* Print without attempting to reuse any original source code.
*/
export declare function prettyPrint(node: types.ASTNode, options?: Options): import("./lib/printer").PrintResultType;
/**
* Convenient command-line interface (see e.g. example/add-braces).
*/
export declare function run(transformer: Transformer, options?: RunOptions): void;
export interface Transformer {
(ast: types.ASTNode, callback: (ast: types.ASTNode) => void): void;
}
export interface RunOptions extends Options {
writeback?(code: string): void;
}

65
frontend/node_modules/recast/main.js generated vendored Normal file
View File

@@ -0,0 +1,65 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.run = exports.prettyPrint = exports.print = exports.visit = exports.types = exports.parse = void 0;
var tslib_1 = require("tslib");
var fs_1 = tslib_1.__importDefault(require("fs"));
var types = tslib_1.__importStar(require("ast-types"));
exports.types = types;
var parser_1 = require("./lib/parser");
Object.defineProperty(exports, "parse", { enumerable: true, get: function () { return parser_1.parse; } });
var printer_1 = require("./lib/printer");
/**
* Traverse and potentially modify an abstract syntax tree using a
* convenient visitor syntax:
*
* recast.visit(ast, {
* names: [],
* visitIdentifier: function(path) {
* var node = path.value;
* this.visitor.names.push(node.name);
* this.traverse(path);
* }
* });
*/
var ast_types_1 = require("ast-types");
Object.defineProperty(exports, "visit", { enumerable: true, get: function () { return ast_types_1.visit; } });
/**
* Reprint a modified syntax tree using as much of the original source
* code as possible.
*/
function print(node, options) {
return new printer_1.Printer(options).print(node);
}
exports.print = print;
/**
* Print without attempting to reuse any original source code.
*/
function prettyPrint(node, options) {
return new printer_1.Printer(options).printGenerically(node);
}
exports.prettyPrint = prettyPrint;
/**
* Convenient command-line interface (see e.g. example/add-braces).
*/
function run(transformer, options) {
return runFile(process.argv[2], transformer, options);
}
exports.run = run;
function runFile(path, transformer, options) {
fs_1.default.readFile(path, "utf-8", function (err, code) {
if (err) {
console.error(err);
return;
}
runString(code, transformer, options);
});
}
function defaultWriteback(output) {
process.stdout.write(output);
}
function runString(code, transformer, options) {
var writeback = (options && options.writeback) || defaultWriteback;
transformer((0, parser_1.parse)(code, options), function (node) {
writeback(print(node, options).code);
});
}

74
frontend/node_modules/recast/package.json generated vendored Normal file
View File

@@ -0,0 +1,74 @@
{
"author": "Ben Newman <bn@cs.stanford.edu>",
"name": "recast",
"version": "0.23.11",
"description": "JavaScript syntax tree transformer, nondestructive pretty-printer, and automatic source map generator",
"keywords": [
"ast",
"rewriting",
"refactoring",
"codegen",
"syntax",
"transformation",
"parsing",
"pretty-printing"
],
"homepage": "http://github.com/benjamn/recast",
"repository": {
"type": "git",
"url": "git://github.com/benjamn/recast.git"
},
"license": "MIT",
"main": "main.js",
"types": "main.d.ts",
"scripts": {
"mocha": "test/run.sh",
"debug": "test/run.sh --inspect-brk",
"test": "npm run lint && npm run build && npm run mocha",
"build": "npm run clean && tsc",
"lint": "eslint --ext .ts .",
"format": "prettier --write .",
"format:check": "prettier --check .",
"clean": "tsc --build --clean",
"prepare": "npm run build",
"postpack": "npm run clean"
},
"lint-staged": {
"*.ts": [
"eslint",
"prettier -c"
]
},
"browser": {
"fs": false
},
"dependencies": {
"ast-types": "^0.16.1",
"esprima": "~4.0.0",
"source-map": "~0.6.1",
"tiny-invariant": "^1.3.3",
"tslib": "^2.0.1"
},
"devDependencies": {
"@babel/core": "7.20.5",
"@babel/parser": "7.20.5",
"@babel/preset-env": "7.20.2",
"@types/esprima": "4.0.3",
"@types/glob": "8.0.0",
"@types/mocha": "10.0.1",
"@types/node": "18.11.15",
"@typescript-eslint/parser": "^5.47.1",
"eslint": "^8.40.0",
"esprima-fb": "15001.1001.0-dev-harmony-fb",
"flow-parser": "0.195.0",
"glob": "8.0.3",
"lint-staged": "^13.2.2",
"mocha": "^10.2.0",
"prettier": "^2.6.2",
"reify": "0.20.12",
"typescript": "^4.9.4"
},
"engines": {
"node": ">= 4"
}
}

View File

@@ -0,0 +1,8 @@
import { ParserOptions, ParserPlugin } from "@babel/parser";
export type Overrides = Partial<{
sourceType: ParserOptions["sourceType"];
strictMode: ParserOptions["strictMode"];
}>;
export default function getBabelOptions(options?: Overrides): ParserOptions & {
plugins: ParserPlugin[];
};

57
frontend/node_modules/recast/parsers/_babel_options.js generated vendored Normal file
View File

@@ -0,0 +1,57 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var util_1 = require("../lib/util");
function getBabelOptions(options) {
// The goal here is to tolerate as much syntax as possible, since Recast
// is not in the business of forbidding anything. If you want your
// parser to be more restrictive for some reason, you can always pass
// your own parser object to recast.parse.
return {
sourceType: (0, util_1.getOption)(options, "sourceType", "module"),
strictMode: (0, util_1.getOption)(options, "strictMode", false),
allowImportExportEverywhere: true,
allowReturnOutsideFunction: true,
startLine: 1,
tokens: true,
plugins: [
"asyncGenerators",
"bigInt",
"classPrivateMethods",
"classPrivateProperties",
"classProperties",
"classStaticBlock",
"decimal",
"decorators-legacy",
"doExpressions",
"dynamicImport",
"exportDefaultFrom",
"exportExtensions",
"exportNamespaceFrom",
"functionBind",
"functionSent",
"importAssertions",
"importMeta",
"nullishCoalescingOperator",
"numericSeparator",
"objectRestSpread",
"optionalCatchBinding",
"optionalChaining",
[
"pipelineOperator",
{
proposal: "minimal",
},
],
[
"recordAndTuple",
{
syntaxType: "hash",
},
],
"throwExpressions",
"topLevelAwait",
"v8intrinsic",
],
};
}
exports.default = getBabelOptions;

1
frontend/node_modules/recast/parsers/acorn.d.ts generated vendored Normal file
View File

@@ -0,0 +1 @@
export declare function parse(source: string, options?: any): any;

33
frontend/node_modules/recast/parsers/acorn.js generated vendored Normal file
View File

@@ -0,0 +1,33 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.parse = void 0;
// This module is suitable for passing as options.parser when calling
// recast.parse to process JavaScript code with Acorn:
//
// const ast = recast.parse(source, {
// parser: require("recast/parsers/acorn")
// });
//
var util_1 = require("../lib/util");
function parse(source, options) {
var comments = [];
var tokens = [];
var ast = require("acorn").parse(source, {
allowHashBang: true,
allowImportExportEverywhere: true,
allowReturnOutsideFunction: true,
ecmaVersion: (0, util_1.getOption)(options, "ecmaVersion", 8),
sourceType: (0, util_1.getOption)(options, "sourceType", "module"),
locations: true,
onComment: comments,
onToken: tokens,
});
if (!ast.comments) {
ast.comments = comments;
}
if (!ast.tokens) {
ast.tokens = tokens;
}
return ast;
}
exports.parse = parse;

4
frontend/node_modules/recast/parsers/babel-ts.d.ts generated vendored Normal file
View File

@@ -0,0 +1,4 @@
import { parser } from "./babel";
import { Overrides } from "./_babel_options";
export { parser };
export declare function parse(source: string, options?: Overrides): import("@babel/parser").ParseResult<import("@babel/types").File>;

13
frontend/node_modules/recast/parsers/babel-ts.js generated vendored Normal file
View File

@@ -0,0 +1,13 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.parse = exports.parser = void 0;
var tslib_1 = require("tslib");
var babel_1 = require("./babel");
Object.defineProperty(exports, "parser", { enumerable: true, get: function () { return babel_1.parser; } });
var _babel_options_1 = tslib_1.__importDefault(require("./_babel_options"));
function parse(source, options) {
var babelOptions = (0, _babel_options_1.default)(options);
babelOptions.plugins.push("jsx", "typescript");
return babel_1.parser.parse(source, babelOptions);
}
exports.parse = parse;

8
frontend/node_modules/recast/parsers/babel.d.ts generated vendored Normal file
View File

@@ -0,0 +1,8 @@
import { parse as babelParse } from "@babel/parser";
import { Overrides } from "./_babel_options";
type BabelParser = {
parse: typeof babelParse;
};
export declare const parser: BabelParser;
export declare function parse(source: string, options?: Overrides): import("@babel/parser").ParseResult<import("@babel/types").File>;
export {};

33
frontend/node_modules/recast/parsers/babel.js generated vendored Normal file
View File

@@ -0,0 +1,33 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.parse = exports.parser = void 0;
var tslib_1 = require("tslib");
var _babel_options_1 = tslib_1.__importDefault(require("./_babel_options"));
// Prefer the new @babel/parser package, but fall back to babylon if
// that's what's available.
exports.parser = (function () {
try {
return require("@babel/parser");
}
catch (_a) {
try {
return require("babylon");
}
catch (_b) {
throw new Error("Install @babel/parser to use the `typescript`, `flow`, or `babel` parsers");
}
}
})();
// This module is suitable for passing as options.parser when calling
// recast.parse to process JavaScript code with Babel:
//
// const ast = recast.parse(source, {
// parser: require("recast/parsers/babel")
// });
//
function parse(source, options) {
var babelOptions = (0, _babel_options_1.default)(options);
babelOptions.plugins.push("jsx", "flow", "decoratorAutoAccessors");
return exports.parser.parse(source, babelOptions);
}
exports.parse = parse;

1
frontend/node_modules/recast/parsers/babylon.d.ts generated vendored Normal file
View File

@@ -0,0 +1 @@
export * from "./babel";

4
frontend/node_modules/recast/parsers/babylon.js generated vendored Normal file
View File

@@ -0,0 +1,4 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
tslib_1.__exportStar(require("./babel"), exports);

1
frontend/node_modules/recast/parsers/esprima.d.ts generated vendored Normal file
View File

@@ -0,0 +1 @@
export declare function parse(source: string, options?: any): any;

30
frontend/node_modules/recast/parsers/esprima.js generated vendored Normal file
View File

@@ -0,0 +1,30 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.parse = void 0;
// This module is suitable for passing as options.parser when calling
// recast.parse to process ECMAScript code with Esprima:
//
// const ast = recast.parse(source, {
// parser: require("recast/parsers/esprima")
// });
//
var util_1 = require("../lib/util");
function parse(source, options) {
var comments = [];
var ast = require("esprima").parse(source, {
loc: true,
locations: true,
comment: true,
onComment: comments,
range: (0, util_1.getOption)(options, "range", false),
tolerant: (0, util_1.getOption)(options, "tolerant", true),
tokens: true,
jsx: (0, util_1.getOption)(options, "jsx", false),
sourceType: (0, util_1.getOption)(options, "sourceType", "module"),
});
if (!Array.isArray(ast.comments)) {
ast.comments = comments;
}
return ast;
}
exports.parse = parse;

2
frontend/node_modules/recast/parsers/flow.d.ts generated vendored Normal file
View File

@@ -0,0 +1,2 @@
import { Overrides } from "./_babel_options";
export declare function parse(source: string, options?: Overrides): import("@babel/parser").ParseResult<import("@babel/types").File>;

19
frontend/node_modules/recast/parsers/flow.js generated vendored Normal file
View File

@@ -0,0 +1,19 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.parse = void 0;
var tslib_1 = require("tslib");
var babel_1 = require("./babel");
var _babel_options_1 = tslib_1.__importDefault(require("./_babel_options"));
// This module is suitable for passing as options.parser when calling
// recast.parse to process Flow code:
//
// const ast = recast.parse(source, {
// parser: require("recast/parsers/flow")
// });
//
function parse(source, options) {
var babelOptions = (0, _babel_options_1.default)(options);
babelOptions.plugins.push("jsx", "flow");
return babel_1.parser.parse(source, babelOptions);
}
exports.parse = parse;

2
frontend/node_modules/recast/parsers/typescript.d.ts generated vendored Normal file
View File

@@ -0,0 +1,2 @@
import { Overrides } from "./_babel_options";
export declare function parse(source: string, options?: Overrides): import("@babel/parser").ParseResult<import("@babel/types").File>;

19
frontend/node_modules/recast/parsers/typescript.js generated vendored Normal file
View File

@@ -0,0 +1,19 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.parse = void 0;
var tslib_1 = require("tslib");
var babel_1 = require("./babel");
var _babel_options_1 = tslib_1.__importDefault(require("./_babel_options"));
// This module is suitable for passing as options.parser when calling
// recast.parse to process TypeScript code:
//
// const ast = recast.parse(source, {
// parser: require("recast/parsers/typescript")
// });
//
function parse(source, options) {
var babelOptions = (0, _babel_options_1.default)(options);
babelOptions.plugins.push("typescript");
return babel_1.parser.parse(source, babelOptions);
}
exports.parse = parse;

18
frontend/node_modules/recast/tsconfig.json generated vendored Normal file
View File

@@ -0,0 +1,18 @@
{
"compilerOptions": {
"target": "es5",
"lib": ["es2015"],
"module": "commonjs",
"declaration": true,
"rootDir": ".",
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true,
"moduleResolution": "node",
"esModuleInterop": true,
"importHelpers": true,
"stripInternal": true
},
"exclude": ["node_modules", "test/data"]
}