@@ -1,5 +1,4 @@ | |||
.DS_Store | |||
node_modules/ | |||
/dist/ | |||
npm-debug.log* | |||
yarn-debug.log* | |||
@@ -0,0 +1,15 @@ | |||
#!/bin/sh | |||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')") | |||
case `uname` in | |||
*CYGWIN*) basedir=`cygpath -w "$basedir"`;; | |||
esac | |||
if [ -x "$basedir/node" ]; then | |||
"$basedir/node" "$basedir/../acorn/bin/acorn" "$@" | |||
ret=$? | |||
else | |||
node "$basedir/../acorn/bin/acorn" "$@" | |||
ret=$? | |||
fi | |||
exit $ret |
@@ -0,0 +1,7 @@ | |||
@IF EXIST "%~dp0\node.exe" ( | |||
"%~dp0\node.exe" "%~dp0\..\acorn\bin\acorn" %* | |||
) ELSE ( | |||
@SETLOCAL | |||
@SET PATHEXT=%PATHEXT:;.JS;=;% | |||
node "%~dp0\..\acorn\bin\acorn" %* | |||
) |
@@ -0,0 +1,15 @@ | |||
#!/bin/sh | |||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')") | |||
case `uname` in | |||
*CYGWIN*) basedir=`cygpath -w "$basedir"`;; | |||
esac | |||
if [ -x "$basedir/node" ]; then | |||
"$basedir/node" "$basedir/../ansi-html/bin/ansi-html" "$@" | |||
ret=$? | |||
else | |||
node "$basedir/../ansi-html/bin/ansi-html" "$@" | |||
ret=$? | |||
fi | |||
exit $ret |
@@ -0,0 +1,7 @@ | |||
@IF EXIST "%~dp0\node.exe" ( | |||
"%~dp0\node.exe" "%~dp0\..\ansi-html\bin\ansi-html" %* | |||
) ELSE ( | |||
@SETLOCAL | |||
@SET PATHEXT=%PATHEXT:;.JS;=;% | |||
node "%~dp0\..\ansi-html\bin\ansi-html" %* | |||
) |
@@ -0,0 +1,15 @@ | |||
#!/bin/sh | |||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')") | |||
case `uname` in | |||
*CYGWIN*) basedir=`cygpath -w "$basedir"`;; | |||
esac | |||
if [ -x "$basedir/node" ]; then | |||
"$basedir/node" "$basedir/../atob/bin/atob.js" "$@" | |||
ret=$? | |||
else | |||
node "$basedir/../atob/bin/atob.js" "$@" | |||
ret=$? | |||
fi | |||
exit $ret |
@@ -0,0 +1,7 @@ | |||
@IF EXIST "%~dp0\node.exe" ( | |||
"%~dp0\node.exe" "%~dp0\..\atob\bin\atob.js" %* | |||
) ELSE ( | |||
@SETLOCAL | |||
@SET PATHEXT=%PATHEXT:;.JS;=;% | |||
node "%~dp0\..\atob\bin\atob.js" %* | |||
) |
@@ -0,0 +1,15 @@ | |||
#!/bin/sh | |||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')") | |||
case `uname` in | |||
*CYGWIN*) basedir=`cygpath -w "$basedir"`;; | |||
esac | |||
if [ -x "$basedir/node" ]; then | |||
"$basedir/node" "$basedir/../autoprefixer/bin/autoprefixer-info" "$@" | |||
ret=$? | |||
else | |||
node "$basedir/../autoprefixer/bin/autoprefixer-info" "$@" | |||
ret=$? | |||
fi | |||
exit $ret |
@@ -0,0 +1,7 @@ | |||
@IF EXIST "%~dp0\node.exe" ( | |||
"%~dp0\node.exe" "%~dp0\..\autoprefixer\bin\autoprefixer-info" %* | |||
) ELSE ( | |||
@SETLOCAL | |||
@SET PATHEXT=%PATHEXT:;.JS;=;% | |||
node "%~dp0\..\autoprefixer\bin\autoprefixer-info" %* | |||
) |
@@ -0,0 +1,15 @@ | |||
#!/bin/sh | |||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')") | |||
case `uname` in | |||
*CYGWIN*) basedir=`cygpath -w "$basedir"`;; | |||
esac | |||
if [ -x "$basedir/node" ]; then | |||
"$basedir/node" "$basedir/../babylon/bin/babylon.js" "$@" | |||
ret=$? | |||
else | |||
node "$basedir/../babylon/bin/babylon.js" "$@" | |||
ret=$? | |||
fi | |||
exit $ret |
@@ -0,0 +1,7 @@ | |||
@IF EXIST "%~dp0\node.exe" ( | |||
"%~dp0\node.exe" "%~dp0\..\babylon\bin\babylon.js" %* | |||
) ELSE ( | |||
@SETLOCAL | |||
@SET PATHEXT=%PATHEXT:;.JS;=;% | |||
node "%~dp0\..\babylon\bin\babylon.js" %* | |||
) |
@@ -0,0 +1,15 @@ | |||
#!/bin/sh | |||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')") | |||
case `uname` in | |||
*CYGWIN*) basedir=`cygpath -w "$basedir"`;; | |||
esac | |||
if [ -x "$basedir/node" ]; then | |||
"$basedir/node" "$basedir/../browserslist/cli.js" "$@" | |||
ret=$? | |||
else | |||
node "$basedir/../browserslist/cli.js" "$@" | |||
ret=$? | |||
fi | |||
exit $ret |
@@ -0,0 +1,7 @@ | |||
@IF EXIST "%~dp0\node.exe" ( | |||
"%~dp0\node.exe" "%~dp0\..\browserslist\cli.js" %* | |||
) ELSE ( | |||
@SETLOCAL | |||
@SET PATHEXT=%PATHEXT:;.JS;=;% | |||
node "%~dp0\..\browserslist\cli.js" %* | |||
) |
@@ -0,0 +1,15 @@ | |||
#!/bin/sh | |||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')") | |||
case `uname` in | |||
*CYGWIN*) basedir=`cygpath -w "$basedir"`;; | |||
esac | |||
if [ -x "$basedir/node" ]; then | |||
"$basedir/node" "$basedir/../cssesc/bin/cssesc" "$@" | |||
ret=$? | |||
else | |||
node "$basedir/../cssesc/bin/cssesc" "$@" | |||
ret=$? | |||
fi | |||
exit $ret |
@@ -0,0 +1,7 @@ | |||
@IF EXIST "%~dp0\node.exe" ( | |||
"%~dp0\node.exe" "%~dp0\..\cssesc\bin\cssesc" %* | |||
) ELSE ( | |||
@SETLOCAL | |||
@SET PATHEXT=%PATHEXT:;.JS;=;% | |||
node "%~dp0\..\cssesc\bin\cssesc" %* | |||
) |
@@ -0,0 +1,15 @@ | |||
#!/bin/sh | |||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')") | |||
case `uname` in | |||
*CYGWIN*) basedir=`cygpath -w "$basedir"`;; | |||
esac | |||
if [ -x "$basedir/node" ]; then | |||
"$basedir/node" "$basedir/../csso/bin/csso" "$@" | |||
ret=$? | |||
else | |||
node "$basedir/../csso/bin/csso" "$@" | |||
ret=$? | |||
fi | |||
exit $ret |
@@ -0,0 +1,7 @@ | |||
@IF EXIST "%~dp0\node.exe" ( | |||
"%~dp0\node.exe" "%~dp0\..\csso\bin\csso" %* | |||
) ELSE ( | |||
@SETLOCAL | |||
@SET PATHEXT=%PATHEXT:;.JS;=;% | |||
node "%~dp0\..\csso\bin\csso" %* | |||
) |
@@ -0,0 +1,15 @@ | |||
#!/bin/sh | |||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')") | |||
case `uname` in | |||
*CYGWIN*) basedir=`cygpath -w "$basedir"`;; | |||
esac | |||
if [ -x "$basedir/node" ]; then | |||
"$basedir/node" "$basedir/../errno/cli.js" "$@" | |||
ret=$? | |||
else | |||
node "$basedir/../errno/cli.js" "$@" | |||
ret=$? | |||
fi | |||
exit $ret |
@@ -0,0 +1,7 @@ | |||
@IF EXIST "%~dp0\node.exe" ( | |||
"%~dp0\node.exe" "%~dp0\..\errno\cli.js" %* | |||
) ELSE ( | |||
@SETLOCAL | |||
@SET PATHEXT=%PATHEXT:;.JS;=;% | |||
node "%~dp0\..\errno\cli.js" %* | |||
) |
@@ -0,0 +1,15 @@ | |||
#!/bin/sh | |||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')") | |||
case `uname` in | |||
*CYGWIN*) basedir=`cygpath -w "$basedir"`;; | |||
esac | |||
if [ -x "$basedir/node" ]; then | |||
"$basedir/node" "$basedir/../eslint/bin/eslint.js" "$@" | |||
ret=$? | |||
else | |||
node "$basedir/../eslint/bin/eslint.js" "$@" | |||
ret=$? | |||
fi | |||
exit $ret |
@@ -0,0 +1,7 @@ | |||
@IF EXIST "%~dp0\node.exe" ( | |||
"%~dp0\node.exe" "%~dp0\..\eslint\bin\eslint.js" %* | |||
) ELSE ( | |||
@SETLOCAL | |||
@SET PATHEXT=%PATHEXT:;.JS;=;% | |||
node "%~dp0\..\eslint\bin\eslint.js" %* | |||
) |
@@ -0,0 +1,15 @@ | |||
#!/bin/sh | |||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')") | |||
case `uname` in | |||
*CYGWIN*) basedir=`cygpath -w "$basedir"`;; | |||
esac | |||
if [ -x "$basedir/node" ]; then | |||
"$basedir/node" "$basedir/../esprima/bin/esparse.js" "$@" | |||
ret=$? | |||
else | |||
node "$basedir/../esprima/bin/esparse.js" "$@" | |||
ret=$? | |||
fi | |||
exit $ret |
@@ -0,0 +1,7 @@ | |||
@IF EXIST "%~dp0\node.exe" ( | |||
"%~dp0\node.exe" "%~dp0\..\esprima\bin\esparse.js" %* | |||
) ELSE ( | |||
@SETLOCAL | |||
@SET PATHEXT=%PATHEXT:;.JS;=;% | |||
node "%~dp0\..\esprima\bin\esparse.js" %* | |||
) |
@@ -0,0 +1,15 @@ | |||
#!/bin/sh | |||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')") | |||
case `uname` in | |||
*CYGWIN*) basedir=`cygpath -w "$basedir"`;; | |||
esac | |||
if [ -x "$basedir/node" ]; then | |||
"$basedir/node" "$basedir/../esprima/bin/esvalidate.js" "$@" | |||
ret=$? | |||
else | |||
node "$basedir/../esprima/bin/esvalidate.js" "$@" | |||
ret=$? | |||
fi | |||
exit $ret |
@@ -0,0 +1,7 @@ | |||
@IF EXIST "%~dp0\node.exe" ( | |||
"%~dp0\node.exe" "%~dp0\..\esprima\bin\esvalidate.js" %* | |||
) ELSE ( | |||
@SETLOCAL | |||
@SET PATHEXT=%PATHEXT:;.JS;=;% | |||
node "%~dp0\..\esprima\bin\esvalidate.js" %* | |||
) |
@@ -0,0 +1,15 @@ | |||
#!/bin/sh | |||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')") | |||
case `uname` in | |||
*CYGWIN*) basedir=`cygpath -w "$basedir"`;; | |||
esac | |||
if [ -x "$basedir/node" ]; then | |||
"$basedir/node" "$basedir/../he/bin/he" "$@" | |||
ret=$? | |||
else | |||
node "$basedir/../he/bin/he" "$@" | |||
ret=$? | |||
fi | |||
exit $ret |
@@ -0,0 +1,7 @@ | |||
@IF EXIST "%~dp0\node.exe" ( | |||
"%~dp0\node.exe" "%~dp0\..\he\bin\he" %* | |||
) ELSE ( | |||
@SETLOCAL | |||
@SET PATHEXT=%PATHEXT:;.JS;=;% | |||
node "%~dp0\..\he\bin\he" %* | |||
) |
@@ -0,0 +1,15 @@ | |||
#!/bin/sh | |||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')") | |||
case `uname` in | |||
*CYGWIN*) basedir=`cygpath -w "$basedir"`;; | |||
esac | |||
if [ -x "$basedir/node" ]; then | |||
"$basedir/node" "$basedir/../html-minifier/cli.js" "$@" | |||
ret=$? | |||
else | |||
node "$basedir/../html-minifier/cli.js" "$@" | |||
ret=$? | |||
fi | |||
exit $ret |
@@ -0,0 +1,7 @@ | |||
@IF EXIST "%~dp0\node.exe" ( | |||
"%~dp0\node.exe" "%~dp0\..\html-minifier\cli.js" %* | |||
) ELSE ( | |||
@SETLOCAL | |||
@SET PATHEXT=%PATHEXT:;.JS;=;% | |||
node "%~dp0\..\html-minifier\cli.js" %* | |||
) |
@@ -0,0 +1,15 @@ | |||
#!/bin/sh | |||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')") | |||
case `uname` in | |||
*CYGWIN*) basedir=`cygpath -w "$basedir"`;; | |||
esac | |||
if [ -x "$basedir/node" ]; then | |||
"$basedir/node" "$basedir/../import-local/fixtures/cli.js" "$@" | |||
ret=$? | |||
else | |||
node "$basedir/../import-local/fixtures/cli.js" "$@" | |||
ret=$? | |||
fi | |||
exit $ret |
@@ -0,0 +1,7 @@ | |||
@IF EXIST "%~dp0\node.exe" ( | |||
"%~dp0\node.exe" "%~dp0\..\import-local\fixtures\cli.js" %* | |||
) ELSE ( | |||
@SETLOCAL | |||
@SET PATHEXT=%PATHEXT:;.JS;=;% | |||
node "%~dp0\..\import-local\fixtures\cli.js" %* | |||
) |
@@ -0,0 +1,15 @@ | |||
#!/bin/sh | |||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')") | |||
case `uname` in | |||
*CYGWIN*) basedir=`cygpath -w "$basedir"`;; | |||
esac | |||
if [ -x "$basedir/node" ]; then | |||
"$basedir/node" "$basedir/../internal-ip/cli.js" "$@" | |||
ret=$? | |||
else | |||
node "$basedir/../internal-ip/cli.js" "$@" | |||
ret=$? | |||
fi | |||
exit $ret |
@@ -0,0 +1,7 @@ | |||
@IF EXIST "%~dp0\node.exe" ( | |||
"%~dp0\node.exe" "%~dp0\..\internal-ip\cli.js" %* | |||
) ELSE ( | |||
@SETLOCAL | |||
@SET PATHEXT=%PATHEXT:;.JS;=;% | |||
node "%~dp0\..\internal-ip\cli.js" %* | |||
) |
@@ -0,0 +1,15 @@ | |||
#!/bin/sh | |||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')") | |||
case `uname` in | |||
*CYGWIN*) basedir=`cygpath -w "$basedir"`;; | |||
esac | |||
if [ -x "$basedir/node" ]; then | |||
"$basedir/node" "$basedir/../js-yaml/bin/js-yaml.js" "$@" | |||
ret=$? | |||
else | |||
node "$basedir/../js-yaml/bin/js-yaml.js" "$@" | |||
ret=$? | |||
fi | |||
exit $ret |
@@ -0,0 +1,7 @@ | |||
@IF EXIST "%~dp0\node.exe" ( | |||
"%~dp0\node.exe" "%~dp0\..\js-yaml\bin\js-yaml.js" %* | |||
) ELSE ( | |||
@SETLOCAL | |||
@SET PATHEXT=%PATHEXT:;.JS;=;% | |||
node "%~dp0\..\js-yaml\bin\js-yaml.js" %* | |||
) |
@@ -0,0 +1,15 @@ | |||
#!/bin/sh | |||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')") | |||
case `uname` in | |||
*CYGWIN*) basedir=`cygpath -w "$basedir"`;; | |||
esac | |||
if [ -x "$basedir/node" ]; then | |||
"$basedir/node" "$basedir/../jsesc/bin/jsesc" "$@" | |||
ret=$? | |||
else | |||
node "$basedir/../jsesc/bin/jsesc" "$@" | |||
ret=$? | |||
fi | |||
exit $ret |
@@ -0,0 +1,7 @@ | |||
@IF EXIST "%~dp0\node.exe" ( | |||
"%~dp0\node.exe" "%~dp0\..\jsesc\bin\jsesc" %* | |||
) ELSE ( | |||
@SETLOCAL | |||
@SET PATHEXT=%PATHEXT:;.JS;=;% | |||
node "%~dp0\..\jsesc\bin\jsesc" %* | |||
) |
@@ -0,0 +1,15 @@ | |||
#!/bin/sh | |||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')") | |||
case `uname` in | |||
*CYGWIN*) basedir=`cygpath -w "$basedir"`;; | |||
esac | |||
if [ -x "$basedir/node" ]; then | |||
"$basedir/node" "$basedir/../json5/lib/cli.js" "$@" | |||
ret=$? | |||
else | |||
node "$basedir/../json5/lib/cli.js" "$@" | |||
ret=$? | |||
fi | |||
exit $ret |
@@ -0,0 +1,7 @@ | |||
@IF EXIST "%~dp0\node.exe" ( | |||
"%~dp0\node.exe" "%~dp0\..\json5\lib\cli.js" %* | |||
) ELSE ( | |||
@SETLOCAL | |||
@SET PATHEXT=%PATHEXT:;.JS;=;% | |||
node "%~dp0\..\json5\lib\cli.js" %* | |||
) |
@@ -0,0 +1,15 @@ | |||
#!/bin/sh | |||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')") | |||
case `uname` in | |||
*CYGWIN*) basedir=`cygpath -w "$basedir"`;; | |||
esac | |||
if [ -x "$basedir/node" ]; then | |||
"$basedir/node" "$basedir/../loose-envify/cli.js" "$@" | |||
ret=$? | |||
else | |||
node "$basedir/../loose-envify/cli.js" "$@" | |||
ret=$? | |||
fi | |||
exit $ret |
@@ -0,0 +1,7 @@ | |||
@IF EXIST "%~dp0\node.exe" ( | |||
"%~dp0\node.exe" "%~dp0\..\loose-envify\cli.js" %* | |||
) ELSE ( | |||
@SETLOCAL | |||
@SET PATHEXT=%PATHEXT:;.JS;=;% | |||
node "%~dp0\..\loose-envify\cli.js" %* | |||
) |
@@ -0,0 +1,15 @@ | |||
#!/bin/sh | |||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')") | |||
case `uname` in | |||
*CYGWIN*) basedir=`cygpath -w "$basedir"`;; | |||
esac | |||
if [ -x "$basedir/node" ]; then | |||
"$basedir/node" "$basedir/../miller-rabin/bin/miller-rabin" "$@" | |||
ret=$? | |||
else | |||
node "$basedir/../miller-rabin/bin/miller-rabin" "$@" | |||
ret=$? | |||
fi | |||
exit $ret |
@@ -0,0 +1,7 @@ | |||
@IF EXIST "%~dp0\node.exe" ( | |||
"%~dp0\node.exe" "%~dp0\..\miller-rabin\bin\miller-rabin" %* | |||
) ELSE ( | |||
@SETLOCAL | |||
@SET PATHEXT=%PATHEXT:;.JS;=;% | |||
node "%~dp0\..\miller-rabin\bin\miller-rabin" %* | |||
) |
@@ -0,0 +1,15 @@ | |||
#!/bin/sh | |||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')") | |||
case `uname` in | |||
*CYGWIN*) basedir=`cygpath -w "$basedir"`;; | |||
esac | |||
if [ -x "$basedir/node" ]; then | |||
"$basedir/node" "$basedir/../mime/cli.js" "$@" | |||
ret=$? | |||
else | |||
node "$basedir/../mime/cli.js" "$@" | |||
ret=$? | |||
fi | |||
exit $ret |
@@ -0,0 +1,7 @@ | |||
@IF EXIST "%~dp0\node.exe" ( | |||
"%~dp0\node.exe" "%~dp0\..\mime\cli.js" %* | |||
) ELSE ( | |||
@SETLOCAL | |||
@SET PATHEXT=%PATHEXT:;.JS;=;% | |||
node "%~dp0\..\mime\cli.js" %* | |||
) |
@@ -0,0 +1,15 @@ | |||
#!/bin/sh | |||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')") | |||
case `uname` in | |||
*CYGWIN*) basedir=`cygpath -w "$basedir"`;; | |||
esac | |||
if [ -x "$basedir/node" ]; then | |||
"$basedir/node" "$basedir/../mkdirp/bin/cmd.js" "$@" | |||
ret=$? | |||
else | |||
node "$basedir/../mkdirp/bin/cmd.js" "$@" | |||
ret=$? | |||
fi | |||
exit $ret |
@@ -0,0 +1,7 @@ | |||
@IF EXIST "%~dp0\node.exe" ( | |||
"%~dp0\node.exe" "%~dp0\..\mkdirp\bin\cmd.js" %* | |||
) ELSE ( | |||
@SETLOCAL | |||
@SET PATHEXT=%PATHEXT:;.JS;=;% | |||
node "%~dp0\..\mkdirp\bin\cmd.js" %* | |||
) |
@@ -0,0 +1,15 @@ | |||
#!/bin/sh | |||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')") | |||
case `uname` in | |||
*CYGWIN*) basedir=`cygpath -w "$basedir"`;; | |||
esac | |||
if [ -x "$basedir/node" ]; then | |||
"$basedir/node" "$basedir/../multicast-dns/cli.js" "$@" | |||
ret=$? | |||
else | |||
node "$basedir/../multicast-dns/cli.js" "$@" | |||
ret=$? | |||
fi | |||
exit $ret |
@@ -0,0 +1,7 @@ | |||
@IF EXIST "%~dp0\node.exe" ( | |||
"%~dp0\node.exe" "%~dp0\..\multicast-dns\cli.js" %* | |||
) ELSE ( | |||
@SETLOCAL | |||
@SET PATHEXT=%PATHEXT:;.JS;=;% | |||
node "%~dp0\..\multicast-dns\cli.js" %* | |||
) |
@@ -0,0 +1,15 @@ | |||
#!/bin/sh | |||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')") | |||
case `uname` in | |||
*CYGWIN*) basedir=`cygpath -w "$basedir"`;; | |||
esac | |||
if [ -x "$basedir/node" ]; then | |||
"$basedir/node" "$basedir/../opener/bin/opener-bin.js" "$@" | |||
ret=$? | |||
else | |||
node "$basedir/../opener/bin/opener-bin.js" "$@" | |||
ret=$? | |||
fi | |||
exit $ret |
@@ -0,0 +1,7 @@ | |||
@IF EXIST "%~dp0\node.exe" ( | |||
"%~dp0\node.exe" "%~dp0\..\opener\bin\opener-bin.js" %* | |||
) ELSE ( | |||
@SETLOCAL | |||
@SET PATHEXT=%PATHEXT:;.JS;=;% | |||
node "%~dp0\..\opener\bin\opener-bin.js" %* | |||
) |
@@ -0,0 +1,15 @@ | |||
#!/bin/sh | |||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')") | |||
case `uname` in | |||
*CYGWIN*) basedir=`cygpath -w "$basedir"`;; | |||
esac | |||
if [ -x "$basedir/node" ]; then | |||
"$basedir/node" "$basedir/../prettier/bin-prettier.js" "$@" | |||
ret=$? | |||
else | |||
node "$basedir/../prettier/bin-prettier.js" "$@" | |||
ret=$? | |||
fi | |||
exit $ret |
@@ -0,0 +1,7 @@ | |||
@IF EXIST "%~dp0\node.exe" ( | |||
"%~dp0\node.exe" "%~dp0\..\prettier\bin-prettier.js" %* | |||
) ELSE ( | |||
@SETLOCAL | |||
@SET PATHEXT=%PATHEXT:;.JS;=;% | |||
node "%~dp0\..\prettier\bin-prettier.js" %* | |||
) |
@@ -0,0 +1,15 @@ | |||
#!/bin/sh | |||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')") | |||
case `uname` in | |||
*CYGWIN*) basedir=`cygpath -w "$basedir"`;; | |||
esac | |||
if [ -x "$basedir/node" ]; then | |||
"$basedir/node" "$basedir/../regjsparser/bin/parser" "$@" | |||
ret=$? | |||
else | |||
node "$basedir/../regjsparser/bin/parser" "$@" | |||
ret=$? | |||
fi | |||
exit $ret |
@@ -0,0 +1,7 @@ | |||
@IF EXIST "%~dp0\node.exe" ( | |||
"%~dp0\node.exe" "%~dp0\..\regjsparser\bin\parser" %* | |||
) ELSE ( | |||
@SETLOCAL | |||
@SET PATHEXT=%PATHEXT:;.JS;=;% | |||
node "%~dp0\..\regjsparser\bin\parser" %* | |||
) |
@@ -0,0 +1,15 @@ | |||
#!/bin/sh | |||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')") | |||
case `uname` in | |||
*CYGWIN*) basedir=`cygpath -w "$basedir"`;; | |||
esac | |||
if [ -x "$basedir/node" ]; then | |||
"$basedir/node" "$basedir/../rimraf/bin.js" "$@" | |||
ret=$? | |||
else | |||
node "$basedir/../rimraf/bin.js" "$@" | |||
ret=$? | |||
fi | |||
exit $ret |
@@ -0,0 +1,7 @@ | |||
@IF EXIST "%~dp0\node.exe" ( | |||
"%~dp0\node.exe" "%~dp0\..\rimraf\bin.js" %* | |||
) ELSE ( | |||
@SETLOCAL | |||
@SET PATHEXT=%PATHEXT:;.JS;=;% | |||
node "%~dp0\..\rimraf\bin.js" %* | |||
) |
@@ -0,0 +1,15 @@ | |||
#!/bin/sh | |||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')") | |||
case `uname` in | |||
*CYGWIN*) basedir=`cygpath -w "$basedir"`;; | |||
esac | |||
if [ -x "$basedir/node" ]; then | |||
"$basedir/node" "$basedir/../semver/bin/semver" "$@" | |||
ret=$? | |||
else | |||
node "$basedir/../semver/bin/semver" "$@" | |||
ret=$? | |||
fi | |||
exit $ret |
@@ -0,0 +1,7 @@ | |||
@IF EXIST "%~dp0\node.exe" ( | |||
"%~dp0\node.exe" "%~dp0\..\semver\bin\semver" %* | |||
) ELSE ( | |||
@SETLOCAL | |||
@SET PATHEXT=%PATHEXT:;.JS;=;% | |||
node "%~dp0\..\semver\bin\semver" %* | |||
) |
@@ -0,0 +1,15 @@ | |||
#!/bin/sh | |||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')") | |||
case `uname` in | |||
*CYGWIN*) basedir=`cygpath -w "$basedir"`;; | |||
esac | |||
if [ -x "$basedir/node" ]; then | |||
"$basedir/node" "$basedir/../sha.js/bin.js" "$@" | |||
ret=$? | |||
else | |||
node "$basedir/../sha.js/bin.js" "$@" | |||
ret=$? | |||
fi | |||
exit $ret |
@@ -0,0 +1,7 @@ | |||
@IF EXIST "%~dp0\node.exe" ( | |||
"%~dp0\node.exe" "%~dp0\..\sha.js\bin.js" %* | |||
) ELSE ( | |||
@SETLOCAL | |||
@SET PATHEXT=%PATHEXT:;.JS;=;% | |||
node "%~dp0\..\sha.js\bin.js" %* | |||
) |
@@ -0,0 +1,15 @@ | |||
#!/bin/sh | |||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')") | |||
case `uname` in | |||
*CYGWIN*) basedir=`cygpath -w "$basedir"`;; | |||
esac | |||
if [ -x "$basedir/node" ]; then | |||
"$basedir/node" "$basedir/../shelljs/bin/shjs" "$@" | |||
ret=$? | |||
else | |||
node "$basedir/../shelljs/bin/shjs" "$@" | |||
ret=$? | |||
fi | |||
exit $ret |
@@ -0,0 +1,7 @@ | |||
@IF EXIST "%~dp0\node.exe" ( | |||
"%~dp0\node.exe" "%~dp0\..\shelljs\bin\shjs" %* | |||
) ELSE ( | |||
@SETLOCAL | |||
@SET PATHEXT=%PATHEXT:;.JS;=;% | |||
node "%~dp0\..\shelljs\bin\shjs" %* | |||
) |
@@ -0,0 +1,15 @@ | |||
#!/bin/sh | |||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')") | |||
case `uname` in | |||
*CYGWIN*) basedir=`cygpath -w "$basedir"`;; | |||
esac | |||
if [ -x "$basedir/node" ]; then | |||
"$basedir/node" "$basedir/../strip-indent/cli.js" "$@" | |||
ret=$? | |||
else | |||
node "$basedir/../strip-indent/cli.js" "$@" | |||
ret=$? | |||
fi | |||
exit $ret |
@@ -0,0 +1,7 @@ | |||
@IF EXIST "%~dp0\node.exe" ( | |||
"%~dp0\node.exe" "%~dp0\..\strip-indent\cli.js" %* | |||
) ELSE ( | |||
@SETLOCAL | |||
@SET PATHEXT=%PATHEXT:;.JS;=;% | |||
node "%~dp0\..\strip-indent\cli.js" %* | |||
) |
@@ -0,0 +1,15 @@ | |||
#!/bin/sh | |||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')") | |||
case `uname` in | |||
*CYGWIN*) basedir=`cygpath -w "$basedir"`;; | |||
esac | |||
if [ -x "$basedir/node" ]; then | |||
"$basedir/node" "$basedir/../svgo/bin/svgo" "$@" | |||
ret=$? | |||
else | |||
node "$basedir/../svgo/bin/svgo" "$@" | |||
ret=$? | |||
fi | |||
exit $ret |
@@ -0,0 +1,7 @@ | |||
@IF EXIST "%~dp0\node.exe" ( | |||
"%~dp0\node.exe" "%~dp0\..\svgo\bin\svgo" %* | |||
) ELSE ( | |||
@SETLOCAL | |||
@SET PATHEXT=%PATHEXT:;.JS;=;% | |||
node "%~dp0\..\svgo\bin\svgo" %* | |||
) |
@@ -0,0 +1,15 @@ | |||
#!/bin/sh | |||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')") | |||
case `uname` in | |||
*CYGWIN*) basedir=`cygpath -w "$basedir"`;; | |||
esac | |||
if [ -x "$basedir/node" ]; then | |||
"$basedir/node" "$basedir/../uglify-js/bin/uglifyjs" "$@" | |||
ret=$? | |||
else | |||
node "$basedir/../uglify-js/bin/uglifyjs" "$@" | |||
ret=$? | |||
fi | |||
exit $ret |
@@ -0,0 +1,7 @@ | |||
@IF EXIST "%~dp0\node.exe" ( | |||
"%~dp0\node.exe" "%~dp0\..\uglify-js\bin\uglifyjs" %* | |||
) ELSE ( | |||
@SETLOCAL | |||
@SET PATHEXT=%PATHEXT:;.JS;=;% | |||
node "%~dp0\..\uglify-js\bin\uglifyjs" %* | |||
) |
@@ -0,0 +1,15 @@ | |||
#!/bin/sh | |||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')") | |||
case `uname` in | |||
*CYGWIN*) basedir=`cygpath -w "$basedir"`;; | |||
esac | |||
if [ -x "$basedir/node" ]; then | |||
"$basedir/node" "$basedir/../uuid/bin/uuid" "$@" | |||
ret=$? | |||
else | |||
node "$basedir/../uuid/bin/uuid" "$@" | |||
ret=$? | |||
fi | |||
exit $ret |
@@ -0,0 +1,7 @@ | |||
@IF EXIST "%~dp0\node.exe" ( | |||
"%~dp0\node.exe" "%~dp0\..\uuid\bin\uuid" %* | |||
) ELSE ( | |||
@SETLOCAL | |||
@SET PATHEXT=%PATHEXT:;.JS;=;% | |||
node "%~dp0\..\uuid\bin\uuid" %* | |||
) |
@@ -0,0 +1,15 @@ | |||
#!/bin/sh | |||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')") | |||
case `uname` in | |||
*CYGWIN*) basedir=`cygpath -w "$basedir"`;; | |||
esac | |||
if [ -x "$basedir/node" ]; then | |||
"$basedir/node" "$basedir/../webpack/bin/webpack.js" "$@" | |||
ret=$? | |||
else | |||
node "$basedir/../webpack/bin/webpack.js" "$@" | |||
ret=$? | |||
fi | |||
exit $ret |
@@ -0,0 +1,15 @@ | |||
#!/bin/sh | |||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')") | |||
case `uname` in | |||
*CYGWIN*) basedir=`cygpath -w "$basedir"`;; | |||
esac | |||
if [ -x "$basedir/node" ]; then | |||
"$basedir/node" "$basedir/../webpack-bundle-analyzer/lib/bin/analyzer.js" "$@" | |||
ret=$? | |||
else | |||
node "$basedir/../webpack-bundle-analyzer/lib/bin/analyzer.js" "$@" | |||
ret=$? | |||
fi | |||
exit $ret |
@@ -0,0 +1,7 @@ | |||
@IF EXIST "%~dp0\node.exe" ( | |||
"%~dp0\node.exe" "%~dp0\..\webpack-bundle-analyzer\lib\bin\analyzer.js" %* | |||
) ELSE ( | |||
@SETLOCAL | |||
@SET PATHEXT=%PATHEXT:;.JS;=;% | |||
node "%~dp0\..\webpack-bundle-analyzer\lib\bin\analyzer.js" %* | |||
) |
@@ -0,0 +1,15 @@ | |||
#!/bin/sh | |||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')") | |||
case `uname` in | |||
*CYGWIN*) basedir=`cygpath -w "$basedir"`;; | |||
esac | |||
if [ -x "$basedir/node" ]; then | |||
"$basedir/node" "$basedir/../webpack-dev-server/bin/webpack-dev-server.js" "$@" | |||
ret=$? | |||
else | |||
node "$basedir/../webpack-dev-server/bin/webpack-dev-server.js" "$@" | |||
ret=$? | |||
fi | |||
exit $ret |
@@ -0,0 +1,7 @@ | |||
@IF EXIST "%~dp0\node.exe" ( | |||
"%~dp0\node.exe" "%~dp0\..\webpack-dev-server\bin\webpack-dev-server.js" %* | |||
) ELSE ( | |||
@SETLOCAL | |||
@SET PATHEXT=%PATHEXT:;.JS;=;% | |||
node "%~dp0\..\webpack-dev-server\bin\webpack-dev-server.js" %* | |||
) |
@@ -0,0 +1,7 @@ | |||
@IF EXIST "%~dp0\node.exe" ( | |||
"%~dp0\node.exe" "%~dp0\..\webpack\bin\webpack.js" %* | |||
) ELSE ( | |||
@SETLOCAL | |||
@SET PATHEXT=%PATHEXT:;.JS;=;% | |||
node "%~dp0\..\webpack\bin\webpack.js" %* | |||
) |
@@ -0,0 +1,15 @@ | |||
#!/bin/sh | |||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')") | |||
case `uname` in | |||
*CYGWIN*) basedir=`cygpath -w "$basedir"`;; | |||
esac | |||
if [ -x "$basedir/node" ]; then | |||
"$basedir/node" "$basedir/../which/bin/which" "$@" | |||
ret=$? | |||
else | |||
node "$basedir/../which/bin/which" "$@" | |||
ret=$? | |||
fi | |||
exit $ret |
@@ -0,0 +1,7 @@ | |||
@IF EXIST "%~dp0\node.exe" ( | |||
"%~dp0\node.exe" "%~dp0\..\which\bin\which" %* | |||
) ELSE ( | |||
@SETLOCAL | |||
@SET PATHEXT=%PATHEXT:;.JS;=;% | |||
node "%~dp0\..\which\bin\which" %* | |||
) |
@@ -0,0 +1,142 @@ | |||
# @babel/code-frame | |||
> Generate errors that contain a code frame that point to source locations. | |||
## Install | |||
```sh | |||
npm install --save-dev @babel/code-frame | |||
``` | |||
## Usage | |||
```js | |||
import { codeFrameColumns } from '@babel/code-frame'; | |||
const rawLines = `class Foo { | |||
constructor() | |||
}`; | |||
const location = { start: { line: 2, column: 16 } }; | |||
const result = codeFrameColumns(rawLines, location, { /* options */ }); | |||
console.log(result); | |||
``` | |||
``` | |||
1 | class Foo { | |||
> 2 | constructor() | |||
| ^ | |||
3 | } | |||
``` | |||
If the column number is not known, you may omit it. | |||
You can also pass an `end` hash in `location`. | |||
```js | |||
import { codeFrameColumns } from '@babel/code-frame'; | |||
const rawLines = `class Foo { | |||
constructor() { | |||
console.log("hello"); | |||
} | |||
}`; | |||
const location = { start: { line: 2, column: 17 }, end: { line: 4, column: 3 } }; | |||
const result = codeFrameColumns(rawLines, location, { /* options */ }); | |||
console.log(result); | |||
``` | |||
``` | |||
1 | class Foo { | |||
> 2 | constructor() { | |||
| ^ | |||
> 3 | console.log("hello"); | |||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ | |||
> 4 | } | |||
| ^^^ | |||
5 | }; | |||
``` | |||
## Options | |||
### `highlightCode` | |||
`boolean`, defaults to `false`. | |||
Toggles syntax highlighting the code as JavaScript for terminals. | |||
### `linesAbove` | |||
`number`, defaults to `2`. | |||
Adjust the number of lines to show above the error. | |||
### `linesBelow` | |||
`number`, defaults to `3`. | |||
Adjust the number of lines to show below the error. | |||
### `forceColor` | |||
`boolean`, defaults to `false`. | |||
Enable this to forcibly syntax highlight the code as JavaScript (for non-terminals); overrides `highlightCode`. | |||
### `message` | |||
`string`, otherwise nothing | |||
Pass in a string to be displayed inline (if possible) next to the highlighted | |||
location in the code. If it can't be positioned inline, it will be placed above | |||
the code frame. | |||
``` | |||
1 | class Foo { | |||
> 2 | constructor() | |||
| ^ Missing { | |||
3 | }; | |||
``` | |||
## Upgrading from prior versions | |||
Prior to version 7, the only API exposed by this module was for a single line and optional column pointer. The old API will now log a deprecation warning. | |||
The new API takes a `location` object, similar to what is available in an AST. | |||
This is an example of the deprecated (but still available) API: | |||
```js | |||
import codeFrame from '@babel/code-frame'; | |||
const rawLines = `class Foo { | |||
constructor() | |||
}`; | |||
const lineNumber = 2; | |||
const colNumber = 16; | |||
const result = codeFrame(rawLines, lineNumber, colNumber, { /* options */ }); | |||
console.log(result); | |||
``` | |||
To get the same highlighting using the new API: | |||
```js | |||
import { codeFrameColumns } from '@babel/code-frame'; | |||
const rawLines = `class Foo { | |||
constructor() { | |||
console.log("hello"); | |||
} | |||
}`; | |||
const location = { start: { line: 2, column: 16 } }; | |||
const result = codeFrameColumns(rawLines, location, { /* options */ }); | |||
console.log(result); | |||
``` |
@@ -0,0 +1,185 @@ | |||
"use strict"; | |||
Object.defineProperty(exports, "__esModule", { | |||
value: true | |||
}); | |||
exports.codeFrameColumns = codeFrameColumns; | |||
exports.default = _default; | |||
function _highlight() { | |||
var data = _interopRequireWildcard(require("@babel/highlight")); | |||
_highlight = function _highlight() { | |||
return data; | |||
}; | |||
return data; | |||
} | |||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } | |||
var deprecationWarningShown = false; | |||
function getDefs(chalk) { | |||
return { | |||
gutter: chalk.grey, | |||
marker: chalk.red.bold, | |||
message: chalk.red.bold | |||
}; | |||
} | |||
var NEWLINE = /\r\n|[\n\r\u2028\u2029]/; | |||
function getMarkerLines(loc, source, opts) { | |||
var startLoc = Object.assign({}, { | |||
column: 0, | |||
line: -1 | |||
}, loc.start); | |||
var endLoc = Object.assign({}, startLoc, loc.end); | |||
var _ref = opts || {}, | |||
_ref$linesAbove = _ref.linesAbove, | |||
linesAbove = _ref$linesAbove === void 0 ? 2 : _ref$linesAbove, | |||
_ref$linesBelow = _ref.linesBelow, | |||
linesBelow = _ref$linesBelow === void 0 ? 3 : _ref$linesBelow; | |||
var startLine = startLoc.line; | |||
var startColumn = startLoc.column; | |||
var endLine = endLoc.line; | |||
var endColumn = endLoc.column; | |||
var start = Math.max(startLine - (linesAbove + 1), 0); | |||
var end = Math.min(source.length, endLine + linesBelow); | |||
if (startLine === -1) { | |||
start = 0; | |||
} | |||
if (endLine === -1) { | |||
end = source.length; | |||
} | |||
var lineDiff = endLine - startLine; | |||
var markerLines = {}; | |||
if (lineDiff) { | |||
for (var i = 0; i <= lineDiff; i++) { | |||
var lineNumber = i + startLine; | |||
if (!startColumn) { | |||
markerLines[lineNumber] = true; | |||
} else if (i === 0) { | |||
var sourceLength = source[lineNumber - 1].length; | |||
markerLines[lineNumber] = [startColumn, sourceLength - startColumn]; | |||
} else if (i === lineDiff) { | |||
markerLines[lineNumber] = [0, endColumn]; | |||
} else { | |||
var _sourceLength = source[lineNumber - i].length; | |||
markerLines[lineNumber] = [0, _sourceLength]; | |||
} | |||
} | |||
} else { | |||
if (startColumn === endColumn) { | |||
if (startColumn) { | |||
markerLines[startLine] = [startColumn, 0]; | |||
} else { | |||
markerLines[startLine] = true; | |||
} | |||
} else { | |||
markerLines[startLine] = [startColumn, endColumn - startColumn]; | |||
} | |||
} | |||
return { | |||
start: start, | |||
end: end, | |||
markerLines: markerLines | |||
}; | |||
} | |||
function codeFrameColumns(rawLines, loc, opts) { | |||
if (opts === void 0) { | |||
opts = {}; | |||
} | |||
var highlighted = (opts.highlightCode || opts.forceColor) && (0, _highlight().shouldHighlight)(opts); | |||
var chalk = (0, _highlight().getChalk)(opts); | |||
var defs = getDefs(chalk); | |||
var maybeHighlight = function maybeHighlight(chalkFn, string) { | |||
return highlighted ? chalkFn(string) : string; | |||
}; | |||
if (highlighted) rawLines = (0, _highlight().default)(rawLines, opts); | |||
var lines = rawLines.split(NEWLINE); | |||
var _getMarkerLines = getMarkerLines(loc, lines, opts), | |||
start = _getMarkerLines.start, | |||
end = _getMarkerLines.end, | |||
markerLines = _getMarkerLines.markerLines; | |||
var hasColumns = loc.start && typeof loc.start.column === "number"; | |||
var numberMaxWidth = String(end).length; | |||
var frame = lines.slice(start, end).map(function (line, index) { | |||
var number = start + 1 + index; | |||
var paddedNumber = (" " + number).slice(-numberMaxWidth); | |||
var gutter = " " + paddedNumber + " | "; | |||
var hasMarker = markerLines[number]; | |||
var lastMarkerLine = !markerLines[number + 1]; | |||
if (hasMarker) { | |||
var markerLine = ""; | |||
if (Array.isArray(hasMarker)) { | |||
var markerSpacing = line.slice(0, Math.max(hasMarker[0] - 1, 0)).replace(/[^\t]/g, " "); | |||
var numberOfMarkers = hasMarker[1] || 1; | |||
markerLine = ["\n ", maybeHighlight(defs.gutter, gutter.replace(/\d/g, " ")), markerSpacing, maybeHighlight(defs.marker, "^").repeat(numberOfMarkers)].join(""); | |||
if (lastMarkerLine && opts.message) { | |||
markerLine += " " + maybeHighlight(defs.message, opts.message); | |||
} | |||
} | |||
return [maybeHighlight(defs.marker, ">"), maybeHighlight(defs.gutter, gutter), line, markerLine].join(""); | |||
} else { | |||
return " " + maybeHighlight(defs.gutter, gutter) + line; | |||
} | |||
}).join("\n"); | |||
if (opts.message && !hasColumns) { | |||
frame = "" + " ".repeat(numberMaxWidth + 1) + opts.message + "\n" + frame; | |||
} | |||
if (highlighted) { | |||
return chalk.reset(frame); | |||
} else { | |||
return frame; | |||
} | |||
} | |||
function _default(rawLines, lineNumber, colNumber, opts) { | |||
if (opts === void 0) { | |||
opts = {}; | |||
} | |||
if (!deprecationWarningShown) { | |||
deprecationWarningShown = true; | |||
var message = "Passing lineNumber and colNumber is deprecated to @babel/code-frame. Please use `codeFrameColumns`."; | |||
if (process.emitWarning) { | |||
process.emitWarning(message, "DeprecationWarning"); | |||
} else { | |||
var deprecationError = new Error(message); | |||
deprecationError.name = "DeprecationWarning"; | |||
console.warn(new Error(message)); | |||
} | |||
} | |||
colNumber = Math.max(colNumber, 0); | |||
var location = { | |||
start: { | |||
column: colNumber, | |||
line: lineNumber | |||
} | |||
}; | |||
return codeFrameColumns(rawLines, location, opts); | |||
} |
@@ -0,0 +1,55 @@ | |||
{ | |||
"_args": [ | |||
[ | |||
"@babel/code-frame@7.0.0-beta.44", | |||
"D:\\A易云\\YiYunJianZhu" | |||
] | |||
], | |||
"_development": true, | |||
"_from": "@babel/code-frame@7.0.0-beta.44", | |||
"_id": "@babel/code-frame@7.0.0-beta.44", | |||
"_inBundle": false, | |||
"_integrity": "sha512-cuAuTTIQ9RqcFRJ/Y8PvTh+paepNcaGxwQwjIDRWPXmzzyAeCO4KqS9ikMvq0MCbRk6GlYKwfzStrcP3/jSL8g==", | |||
"_location": "/@babel/code-frame", | |||
"_phantomChildren": {}, | |||
"_requested": { | |||
"type": "version", | |||
"registry": true, | |||
"raw": "@babel/code-frame@7.0.0-beta.44", | |||
"name": "@babel/code-frame", | |||
"escapedName": "@babel%2fcode-frame", | |||
"scope": "@babel", | |||
"rawSpec": "7.0.0-beta.44", | |||
"saveSpec": null, | |||
"fetchSpec": "7.0.0-beta.44" | |||
}, | |||
"_requiredBy": [ | |||
"/@babel/template", | |||
"/@babel/traverse", | |||
"/babel-eslint" | |||
], | |||
"_resolved": "http://registry.npmjs.org/@babel/code-frame/-/code-frame-7.0.0-beta.44.tgz", | |||
"_spec": "7.0.0-beta.44", | |||
"_where": "D:\\A易云\\YiYunJianZhu", | |||
"author": { | |||
"name": "Sebastian McKenzie", | |||
"email": "sebmck@gmail.com" | |||
}, | |||
"dependencies": { | |||
"@babel/highlight": "7.0.0-beta.44" | |||
}, | |||
"description": "Generate errors that contain a code frame that point to source locations.", | |||
"devDependencies": { | |||
"chalk": "^2.0.0", | |||
"strip-ansi": "^4.0.0" | |||
}, | |||
"homepage": "https://babeljs.io/", | |||
"license": "MIT", | |||
"main": "lib/index.js", | |||
"name": "@babel/code-frame", | |||
"repository": { | |||
"type": "git", | |||
"url": "https://github.com/babel/babel/tree/master/packages/babel-code-frame" | |||
}, | |||
"version": "7.0.0-beta.44" | |||
} |
@@ -0,0 +1,78 @@ | |||
# @babel/generator | |||
> Turns a [Babylon AST](https://github.com/babel/babel/blob/master/packages/babylon/ast/spec.md) into code. | |||
## Install | |||
```sh | |||
npm install --save-dev @babel/generator | |||
``` | |||
## Usage | |||
```js | |||
import {parse} from 'babylon'; | |||
import generate from '@babel/generator'; | |||
const code = 'class Example {}'; | |||
const ast = parse(code); | |||
const output = generate(ast, { /* options */ }, code); | |||
``` | |||
## Options | |||
Options for formatting output: | |||
name | type | default | description | |||
-----------------------|----------|-----------------|-------------------------------------------------------------------------- | |||
auxiliaryCommentBefore | string | | Optional string to add as a block comment at the start of the output file | |||
auxiliaryCommentAfter | string | | Optional string to add as a block comment at the end of the output file | |||
shouldPrintComment | function | `opts.comments` | Function that takes a comment (as a string) and returns `true` if the comment should be included in the output. By default, comments are included if `opts.comments` is `true` or if `opts.minifed` is `false` and the comment contains `@preserve` or `@license` | |||
retainLines | boolean | `false` | Attempt to use the same line numbers in the output code as in the source code (helps preserve stack traces) | |||
retainFunctionParens | boolean | `false` | Retain parens around function expressions (could be used to change engine parsing behavior) | |||
comments | boolean | `true` | Should comments be included in output | |||
compact | boolean or `'auto'` | `opts.minified` | Set to `true` to avoid adding whitespace for formatting | |||
minified | boolean | `false` | Should the output be minified | |||
concise | boolean | `false` | Set to `true` to reduce whitespace (but not as much as `opts.compact`) | |||
filename | string | | Used in warning messages | |||
jsonCompatibleStrings | boolean | `false` | Set to true to run `jsesc` with "json": true to print "\u00A9" vs. "©"; | |||
Options for source maps: | |||
name | type | default | description | |||
-----------------------|----------|-----------------|-------------------------------------------------------------------------- | |||
sourceMaps | boolean | `false` | Enable generating source maps | |||
sourceRoot | string | | A root for all relative URLs in the source map | |||
sourceFileName | string | | The filename for the source code (i.e. the code in the `code` argument). This will only be used if `code` is a string. | |||
## AST from Multiple Sources | |||
In most cases, Babel does a 1:1 transformation of input-file to output-file. However, | |||
you may be dealing with AST constructed from multiple sources - JS files, templates, etc. | |||
If this is the case, and you want the sourcemaps to reflect the correct sources, you'll need | |||
to pass an object to `generate` as the `code` parameter. Keys | |||
should be the source filenames, and values should be the source content. | |||
Here's an example of what that might look like: | |||
```js | |||
import {parse} from 'babylon'; | |||
import generate from '@babel/generator'; | |||
const a = 'var a = 1;'; | |||
const b = 'var b = 2;'; | |||
const astA = parse(a, { sourceFilename: 'a.js' }); | |||
const astB = parse(b, { sourceFilename: 'b.js' }); | |||
const ast = { | |||
type: 'Program', | |||
body: [].concat(astA.program.body, astB.program.body) | |||
}; | |||
const { code, map } = generate(ast, { sourceMaps: true }, { | |||
'a.js': a, | |||
'b.js': b | |||
}); | |||
// Sourcemap will point to both a.js and b.js where appropriate. | |||
``` |
@@ -0,0 +1,217 @@ | |||
"use strict"; | |||
Object.defineProperty(exports, "__esModule", { | |||
value: true | |||
}); | |||
exports.default = void 0; | |||
function _trimRight() { | |||
var data = _interopRequireDefault(require("trim-right")); | |||
_trimRight = function _trimRight() { | |||
return data; | |||
}; | |||
return data; | |||
} | |||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | |||
var SPACES_RE = /^[ \t]+$/; | |||
var Buffer = function () { | |||
function Buffer(map) { | |||
this._map = null; | |||
this._buf = []; | |||
this._last = ""; | |||
this._queue = []; | |||
this._position = { | |||
line: 1, | |||
column: 0 | |||
}; | |||
this._sourcePosition = { | |||
identifierName: null, | |||
line: null, | |||
column: null, | |||
filename: null | |||
}; | |||
this._map = map; | |||
} | |||
var _proto = Buffer.prototype; | |||
_proto.get = function get() { | |||
this._flush(); | |||
var map = this._map; | |||
var result = { | |||
code: (0, _trimRight().default)(this._buf.join("")), | |||
map: null, | |||
rawMappings: map && map.getRawMappings() | |||
}; | |||
if (map) { | |||
Object.defineProperty(result, "map", { | |||
configurable: true, | |||
enumerable: true, | |||
get: function get() { | |||
return this.map = map.get(); | |||
}, | |||
set: function set(value) { | |||
Object.defineProperty(this, "map", { | |||
value: value, | |||
writable: true | |||
}); | |||
} | |||
}); | |||
} | |||
return result; | |||
}; | |||
_proto.append = function append(str) { | |||
this._flush(); | |||
var _sourcePosition = this._sourcePosition, | |||
line = _sourcePosition.line, | |||
column = _sourcePosition.column, | |||
filename = _sourcePosition.filename, | |||
identifierName = _sourcePosition.identifierName; | |||
this._append(str, line, column, identifierName, filename); | |||
}; | |||
_proto.queue = function queue(str) { | |||
if (str === "\n") { | |||
while (this._queue.length > 0 && SPACES_RE.test(this._queue[0][0])) { | |||
this._queue.shift(); | |||
} | |||
} | |||
var _sourcePosition2 = this._sourcePosition, | |||
line = _sourcePosition2.line, | |||
column = _sourcePosition2.column, | |||
filename = _sourcePosition2.filename, | |||
identifierName = _sourcePosition2.identifierName; | |||
this._queue.unshift([str, line, column, identifierName, filename]); | |||
}; | |||
_proto._flush = function _flush() { | |||
var item; | |||
while (item = this._queue.pop()) { | |||
this._append.apply(this, item); | |||
} | |||
}; | |||
_proto._append = function _append(str, line, column, identifierName, filename) { | |||
if (this._map && str[0] !== "\n") { | |||
this._map.mark(this._position.line, this._position.column, line, column, identifierName, filename); | |||
} | |||
this._buf.push(str); | |||
this._last = str[str.length - 1]; | |||
for (var i = 0; i < str.length; i++) { | |||
if (str[i] === "\n") { | |||
this._position.line++; | |||
this._position.column = 0; | |||
} else { | |||
this._position.column++; | |||
} | |||
} | |||
}; | |||
_proto.removeTrailingNewline = function removeTrailingNewline() { | |||
if (this._queue.length > 0 && this._queue[0][0] === "\n") { | |||
this._queue.shift(); | |||
} | |||
}; | |||
_proto.removeLastSemicolon = function removeLastSemicolon() { | |||
if (this._queue.length > 0 && this._queue[0][0] === ";") { | |||
this._queue.shift(); | |||
} | |||
}; | |||
_proto.endsWith = function endsWith(suffix) { | |||
if (suffix.length === 1) { | |||
var last; | |||
if (this._queue.length > 0) { | |||
var str = this._queue[0][0]; | |||
last = str[str.length - 1]; | |||
} else { | |||
last = this._last; | |||
} | |||
return last === suffix; | |||
} | |||
var end = this._last + this._queue.reduce(function (acc, item) { | |||
return item[0] + acc; | |||
}, ""); | |||
if (suffix.length <= end.length) { | |||
return end.slice(-suffix.length) === suffix; | |||
} | |||
return false; | |||
}; | |||
_proto.hasContent = function hasContent() { | |||
return this._queue.length > 0 || !!this._last; | |||
}; | |||
_proto.source = function source(prop, loc) { | |||
if (prop && !loc) return; | |||
var pos = loc ? loc[prop] : null; | |||
this._sourcePosition.identifierName = loc && loc.identifierName || null; | |||
this._sourcePosition.line = pos ? pos.line : null; | |||
this._sourcePosition.column = pos ? pos.column : null; | |||
this._sourcePosition.filename = loc && loc.filename || null; | |||
}; | |||
_proto.withSource = function withSource(prop, loc, cb) { | |||
if (!this._map) return cb(); | |||
var originalLine = this._sourcePosition.line; | |||
var originalColumn = this._sourcePosition.column; | |||
var originalFilename = this._sourcePosition.filename; | |||
var originalIdentifierName = this._sourcePosition.identifierName; | |||
this.source(prop, loc); | |||
cb(); | |||
this._sourcePosition.line = originalLine; | |||
this._sourcePosition.column = originalColumn; | |||
this._sourcePosition.filename = originalFilename; | |||
this._sourcePosition.identifierName = originalIdentifierName; | |||
}; | |||
_proto.getCurrentColumn = function getCurrentColumn() { | |||
var extra = this._queue.reduce(function (acc, item) { | |||
return item[0] + acc; | |||
}, ""); | |||
var lastIndex = extra.lastIndexOf("\n"); | |||
return lastIndex === -1 ? this._position.column + extra.length : extra.length - 1 - lastIndex; | |||
}; | |||
_proto.getCurrentLine = function getCurrentLine() { | |||
var extra = this._queue.reduce(function (acc, item) { | |||
return item[0] + acc; | |||
}, ""); | |||
var count = 0; | |||
for (var i = 0; i < extra.length; i++) { | |||
if (extra[i] === "\n") count++; | |||
} | |||
return this._position.line + count; | |||
}; | |||
return Buffer; | |||
}(); | |||
exports.default = Buffer; |
@@ -0,0 +1,60 @@ | |||
"use strict"; | |||
Object.defineProperty(exports, "__esModule", { | |||
value: true | |||
}); | |||
exports.File = File; | |||
exports.Program = Program; | |||
exports.BlockStatement = BlockStatement; | |||
exports.Noop = Noop; | |||
exports.Directive = Directive; | |||
Object.defineProperty(exports, "DirectiveLiteral", { | |||
enumerable: true, | |||
get: function get() { | |||
return _types.StringLiteral; | |||
} | |||
}); | |||
var _types = require("./types"); | |||
function File(node) { | |||
this.print(node.program, node); | |||
} | |||
function Program(node) { | |||
this.printInnerComments(node, false); | |||
this.printSequence(node.directives, node); | |||
if (node.directives && node.directives.length) this.newline(); | |||
this.printSequence(node.body, node); | |||
} | |||
function BlockStatement(node) { | |||
this.token("{"); | |||
this.printInnerComments(node); | |||
var hasDirectives = node.directives && node.directives.length; | |||
if (node.body.length || hasDirectives) { | |||
this.newline(); | |||
this.printSequence(node.directives, node, { | |||
indent: true | |||
}); | |||
if (hasDirectives) this.newline(); | |||
this.printSequence(node.body, node, { | |||
indent: true | |||
}); | |||
this.removeTrailingNewline(); | |||
this.source("end", node.loc); | |||
if (!this.endsWith("\n")) this.newline(); | |||
this.rightBrace(); | |||
} else { | |||
this.source("end", node.loc); | |||
this.token("}"); | |||
} | |||
} | |||
function Noop() {} | |||
function Directive(node) { | |||
this.print(node.value, node); | |||
this.semicolon(); | |||
} |
@@ -0,0 +1,162 @@ | |||
"use strict"; | |||
Object.defineProperty(exports, "__esModule", { | |||
value: true | |||
}); | |||
exports.ClassExpression = exports.ClassDeclaration = ClassDeclaration; | |||
exports.ClassBody = ClassBody; | |||
exports.ClassProperty = ClassProperty; | |||
exports.ClassMethod = ClassMethod; | |||
exports._classMethodHead = _classMethodHead; | |||
function t() { | |||
var data = _interopRequireWildcard(require("@babel/types")); | |||
t = function t() { | |||
return data; | |||
}; | |||
return data; | |||
} | |||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } | |||
function ClassDeclaration(node, parent) { | |||
if (!t().isExportDefaultDeclaration(parent) && !t().isExportNamedDeclaration(parent)) { | |||
this.printJoin(node.decorators, node); | |||
} | |||
if (node.declare) { | |||
this.word("declare"); | |||
this.space(); | |||
} | |||
if (node.abstract) { | |||
this.word("abstract"); | |||
this.space(); | |||
} | |||
this.word("class"); | |||
if (node.id) { | |||
this.space(); | |||
this.print(node.id, node); | |||
} | |||
this.print(node.typeParameters, node); | |||
if (node.superClass) { | |||
this.space(); | |||
this.word("extends"); | |||
this.space(); | |||
this.print(node.superClass, node); | |||
this.print(node.superTypeParameters, node); | |||
} | |||
if (node.implements) { | |||
this.space(); | |||
this.word("implements"); | |||
this.space(); | |||
this.printList(node.implements, node); | |||
} | |||
this.space(); | |||
this.print(node.body, node); | |||
} | |||
function ClassBody(node) { | |||
this.token("{"); | |||
this.printInnerComments(node); | |||
if (node.body.length === 0) { | |||
this.token("}"); | |||
} else { | |||
this.newline(); | |||
this.indent(); | |||
this.printSequence(node.body, node); | |||
this.dedent(); | |||
if (!this.endsWith("\n")) this.newline(); | |||
this.rightBrace(); | |||
} | |||
} | |||
function ClassProperty(node) { | |||
this.printJoin(node.decorators, node); | |||
if (node.accessibility) { | |||
this.word(node.accessibility); | |||
this.space(); | |||
} | |||
if (node.static) { | |||
this.word("static"); | |||
this.space(); | |||
} | |||
if (node.abstract) { | |||
this.word("abstract"); | |||
this.space(); | |||
} | |||
if (node.readonly) { | |||
this.word("readonly"); | |||
this.space(); | |||
} | |||
if (node.computed) { | |||
this.token("["); | |||
this.print(node.key, node); | |||
this.token("]"); | |||
} else { | |||
this._variance(node); | |||
this.print(node.key, node); | |||
} | |||
if (node.optional) { | |||
this.token("?"); | |||
} | |||
if (node.definite) { | |||
this.token("!"); | |||
} | |||
this.print(node.typeAnnotation, node); | |||
if (node.value) { | |||
this.space(); | |||
this.token("="); | |||
this.space(); | |||
this.print(node.value, node); | |||
} | |||
this.semicolon(); | |||
} | |||
function ClassMethod(node) { | |||
this._classMethodHead(node); | |||
this.space(); | |||
this.print(node.body, node); | |||
} | |||
function _classMethodHead(node) { | |||
this.printJoin(node.decorators, node); | |||
if (node.accessibility) { | |||
this.word(node.accessibility); | |||
this.space(); | |||
} | |||
if (node.abstract) { | |||
this.word("abstract"); | |||
this.space(); | |||
} | |||
if (node.static) { | |||
this.word("static"); | |||
this.space(); | |||
} | |||
this._methodHead(node); | |||
} |
@@ -0,0 +1,283 @@ | |||
"use strict"; | |||
Object.defineProperty(exports, "__esModule", { | |||
value: true | |||
}); | |||
exports.UnaryExpression = UnaryExpression; | |||
exports.DoExpression = DoExpression; | |||
exports.ParenthesizedExpression = ParenthesizedExpression; | |||
exports.UpdateExpression = UpdateExpression; | |||
exports.ConditionalExpression = ConditionalExpression; | |||
exports.NewExpression = NewExpression; | |||
exports.SequenceExpression = SequenceExpression; | |||
exports.ThisExpression = ThisExpression; | |||
exports.Super = Super; | |||
exports.Decorator = Decorator; | |||
exports.OptionalMemberExpression = OptionalMemberExpression; | |||
exports.OptionalCallExpression = OptionalCallExpression; | |||
exports.CallExpression = CallExpression; | |||
exports.Import = Import; | |||
exports.EmptyStatement = EmptyStatement; | |||
exports.ExpressionStatement = ExpressionStatement; | |||
exports.AssignmentPattern = AssignmentPattern; | |||
exports.LogicalExpression = exports.BinaryExpression = exports.AssignmentExpression = AssignmentExpression; | |||
exports.BindExpression = BindExpression; | |||
exports.MemberExpression = MemberExpression; | |||
exports.MetaProperty = MetaProperty; | |||
exports.AwaitExpression = exports.YieldExpression = void 0; | |||
function t() { | |||
var data = _interopRequireWildcard(require("@babel/types")); | |||
t = function t() { | |||
return data; | |||
}; | |||
return data; | |||
} | |||
var n = _interopRequireWildcard(require("../node")); | |||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } | |||
function UnaryExpression(node) { | |||
if (node.operator === "void" || node.operator === "delete" || node.operator === "typeof") { | |||
this.word(node.operator); | |||
this.space(); | |||
} else { | |||
this.token(node.operator); | |||
} | |||
this.print(node.argument, node); | |||
} | |||
function DoExpression(node) { | |||
this.word("do"); | |||
this.space(); | |||
this.print(node.body, node); | |||
} | |||
function ParenthesizedExpression(node) { | |||
this.token("("); | |||
this.print(node.expression, node); | |||
this.token(")"); | |||
} | |||
function UpdateExpression(node) { | |||
if (node.prefix) { | |||
this.token(node.operator); | |||
this.print(node.argument, node); | |||
} else { | |||
this.startTerminatorless(true); | |||
this.print(node.argument, node); | |||
this.endTerminatorless(); | |||
this.token(node.operator); | |||
} | |||
} | |||
function ConditionalExpression(node) { | |||
this.print(node.test, node); | |||
this.space(); | |||
this.token("?"); | |||
this.space(); | |||
this.print(node.consequent, node); | |||
this.space(); | |||
this.token(":"); | |||
this.space(); | |||
this.print(node.alternate, node); | |||
} | |||
function NewExpression(node, parent) { | |||
this.word("new"); | |||
this.space(); | |||
this.print(node.callee, node); | |||
if (this.format.minified && node.arguments.length === 0 && !node.optional && !t().isCallExpression(parent, { | |||
callee: node | |||
}) && !t().isMemberExpression(parent) && !t().isNewExpression(parent)) { | |||
return; | |||
} | |||
this.print(node.typeParameters, node); | |||
if (node.optional) { | |||
this.token("?."); | |||
} | |||
this.token("("); | |||
this.printList(node.arguments, node); | |||
this.token(")"); | |||
} | |||
function SequenceExpression(node) { | |||
this.printList(node.expressions, node); | |||
} | |||
function ThisExpression() { | |||
this.word("this"); | |||
} | |||
function Super() { | |||
this.word("super"); | |||
} | |||
function Decorator(node) { | |||
this.token("@"); | |||
this.print(node.expression, node); | |||
this.newline(); | |||
} | |||
function OptionalMemberExpression(node) { | |||
this.print(node.object, node); | |||
if (!node.computed && t().isMemberExpression(node.property)) { | |||
throw new TypeError("Got a MemberExpression for MemberExpression property"); | |||
} | |||
var computed = node.computed; | |||
if (t().isLiteral(node.property) && typeof node.property.value === "number") { | |||
computed = true; | |||
} | |||
if (node.optional) { | |||
this.token("?."); | |||
} | |||
if (computed) { | |||
this.token("["); | |||
this.print(node.property, node); | |||
this.token("]"); | |||
} else { | |||
if (!node.optional) { | |||
this.token("."); | |||
} | |||
this.print(node.property, node); | |||
} | |||
} | |||
function OptionalCallExpression(node) { | |||
this.print(node.callee, node); | |||
this.print(node.typeParameters, node); | |||
if (node.optional) { | |||
this.token("?."); | |||
} | |||
this.token("("); | |||
this.printList(node.arguments, node); | |||
this.token(")"); | |||
} | |||
function CallExpression(node) { | |||
this.print(node.callee, node); | |||
this.print(node.typeParameters, node); | |||
this.token("("); | |||
this.printList(node.arguments, node); | |||
this.token(")"); | |||
} | |||
function Import() { | |||
this.word("import"); | |||
} | |||
function buildYieldAwait(keyword) { | |||
return function (node) { | |||
this.word(keyword); | |||
if (node.delegate) { | |||
this.token("*"); | |||
} | |||
if (node.argument) { | |||
this.space(); | |||
var terminatorState = this.startTerminatorless(); | |||
this.print(node.argument, node); | |||
this.endTerminatorless(terminatorState); | |||
} | |||
}; | |||
} | |||
var YieldExpression = buildYieldAwait("yield"); | |||
exports.YieldExpression = YieldExpression; | |||
var AwaitExpression = buildYieldAwait("await"); | |||
exports.AwaitExpression = AwaitExpression; | |||
function EmptyStatement() { | |||
this.semicolon(true); | |||
} | |||
function ExpressionStatement(node) { | |||
this.print(node.expression, node); | |||
this.semicolon(); | |||
} | |||
function AssignmentPattern(node) { | |||
this.print(node.left, node); | |||
if (node.left.optional) this.token("?"); | |||
this.print(node.left.typeAnnotation, node); | |||
this.space(); | |||
this.token("="); | |||
this.space(); | |||
this.print(node.right, node); | |||
} | |||
function AssignmentExpression(node, parent) { | |||
var parens = this.inForStatementInitCounter && node.operator === "in" && !n.needsParens(node, parent); | |||
if (parens) { | |||
this.token("("); | |||
} | |||
this.print(node.left, node); | |||
this.space(); | |||
if (node.operator === "in" || node.operator === "instanceof") { | |||
this.word(node.operator); | |||
} else { | |||
this.token(node.operator); | |||
} | |||
this.space(); | |||
this.print(node.right, node); | |||
if (parens) { | |||
this.token(")"); | |||
} | |||
} | |||
function BindExpression(node) { | |||
this.print(node.object, node); | |||
this.token("::"); | |||
this.print(node.callee, node); | |||
} | |||
function MemberExpression(node) { | |||
this.print(node.object, node); | |||
if (!node.computed && t().isMemberExpression(node.property)) { | |||
throw new TypeError("Got a MemberExpression for MemberExpression property"); | |||
} | |||
var computed = node.computed; | |||
if (t().isLiteral(node.property) && typeof node.property.value === "number") { | |||
computed = true; | |||
} | |||
if (computed) { | |||
this.token("["); | |||
this.print(node.property, node); | |||
this.token("]"); | |||
} else { | |||
this.token("."); | |||
this.print(node.property, node); | |||
} | |||
} | |||
function MetaProperty(node) { | |||
this.print(node.meta, node); | |||
this.token("."); | |||
this.print(node.property, node); | |||
} |
@@ -0,0 +1,577 @@ | |||
"use strict"; | |||
Object.defineProperty(exports, "__esModule", { | |||
value: true | |||
}); | |||
exports.AnyTypeAnnotation = AnyTypeAnnotation; | |||
exports.ArrayTypeAnnotation = ArrayTypeAnnotation; | |||
exports.BooleanTypeAnnotation = BooleanTypeAnnotation; | |||
exports.BooleanLiteralTypeAnnotation = BooleanLiteralTypeAnnotation; | |||
exports.NullLiteralTypeAnnotation = NullLiteralTypeAnnotation; | |||
exports.DeclareClass = DeclareClass; | |||
exports.DeclareFunction = DeclareFunction; | |||
exports.InferredPredicate = InferredPredicate; | |||
exports.DeclaredPredicate = DeclaredPredicate; | |||
exports.DeclareInterface = DeclareInterface; | |||
exports.DeclareModule = DeclareModule; | |||
exports.DeclareModuleExports = DeclareModuleExports; | |||
exports.DeclareTypeAlias = DeclareTypeAlias; | |||
exports.DeclareOpaqueType = DeclareOpaqueType; | |||
exports.DeclareVariable = DeclareVariable; | |||
exports.DeclareExportDeclaration = DeclareExportDeclaration; | |||
exports.DeclareExportAllDeclaration = DeclareExportAllDeclaration; | |||
exports.ExistsTypeAnnotation = ExistsTypeAnnotation; | |||
exports.FunctionTypeAnnotation = FunctionTypeAnnotation; | |||
exports.FunctionTypeParam = FunctionTypeParam; | |||
exports.GenericTypeAnnotation = exports.ClassImplements = exports.InterfaceExtends = InterfaceExtends; | |||
exports._interfaceish = _interfaceish; | |||
exports._variance = _variance; | |||
exports.InterfaceDeclaration = InterfaceDeclaration; | |||
exports.IntersectionTypeAnnotation = IntersectionTypeAnnotation; | |||
exports.MixedTypeAnnotation = MixedTypeAnnotation; | |||
exports.EmptyTypeAnnotation = EmptyTypeAnnotation; | |||
exports.NullableTypeAnnotation = NullableTypeAnnotation; | |||
exports.NumberTypeAnnotation = NumberTypeAnnotation; | |||
exports.StringTypeAnnotation = StringTypeAnnotation; | |||
exports.ThisTypeAnnotation = ThisTypeAnnotation; | |||
exports.TupleTypeAnnotation = TupleTypeAnnotation; | |||
exports.TypeofTypeAnnotation = TypeofTypeAnnotation; | |||
exports.TypeAlias = TypeAlias; | |||
exports.TypeAnnotation = TypeAnnotation; | |||
exports.TypeParameterDeclaration = exports.TypeParameterInstantiation = TypeParameterInstantiation; | |||
exports.TypeParameter = TypeParameter; | |||
exports.OpaqueType = OpaqueType; | |||
exports.ObjectTypeAnnotation = ObjectTypeAnnotation; | |||
exports.ObjectTypeCallProperty = ObjectTypeCallProperty; | |||
exports.ObjectTypeIndexer = ObjectTypeIndexer; | |||
exports.ObjectTypeProperty = ObjectTypeProperty; | |||
exports.ObjectTypeSpreadProperty = ObjectTypeSpreadProperty; | |||
exports.QualifiedTypeIdentifier = QualifiedTypeIdentifier; | |||
exports.UnionTypeAnnotation = UnionTypeAnnotation; | |||
exports.TypeCastExpression = TypeCastExpression; | |||
exports.Variance = Variance; | |||
exports.VoidTypeAnnotation = VoidTypeAnnotation; | |||
Object.defineProperty(exports, "NumberLiteralTypeAnnotation", { | |||
enumerable: true, | |||
get: function get() { | |||
return _types2.NumericLiteral; | |||
} | |||
}); | |||
Object.defineProperty(exports, "StringLiteralTypeAnnotation", { | |||
enumerable: true, | |||
get: function get() { | |||
return _types2.StringLiteral; | |||
} | |||
}); | |||
function t() { | |||
var data = _interopRequireWildcard(require("@babel/types")); | |||
t = function t() { | |||
return data; | |||
}; | |||
return data; | |||
} | |||
var _modules = require("./modules"); | |||
var _types2 = require("./types"); | |||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } | |||
function AnyTypeAnnotation() { | |||
this.word("any"); | |||
} | |||
function ArrayTypeAnnotation(node) { | |||
this.print(node.elementType, node); | |||
this.token("["); | |||
this.token("]"); | |||
} | |||
function BooleanTypeAnnotation() { | |||
this.word("boolean"); | |||
} | |||
function BooleanLiteralTypeAnnotation(node) { | |||
this.word(node.value ? "true" : "false"); | |||
} | |||
function NullLiteralTypeAnnotation() { | |||
this.word("null"); | |||
} | |||
function DeclareClass(node, parent) { | |||
if (!t().isDeclareExportDeclaration(parent)) { | |||
this.word("declare"); | |||
this.space(); | |||
} | |||
this.word("class"); | |||
this.space(); | |||
this._interfaceish(node); | |||
} | |||
function DeclareFunction(node, parent) { | |||
if (!t().isDeclareExportDeclaration(parent)) { | |||
this.word("declare"); | |||
this.space(); | |||
} | |||
this.word("function"); | |||
this.space(); | |||
this.print(node.id, node); | |||
this.print(node.id.typeAnnotation.typeAnnotation, node); | |||
if (node.predicate) { | |||
this.space(); | |||
this.print(node.predicate, node); | |||
} | |||
this.semicolon(); | |||
} | |||
function InferredPredicate() { | |||
this.token("%"); | |||
this.word("checks"); | |||
} | |||
function DeclaredPredicate(node) { | |||
this.token("%"); | |||
this.word("checks"); | |||
this.token("("); | |||
this.print(node.value, node); | |||
this.token(")"); | |||
} | |||
function DeclareInterface(node) { | |||
this.word("declare"); | |||
this.space(); | |||
this.InterfaceDeclaration(node); | |||
} | |||
function DeclareModule(node) { | |||
this.word("declare"); | |||
this.space(); | |||
this.word("module"); | |||
this.space(); | |||
this.print(node.id, node); | |||
this.space(); | |||
this.print(node.body, node); | |||
} | |||
function DeclareModuleExports(node) { | |||
this.word("declare"); | |||
this.space(); | |||
this.word("module"); | |||
this.token("."); | |||
this.word("exports"); | |||
this.print(node.typeAnnotation, node); | |||
} | |||
function DeclareTypeAlias(node) { | |||
this.word("declare"); | |||
this.space(); | |||
this.TypeAlias(node); | |||
} | |||
function DeclareOpaqueType(node, parent) { | |||
if (!t().isDeclareExportDeclaration(parent)) { | |||
this.word("declare"); | |||
this.space(); | |||
} | |||
this.OpaqueType(node); | |||
} | |||
function DeclareVariable(node, parent) { | |||
if (!t().isDeclareExportDeclaration(parent)) { | |||
this.word("declare"); | |||
this.space(); | |||
} | |||
this.word("var"); | |||
this.space(); | |||
this.print(node.id, node); | |||
this.print(node.id.typeAnnotation, node); | |||
this.semicolon(); | |||
} | |||
function DeclareExportDeclaration(node) { | |||
this.word("declare"); | |||
this.space(); | |||
this.word("export"); | |||
this.space(); | |||
if (node.default) { | |||
this.word("default"); | |||
this.space(); | |||
} | |||
FlowExportDeclaration.apply(this, arguments); | |||
} | |||
function DeclareExportAllDeclaration() { | |||
this.word("declare"); | |||
this.space(); | |||
_modules.ExportAllDeclaration.apply(this, arguments); | |||
} | |||
function FlowExportDeclaration(node) { | |||
if (node.declaration) { | |||
var declar = node.declaration; | |||
this.print(declar, node); | |||
if (!t().isStatement(declar)) this.semicolon(); | |||
} else { | |||
this.token("{"); | |||
if (node.specifiers.length) { | |||
this.space(); | |||
this.printList(node.specifiers, node); | |||
this.space(); | |||
} | |||
this.token("}"); | |||
if (node.source) { | |||
this.space(); | |||
this.word("from"); | |||
this.space(); | |||
this.print(node.source, node); | |||
} | |||
this.semicolon(); | |||
} | |||
} | |||
function ExistsTypeAnnotation() { | |||
this.token("*"); | |||
} | |||
function FunctionTypeAnnotation(node, parent) { | |||
this.print(node.typeParameters, node); | |||
this.token("("); | |||
this.printList(node.params, node); | |||
if (node.rest) { | |||
if (node.params.length) { | |||
this.token(","); | |||
this.space(); | |||
} | |||
this.token("..."); | |||
this.print(node.rest, node); | |||
} | |||
this.token(")"); | |||
if (parent.type === "ObjectTypeCallProperty" || parent.type === "DeclareFunction" || parent.type === "ObjectTypeProperty" && parent.method) { | |||
this.token(":"); | |||
} else { | |||
this.space(); | |||
this.token("=>"); | |||
} | |||
this.space(); | |||
this.print(node.returnType, node); | |||
} | |||
function FunctionTypeParam(node) { | |||
this.print(node.name, node); | |||
if (node.optional) this.token("?"); | |||
this.token(":"); | |||
this.space(); | |||
this.print(node.typeAnnotation, node); | |||
} | |||
function InterfaceExtends(node) { | |||
this.print(node.id, node); | |||
this.print(node.typeParameters, node); | |||
} | |||
function _interfaceish(node) { | |||
this.print(node.id, node); | |||
this.print(node.typeParameters, node); | |||
if (node.extends.length) { | |||
this.space(); | |||
this.word("extends"); | |||
this.space(); | |||
this.printList(node.extends, node); | |||
} | |||
if (node.mixins && node.mixins.length) { | |||
this.space(); | |||
this.word("mixins"); | |||
this.space(); | |||
this.printList(node.mixins, node); | |||
} | |||
this.space(); | |||
this.print(node.body, node); | |||
} | |||
function _variance(node) { | |||
if (node.variance) { | |||
if (node.variance.kind === "plus") { | |||
this.token("+"); | |||
} else if (node.variance.kind === "minus") { | |||
this.token("-"); | |||
} | |||
} | |||
} | |||
function InterfaceDeclaration(node) { | |||
this.word("interface"); | |||
this.space(); | |||
this._interfaceish(node); | |||
} | |||
function andSeparator() { | |||
this.space(); | |||
this.token("&"); | |||
this.space(); | |||
} | |||
function IntersectionTypeAnnotation(node) { | |||
this.printJoin(node.types, node, { | |||
separator: andSeparator | |||
}); | |||
} | |||
function MixedTypeAnnotation() { | |||
this.word("mixed"); | |||
} | |||
function EmptyTypeAnnotation() { | |||
this.word("empty"); | |||
} | |||
function NullableTypeAnnotation(node) { | |||
this.token("?"); | |||
this.print(node.typeAnnotation, node); | |||
} | |||
function NumberTypeAnnotation() { | |||
this.word("number"); | |||
} | |||
function StringTypeAnnotation() { | |||
this.word("string"); | |||
} | |||
function ThisTypeAnnotation() { | |||
this.word("this"); | |||
} | |||
function TupleTypeAnnotation(node) { | |||
this.token("["); | |||
this.printList(node.types, node); | |||
this.token("]"); | |||
} | |||
function TypeofTypeAnnotation(node) { | |||
this.word("typeof"); | |||
this.space(); | |||
this.print(node.argument, node); | |||
} | |||
function TypeAlias(node) { | |||
this.word("type"); | |||
this.space(); | |||
this.print(node.id, node); | |||
this.print(node.typeParameters, node); | |||
this.space(); | |||
this.token("="); | |||
this.space(); | |||
this.print(node.right, node); | |||
this.semicolon(); | |||
} | |||
function TypeAnnotation(node) { | |||
this.token(":"); | |||
this.space(); | |||
if (node.optional) this.token("?"); | |||
this.print(node.typeAnnotation, node); | |||
} | |||
function TypeParameterInstantiation(node) { | |||
this.token("<"); | |||
this.printList(node.params, node, {}); | |||
this.token(">"); | |||
} | |||
function TypeParameter(node) { | |||
this._variance(node); | |||
this.word(node.name); | |||
if (node.bound) { | |||
this.print(node.bound, node); | |||
} | |||
if (node.default) { | |||
this.space(); | |||
this.token("="); | |||
this.space(); | |||
this.print(node.default, node); | |||
} | |||
} | |||
function OpaqueType(node) { | |||
this.word("opaque"); | |||
this.space(); | |||
this.word("type"); | |||
this.space(); | |||
this.print(node.id, node); | |||
this.print(node.typeParameters, node); | |||
if (node.supertype) { | |||
this.token(":"); | |||
this.space(); | |||
this.print(node.supertype, node); | |||
} | |||
if (node.impltype) { | |||
this.space(); | |||
this.token("="); | |||
this.space(); | |||
this.print(node.impltype, node); | |||
} | |||
this.semicolon(); | |||
} | |||
function ObjectTypeAnnotation(node) { | |||
var _this = this; | |||
if (node.exact) { | |||
this.token("{|"); | |||
} else { | |||
this.token("{"); | |||
} | |||
var props = node.properties.concat(node.callProperties || [], node.indexers || []); | |||
if (props.length) { | |||
this.space(); | |||
this.printJoin(props, node, { | |||
addNewlines: function addNewlines(leading) { | |||
if (leading && !props[0]) return 1; | |||
}, | |||
indent: true, | |||
statement: true, | |||
iterator: function iterator() { | |||
if (props.length !== 1) { | |||
_this.token(","); | |||
_this.space(); | |||
} | |||
} | |||
}); | |||
this.space(); | |||
} | |||
if (node.exact) { | |||
this.token("|}"); | |||
} else { | |||
this.token("}"); | |||
} | |||
} | |||
function ObjectTypeCallProperty(node) { | |||
if (node.static) { | |||
this.word("static"); | |||
this.space(); | |||
} | |||
this.print(node.value, node); | |||
} | |||
function ObjectTypeIndexer(node) { | |||
if (node.static) { | |||
this.word("static"); | |||
this.space(); | |||
} | |||
this._variance(node); | |||
this.token("["); | |||
if (node.id) { | |||
this.print(node.id, node); | |||
this.token(":"); | |||
this.space(); | |||
} | |||
this.print(node.key, node); | |||
this.token("]"); | |||
this.token(":"); | |||
this.space(); | |||
this.print(node.value, node); | |||
} | |||
function ObjectTypeProperty(node) { | |||
if (node.static) { | |||
this.word("static"); | |||
this.space(); | |||
} | |||
this._variance(node); | |||
this.print(node.key, node); | |||
if (node.optional) this.token("?"); | |||
if (!node.method) { | |||
this.token(":"); | |||
this.space(); | |||
} | |||
this.print(node.value, node); | |||
} | |||
function ObjectTypeSpreadProperty(node) { | |||
this.token("..."); | |||
this.print(node.argument, node); | |||
} | |||
function QualifiedTypeIdentifier(node) { | |||
this.print(node.qualification, node); | |||
this.token("."); | |||
this.print(node.id, node); | |||
} | |||
function orSeparator() { | |||
this.space(); | |||
this.token("|"); | |||
this.space(); | |||
} | |||
function UnionTypeAnnotation(node) { | |||
this.printJoin(node.types, node, { | |||
separator: orSeparator | |||
}); | |||
} | |||
function TypeCastExpression(node) { | |||
this.token("("); | |||
this.print(node.expression, node); | |||
this.print(node.typeAnnotation, node); | |||
this.token(")"); | |||
} | |||
function Variance(node) { | |||
if (node.kind === "plus") { | |||
this.token("+"); | |||
} else { | |||
this.token("-"); | |||
} | |||
} | |||
function VoidTypeAnnotation() { | |||
this.word("void"); | |||
} |
@@ -0,0 +1,137 @@ | |||
"use strict"; | |||
Object.defineProperty(exports, "__esModule", { | |||
value: true | |||
}); | |||
var _templateLiterals = require("./template-literals"); | |||
Object.keys(_templateLiterals).forEach(function (key) { | |||
if (key === "default" || key === "__esModule") return; | |||
Object.defineProperty(exports, key, { | |||
enumerable: true, | |||
get: function get() { | |||
return _templateLiterals[key]; | |||
} | |||
}); | |||
}); | |||
var _expressions = require("./expressions"); | |||
Object.keys(_expressions).forEach(function (key) { | |||
if (key === "default" || key === "__esModule") return; | |||
Object.defineProperty(exports, key, { | |||
enumerable: true, | |||
get: function get() { | |||
return _expressions[key]; | |||
} | |||
}); | |||
}); | |||
var _statements = require("./statements"); | |||
Object.keys(_statements).forEach(function (key) { | |||
if (key === "default" || key === "__esModule") return; | |||
Object.defineProperty(exports, key, { | |||
enumerable: true, | |||
get: function get() { | |||
return _statements[key]; | |||
} | |||
}); | |||
}); | |||
var _classes = require("./classes"); | |||
Object.keys(_classes).forEach(function (key) { | |||
if (key === "default" || key === "__esModule") return; | |||
Object.defineProperty(exports, key, { | |||
enumerable: true, | |||
get: function get() { | |||
return _classes[key]; | |||
} | |||
}); | |||
}); | |||
var _methods = require("./methods"); | |||
Object.keys(_methods).forEach(function (key) { | |||
if (key === "default" || key === "__esModule") return; | |||
Object.defineProperty(exports, key, { | |||
enumerable: true, | |||
get: function get() { | |||
return _methods[key]; | |||
} | |||
}); | |||
}); | |||
var _modules = require("./modules"); | |||
Object.keys(_modules).forEach(function (key) { | |||
if (key === "default" || key === "__esModule") return; | |||
Object.defineProperty(exports, key, { | |||
enumerable: true, | |||
get: function get() { | |||
return _modules[key]; | |||
} | |||
}); | |||
}); | |||
var _types = require("./types"); | |||
Object.keys(_types).forEach(function (key) { | |||
if (key === "default" || key === "__esModule") return; | |||
Object.defineProperty(exports, key, { | |||
enumerable: true, | |||
get: function get() { | |||
return _types[key]; | |||
} | |||
}); | |||
}); | |||
var _flow = require("./flow"); | |||
Object.keys(_flow).forEach(function (key) { | |||
if (key === "default" || key === "__esModule") return; | |||
Object.defineProperty(exports, key, { | |||
enumerable: true, | |||
get: function get() { | |||
return _flow[key]; | |||
} | |||
}); | |||
}); | |||
var _base = require("./base"); | |||
Object.keys(_base).forEach(function (key) { | |||
if (key === "default" || key === "__esModule") return; | |||
Object.defineProperty(exports, key, { | |||
enumerable: true, | |||
get: function get() { | |||
return _base[key]; | |||
} | |||
}); | |||
}); | |||
var _jsx = require("./jsx"); | |||
Object.keys(_jsx).forEach(function (key) { | |||
if (key === "default" || key === "__esModule") return; | |||
Object.defineProperty(exports, key, { | |||
enumerable: true, | |||
get: function get() { | |||
return _jsx[key]; | |||
} | |||
}); | |||
}); | |||
var _typescript = require("./typescript"); | |||
Object.keys(_typescript).forEach(function (key) { | |||
if (key === "default" || key === "__esModule") return; | |||
Object.defineProperty(exports, key, { | |||
enumerable: true, | |||
get: function get() { | |||
return _typescript[key]; | |||
} | |||
}); | |||
}); |
@@ -0,0 +1,148 @@ | |||
"use strict"; | |||
Object.defineProperty(exports, "__esModule", { | |||
value: true | |||
}); | |||
exports.JSXAttribute = JSXAttribute; | |||
exports.JSXIdentifier = JSXIdentifier; | |||
exports.JSXNamespacedName = JSXNamespacedName; | |||
exports.JSXMemberExpression = JSXMemberExpression; | |||
exports.JSXSpreadAttribute = JSXSpreadAttribute; | |||
exports.JSXExpressionContainer = JSXExpressionContainer; | |||
exports.JSXSpreadChild = JSXSpreadChild; | |||
exports.JSXText = JSXText; | |||
exports.JSXElement = JSXElement; | |||
exports.JSXOpeningElement = JSXOpeningElement; | |||
exports.JSXClosingElement = JSXClosingElement; | |||
exports.JSXEmptyExpression = JSXEmptyExpression; | |||
exports.JSXFragment = JSXFragment; | |||
exports.JSXOpeningFragment = JSXOpeningFragment; | |||
exports.JSXClosingFragment = JSXClosingFragment; | |||
function JSXAttribute(node) { | |||
this.print(node.name, node); | |||
if (node.value) { | |||
this.token("="); | |||
this.print(node.value, node); | |||
} | |||
} | |||
function JSXIdentifier(node) { | |||
this.word(node.name); | |||
} | |||
function JSXNamespacedName(node) { | |||
this.print(node.namespace, node); | |||
this.token(":"); | |||
this.print(node.name, node); | |||
} | |||
function JSXMemberExpression(node) { | |||
this.print(node.object, node); | |||
this.token("."); | |||
this.print(node.property, node); | |||
} | |||
function JSXSpreadAttribute(node) { | |||
this.token("{"); | |||
this.token("..."); | |||
this.print(node.argument, node); | |||
this.token("}"); | |||
} | |||
function JSXExpressionContainer(node) { | |||
this.token("{"); | |||
this.print(node.expression, node); | |||
this.token("}"); | |||
} | |||
function JSXSpreadChild(node) { | |||
this.token("{"); | |||
this.token("..."); | |||
this.print(node.expression, node); | |||
this.token("}"); | |||
} | |||
function JSXText(node) { | |||
var raw = this.getPossibleRaw(node); | |||
if (raw != null) { | |||
this.token(raw); | |||
} else { | |||
this.token(node.value); | |||
} | |||
} | |||
function JSXElement(node) { | |||
var open = node.openingElement; | |||
this.print(open, node); | |||
if (open.selfClosing) return; | |||
this.indent(); | |||
var _arr = node.children; | |||
for (var _i = 0; _i < _arr.length; _i++) { | |||
var child = _arr[_i]; | |||
this.print(child, node); | |||
} | |||
this.dedent(); | |||
this.print(node.closingElement, node); | |||
} | |||
function spaceSeparator() { | |||
this.space(); | |||
} | |||
function JSXOpeningElement(node) { | |||
this.token("<"); | |||
this.print(node.name, node); | |||
if (node.attributes.length > 0) { | |||
this.space(); | |||
this.printJoin(node.attributes, node, { | |||
separator: spaceSeparator | |||
}); | |||
} | |||
if (node.selfClosing) { | |||
this.space(); | |||
this.token("/>"); | |||
} else { | |||
this.token(">"); | |||
} | |||
} | |||
function JSXClosingElement(node) { | |||
this.token("</"); | |||
this.print(node.name, node); | |||
this.token(">"); | |||
} | |||
function JSXEmptyExpression(node) { | |||
this.printInnerComments(node); | |||
} | |||
function JSXFragment(node) { | |||
this.print(node.openingFragment, node); | |||
this.indent(); | |||
var _arr2 = node.children; | |||
for (var _i2 = 0; _i2 < _arr2.length; _i2++) { | |||
var child = _arr2[_i2]; | |||
this.print(child, node); | |||
} | |||
this.dedent(); | |||
this.print(node.closingFragment, node); | |||
} | |||
function JSXOpeningFragment() { | |||
this.token("<"); | |||
this.token(">"); | |||
} | |||
function JSXClosingFragment() { | |||
this.token("</"); | |||
this.token(">"); | |||
} |
@@ -0,0 +1,151 @@ | |||
"use strict"; | |||
Object.defineProperty(exports, "__esModule", { | |||
value: true | |||
}); | |||
exports._params = _params; | |||
exports._parameters = _parameters; | |||
exports._param = _param; | |||
exports._methodHead = _methodHead; | |||
exports._predicate = _predicate; | |||
exports._functionHead = _functionHead; | |||
exports.FunctionDeclaration = exports.FunctionExpression = FunctionExpression; | |||
exports.ArrowFunctionExpression = ArrowFunctionExpression; | |||
function t() { | |||
var data = _interopRequireWildcard(require("@babel/types")); | |||
t = function t() { | |||
return data; | |||
}; | |||
return data; | |||
} | |||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } | |||
function _params(node) { | |||
this.print(node.typeParameters, node); | |||
this.token("("); | |||
this._parameters(node.params, node); | |||
this.token(")"); | |||
this.print(node.returnType, node); | |||
} | |||
function _parameters(parameters, parent) { | |||
for (var i = 0; i < parameters.length; i++) { | |||
this._param(parameters[i], parent); | |||
if (i < parameters.length - 1) { | |||
this.token(","); | |||
this.space(); | |||
} | |||
} | |||
} | |||
function _param(parameter, parent) { | |||
this.printJoin(parameter.decorators, parameter); | |||
this.print(parameter, parent); | |||
if (parameter.optional) this.token("?"); | |||
this.print(parameter.typeAnnotation, parameter); | |||
} | |||
function _methodHead(node) { | |||
var kind = node.kind; | |||
var key = node.key; | |||
if (kind === "get" || kind === "set") { | |||
this.word(kind); | |||
this.space(); | |||
} | |||
if (node.async) { | |||
this.word("async"); | |||
this.space(); | |||
} | |||
if (kind === "method" || kind === "init") { | |||
if (node.generator) { | |||
this.token("*"); | |||
} | |||
} | |||
if (node.computed) { | |||
this.token("["); | |||
this.print(key, node); | |||
this.token("]"); | |||
} else { | |||
this.print(key, node); | |||
} | |||
if (node.optional) { | |||
this.token("?"); | |||
} | |||
this._params(node); | |||
} | |||
function _predicate(node) { | |||
if (node.predicate) { | |||
if (!node.returnType) { | |||
this.token(":"); | |||
} | |||
this.space(); | |||
this.print(node.predicate, node); | |||
} | |||
} | |||
function _functionHead(node) { | |||
if (node.async) { | |||
this.word("async"); | |||
this.space(); | |||
} | |||
this.word("function"); | |||
if (node.generator) this.token("*"); | |||
this.space(); | |||
if (node.id) { | |||
this.print(node.id, node); | |||
} | |||
this._params(node); | |||
this._predicate(node); | |||
} | |||
function FunctionExpression(node) { | |||
this._functionHead(node); | |||
this.space(); | |||
this.print(node.body, node); | |||
} | |||
function ArrowFunctionExpression(node) { | |||
if (node.async) { | |||
this.word("async"); | |||
this.space(); | |||
} | |||
var firstParam = node.params[0]; | |||
if (node.params.length === 1 && t().isIdentifier(firstParam) && !hasTypes(node, firstParam)) { | |||
this.print(firstParam, node); | |||
} else { | |||
this._params(node); | |||
} | |||
this._predicate(node); | |||
this.space(); | |||
this.token("=>"); | |||
this.space(); | |||
this.print(node.body, node); | |||
} | |||
function hasTypes(node, param) { | |||
return node.typeParameters || node.returnType || param.typeAnnotation || param.optional || param.trailingComments; | |||
} |
@@ -0,0 +1,214 @@ | |||
"use strict"; | |||
Object.defineProperty(exports, "__esModule", { | |||
value: true | |||
}); | |||
exports.ImportSpecifier = ImportSpecifier; | |||
exports.ImportDefaultSpecifier = ImportDefaultSpecifier; | |||
exports.ExportDefaultSpecifier = ExportDefaultSpecifier; | |||
exports.ExportSpecifier = ExportSpecifier; | |||
exports.ExportNamespaceSpecifier = ExportNamespaceSpecifier; | |||
exports.ExportAllDeclaration = ExportAllDeclaration; | |||
exports.ExportNamedDeclaration = ExportNamedDeclaration; | |||
exports.ExportDefaultDeclaration = ExportDefaultDeclaration; | |||
exports.ImportDeclaration = ImportDeclaration; | |||
exports.ImportNamespaceSpecifier = ImportNamespaceSpecifier; | |||
function t() { | |||
var data = _interopRequireWildcard(require("@babel/types")); | |||
t = function t() { | |||
return data; | |||
}; | |||
return data; | |||
} | |||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } | |||
function ImportSpecifier(node) { | |||
if (node.importKind === "type" || node.importKind === "typeof") { | |||
this.word(node.importKind); | |||
this.space(); | |||
} | |||
this.print(node.imported, node); | |||
if (node.local && node.local.name !== node.imported.name) { | |||
this.space(); | |||
this.word("as"); | |||
this.space(); | |||
this.print(node.local, node); | |||
} | |||
} | |||
function ImportDefaultSpecifier(node) { | |||
this.print(node.local, node); | |||
} | |||
function ExportDefaultSpecifier(node) { | |||
this.print(node.exported, node); | |||
} | |||
function ExportSpecifier(node) { | |||
this.print(node.local, node); | |||
if (node.exported && node.local.name !== node.exported.name) { | |||
this.space(); | |||
this.word("as"); | |||
this.space(); | |||
this.print(node.exported, node); | |||
} | |||
} | |||
function ExportNamespaceSpecifier(node) { | |||
this.token("*"); | |||
this.space(); | |||
this.word("as"); | |||
this.space(); | |||
this.print(node.exported, node); | |||
} | |||
function ExportAllDeclaration(node) { | |||
this.word("export"); | |||
this.space(); | |||
if (node.exportKind === "type") { | |||
this.word("type"); | |||
this.space(); | |||
} | |||
this.token("*"); | |||
this.space(); | |||
this.word("from"); | |||
this.space(); | |||
this.print(node.source, node); | |||
this.semicolon(); | |||
} | |||
function ExportNamedDeclaration(node) { | |||
if (t().isClassDeclaration(node.declaration)) { | |||
this.printJoin(node.declaration.decorators, node); | |||
} | |||
this.word("export"); | |||
this.space(); | |||
ExportDeclaration.apply(this, arguments); | |||
} | |||
function ExportDefaultDeclaration(node) { | |||
if (t().isClassDeclaration(node.declaration)) { | |||
this.printJoin(node.declaration.decorators, node); | |||
} | |||
this.word("export"); | |||
this.space(); | |||
this.word("default"); | |||
this.space(); | |||
ExportDeclaration.apply(this, arguments); | |||
} | |||
function ExportDeclaration(node) { | |||
if (node.declaration) { | |||
var declar = node.declaration; | |||
this.print(declar, node); | |||
if (!t().isStatement(declar)) this.semicolon(); | |||
} else { | |||
if (node.exportKind === "type") { | |||
this.word("type"); | |||
this.space(); | |||
} | |||
var specifiers = node.specifiers.slice(0); | |||
var hasSpecial = false; | |||
while (true) { | |||
var first = specifiers[0]; | |||
if (t().isExportDefaultSpecifier(first) || t().isExportNamespaceSpecifier(first)) { | |||
hasSpecial = true; | |||
this.print(specifiers.shift(), node); | |||
if (specifiers.length) { | |||
this.token(","); | |||
this.space(); | |||
} | |||
} else { | |||
break; | |||
} | |||
} | |||
if (specifiers.length || !specifiers.length && !hasSpecial) { | |||
this.token("{"); | |||
if (specifiers.length) { | |||
this.space(); | |||
this.printList(specifiers, node); | |||
this.space(); | |||
} | |||
this.token("}"); | |||
} | |||
if (node.source) { | |||
this.space(); | |||
this.word("from"); | |||
this.space(); | |||
this.print(node.source, node); | |||
} | |||
this.semicolon(); | |||
} | |||
} | |||
function ImportDeclaration(node) { | |||
this.word("import"); | |||
this.space(); | |||
if (node.importKind === "type" || node.importKind === "typeof") { | |||
this.word(node.importKind); | |||
this.space(); | |||
} | |||
var specifiers = node.specifiers.slice(0); | |||
if (specifiers && specifiers.length) { | |||
while (true) { | |||
var first = specifiers[0]; | |||
if (t().isImportDefaultSpecifier(first) || t().isImportNamespaceSpecifier(first)) { | |||
this.print(specifiers.shift(), node); | |||
if (specifiers.length) { | |||
this.token(","); | |||
this.space(); | |||
} | |||
} else { | |||
break; | |||
} | |||
} | |||
if (specifiers.length) { | |||
this.token("{"); | |||
this.space(); | |||
this.printList(specifiers, node); | |||
this.space(); | |||
this.token("}"); | |||
} | |||
this.space(); | |||
this.word("from"); | |||
this.space(); | |||
} | |||
this.print(node.source, node); | |||
this.semicolon(); | |||
} | |||
function ImportNamespaceSpecifier(node) { | |||
this.token("*"); | |||
this.space(); | |||
this.word("as"); | |||
this.space(); | |||
this.print(node.local, node); | |||
} |
@@ -0,0 +1,329 @@ | |||
"use strict"; | |||
Object.defineProperty(exports, "__esModule", { | |||
value: true | |||
}); | |||
exports.WithStatement = WithStatement; | |||
exports.IfStatement = IfStatement; | |||
exports.ForStatement = ForStatement; | |||
exports.WhileStatement = WhileStatement; | |||
exports.DoWhileStatement = DoWhileStatement; | |||
exports.LabeledStatement = LabeledStatement; | |||
exports.TryStatement = TryStatement; | |||
exports.CatchClause = CatchClause; | |||
exports.SwitchStatement = SwitchStatement; | |||
exports.SwitchCase = SwitchCase; | |||
exports.DebuggerStatement = DebuggerStatement; | |||
exports.VariableDeclaration = VariableDeclaration; | |||
exports.VariableDeclarator = VariableDeclarator; | |||
exports.ThrowStatement = exports.BreakStatement = exports.ReturnStatement = exports.ContinueStatement = exports.ForOfStatement = exports.ForInStatement = void 0; | |||
function t() { | |||
var data = _interopRequireWildcard(require("@babel/types")); | |||
t = function t() { | |||
return data; | |||
}; | |||
return data; | |||
} | |||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } | |||
function WithStatement(node) { | |||
this.word("with"); | |||
this.space(); | |||
this.token("("); | |||
this.print(node.object, node); | |||
this.token(")"); | |||
this.printBlock(node); | |||
} | |||
function IfStatement(node) { | |||
this.word("if"); | |||
this.space(); | |||
this.token("("); | |||
this.print(node.test, node); | |||
this.token(")"); | |||
this.space(); | |||
var needsBlock = node.alternate && t().isIfStatement(getLastStatement(node.consequent)); | |||
if (needsBlock) { | |||
this.token("{"); | |||
this.newline(); | |||
this.indent(); | |||
} | |||
this.printAndIndentOnComments(node.consequent, node); | |||
if (needsBlock) { | |||
this.dedent(); | |||
this.newline(); | |||
this.token("}"); | |||
} | |||
if (node.alternate) { | |||
if (this.endsWith("}")) this.space(); | |||
this.word("else"); | |||
this.space(); | |||
this.printAndIndentOnComments(node.alternate, node); | |||
} | |||
} | |||
function getLastStatement(statement) { | |||
if (!t().isStatement(statement.body)) return statement; | |||
return getLastStatement(statement.body); | |||
} | |||
function ForStatement(node) { | |||
this.word("for"); | |||
this.space(); | |||
this.token("("); | |||
this.inForStatementInitCounter++; | |||
this.print(node.init, node); | |||
this.inForStatementInitCounter--; | |||
this.token(";"); | |||
if (node.test) { | |||
this.space(); | |||
this.print(node.test, node); | |||
} | |||
this.token(";"); | |||
if (node.update) { | |||
this.space(); | |||
this.print(node.update, node); | |||
} | |||
this.token(")"); | |||
this.printBlock(node); | |||
} | |||
function WhileStatement(node) { | |||
this.word("while"); | |||
this.space(); | |||
this.token("("); | |||
this.print(node.test, node); | |||
this.token(")"); | |||
this.printBlock(node); | |||
} | |||
var buildForXStatement = function buildForXStatement(op) { | |||
return function (node) { | |||
this.word("for"); | |||
this.space(); | |||
if (op === "of" && node.await) { | |||
this.word("await"); | |||
this.space(); | |||
} | |||
this.token("("); | |||
this.print(node.left, node); | |||
this.space(); | |||
this.word(op); | |||
this.space(); | |||
this.print(node.right, node); | |||
this.token(")"); | |||
this.printBlock(node); | |||
}; | |||
}; | |||
var ForInStatement = buildForXStatement("in"); | |||
exports.ForInStatement = ForInStatement; | |||
var ForOfStatement = buildForXStatement("of"); | |||
exports.ForOfStatement = ForOfStatement; | |||
function DoWhileStatement(node) { | |||
this.word("do"); | |||
this.space(); | |||
this.print(node.body, node); | |||
this.space(); | |||
this.word("while"); | |||
this.space(); | |||
this.token("("); | |||
this.print(node.test, node); | |||
this.token(")"); | |||
this.semicolon(); | |||
} | |||
function buildLabelStatement(prefix, key) { | |||
if (key === void 0) { | |||
key = "label"; | |||
} | |||
return function (node) { | |||
this.word(prefix); | |||
var label = node[key]; | |||
if (label) { | |||
this.space(); | |||
var isLabel = key == "label"; | |||
var terminatorState = this.startTerminatorless(isLabel); | |||
this.print(label, node); | |||
this.endTerminatorless(terminatorState); | |||
} | |||
this.semicolon(); | |||
}; | |||
} | |||
var ContinueStatement = buildLabelStatement("continue"); | |||
exports.ContinueStatement = ContinueStatement; | |||
var ReturnStatement = buildLabelStatement("return", "argument"); | |||
exports.ReturnStatement = ReturnStatement; | |||
var BreakStatement = buildLabelStatement("break"); | |||
exports.BreakStatement = BreakStatement; | |||
var ThrowStatement = buildLabelStatement("throw", "argument"); | |||
exports.ThrowStatement = ThrowStatement; | |||
function LabeledStatement(node) { | |||
this.print(node.label, node); | |||
this.token(":"); | |||
this.space(); | |||
this.print(node.body, node); | |||
} | |||
function TryStatement(node) { | |||
this.word("try"); | |||
this.space(); | |||
this.print(node.block, node); | |||
this.space(); | |||
if (node.handlers) { | |||
this.print(node.handlers[0], node); | |||
} else { | |||
this.print(node.handler, node); | |||
} | |||
if (node.finalizer) { | |||
this.space(); | |||
this.word("finally"); | |||
this.space(); | |||
this.print(node.finalizer, node); | |||
} | |||
} | |||
function CatchClause(node) { | |||
this.word("catch"); | |||
this.space(); | |||
if (node.param) { | |||
this.token("("); | |||
this.print(node.param, node); | |||
this.token(")"); | |||
this.space(); | |||
} | |||
this.print(node.body, node); | |||
} | |||
function SwitchStatement(node) { | |||
this.word("switch"); | |||
this.space(); | |||
this.token("("); | |||
this.print(node.discriminant, node); | |||
this.token(")"); | |||
this.space(); | |||
this.token("{"); | |||
this.printSequence(node.cases, node, { | |||
indent: true, | |||
addNewlines: function addNewlines(leading, cas) { | |||
if (!leading && node.cases[node.cases.length - 1] === cas) return -1; | |||
} | |||
}); | |||
this.token("}"); | |||
} | |||
function SwitchCase(node) { | |||
if (node.test) { | |||
this.word("case"); | |||
this.space(); | |||
this.print(node.test, node); | |||
this.token(":"); | |||
} else { | |||
this.word("default"); | |||
this.token(":"); | |||
} | |||
if (node.consequent.length) { | |||
this.newline(); | |||
this.printSequence(node.consequent, node, { | |||
indent: true | |||
}); | |||
} | |||
} | |||
function DebuggerStatement() { | |||
this.word("debugger"); | |||
this.semicolon(); | |||
} | |||
function variableDeclarationIndent() { | |||
this.token(","); | |||
this.newline(); | |||
if (this.endsWith("\n")) for (var i = 0; i < 4; i++) { | |||
this.space(true); | |||
} | |||
} | |||
function constDeclarationIndent() { | |||
this.token(","); | |||
this.newline(); | |||
if (this.endsWith("\n")) for (var i = 0; i < 6; i++) { | |||
this.space(true); | |||
} | |||
} | |||
function VariableDeclaration(node, parent) { | |||
if (node.declare) { | |||
this.word("declare"); | |||
this.space(); | |||
} | |||
this.word(node.kind); | |||
this.space(); | |||
var hasInits = false; | |||
if (!t().isFor(parent)) { | |||
var _arr = node.declarations; | |||
for (var _i = 0; _i < _arr.length; _i++) { | |||
var declar = _arr[_i]; | |||
if (declar.init) { | |||
hasInits = true; | |||
} | |||
} | |||
} | |||
var separator; | |||
if (hasInits) { | |||
separator = node.kind === "const" ? constDeclarationIndent : variableDeclarationIndent; | |||
} | |||
this.printList(node.declarations, node, { | |||
separator: separator | |||
}); | |||
if (t().isFor(parent)) { | |||
if (parent.left === node || parent.init === node) return; | |||
} | |||
this.semicolon(); | |||
} | |||
function VariableDeclarator(node) { | |||
this.print(node.id, node); | |||
if (node.definite) this.token("!"); | |||
this.print(node.id.typeAnnotation, node); | |||
if (node.init) { | |||
this.space(); | |||
this.token("="); | |||
this.space(); | |||
this.print(node.init, node); | |||
} | |||
} |
@@ -0,0 +1,32 @@ | |||
"use strict"; | |||
Object.defineProperty(exports, "__esModule", { | |||
value: true | |||
}); | |||
exports.TaggedTemplateExpression = TaggedTemplateExpression; | |||
exports.TemplateElement = TemplateElement; | |||
exports.TemplateLiteral = TemplateLiteral; | |||
function TaggedTemplateExpression(node) { | |||
this.print(node.tag, node); | |||
this.print(node.quasi, node); | |||
} | |||
function TemplateElement(node, parent) { | |||
var isFirst = parent.quasis[0] === node; | |||
var isLast = parent.quasis[parent.quasis.length - 1] === node; | |||
var value = (isFirst ? "`" : "}") + node.value.raw + (isLast ? "`" : "${"); | |||
this.token(value); | |||
} | |||
function TemplateLiteral(node) { | |||
var quasis = node.quasis; | |||
for (var i = 0; i < quasis.length; i++) { | |||
this.print(quasis[i], node); | |||
if (i + 1 < quasis.length) { | |||
this.print(node.expressions[i], node); | |||
} | |||
} | |||
} |
@@ -0,0 +1,167 @@ | |||
"use strict"; | |||
Object.defineProperty(exports, "__esModule", { | |||
value: true | |||
}); | |||
exports.Identifier = Identifier; | |||
exports.SpreadElement = exports.RestElement = RestElement; | |||
exports.ObjectPattern = exports.ObjectExpression = ObjectExpression; | |||
exports.ObjectMethod = ObjectMethod; | |||
exports.ObjectProperty = ObjectProperty; | |||
exports.ArrayPattern = exports.ArrayExpression = ArrayExpression; | |||
exports.RegExpLiteral = RegExpLiteral; | |||
exports.BooleanLiteral = BooleanLiteral; | |||
exports.NullLiteral = NullLiteral; | |||
exports.NumericLiteral = NumericLiteral; | |||
exports.StringLiteral = StringLiteral; | |||
function t() { | |||
var data = _interopRequireWildcard(require("@babel/types")); | |||
t = function t() { | |||
return data; | |||
}; | |||
return data; | |||
} | |||
function _jsesc() { | |||
var data = _interopRequireDefault(require("jsesc")); | |||
_jsesc = function _jsesc() { | |||
return data; | |||
}; | |||
return data; | |||
} | |||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | |||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } | |||
function Identifier(node) { | |||
this.word(node.name); | |||
} | |||
function RestElement(node) { | |||
this.token("..."); | |||
this.print(node.argument, node); | |||
} | |||
function ObjectExpression(node) { | |||
var props = node.properties; | |||
this.token("{"); | |||
this.printInnerComments(node); | |||
if (props.length) { | |||
this.space(); | |||
this.printList(props, node, { | |||
indent: true, | |||
statement: true | |||
}); | |||
this.space(); | |||
} | |||
this.token("}"); | |||
} | |||
function ObjectMethod(node) { | |||
this.printJoin(node.decorators, node); | |||
this._methodHead(node); | |||
this.space(); | |||
this.print(node.body, node); | |||
} | |||
function ObjectProperty(node) { | |||
this.printJoin(node.decorators, node); | |||
if (node.computed) { | |||
this.token("["); | |||
this.print(node.key, node); | |||
this.token("]"); | |||
} else { | |||
if (t().isAssignmentPattern(node.value) && t().isIdentifier(node.key) && node.key.name === node.value.left.name) { | |||
this.print(node.value, node); | |||
return; | |||
} | |||
this.print(node.key, node); | |||
if (node.shorthand && t().isIdentifier(node.key) && t().isIdentifier(node.value) && node.key.name === node.value.name) { | |||
return; | |||
} | |||
} | |||
this.token(":"); | |||
this.space(); | |||
this.print(node.value, node); | |||
} | |||
function ArrayExpression(node) { | |||
var elems = node.elements; | |||
var len = elems.length; | |||
this.token("["); | |||
this.printInnerComments(node); | |||
for (var i = 0; i < elems.length; i++) { | |||
var elem = elems[i]; | |||
if (elem) { | |||
if (i > 0) this.space(); | |||
this.print(elem, node); | |||
if (i < len - 1) this.token(","); | |||
} else { | |||
this.token(","); | |||
} | |||
} | |||
this.token("]"); | |||
} | |||
function RegExpLiteral(node) { | |||
this.word("/" + node.pattern + "/" + node.flags); | |||
} | |||
function BooleanLiteral(node) { | |||
this.word(node.value ? "true" : "false"); | |||
} | |||
function NullLiteral() { | |||
this.word("null"); | |||
} | |||
function NumericLiteral(node) { | |||
var raw = this.getPossibleRaw(node); | |||
var value = node.value + ""; | |||
if (raw == null) { | |||
this.number(value); | |||
} else if (this.format.minified) { | |||
this.number(raw.length < value.length ? raw : value); | |||
} else { | |||
this.number(raw); | |||
} | |||
} | |||
function StringLiteral(node) { | |||
var raw = this.getPossibleRaw(node); | |||
if (!this.format.minified && raw != null) { | |||
this.token(raw); | |||
return; | |||
} | |||
var opts = { | |||
quotes: "double", | |||
wrap: true | |||
}; | |||
if (this.format.jsonCompatibleStrings) { | |||
opts.json = true; | |||
} | |||
var val = (0, _jsesc().default)(node.value, opts); | |||
return this.token(val); | |||
} |
@@ -0,0 +1,661 @@ | |||
"use strict"; | |||
Object.defineProperty(exports, "__esModule", { | |||
value: true | |||
}); | |||
exports.TSTypeAnnotation = TSTypeAnnotation; | |||
exports.TSTypeParameterDeclaration = exports.TSTypeParameterInstantiation = TSTypeParameterInstantiation; | |||
exports.TSTypeParameter = TSTypeParameter; | |||
exports.TSParameterProperty = TSParameterProperty; | |||
exports.TSDeclareFunction = TSDeclareFunction; | |||
exports.TSDeclareMethod = TSDeclareMethod; | |||
exports.TSQualifiedName = TSQualifiedName; | |||
exports.TSCallSignatureDeclaration = TSCallSignatureDeclaration; | |||
exports.TSConstructSignatureDeclaration = TSConstructSignatureDeclaration; | |||
exports.TSPropertySignature = TSPropertySignature; | |||
exports.tsPrintPropertyOrMethodName = tsPrintPropertyOrMethodName; | |||
exports.TSMethodSignature = TSMethodSignature; | |||
exports.TSIndexSignature = TSIndexSignature; | |||
exports.TSAnyKeyword = TSAnyKeyword; | |||
exports.TSNumberKeyword = TSNumberKeyword; | |||
exports.TSObjectKeyword = TSObjectKeyword; | |||
exports.TSBooleanKeyword = TSBooleanKeyword; | |||
exports.TSStringKeyword = TSStringKeyword; | |||
exports.TSSymbolKeyword = TSSymbolKeyword; | |||
exports.TSVoidKeyword = TSVoidKeyword; | |||
exports.TSUndefinedKeyword = TSUndefinedKeyword; | |||
exports.TSNullKeyword = TSNullKeyword; | |||
exports.TSNeverKeyword = TSNeverKeyword; | |||
exports.TSThisType = TSThisType; | |||
exports.TSFunctionType = TSFunctionType; | |||
exports.TSConstructorType = TSConstructorType; | |||
exports.tsPrintFunctionOrConstructorType = tsPrintFunctionOrConstructorType; | |||
exports.TSTypeReference = TSTypeReference; | |||
exports.TSTypePredicate = TSTypePredicate; | |||
exports.TSTypeQuery = TSTypeQuery; | |||
exports.TSTypeLiteral = TSTypeLiteral; | |||
exports.tsPrintTypeLiteralOrInterfaceBody = tsPrintTypeLiteralOrInterfaceBody; | |||
exports.tsPrintBraced = tsPrintBraced; | |||
exports.TSArrayType = TSArrayType; | |||
exports.TSTupleType = TSTupleType; | |||
exports.TSUnionType = TSUnionType; | |||
exports.TSIntersectionType = TSIntersectionType; | |||
exports.tsPrintUnionOrIntersectionType = tsPrintUnionOrIntersectionType; | |||
exports.TSConditionalType = TSConditionalType; | |||
exports.TSInferType = TSInferType; | |||
exports.TSParenthesizedType = TSParenthesizedType; | |||
exports.TSTypeOperator = TSTypeOperator; | |||
exports.TSIndexedAccessType = TSIndexedAccessType; | |||
exports.TSMappedType = TSMappedType; | |||
exports.TSLiteralType = TSLiteralType; | |||
exports.TSExpressionWithTypeArguments = TSExpressionWithTypeArguments; | |||
exports.TSInterfaceDeclaration = TSInterfaceDeclaration; | |||
exports.TSInterfaceBody = TSInterfaceBody; | |||
exports.TSTypeAliasDeclaration = TSTypeAliasDeclaration; | |||
exports.TSAsExpression = TSAsExpression; | |||
exports.TSTypeAssertion = TSTypeAssertion; | |||
exports.TSEnumDeclaration = TSEnumDeclaration; | |||
exports.TSEnumMember = TSEnumMember; | |||
exports.TSModuleDeclaration = TSModuleDeclaration; | |||
exports.TSModuleBlock = TSModuleBlock; | |||
exports.TSImportEqualsDeclaration = TSImportEqualsDeclaration; | |||
exports.TSExternalModuleReference = TSExternalModuleReference; | |||
exports.TSNonNullExpression = TSNonNullExpression; | |||
exports.TSExportAssignment = TSExportAssignment; | |||
exports.TSNamespaceExportDeclaration = TSNamespaceExportDeclaration; | |||
exports.tsPrintSignatureDeclarationBase = tsPrintSignatureDeclarationBase; | |||
function TSTypeAnnotation(node) { | |||
this.token(":"); | |||
this.space(); | |||
if (node.optional) this.token("?"); | |||
this.print(node.typeAnnotation, node); | |||
} | |||
function TSTypeParameterInstantiation(node) { | |||
this.token("<"); | |||
this.printList(node.params, node, {}); | |||
this.token(">"); | |||
} | |||
function TSTypeParameter(node) { | |||
this.word(node.name); | |||
if (node.constraint) { | |||
this.space(); | |||
this.word("extends"); | |||
this.space(); | |||
this.print(node.constraint, node); | |||
} | |||
if (node.default) { | |||
this.space(); | |||
this.token("="); | |||
this.space(); | |||
this.print(node.default, node); | |||
} | |||
} | |||
function TSParameterProperty(node) { | |||
if (node.accessibility) { | |||
this.word(node.accessibility); | |||
this.space(); | |||
} | |||
if (node.readonly) { | |||
this.word("readonly"); | |||
this.space(); | |||
} | |||
this._param(node.parameter); | |||
} | |||
function TSDeclareFunction(node) { | |||
if (node.declare) { | |||
this.word("declare"); | |||
this.space(); | |||
} | |||
this._functionHead(node); | |||
this.token(";"); | |||
} | |||
function TSDeclareMethod(node) { | |||
this._classMethodHead(node); | |||
this.token(";"); | |||
} | |||
function TSQualifiedName(node) { | |||
this.print(node.left, node); | |||
this.token("."); | |||
this.print(node.right, node); | |||
} | |||
function TSCallSignatureDeclaration(node) { | |||
this.tsPrintSignatureDeclarationBase(node); | |||
} | |||
function TSConstructSignatureDeclaration(node) { | |||
this.word("new"); | |||
this.space(); | |||
this.tsPrintSignatureDeclarationBase(node); | |||
} | |||
function TSPropertySignature(node) { | |||
var readonly = node.readonly, | |||
initializer = node.initializer; | |||
if (readonly) { | |||
this.word("readonly"); | |||
this.space(); | |||
} | |||
this.tsPrintPropertyOrMethodName(node); | |||
this.print(node.typeAnnotation, node); | |||
if (initializer) { | |||
this.space(); | |||
this.token("="); | |||
this.space(); | |||
this.print(initializer, node); | |||
} | |||
this.token(";"); | |||
} | |||
function tsPrintPropertyOrMethodName(node) { | |||
if (node.computed) { | |||
this.token("["); | |||
} | |||
this.print(node.key, node); | |||
if (node.computed) { | |||
this.token("]"); | |||
} | |||
if (node.optional) { | |||
this.token("?"); | |||
} | |||
} | |||
function TSMethodSignature(node) { | |||
this.tsPrintPropertyOrMethodName(node); | |||
this.tsPrintSignatureDeclarationBase(node); | |||
this.token(";"); | |||
} | |||
function TSIndexSignature(node) { | |||
var readonly = node.readonly; | |||
if (readonly) { | |||
this.word("readonly"); | |||
this.space(); | |||
} | |||
this.token("["); | |||
this._parameters(node.parameters, node); | |||
this.token("]"); | |||
this.print(node.typeAnnotation, node); | |||
this.token(";"); | |||
} | |||
function TSAnyKeyword() { | |||
this.word("any"); | |||
} | |||
function TSNumberKeyword() { | |||
this.word("number"); | |||
} | |||
function TSObjectKeyword() { | |||
this.word("object"); | |||
} | |||
function TSBooleanKeyword() { | |||
this.word("boolean"); | |||
} | |||
function TSStringKeyword() { | |||
this.word("string"); | |||
} | |||
function TSSymbolKeyword() { | |||
this.word("symbol"); | |||
} | |||
function TSVoidKeyword() { | |||
this.word("void"); | |||
} | |||
function TSUndefinedKeyword() { | |||
this.word("undefined"); | |||
} | |||
function TSNullKeyword() { | |||
this.word("null"); | |||
} | |||
function TSNeverKeyword() { | |||
this.word("never"); | |||
} | |||
function TSThisType() { | |||
this.word("this"); | |||
} | |||
function TSFunctionType(node) { | |||
this.tsPrintFunctionOrConstructorType(node); | |||
} | |||
function TSConstructorType(node) { | |||
this.word("new"); | |||
this.space(); | |||
this.tsPrintFunctionOrConstructorType(node); | |||
} | |||
function tsPrintFunctionOrConstructorType(node) { | |||
var typeParameters = node.typeParameters, | |||
parameters = node.parameters; | |||
this.print(typeParameters, node); | |||
this.token("("); | |||
this._parameters(parameters, node); | |||
this.token(")"); | |||
this.space(); | |||
this.token("=>"); | |||
this.space(); | |||
this.print(node.typeAnnotation.typeAnnotation, node); | |||
} | |||
function TSTypeReference(node) { | |||
this.print(node.typeName, node); | |||
this.print(node.typeParameters, node); | |||
} | |||
function TSTypePredicate(node) { | |||
this.print(node.parameterName); | |||
this.space(); | |||
this.word("is"); | |||
this.space(); | |||
this.print(node.typeAnnotation.typeAnnotation); | |||
} | |||
function TSTypeQuery(node) { | |||
this.word("typeof"); | |||
this.space(); | |||
this.print(node.exprName); | |||
} | |||
function TSTypeLiteral(node) { | |||
this.tsPrintTypeLiteralOrInterfaceBody(node.members, node); | |||
} | |||
function tsPrintTypeLiteralOrInterfaceBody(members, node) { | |||
this.tsPrintBraced(members, node); | |||
} | |||
function tsPrintBraced(members, node) { | |||
this.token("{"); | |||
if (members.length) { | |||
this.indent(); | |||
this.newline(); | |||
for (var _iterator = members, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) { | |||
var _ref; | |||
if (_isArray) { | |||
if (_i >= _iterator.length) break; | |||
_ref = _iterator[_i++]; | |||
} else { | |||
_i = _iterator.next(); | |||
if (_i.done) break; | |||
_ref = _i.value; | |||
} | |||
var member = _ref; | |||
this.print(member, node); | |||
this.newline(); | |||
} | |||
this.dedent(); | |||
this.rightBrace(); | |||
} else { | |||
this.token("}"); | |||
} | |||
} | |||
function TSArrayType(node) { | |||
this.print(node.elementType); | |||
this.token("[]"); | |||
} | |||
function TSTupleType(node) { | |||
this.token("["); | |||
this.printList(node.elementTypes, node); | |||
this.token("]"); | |||
} | |||
function TSUnionType(node) { | |||
this.tsPrintUnionOrIntersectionType(node, "|"); | |||
} | |||
function TSIntersectionType(node) { | |||
this.tsPrintUnionOrIntersectionType(node, "&"); | |||
} | |||
function tsPrintUnionOrIntersectionType(node, sep) { | |||
this.printJoin(node.types, node, { | |||
separator: function separator() { | |||
this.space(); | |||
this.token(sep); | |||
this.space(); | |||
} | |||
}); | |||
} | |||
function TSConditionalType(node) { | |||
this.print(node.checkType); | |||
this.space(); | |||
this.word("extends"); | |||
this.space(); | |||
this.print(node.extendsType); | |||
this.space(); | |||
this.token("?"); | |||
this.space(); | |||
this.print(node.trueType); | |||
this.space(); | |||
this.token(":"); | |||
this.space(); | |||
this.print(node.falseType); | |||
} | |||
function TSInferType(node) { | |||
this.token("infer"); | |||
this.space(); | |||
this.print(node.typeParameter); | |||
} | |||
function TSParenthesizedType(node) { | |||
this.token("("); | |||
this.print(node.typeAnnotation, node); | |||
this.token(")"); | |||
} | |||
function TSTypeOperator(node) { | |||
this.token(node.operator); | |||
this.space(); | |||
this.print(node.typeAnnotation, node); | |||
} | |||
function TSIndexedAccessType(node) { | |||
this.print(node.objectType, node); | |||
this.token("["); | |||
this.print(node.indexType, node); | |||
this.token("]"); | |||
} | |||
function TSMappedType(node) { | |||
var readonly = node.readonly, | |||
typeParameter = node.typeParameter, | |||
optional = node.optional; | |||
this.token("{"); | |||
this.space(); | |||
if (readonly) { | |||
tokenIfPlusMinus(this, readonly); | |||
this.word("readonly"); | |||
this.space(); | |||
} | |||
this.token("["); | |||
this.word(typeParameter.name); | |||
this.space(); | |||
this.word("in"); | |||
this.space(); | |||
this.print(typeParameter.constraint, typeParameter); | |||
this.token("]"); | |||
if (optional) { | |||
tokenIfPlusMinus(this, optional); | |||
this.token("?"); | |||
} | |||
this.token(":"); | |||
this.space(); | |||
this.print(node.typeAnnotation, node); | |||
this.space(); | |||
this.token("}"); | |||
} | |||
function tokenIfPlusMinus(self, tok) { | |||
if (tok !== true) { | |||
self.token(tok); | |||
} | |||
} | |||
function TSLiteralType(node) { | |||
this.print(node.literal, node); | |||
} | |||
function TSExpressionWithTypeArguments(node) { | |||
this.print(node.expression, node); | |||
this.print(node.typeParameters, node); | |||
} | |||
function TSInterfaceDeclaration(node) { | |||
var declare = node.declare, | |||
id = node.id, | |||
typeParameters = node.typeParameters, | |||
extendz = node.extends, | |||
body = node.body; | |||
if (declare) { | |||
this.word("declare"); | |||
this.space(); | |||
} | |||
this.word("interface"); | |||
this.space(); | |||
this.print(id, node); | |||
this.print(typeParameters, node); | |||
if (extendz) { | |||
this.space(); | |||
this.word("extends"); | |||
this.space(); | |||
this.printList(extendz, node); | |||
} | |||
this.space(); | |||
this.print(body, node); | |||
} | |||
function TSInterfaceBody(node) { | |||
this.tsPrintTypeLiteralOrInterfaceBody(node.body, node); | |||
} | |||
function TSTypeAliasDeclaration(node) { | |||
var declare = node.declare, | |||
id = node.id, | |||
typeParameters = node.typeParameters, | |||
typeAnnotation = node.typeAnnotation; | |||
if (declare) { | |||
this.word("declare"); | |||
this.space(); | |||
} | |||
this.word("type"); | |||
this.space(); | |||
this.print(id, node); | |||
this.print(typeParameters, node); | |||
this.space(); | |||
this.token("="); | |||
this.space(); | |||
this.print(typeAnnotation, node); | |||
this.token(";"); | |||
} | |||
function TSAsExpression(node) { | |||
var expression = node.expression, | |||
typeAnnotation = node.typeAnnotation; | |||
this.print(expression, node); | |||
this.space(); | |||
this.word("as"); | |||
this.space(); | |||
this.print(typeAnnotation, node); | |||
} | |||
function TSTypeAssertion(node) { | |||
var typeAnnotation = node.typeAnnotation, | |||
expression = node.expression; | |||
this.token("<"); | |||
this.print(typeAnnotation, node); | |||
this.token(">"); | |||
this.space(); | |||
this.print(expression, node); | |||
} | |||
function TSEnumDeclaration(node) { | |||
var declare = node.declare, | |||
isConst = node.const, | |||
id = node.id, | |||
members = node.members; | |||
if (declare) { | |||
this.word("declare"); | |||
this.space(); | |||
} | |||
if (isConst) { | |||
this.word("const"); | |||
this.space(); | |||
} | |||
this.word("enum"); | |||
this.space(); | |||
this.print(id, node); | |||
this.space(); | |||
this.tsPrintBraced(members, node); | |||
} | |||
function TSEnumMember(node) { | |||
var id = node.id, | |||
initializer = node.initializer; | |||
this.print(id, node); | |||
if (initializer) { | |||
this.space(); | |||
this.token("="); | |||
this.space(); | |||
this.print(initializer, node); | |||
} | |||
this.token(","); | |||
} | |||
function TSModuleDeclaration(node) { | |||
var declare = node.declare, | |||
id = node.id; | |||
if (declare) { | |||
this.word("declare"); | |||
this.space(); | |||
} | |||
if (!node.global) { | |||
this.word(id.type === "Identifier" ? "namespace" : "module"); | |||
this.space(); | |||
} | |||
this.print(id, node); | |||
if (!node.body) { | |||
this.token(";"); | |||
return; | |||
} | |||
var body = node.body; | |||
while (body.type === "TSModuleDeclaration") { | |||
this.token("."); | |||
this.print(body.id, body); | |||
body = body.body; | |||
} | |||
this.space(); | |||
this.print(body, node); | |||
} | |||
function TSModuleBlock(node) { | |||
this.tsPrintBraced(node.body, node); | |||
} | |||
function TSImportEqualsDeclaration(node) { | |||
var isExport = node.isExport, | |||
id = node.id, | |||
moduleReference = node.moduleReference; | |||
if (isExport) { | |||
this.word("export"); | |||
this.space(); | |||
} | |||
this.word("import"); | |||
this.space(); | |||
this.print(id, node); | |||
this.space(); | |||
this.token("="); | |||
this.space(); | |||
this.print(moduleReference, node); | |||
this.token(";"); | |||
} | |||
function TSExternalModuleReference(node) { | |||
this.token("require("); | |||
this.print(node.expression, node); | |||
this.token(")"); | |||
} | |||
function TSNonNullExpression(node) { | |||
this.print(node.expression, node); | |||
this.token("!"); | |||
} | |||
function TSExportAssignment(node) { | |||
this.word("export"); | |||
this.space(); | |||
this.token("="); | |||
this.space(); | |||
this.print(node.expression, node); | |||
this.token(";"); | |||
} | |||
function TSNamespaceExportDeclaration(node) { | |||
this.word("export"); | |||
this.space(); | |||
this.word("as"); | |||
this.space(); | |||
this.word("namespace"); | |||
this.space(); | |||
this.print(node.id, node); | |||
} | |||
function tsPrintSignatureDeclarationBase(node) { | |||
var typeParameters = node.typeParameters, | |||
parameters = node.parameters; | |||
this.print(typeParameters, node); | |||
this.token("("); | |||
this._parameters(parameters, node); | |||
this.token(")"); | |||
this.print(node.typeAnnotation, node); | |||
} |
@@ -0,0 +1,108 @@ | |||
"use strict"; | |||
Object.defineProperty(exports, "__esModule", { | |||
value: true | |||
}); | |||
exports.default = _default; | |||
exports.CodeGenerator = void 0; | |||
var _sourceMap = _interopRequireDefault(require("./source-map")); | |||
var _printer = _interopRequireDefault(require("./printer")); | |||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | |||
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; } | |||
var Generator = function (_Printer) { | |||
_inheritsLoose(Generator, _Printer); | |||
function Generator(ast, opts, code) { | |||
var _this; | |||
if (opts === void 0) { | |||
opts = {}; | |||
} | |||
var format = normalizeOptions(code, opts); | |||
var map = opts.sourceMaps ? new _sourceMap.default(opts, code) : null; | |||
_this = _Printer.call(this, format, map) || this; | |||
_this.ast = ast; | |||
return _this; | |||
} | |||
var _proto = Generator.prototype; | |||
_proto.generate = function generate() { | |||
return _Printer.prototype.generate.call(this, this.ast); | |||
}; | |||
return Generator; | |||
}(_printer.default); | |||
function normalizeOptions(code, opts) { | |||
var format = { | |||
auxiliaryCommentBefore: opts.auxiliaryCommentBefore, | |||
auxiliaryCommentAfter: opts.auxiliaryCommentAfter, | |||
shouldPrintComment: opts.shouldPrintComment, | |||
retainLines: opts.retainLines, | |||
retainFunctionParens: opts.retainFunctionParens, | |||
comments: opts.comments == null || opts.comments, | |||
compact: opts.compact, | |||
minified: opts.minified, | |||
concise: opts.concise, | |||
jsonCompatibleStrings: opts.jsonCompatibleStrings, | |||
indent: { | |||
adjustMultilineComment: true, | |||
style: " ", | |||
base: 0 | |||
} | |||
}; | |||
if (format.minified) { | |||
format.compact = true; | |||
format.shouldPrintComment = format.shouldPrintComment || function () { | |||
return format.comments; | |||
}; | |||
} else { | |||
format.shouldPrintComment = format.shouldPrintComment || function (value) { | |||
return format.comments || value.indexOf("@license") >= 0 || value.indexOf("@preserve") >= 0; | |||
}; | |||
} | |||
if (format.compact === "auto") { | |||
format.compact = code.length > 500000; | |||
if (format.compact) { | |||
console.error("[BABEL] Note: The code generator has deoptimised the styling of " + (opts.filename + " as it exceeds the max of " + "500KB" + ".")); | |||
} | |||
} | |||
if (format.compact) { | |||
format.indent.adjustMultilineComment = false; | |||
} | |||
return format; | |||
} | |||
var CodeGenerator = function () { | |||
function CodeGenerator(ast, opts, code) { | |||
this._generator = new Generator(ast, opts, code); | |||
} | |||
var _proto2 = CodeGenerator.prototype; | |||
_proto2.generate = function generate() { | |||
return this._generator.generate(); | |||
}; | |||
return CodeGenerator; | |||
}(); | |||
exports.CodeGenerator = CodeGenerator; | |||
function _default(ast, opts, code) { | |||
var gen = new Generator(ast, opts, code); | |||
return gen.generate(); | |||
} |
@@ -0,0 +1,132 @@ | |||
"use strict"; | |||
Object.defineProperty(exports, "__esModule", { | |||
value: true | |||
}); | |||
exports.needsWhitespace = needsWhitespace; | |||
exports.needsWhitespaceBefore = needsWhitespaceBefore; | |||
exports.needsWhitespaceAfter = needsWhitespaceAfter; | |||
exports.needsParens = needsParens; | |||
var whitespace = _interopRequireWildcard(require("./whitespace")); | |||
var parens = _interopRequireWildcard(require("./parentheses")); | |||
function t() { | |||
var data = _interopRequireWildcard(require("@babel/types")); | |||
t = function t() { | |||
return data; | |||
}; | |||
return data; | |||
} | |||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } | |||
function expandAliases(obj) { | |||
var newObj = {}; | |||
function add(type, func) { | |||
var fn = newObj[type]; | |||
newObj[type] = fn ? function (node, parent, stack) { | |||
var result = fn(node, parent, stack); | |||
return result == null ? func(node, parent, stack) : result; | |||
} : func; | |||
} | |||
var _arr = Object.keys(obj); | |||
for (var _i = 0; _i < _arr.length; _i++) { | |||
var type = _arr[_i]; | |||
var aliases = t().FLIPPED_ALIAS_KEYS[type]; | |||
if (aliases) { | |||
for (var _iterator = aliases, _isArray = Array.isArray(_iterator), _i2 = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) { | |||
var _ref; | |||
if (_isArray) { | |||
if (_i2 >= _iterator.length) break; | |||
_ref = _iterator[_i2++]; | |||
} else { | |||
_i2 = _iterator.next(); | |||
if (_i2.done) break; | |||
_ref = _i2.value; | |||
} | |||
var alias = _ref; | |||
add(alias, obj[type]); | |||
} | |||
} else { | |||
add(type, obj[type]); | |||
} | |||
} | |||
return newObj; | |||
} | |||
var expandedParens = expandAliases(parens); | |||
var expandedWhitespaceNodes = expandAliases(whitespace.nodes); | |||
var expandedWhitespaceList = expandAliases(whitespace.list); | |||
function find(obj, node, parent, printStack) { | |||
var fn = obj[node.type]; | |||
return fn ? fn(node, parent, printStack) : null; | |||
} | |||
function isOrHasCallExpression(node) { | |||
if (t().isCallExpression(node)) { | |||
return true; | |||
} | |||
if (t().isMemberExpression(node)) { | |||
return isOrHasCallExpression(node.object) || !node.computed && isOrHasCallExpression(node.property); | |||
} else { | |||
return false; | |||
} | |||
} | |||
function needsWhitespace(node, parent, type) { | |||
if (!node) return 0; | |||
if (t().isExpressionStatement(node)) { | |||
node = node.expression; | |||
} | |||
var linesInfo = find(expandedWhitespaceNodes, node, parent); | |||
if (!linesInfo) { | |||
var items = find(expandedWhitespaceList, node, parent); | |||
if (items) { | |||
for (var i = 0; i < items.length; i++) { | |||
linesInfo = needsWhitespace(items[i], node, type); | |||
if (linesInfo) break; | |||
} | |||
} | |||
} | |||
if (typeof linesInfo === "object" && linesInfo !== null) { | |||
return linesInfo[type] || 0; | |||
} | |||
return 0; | |||
} | |||
function needsWhitespaceBefore(node, parent) { | |||
return needsWhitespace(node, parent, "before"); | |||
} | |||
function needsWhitespaceAfter(node, parent) { | |||
return needsWhitespace(node, parent, "after"); | |||
} | |||
function needsParens(node, parent, printStack) { | |||
if (!parent) return false; | |||
if (t().isNewExpression(parent) && parent.callee === node) { | |||
if (isOrHasCallExpression(node)) return true; | |||
} | |||
return find(expandedParens, node, parent, printStack); | |||
} |
@@ -0,0 +1,243 @@ | |||
"use strict"; | |||
Object.defineProperty(exports, "__esModule", { | |||
value: true | |||
}); | |||
exports.FunctionTypeAnnotation = exports.NullableTypeAnnotation = NullableTypeAnnotation; | |||
exports.UpdateExpression = UpdateExpression; | |||
exports.ObjectExpression = ObjectExpression; | |||
exports.DoExpression = DoExpression; | |||
exports.Binary = Binary; | |||
exports.IntersectionTypeAnnotation = exports.UnionTypeAnnotation = UnionTypeAnnotation; | |||
exports.TSAsExpression = TSAsExpression; | |||
exports.TSTypeAssertion = TSTypeAssertion; | |||
exports.BinaryExpression = BinaryExpression; | |||
exports.SequenceExpression = SequenceExpression; | |||
exports.AwaitExpression = exports.YieldExpression = YieldExpression; | |||
exports.ClassExpression = ClassExpression; | |||
exports.UnaryLike = UnaryLike; | |||
exports.FunctionExpression = FunctionExpression; | |||
exports.ArrowFunctionExpression = ArrowFunctionExpression; | |||
exports.ConditionalExpression = ConditionalExpression; | |||
exports.AssignmentExpression = AssignmentExpression; | |||
exports.NewExpression = NewExpression; | |||
function t() { | |||
var data = _interopRequireWildcard(require("@babel/types")); | |||
t = function t() { | |||
return data; | |||
}; | |||
return data; | |||
} | |||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } | |||
var PRECEDENCE = { | |||
"||": 0, | |||
"&&": 1, | |||
"|": 2, | |||
"^": 3, | |||
"&": 4, | |||
"==": 5, | |||
"===": 5, | |||
"!=": 5, | |||
"!==": 5, | |||
"<": 6, | |||
">": 6, | |||
"<=": 6, | |||
">=": 6, | |||
in: 6, | |||
instanceof: 6, | |||
">>": 7, | |||
"<<": 7, | |||
">>>": 7, | |||
"+": 8, | |||
"-": 8, | |||
"*": 9, | |||
"/": 9, | |||
"%": 9, | |||
"**": 10 | |||
}; | |||
var isClassExtendsClause = function isClassExtendsClause(node, parent) { | |||
return (t().isClassDeclaration(parent) || t().isClassExpression(parent)) && parent.superClass === node; | |||
}; | |||
function NullableTypeAnnotation(node, parent) { | |||
return t().isArrayTypeAnnotation(parent); | |||
} | |||
function UpdateExpression(node, parent) { | |||
return t().isMemberExpression(parent, { | |||
object: node | |||
}) || t().isCallExpression(parent, { | |||
callee: node | |||
}) || t().isNewExpression(parent, { | |||
callee: node | |||
}) || isClassExtendsClause(node, parent); | |||
} | |||
function ObjectExpression(node, parent, printStack) { | |||
return isFirstInStatement(printStack, { | |||
considerArrow: true | |||
}); | |||
} | |||
function DoExpression(node, parent, printStack) { | |||
return isFirstInStatement(printStack); | |||
} | |||
function Binary(node, parent) { | |||
if (node.operator === "**" && t().isBinaryExpression(parent, { | |||
operator: "**" | |||
})) { | |||
return parent.left === node; | |||
} | |||
if (isClassExtendsClause(node, parent)) { | |||
return true; | |||
} | |||
if ((t().isCallExpression(parent) || t().isNewExpression(parent)) && parent.callee === node || t().isUnaryLike(parent) || t().isMemberExpression(parent) && parent.object === node || t().isAwaitExpression(parent)) { | |||
return true; | |||
} | |||
if (t().isBinary(parent)) { | |||
var parentOp = parent.operator; | |||
var parentPos = PRECEDENCE[parentOp]; | |||
var nodeOp = node.operator; | |||
var nodePos = PRECEDENCE[nodeOp]; | |||
if (parentPos === nodePos && parent.right === node && !t().isLogicalExpression(parent) || parentPos > nodePos) { | |||
return true; | |||
} | |||
} | |||
return false; | |||
} | |||
function UnionTypeAnnotation(node, parent) { | |||
return t().isArrayTypeAnnotation(parent) || t().isNullableTypeAnnotation(parent) || t().isIntersectionTypeAnnotation(parent) || t().isUnionTypeAnnotation(parent); | |||
} | |||
function TSAsExpression() { | |||
return true; | |||
} | |||
function TSTypeAssertion() { | |||
return true; | |||
} | |||
function BinaryExpression(node, parent) { | |||
return node.operator === "in" && (t().isVariableDeclarator(parent) || t().isFor(parent)); | |||
} | |||
function SequenceExpression(node, parent) { | |||
if (t().isForStatement(parent) || t().isThrowStatement(parent) || t().isReturnStatement(parent) || t().isIfStatement(parent) && parent.test === node || t().isWhileStatement(parent) && parent.test === node || t().isForInStatement(parent) && parent.right === node || t().isSwitchStatement(parent) && parent.discriminant === node || t().isExpressionStatement(parent) && parent.expression === node) { | |||
return false; | |||
} | |||
return true; | |||
} | |||
function YieldExpression(node, parent) { | |||
return t().isBinary(parent) || t().isUnaryLike(parent) || t().isCallExpression(parent) || t().isMemberExpression(parent) || t().isNewExpression(parent) || t().isConditionalExpression(parent) && node === parent.test || isClassExtendsClause(node, parent); | |||
} | |||
function ClassExpression(node, parent, printStack) { | |||
return isFirstInStatement(printStack, { | |||
considerDefaultExports: true | |||
}); | |||
} | |||
function UnaryLike(node, parent) { | |||
return t().isMemberExpression(parent, { | |||
object: node | |||
}) || t().isCallExpression(parent, { | |||
callee: node | |||
}) || t().isNewExpression(parent, { | |||
callee: node | |||
}) || t().isBinaryExpression(parent, { | |||
operator: "**", | |||
left: node | |||
}) || isClassExtendsClause(node, parent); | |||
} | |||
function FunctionExpression(node, parent, printStack) { | |||
return isFirstInStatement(printStack, { | |||
considerDefaultExports: true | |||
}); | |||
} | |||
function ArrowFunctionExpression(node, parent) { | |||
return t().isExportDeclaration(parent) || ConditionalExpression(node, parent); | |||
} | |||
function ConditionalExpression(node, parent) { | |||
if (t().isUnaryLike(parent) || t().isBinary(parent) || t().isConditionalExpression(parent, { | |||
test: node | |||
}) || t().isAwaitExpression(parent) || t().isTaggedTemplateExpression(parent) || t().isTSTypeAssertion(parent) || t().isTSAsExpression(parent)) { | |||
return true; | |||
} | |||
return UnaryLike(node, parent); | |||
} | |||
function AssignmentExpression(node) { | |||
if (t().isObjectPattern(node.left)) { | |||
return true; | |||
} else { | |||
return ConditionalExpression.apply(void 0, arguments); | |||
} | |||
} | |||
function NewExpression(node, parent) { | |||
return isClassExtendsClause(node, parent); | |||
} | |||
function isFirstInStatement(printStack, _temp) { | |||
var _ref = _temp === void 0 ? {} : _temp, | |||
_ref$considerArrow = _ref.considerArrow, | |||
considerArrow = _ref$considerArrow === void 0 ? false : _ref$considerArrow, | |||
_ref$considerDefaultE = _ref.considerDefaultExports, | |||
considerDefaultExports = _ref$considerDefaultE === void 0 ? false : _ref$considerDefaultE; | |||
var i = printStack.length - 1; | |||
var node = printStack[i]; | |||
i--; | |||
var parent = printStack[i]; | |||
while (i > 0) { | |||
if (t().isExpressionStatement(parent, { | |||
expression: node | |||
}) || t().isTaggedTemplateExpression(parent) || considerDefaultExports && t().isExportDefaultDeclaration(parent, { | |||
declaration: node | |||
}) || considerArrow && t().isArrowFunctionExpression(parent, { | |||
body: node | |||
})) { | |||
return true; | |||
} | |||
if (t().isCallExpression(parent, { | |||
callee: node | |||
}) || t().isSequenceExpression(parent) && parent.expressions[0] === node || t().isMemberExpression(parent, { | |||
object: node | |||
}) || t().isConditional(parent, { | |||
test: node | |||
}) || t().isBinary(parent, { | |||
left: node | |||
}) || t().isAssignmentExpression(parent, { | |||
left: node | |||
})) { | |||
node = parent; | |||
i--; | |||
parent = printStack[i]; | |||
} else { | |||
return false; | |||
} | |||
} | |||
return false; | |||
} |
@@ -0,0 +1,183 @@ | |||
"use strict"; | |||
Object.defineProperty(exports, "__esModule", { | |||
value: true | |||
}); | |||
exports.list = exports.nodes = void 0; | |||
function t() { | |||
var data = _interopRequireWildcard(require("@babel/types")); | |||
t = function t() { | |||
return data; | |||
}; | |||
return data; | |||
} | |||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } | |||
function crawl(node, state) { | |||
if (state === void 0) { | |||
state = {}; | |||
} | |||
if (t().isMemberExpression(node)) { | |||
crawl(node.object, state); | |||
if (node.computed) crawl(node.property, state); | |||
} else if (t().isBinary(node) || t().isAssignmentExpression(node)) { | |||
crawl(node.left, state); | |||
crawl(node.right, state); | |||
} else if (t().isCallExpression(node)) { | |||
state.hasCall = true; | |||
crawl(node.callee, state); | |||
} else if (t().isFunction(node)) { | |||
state.hasFunction = true; | |||
} else if (t().isIdentifier(node)) { | |||
state.hasHelper = state.hasHelper || isHelper(node.callee); | |||
} | |||
return state; | |||
} | |||
function isHelper(node) { | |||
if (t().isMemberExpression(node)) { | |||
return isHelper(node.object) || isHelper(node.property); | |||
} else if (t().isIdentifier(node)) { | |||
return node.name === "require" || node.name[0] === "_"; | |||
} else if (t().isCallExpression(node)) { | |||
return isHelper(node.callee); | |||
} else if (t().isBinary(node) || t().isAssignmentExpression(node)) { | |||
return t().isIdentifier(node.left) && isHelper(node.left) || isHelper(node.right); | |||
} else { | |||
return false; | |||
} | |||
} | |||
function isType(node) { | |||
return t().isLiteral(node) || t().isObjectExpression(node) || t().isArrayExpression(node) || t().isIdentifier(node) || t().isMemberExpression(node); | |||
} | |||
var nodes = { | |||
AssignmentExpression: function AssignmentExpression(node) { | |||
var state = crawl(node.right); | |||
if (state.hasCall && state.hasHelper || state.hasFunction) { | |||
return { | |||
before: state.hasFunction, | |||
after: true | |||
}; | |||
} | |||
}, | |||
SwitchCase: function SwitchCase(node, parent) { | |||
return { | |||
before: node.consequent.length || parent.cases[0] === node, | |||
after: !node.consequent.length && parent.cases[parent.cases.length - 1] === node | |||
}; | |||
}, | |||
LogicalExpression: function LogicalExpression(node) { | |||
if (t().isFunction(node.left) || t().isFunction(node.right)) { | |||
return { | |||
after: true | |||
}; | |||
} | |||
}, | |||
Literal: function Literal(node) { | |||
if (node.value === "use strict") { | |||
return { | |||
after: true | |||
}; | |||
} | |||
}, | |||
CallExpression: function CallExpression(node) { | |||
if (t().isFunction(node.callee) || isHelper(node)) { | |||
return { | |||
before: true, | |||
after: true | |||
}; | |||
} | |||
}, | |||
VariableDeclaration: function VariableDeclaration(node) { | |||
for (var i = 0; i < node.declarations.length; i++) { | |||
var declar = node.declarations[i]; | |||
var enabled = isHelper(declar.id) && !isType(declar.init); | |||
if (!enabled) { | |||
var state = crawl(declar.init); | |||
enabled = isHelper(declar.init) && state.hasCall || state.hasFunction; | |||
} | |||
if (enabled) { | |||
return { | |||
before: true, | |||
after: true | |||
}; | |||
} | |||
} | |||
}, | |||
IfStatement: function IfStatement(node) { | |||
if (t().isBlockStatement(node.consequent)) { | |||
return { | |||
before: true, | |||
after: true | |||
}; | |||
} | |||
} | |||
}; | |||
exports.nodes = nodes; | |||
nodes.ObjectProperty = nodes.ObjectTypeProperty = nodes.ObjectMethod = function (node, parent) { | |||
if (parent.properties[0] === node) { | |||
return { | |||
before: true | |||
}; | |||
} | |||
}; | |||
nodes.ObjectTypeCallProperty = function (node, parent) { | |||
if (parent.callProperties[0] === node && (!parent.properties || !parent.properties.length)) { | |||
return { | |||
before: true | |||
}; | |||
} | |||
}; | |||
nodes.ObjectTypeIndexer = function (node, parent) { | |||
if (parent.indexers[0] === node && (!parent.properties || !parent.properties.length) && (!parent.callProperties || !parent.callProperties.length)) { | |||
return { | |||
before: true | |||
}; | |||
} | |||
}; | |||
var list = { | |||
VariableDeclaration: function VariableDeclaration(node) { | |||
return node.declarations.map(function (decl) { | |||
return decl.init; | |||
}); | |||
}, | |||
ArrayExpression: function ArrayExpression(node) { | |||
return node.elements; | |||
}, | |||
ObjectExpression: function ObjectExpression(node) { | |||
return node.properties; | |||
} | |||
}; | |||
exports.list = list; | |||
[["Function", true], ["Class", true], ["Loop", true], ["LabeledStatement", true], ["SwitchStatement", true], ["TryStatement", true]].forEach(function (_ref) { | |||
var type = _ref[0], | |||
amounts = _ref[1]; | |||
if (typeof amounts === "boolean") { | |||
amounts = { | |||
after: amounts, | |||
before: amounts | |||
}; | |||
} | |||
[type].concat(t().FLIPPED_ALIAS_KEYS[type] || []).forEach(function (type) { | |||
nodes[type] = function () { | |||
return amounts; | |||
}; | |||
}); | |||
}); |