chore:更换到主分支

This commit is contained in:
张益铭
2021-03-01 15:26:05 +08:00
parent 9064b372e8
commit 6a5f1810f9
3530 changed files with 59613 additions and 479452 deletions

15
node_modules/.bin/esparse generated vendored
View File

@@ -1,15 +0,0 @@
#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
case `uname` in
*CYGWIN*|*MINGW*|*MSYS*) 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

17
node_modules/.bin/esparse.cmd generated vendored
View File

@@ -1,17 +0,0 @@
@ECHO off
SETLOCAL
CALL :find_dp0
IF EXIST "%dp0%\node.exe" (
SET "_prog=%dp0%\node.exe"
) ELSE (
SET "_prog=node"
SET PATHEXT=%PATHEXT:;.JS;=;%
)
"%_prog%" "%dp0%\..\esprima\bin\esparse.js" %*
ENDLOCAL
EXIT /b %errorlevel%
:find_dp0
SET dp0=%~dp0
EXIT /b

18
node_modules/.bin/esparse.ps1 generated vendored
View File

@@ -1,18 +0,0 @@
#!/usr/bin/env pwsh
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
$exe=""
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
# Fix case when both the Windows and Linux builds of Node
# are installed in the same directory
$exe=".exe"
}
$ret=0
if (Test-Path "$basedir/node$exe") {
& "$basedir/node$exe" "$basedir/../esprima/bin/esparse.js" $args
$ret=$LASTEXITCODE
} else {
& "node$exe" "$basedir/../esprima/bin/esparse.js" $args
$ret=$LASTEXITCODE
}
exit $ret

15
node_modules/.bin/esvalidate generated vendored
View File

@@ -1,15 +0,0 @@
#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
case `uname` in
*CYGWIN*|*MINGW*|*MSYS*) 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

17
node_modules/.bin/esvalidate.cmd generated vendored
View File

@@ -1,17 +0,0 @@
@ECHO off
SETLOCAL
CALL :find_dp0
IF EXIST "%dp0%\node.exe" (
SET "_prog=%dp0%\node.exe"
) ELSE (
SET "_prog=node"
SET PATHEXT=%PATHEXT:;.JS;=;%
)
"%_prog%" "%dp0%\..\esprima\bin\esvalidate.js" %*
ENDLOCAL
EXIT /b %errorlevel%
:find_dp0
SET dp0=%~dp0
EXIT /b

18
node_modules/.bin/esvalidate.ps1 generated vendored
View File

@@ -1,18 +0,0 @@
#!/usr/bin/env pwsh
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
$exe=""
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
# Fix case when both the Windows and Linux builds of Node
# are installed in the same directory
$exe=".exe"
}
$ret=0
if (Test-Path "$basedir/node$exe") {
& "$basedir/node$exe" "$basedir/../esprima/bin/esvalidate.js" $args
$ret=$LASTEXITCODE
} else {
& "node$exe" "$basedir/../esprima/bin/esvalidate.js" $args
$ret=$LASTEXITCODE
}
exit $ret

15
node_modules/.bin/is-docker generated vendored
View File

@@ -1,15 +0,0 @@
#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
case `uname` in
*CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
esac
if [ -x "$basedir/node" ]; then
"$basedir/node" "$basedir/../is-docker/cli.js" "$@"
ret=$?
else
node "$basedir/../is-docker/cli.js" "$@"
ret=$?
fi
exit $ret

17
node_modules/.bin/is-docker.cmd generated vendored
View File

@@ -1,17 +0,0 @@
@ECHO off
SETLOCAL
CALL :find_dp0
IF EXIST "%dp0%\node.exe" (
SET "_prog=%dp0%\node.exe"
) ELSE (
SET "_prog=node"
SET PATHEXT=%PATHEXT:;.JS;=;%
)
"%_prog%" "%dp0%\..\is-docker\cli.js" %*
ENDLOCAL
EXIT /b %errorlevel%
:find_dp0
SET dp0=%~dp0
EXIT /b

18
node_modules/.bin/is-docker.ps1 generated vendored
View File

@@ -1,18 +0,0 @@
#!/usr/bin/env pwsh
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
$exe=""
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
# Fix case when both the Windows and Linux builds of Node
# are installed in the same directory
$exe=".exe"
}
$ret=0
if (Test-Path "$basedir/node$exe") {
& "$basedir/node$exe" "$basedir/../is-docker/cli.js" $args
$ret=$LASTEXITCODE
} else {
& "node$exe" "$basedir/../is-docker/cli.js" $args
$ret=$LASTEXITCODE
}
exit $ret

15
node_modules/.bin/js-yaml generated vendored
View File

@@ -1,15 +0,0 @@
#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
case `uname` in
*CYGWIN*|*MINGW*|*MSYS*) 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

17
node_modules/.bin/js-yaml.cmd generated vendored
View File

@@ -1,17 +0,0 @@
@ECHO off
SETLOCAL
CALL :find_dp0
IF EXIST "%dp0%\node.exe" (
SET "_prog=%dp0%\node.exe"
) ELSE (
SET "_prog=node"
SET PATHEXT=%PATHEXT:;.JS;=;%
)
"%_prog%" "%dp0%\..\js-yaml\bin\js-yaml.js" %*
ENDLOCAL
EXIT /b %errorlevel%
:find_dp0
SET dp0=%~dp0
EXIT /b

18
node_modules/.bin/js-yaml.ps1 generated vendored
View File

@@ -1,18 +0,0 @@
#!/usr/bin/env pwsh
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
$exe=""
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
# Fix case when both the Windows and Linux builds of Node
# are installed in the same directory
$exe=".exe"
}
$ret=0
if (Test-Path "$basedir/node$exe") {
& "$basedir/node$exe" "$basedir/../js-yaml/bin/js-yaml.js" $args
$ret=$LASTEXITCODE
} else {
& "node$exe" "$basedir/../js-yaml/bin/js-yaml.js" $args
$ret=$LASTEXITCODE
}
exit $ret

15
node_modules/.bin/markdown-it generated vendored
View File

@@ -1,15 +0,0 @@
#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
case `uname` in
*CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
esac
if [ -x "$basedir/node" ]; then
"$basedir/node" "$basedir/../markdown-it/bin/markdown-it.js" "$@"
ret=$?
else
node "$basedir/../markdown-it/bin/markdown-it.js" "$@"
ret=$?
fi
exit $ret

17
node_modules/.bin/markdown-it.cmd generated vendored
View File

@@ -1,17 +0,0 @@
@ECHO off
SETLOCAL
CALL :find_dp0
IF EXIST "%dp0%\node.exe" (
SET "_prog=%dp0%\node.exe"
) ELSE (
SET "_prog=node"
SET PATHEXT=%PATHEXT:;.JS;=;%
)
"%_prog%" "%dp0%\..\markdown-it\bin\markdown-it.js" %*
ENDLOCAL
EXIT /b %errorlevel%
:find_dp0
SET dp0=%~dp0
EXIT /b

18
node_modules/.bin/markdown-it.ps1 generated vendored
View File

@@ -1,18 +0,0 @@
#!/usr/bin/env pwsh
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
$exe=""
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
# Fix case when both the Windows and Linux builds of Node
# are installed in the same directory
$exe=".exe"
}
$ret=0
if (Test-Path "$basedir/node$exe") {
& "$basedir/node$exe" "$basedir/../markdown-it/bin/markdown-it.js" $args
$ret=$LASTEXITCODE
} else {
& "node$exe" "$basedir/../markdown-it/bin/markdown-it.js" $args
$ret=$LASTEXITCODE
}
exit $ret

15
node_modules/.bin/node-which generated vendored
View File

@@ -1,15 +0,0 @@
#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
case `uname` in
*CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
esac
if [ -x "$basedir/node" ]; then
"$basedir/node" "$basedir/../which/bin/node-which" "$@"
ret=$?
else
node "$basedir/../which/bin/node-which" "$@"
ret=$?
fi
exit $ret

17
node_modules/.bin/node-which.cmd generated vendored
View File

@@ -1,17 +0,0 @@
@ECHO off
SETLOCAL
CALL :find_dp0
IF EXIST "%dp0%\node.exe" (
SET "_prog=%dp0%\node.exe"
) ELSE (
SET "_prog=node"
SET PATHEXT=%PATHEXT:;.JS;=;%
)
"%_prog%" "%dp0%\..\which\bin\node-which" %*
ENDLOCAL
EXIT /b %errorlevel%
:find_dp0
SET dp0=%~dp0
EXIT /b

18
node_modules/.bin/node-which.ps1 generated vendored
View File

@@ -1,18 +0,0 @@
#!/usr/bin/env pwsh
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
$exe=""
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
# Fix case when both the Windows and Linux builds of Node
# are installed in the same directory
$exe=".exe"
}
$ret=0
if (Test-Path "$basedir/node$exe") {
& "$basedir/node$exe" "$basedir/../which/bin/node-which" $args
$ret=$LASTEXITCODE
} else {
& "node$exe" "$basedir/../which/bin/node-which" $args
$ret=$LASTEXITCODE
}
exit $ret

15
node_modules/.bin/terser generated vendored
View File

@@ -1,15 +0,0 @@
#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
case `uname` in
*CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
esac
if [ -x "$basedir/node" ]; then
"$basedir/node" "$basedir/../terser/bin/terser" "$@"
ret=$?
else
node "$basedir/../terser/bin/terser" "$@"
ret=$?
fi
exit $ret

17
node_modules/.bin/terser.cmd generated vendored
View File

@@ -1,17 +0,0 @@
@ECHO off
SETLOCAL
CALL :find_dp0
IF EXIST "%dp0%\node.exe" (
SET "_prog=%dp0%\node.exe"
) ELSE (
SET "_prog=node"
SET PATHEXT=%PATHEXT:;.JS;=;%
)
"%_prog%" "%dp0%\..\terser\bin\terser" %*
ENDLOCAL
EXIT /b %errorlevel%
:find_dp0
SET dp0=%~dp0
EXIT /b

18
node_modules/.bin/terser.ps1 generated vendored
View File

@@ -1,18 +0,0 @@
#!/usr/bin/env pwsh
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
$exe=""
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
# Fix case when both the Windows and Linux builds of Node
# are installed in the same directory
$exe=".exe"
}
$ret=0
if (Test-Path "$basedir/node$exe") {
& "$basedir/node$exe" "$basedir/../terser/bin/terser" $args
$ret=$LASTEXITCODE
} else {
& "node$exe" "$basedir/../terser/bin/terser" $args
$ret=$LASTEXITCODE
}
exit $ret

15
node_modules/.bin/vitepress generated vendored
View File

@@ -1,15 +0,0 @@
#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
case `uname` in
*CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
esac
if [ -x "$basedir/node" ]; then
"$basedir/node" "$basedir/../vitepress/bin/vitepress.js" "$@"
ret=$?
else
node "$basedir/../vitepress/bin/vitepress.js" "$@"
ret=$?
fi
exit $ret

17
node_modules/.bin/vitepress.cmd generated vendored
View File

@@ -1,17 +0,0 @@
@ECHO off
SETLOCAL
CALL :find_dp0
IF EXIST "%dp0%\node.exe" (
SET "_prog=%dp0%\node.exe"
) ELSE (
SET "_prog=node"
SET PATHEXT=%PATHEXT:;.JS;=;%
)
"%_prog%" "%dp0%\..\vitepress\bin\vitepress.js" %*
ENDLOCAL
EXIT /b %errorlevel%
:find_dp0
SET dp0=%~dp0
EXIT /b

18
node_modules/.bin/vitepress.ps1 generated vendored
View File

@@ -1,18 +0,0 @@
#!/usr/bin/env pwsh
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
$exe=""
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
# Fix case when both the Windows and Linux builds of Node
# are installed in the same directory
$exe=".exe"
}
$ret=0
if (Test-Path "$basedir/node$exe") {
& "$basedir/node$exe" "$basedir/../vitepress/bin/vitepress.js" $args
$ret=$LASTEXITCODE
} else {
& "node$exe" "$basedir/../vitepress/bin/vitepress.js" $args
$ret=$LASTEXITCODE
}
exit $ret

1
node_modules/.vite_opt_cache/hash generated vendored
View File

@@ -1 +0,0 @@
Q2anvQHGddPtypewx/fx89wZxo4=

View File

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

View File

@@ -1,19 +0,0 @@
# @babel/code-frame
> Generate errors that contain a code frame that point to source locations.
See our website [@babel/code-frame](https://babeljs.io/docs/en/next/babel-code-frame.html) for more information.
## Install
Using npm:
```sh
npm install --save-dev @babel/code-frame
```
or using yarn:
```sh
yarn add @babel/code-frame --dev
```

View File

@@ -1,167 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.codeFrameColumns = codeFrameColumns;
exports.default = _default;
var _highlight = _interopRequireWildcard(require("@babel/highlight"));
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
let deprecationWarningShown = false;
function getDefs(chalk) {
return {
gutter: chalk.grey,
marker: chalk.red.bold,
message: chalk.red.bold
};
}
const NEWLINE = /\r\n|[\n\r\u2028\u2029]/;
function getMarkerLines(loc, source, opts) {
const startLoc = Object.assign({
column: 0,
line: -1
}, loc.start);
const endLoc = Object.assign({}, startLoc, loc.end);
const {
linesAbove = 2,
linesBelow = 3
} = opts || {};
const startLine = startLoc.line;
const startColumn = startLoc.column;
const endLine = endLoc.line;
const endColumn = endLoc.column;
let start = Math.max(startLine - (linesAbove + 1), 0);
let end = Math.min(source.length, endLine + linesBelow);
if (startLine === -1) {
start = 0;
}
if (endLine === -1) {
end = source.length;
}
const lineDiff = endLine - startLine;
const markerLines = {};
if (lineDiff) {
for (let i = 0; i <= lineDiff; i++) {
const lineNumber = i + startLine;
if (!startColumn) {
markerLines[lineNumber] = true;
} else if (i === 0) {
const sourceLength = source[lineNumber - 1].length;
markerLines[lineNumber] = [startColumn, sourceLength - startColumn + 1];
} else if (i === lineDiff) {
markerLines[lineNumber] = [0, endColumn];
} else {
const 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,
end,
markerLines
};
}
function codeFrameColumns(rawLines, loc, opts = {}) {
const highlighted = (opts.highlightCode || opts.forceColor) && (0, _highlight.shouldHighlight)(opts);
const chalk = (0, _highlight.getChalk)(opts);
const defs = getDefs(chalk);
const maybeHighlight = (chalkFn, string) => {
return highlighted ? chalkFn(string) : string;
};
const lines = rawLines.split(NEWLINE);
const {
start,
end,
markerLines
} = getMarkerLines(loc, lines, opts);
const hasColumns = loc.start && typeof loc.start.column === "number";
const numberMaxWidth = String(end).length;
const highlightedLines = highlighted ? (0, _highlight.default)(rawLines, opts) : rawLines;
let frame = highlightedLines.split(NEWLINE).slice(start, end).map((line, index) => {
const number = start + 1 + index;
const paddedNumber = ` ${number}`.slice(-numberMaxWidth);
const gutter = ` ${paddedNumber} | `;
const hasMarker = markerLines[number];
const lastMarkerLine = !markerLines[number + 1];
if (hasMarker) {
let markerLine = "";
if (Array.isArray(hasMarker)) {
const markerSpacing = line.slice(0, Math.max(hasMarker[0] - 1, 0)).replace(/[^\t]/g, " ");
const 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 (!deprecationWarningShown) {
deprecationWarningShown = true;
const message = "Passing lineNumber and colNumber is deprecated to @babel/code-frame. Please use `codeFrameColumns`.";
if (process.emitWarning) {
process.emitWarning(message, "DeprecationWarning");
} else {
const deprecationError = new Error(message);
deprecationError.name = "DeprecationWarning";
console.warn(new Error(message));
}
}
colNumber = Math.max(colNumber, 0);
const location = {
start: {
column: colNumber,
line: lineNumber
}
};
return codeFrameColumns(rawLines, location, opts);
}

View File

@@ -1,62 +0,0 @@
{
"_args": [
[
"@babel/code-frame@7.10.4",
"J:\\Github\\CURD-TS"
]
],
"_development": true,
"_from": "@babel/code-frame@7.10.4",
"_id": "@babel/code-frame@7.10.4",
"_inBundle": false,
"_integrity": "sha1-Fo2ho26Q2miujUnA8bSMfGJJITo=",
"_location": "/@babel/code-frame",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "@babel/code-frame@7.10.4",
"name": "@babel/code-frame",
"escapedName": "@babel%2fcode-frame",
"scope": "@babel",
"rawSpec": "7.10.4",
"saveSpec": null,
"fetchSpec": "7.10.4"
},
"_requiredBy": [
"/parse-json",
"/rollup-plugin-terser"
],
"_resolved": "http://192.168.250.101:4873/@babel%2fcode-frame/-/code-frame-7.10.4.tgz",
"_spec": "7.10.4",
"_where": "J:\\Github\\CURD-TS",
"author": {
"name": "Sebastian McKenzie",
"email": "sebmck@gmail.com"
},
"bugs": {
"url": "https://github.com/babel/babel/issues"
},
"dependencies": {
"@babel/highlight": "^7.10.4"
},
"description": "Generate errors that contain a code frame that point to source locations.",
"devDependencies": {
"chalk": "^2.0.0",
"strip-ansi": "^4.0.0"
},
"gitHead": "7fd40d86a0d03ff0e9c3ea16b29689945433d4df",
"homepage": "https://babeljs.io/",
"license": "MIT",
"main": "lib/index.js",
"name": "@babel/code-frame",
"publishConfig": {
"access": "public"
},
"repository": {
"type": "git",
"url": "git+https://github.com/babel/babel.git",
"directory": "packages/babel-code-frame"
},
"version": "7.10.4"
}

View File

@@ -2,7 +2,7 @@
> Validate identifier/keywords name
See our website [@babel/helper-validator-identifier](https://babeljs.io/docs/en/next/babel-helper-validator-identifier.html) for more information.
See our website [@babel/helper-validator-identifier](https://babeljs.io/docs/en/babel-helper-validator-identifier) for more information.
## Install

View File

@@ -1,34 +1,32 @@
{
"_args": [
[
"@babel/helper-validator-identifier@7.10.4",
"@babel/helper-validator-identifier@7.12.11",
"J:\\Github\\CURD-TS"
]
],
"_development": true,
"_from": "@babel/helper-validator-identifier@7.10.4",
"_id": "@babel/helper-validator-identifier@7.10.4",
"_from": "@babel/helper-validator-identifier@7.12.11",
"_id": "@babel/helper-validator-identifier@7.12.11",
"_inBundle": false,
"_integrity": "sha1-p4x6clHgH2FlEtMbEK3PUq2l4NI=",
"_integrity": "sha1-yaHwIZF9y1zPDU5FPjmQIpgfye0=",
"_location": "/@babel/helper-validator-identifier",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "@babel/helper-validator-identifier@7.10.4",
"raw": "@babel/helper-validator-identifier@7.12.11",
"name": "@babel/helper-validator-identifier",
"escapedName": "@babel%2fhelper-validator-identifier",
"scope": "@babel",
"rawSpec": "7.10.4",
"rawSpec": "7.12.11",
"saveSpec": null,
"fetchSpec": "7.10.4"
"fetchSpec": "7.12.11"
},
"_requiredBy": [
"/@babel/highlight",
"/@babel/types"
],
"_resolved": "http://192.168.250.101:4873/@babel%2fhelper-validator-identifier/-/helper-validator-identifier-7.10.4.tgz",
"_spec": "7.10.4",
"_resolved": "http://192.168.250.101:4873/@babel%2fhelper-validator-identifier/-/helper-validator-identifier-7.12.11.tgz",
"_spec": "7.12.11",
"_where": "J:\\Github\\CURD-TS",
"bugs": {
"url": "https://github.com/babel/babel/issues"
@@ -39,7 +37,6 @@
"unicode-13.0.0": "^0.8.0"
},
"exports": "./lib/index.js",
"gitHead": "7fd40d86a0d03ff0e9c3ea16b29689945433d4df",
"homepage": "https://github.com/babel/babel#readme",
"license": "MIT",
"main": "./lib/index.js",
@@ -52,5 +49,5 @@
"url": "git+https://github.com/babel/babel.git",
"directory": "packages/babel-helper-validator-identifier"
},
"version": "7.10.4"
"version": "7.12.11"
}

View File

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

View File

@@ -1,19 +0,0 @@
# @babel/highlight
> Syntax highlight JavaScript strings for output in terminals.
See our website [@babel/highlight](https://babeljs.io/docs/en/next/babel-highlight.html) for more information.
## Install
Using npm:
```sh
npm install --save-dev @babel/highlight
```
or using yarn:
```sh
yarn add @babel/highlight --dev
```

View File

@@ -1,107 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.shouldHighlight = shouldHighlight;
exports.getChalk = getChalk;
exports.default = highlight;
var _jsTokens = _interopRequireWildcard(require("js-tokens"));
var _helperValidatorIdentifier = require("@babel/helper-validator-identifier");
var _chalk = _interopRequireDefault(require("chalk"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function getDefs(chalk) {
return {
keyword: chalk.cyan,
capitalized: chalk.yellow,
jsx_tag: chalk.yellow,
punctuator: chalk.yellow,
number: chalk.magenta,
string: chalk.green,
regex: chalk.magenta,
comment: chalk.grey,
invalid: chalk.white.bgRed.bold
};
}
const NEWLINE = /\r\n|[\n\r\u2028\u2029]/;
const JSX_TAG = /^[a-z][\w-]*$/i;
const BRACKET = /^[()[\]{}]$/;
function getTokenType(match) {
const [offset, text] = match.slice(-2);
const token = (0, _jsTokens.matchToToken)(match);
if (token.type === "name") {
if ((0, _helperValidatorIdentifier.isKeyword)(token.value) || (0, _helperValidatorIdentifier.isReservedWord)(token.value)) {
return "keyword";
}
if (JSX_TAG.test(token.value) && (text[offset - 1] === "<" || text.substr(offset - 2, 2) == "</")) {
return "jsx_tag";
}
if (token.value[0] !== token.value[0].toLowerCase()) {
return "capitalized";
}
}
if (token.type === "punctuator" && BRACKET.test(token.value)) {
return "bracket";
}
if (token.type === "invalid" && (token.value === "@" || token.value === "#")) {
return "punctuator";
}
return token.type;
}
function highlightTokens(defs, text) {
return text.replace(_jsTokens.default, function (...args) {
const type = getTokenType(args);
const colorize = defs[type];
if (colorize) {
return args[0].split(NEWLINE).map(str => colorize(str)).join("\n");
} else {
return args[0];
}
});
}
function shouldHighlight(options) {
return _chalk.default.supportsColor || options.forceColor;
}
function getChalk(options) {
let chalk = _chalk.default;
if (options.forceColor) {
chalk = new _chalk.default.constructor({
enabled: true,
level: 1
});
}
return chalk;
}
function highlight(code, options = {}) {
if (shouldHighlight(options)) {
const chalk = getChalk(options);
const defs = getDefs(chalk);
return highlightTokens(defs, code);
} else {
return code;
}
}

View File

@@ -1,62 +0,0 @@
{
"_args": [
[
"@babel/highlight@7.10.4",
"J:\\Github\\CURD-TS"
]
],
"_development": true,
"_from": "@babel/highlight@7.10.4",
"_id": "@babel/highlight@7.10.4",
"_inBundle": false,
"_integrity": "sha1-fRvf1ldTU4+r5sOFls23bZrGAUM=",
"_location": "/@babel/highlight",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "@babel/highlight@7.10.4",
"name": "@babel/highlight",
"escapedName": "@babel%2fhighlight",
"scope": "@babel",
"rawSpec": "7.10.4",
"saveSpec": null,
"fetchSpec": "7.10.4"
},
"_requiredBy": [
"/@babel/code-frame"
],
"_resolved": "http://192.168.250.101:4873/@babel%2fhighlight/-/highlight-7.10.4.tgz",
"_spec": "7.10.4",
"_where": "J:\\Github\\CURD-TS",
"author": {
"name": "suchipi",
"email": "me@suchipi.com"
},
"bugs": {
"url": "https://github.com/babel/babel/issues"
},
"dependencies": {
"@babel/helper-validator-identifier": "^7.10.4",
"chalk": "^2.0.0",
"js-tokens": "^4.0.0"
},
"description": "Syntax highlight JavaScript strings for output in terminals.",
"devDependencies": {
"strip-ansi": "^4.0.0"
},
"gitHead": "7fd40d86a0d03ff0e9c3ea16b29689945433d4df",
"homepage": "https://babeljs.io/",
"license": "MIT",
"main": "lib/index.js",
"name": "@babel/highlight",
"publishConfig": {
"access": "public"
},
"repository": {
"type": "git",
"url": "git+https://github.com/babel/babel.git",
"directory": "packages/babel-highlight"
},
"version": "7.10.4"
}

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@@ -1,35 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getOptions = getOptions;
exports.defaultOptions = void 0;
const defaultOptions = {
sourceType: "script",
sourceFilename: undefined,
startLine: 1,
allowAwaitOutsideFunction: false,
allowReturnOutsideFunction: false,
allowImportExportEverywhere: false,
allowSuperOutsideMethod: false,
allowUndeclaredExports: false,
plugins: [],
strictMode: null,
ranges: false,
tokens: false,
createParenthesizedExpressions: false,
errorRecovery: false
};
exports.defaultOptions = defaultOptions;
function getOptions(opts) {
const options = {};
for (let _i = 0, _Object$keys = Object.keys(defaultOptions); _i < _Object$keys.length; _i++) {
const key = _Object$keys[_i];
options[key] = opts && opts[key] != null ? opts[key] : defaultOptions[key];
}
return options;
}

View File

@@ -1,24 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
class BaseParser {
constructor() {
this.sawUnambiguousESM = false;
this.ambiguousScriptDifferentAst = false;
}
hasPlugin(name) {
return this.plugins.has(name);
}
getPluginOption(plugin, name) {
if (this.hasPlugin(plugin)) return this.plugins.get(plugin)[name];
}
}
exports.default = BaseParser;

View File

@@ -1,205 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _base = _interopRequireDefault(require("./base"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function last(stack) {
return stack[stack.length - 1];
}
class CommentsParser extends _base.default {
addComment(comment) {
if (this.filename) comment.loc.filename = this.filename;
this.state.trailingComments.push(comment);
this.state.leadingComments.push(comment);
}
adjustCommentsAfterTrailingComma(node, elements, takeAllComments) {
if (this.state.leadingComments.length === 0) {
return;
}
let lastElement = null;
let i = elements.length;
while (lastElement === null && i > 0) {
lastElement = elements[--i];
}
if (lastElement === null) {
return;
}
for (let j = 0; j < this.state.leadingComments.length; j++) {
if (this.state.leadingComments[j].end < this.state.commentPreviousNode.end) {
this.state.leadingComments.splice(j, 1);
j--;
}
}
const newTrailingComments = [];
for (let i = 0; i < this.state.leadingComments.length; i++) {
const leadingComment = this.state.leadingComments[i];
if (leadingComment.end < node.end) {
newTrailingComments.push(leadingComment);
if (!takeAllComments) {
this.state.leadingComments.splice(i, 1);
i--;
}
} else {
if (node.trailingComments === undefined) {
node.trailingComments = [];
}
node.trailingComments.push(leadingComment);
}
}
if (takeAllComments) this.state.leadingComments = [];
if (newTrailingComments.length > 0) {
lastElement.trailingComments = newTrailingComments;
} else if (lastElement.trailingComments !== undefined) {
lastElement.trailingComments = [];
}
}
processComment(node) {
if (node.type === "Program" && node.body.length > 0) return;
const stack = this.state.commentStack;
let firstChild, lastChild, trailingComments, i, j;
if (this.state.trailingComments.length > 0) {
if (this.state.trailingComments[0].start >= node.end) {
trailingComments = this.state.trailingComments;
this.state.trailingComments = [];
} else {
this.state.trailingComments.length = 0;
}
} else if (stack.length > 0) {
const lastInStack = last(stack);
if (lastInStack.trailingComments && lastInStack.trailingComments[0].start >= node.end) {
trailingComments = lastInStack.trailingComments;
delete lastInStack.trailingComments;
}
}
if (stack.length > 0 && last(stack).start >= node.start) {
firstChild = stack.pop();
}
while (stack.length > 0 && last(stack).start >= node.start) {
lastChild = stack.pop();
}
if (!lastChild && firstChild) lastChild = firstChild;
if (firstChild) {
switch (node.type) {
case "ObjectExpression":
this.adjustCommentsAfterTrailingComma(node, node.properties);
break;
case "ObjectPattern":
this.adjustCommentsAfterTrailingComma(node, node.properties, true);
break;
case "CallExpression":
this.adjustCommentsAfterTrailingComma(node, node.arguments);
break;
case "ArrayExpression":
this.adjustCommentsAfterTrailingComma(node, node.elements);
break;
case "ArrayPattern":
this.adjustCommentsAfterTrailingComma(node, node.elements, true);
break;
}
} else if (this.state.commentPreviousNode && (this.state.commentPreviousNode.type === "ImportSpecifier" && node.type !== "ImportSpecifier" || this.state.commentPreviousNode.type === "ExportSpecifier" && node.type !== "ExportSpecifier")) {
this.adjustCommentsAfterTrailingComma(node, [this.state.commentPreviousNode]);
}
if (lastChild) {
if (lastChild.leadingComments) {
if (lastChild !== node && lastChild.leadingComments.length > 0 && last(lastChild.leadingComments).end <= node.start) {
node.leadingComments = lastChild.leadingComments;
delete lastChild.leadingComments;
} else {
for (i = lastChild.leadingComments.length - 2; i >= 0; --i) {
if (lastChild.leadingComments[i].end <= node.start) {
node.leadingComments = lastChild.leadingComments.splice(0, i + 1);
break;
}
}
}
}
} else if (this.state.leadingComments.length > 0) {
if (last(this.state.leadingComments).end <= node.start) {
if (this.state.commentPreviousNode) {
for (j = 0; j < this.state.leadingComments.length; j++) {
if (this.state.leadingComments[j].end < this.state.commentPreviousNode.end) {
this.state.leadingComments.splice(j, 1);
j--;
}
}
}
if (this.state.leadingComments.length > 0) {
node.leadingComments = this.state.leadingComments;
this.state.leadingComments = [];
}
} else {
for (i = 0; i < this.state.leadingComments.length; i++) {
if (this.state.leadingComments[i].end > node.start) {
break;
}
}
const leadingComments = this.state.leadingComments.slice(0, i);
if (leadingComments.length) {
node.leadingComments = leadingComments;
}
trailingComments = this.state.leadingComments.slice(i);
if (trailingComments.length === 0) {
trailingComments = null;
}
}
}
this.state.commentPreviousNode = node;
if (trailingComments) {
if (trailingComments.length && trailingComments[0].start >= node.start && last(trailingComments).end <= node.end) {
node.innerComments = trailingComments;
} else {
const firstTrailingCommentIndex = trailingComments.findIndex(comment => comment.end >= node.end);
if (firstTrailingCommentIndex > 0) {
node.innerComments = trailingComments.slice(0, firstTrailingCommentIndex);
node.trailingComments = trailingComments.slice(firstTrailingCommentIndex);
} else {
node.trailingComments = trailingComments;
}
}
}
stack.push(node);
}
}
exports.default = CommentsParser;

View File

@@ -1,154 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.ErrorMessages = void 0;
const ErrorMessages = Object.freeze({
AccessorIsGenerator: "A %0ter cannot be a generator",
ArgumentsInClass: "'arguments' is only allowed in functions and class methods",
AsyncFunctionInSingleStatementContext: "Async functions can only be declared at the top level or inside a block",
AwaitBindingIdentifier: "Can not use 'await' as identifier inside an async function",
AwaitExpressionFormalParameter: "await is not allowed in async function parameters",
AwaitNotInAsyncContext: "'await' is only allowed within async functions and at the top levels of modules",
AwaitNotInAsyncFunction: "'await' is only allowed within async functions",
BadGetterArity: "getter must not have any formal parameters",
BadSetterArity: "setter must have exactly one formal parameter",
BadSetterRestParameter: "setter function argument must not be a rest parameter",
ConstructorClassField: "Classes may not have a field named 'constructor'",
ConstructorClassPrivateField: "Classes may not have a private field named '#constructor'",
ConstructorIsAccessor: "Class constructor may not be an accessor",
ConstructorIsAsync: "Constructor can't be an async function",
ConstructorIsGenerator: "Constructor can't be a generator",
DeclarationMissingInitializer: "%0 require an initialization value",
DecoratorBeforeExport: "Decorators must be placed *before* the 'export' keyword. You can set the 'decoratorsBeforeExport' option to false to use the 'export @decorator class {}' syntax",
DecoratorConstructor: "Decorators can't be used with a constructor. Did you mean '@dec class { ... }'?",
DecoratorExportClass: "Using the export keyword between a decorator and a class is not allowed. Please use `export @dec class` instead.",
DecoratorSemicolon: "Decorators must not be followed by a semicolon",
DecoratorStaticBlock: "Decorators can't be used with a static block",
DeletePrivateField: "Deleting a private field is not allowed",
DestructureNamedImport: "ES2015 named imports do not destructure. Use another statement for destructuring after the import.",
DuplicateConstructor: "Duplicate constructor in the same class",
DuplicateDefaultExport: "Only one default export allowed per module.",
DuplicateExport: "`%0` has already been exported. Exported identifiers must be unique.",
DuplicateProto: "Redefinition of __proto__ property",
DuplicateRegExpFlags: "Duplicate regular expression flag",
DuplicateStaticBlock: "Duplicate static block in the same class",
ElementAfterRest: "Rest element must be last element",
EscapedCharNotAnIdentifier: "Invalid Unicode escape",
ExportBindingIsString: "A string literal cannot be used as an exported binding without `from`.\n- Did you mean `export { %0 as '%1' } from 'some-module'`?",
ExportDefaultFromAsIdentifier: "'from' is not allowed as an identifier after 'export default'",
ForInOfLoopInitializer: "%0 loop variable declaration may not have an initializer",
GeneratorInSingleStatementContext: "Generators can only be declared at the top level or inside a block",
IllegalBreakContinue: "Unsyntactic %0",
IllegalLanguageModeDirective: "Illegal 'use strict' directive in function with non-simple parameter list",
IllegalReturn: "'return' outside of function",
ImportBindingIsString: 'A string literal cannot be used as an imported binding.\n- Did you mean `import { "%0" as foo }`?',
ImportCallArgumentTrailingComma: "Trailing comma is disallowed inside import(...) arguments",
ImportCallArity: "import() requires exactly %0",
ImportCallNotNewExpression: "Cannot use new with import(...)",
ImportCallSpreadArgument: "... is not allowed in import()",
ImportMetaOutsideModule: `import.meta may appear only with 'sourceType: "module"'`,
ImportOutsideModule: `'import' and 'export' may appear only with 'sourceType: "module"'`,
InvalidBigIntLiteral: "Invalid BigIntLiteral",
InvalidCodePoint: "Code point out of bounds",
InvalidDecimal: "Invalid decimal",
InvalidDigit: "Expected number in radix %0",
InvalidEscapeSequence: "Bad character escape sequence",
InvalidEscapeSequenceTemplate: "Invalid escape sequence in template",
InvalidEscapedReservedWord: "Escape sequence in keyword %0",
InvalidIdentifier: "Invalid identifier %0",
InvalidLhs: "Invalid left-hand side in %0",
InvalidLhsBinding: "Binding invalid left-hand side in %0",
InvalidNumber: "Invalid number",
InvalidOrMissingExponent: "Floating-point numbers require a valid exponent after the 'e'",
InvalidOrUnexpectedToken: "Unexpected character '%0'",
InvalidParenthesizedAssignment: "Invalid parenthesized assignment pattern",
InvalidPrivateFieldResolution: "Private name #%0 is not defined",
InvalidPropertyBindingPattern: "Binding member expression",
InvalidRecordProperty: "Only properties and spread elements are allowed in record definitions",
InvalidRestAssignmentPattern: "Invalid rest operator's argument",
LabelRedeclaration: "Label '%0' is already declared",
LetInLexicalBinding: "'let' is not allowed to be used as a name in 'let' or 'const' declarations.",
LineTerminatorBeforeArrow: "No line break is allowed before '=>'",
MalformedRegExpFlags: "Invalid regular expression flag",
MissingClassName: "A class name is required",
MissingEqInAssignment: "Only '=' operator can be used for specifying default value.",
MissingUnicodeEscape: "Expecting Unicode escape sequence \\uXXXX",
MixingCoalesceWithLogical: "Nullish coalescing operator(??) requires parens when mixing with logical operators",
ModuleAttributeDifferentFromType: "The only accepted module attribute is `type`",
ModuleAttributeInvalidValue: "Only string literals are allowed as module attribute values",
ModuleAttributesWithDuplicateKeys: 'Duplicate key "%0" is not allowed in module attributes',
ModuleExportNameHasLoneSurrogate: "An export name cannot include a lone surrogate, found '\\u%0'",
ModuleExportUndefined: "Export '%0' is not defined",
MultipleDefaultsInSwitch: "Multiple default clauses",
NewlineAfterThrow: "Illegal newline after throw",
NoCatchOrFinally: "Missing catch or finally clause",
NumberIdentifier: "Identifier directly after number",
NumericSeparatorInEscapeSequence: "Numeric separators are not allowed inside unicode escape sequences or hex escape sequences",
ObsoleteAwaitStar: "await* has been removed from the async functions proposal. Use Promise.all() instead.",
OptionalChainingNoNew: "constructors in/after an Optional Chain are not allowed",
OptionalChainingNoTemplate: "Tagged Template Literals are not allowed in optionalChain",
ParamDupe: "Argument name clash",
PatternHasAccessor: "Object pattern can't contain getter or setter",
PatternHasMethod: "Object pattern can't contain methods",
PipelineBodyNoArrow: 'Unexpected arrow "=>" after pipeline body; arrow function in pipeline body must be parenthesized',
PipelineBodySequenceExpression: "Pipeline body may not be a comma-separated sequence expression",
PipelineHeadSequenceExpression: "Pipeline head should not be a comma-separated sequence expression",
PipelineTopicUnused: "Pipeline is in topic style but does not use topic reference",
PrimaryTopicNotAllowed: "Topic reference was used in a lexical context without topic binding",
PrimaryTopicRequiresSmartPipeline: "Primary Topic Reference found but pipelineOperator not passed 'smart' for 'proposal' option.",
PrivateInExpectedIn: "Private names are only allowed in property accesses (`obj.#%0`) or in `in` expressions (`#%0 in obj`)",
PrivateNameRedeclaration: "Duplicate private name #%0",
RecordExpressionBarIncorrectEndSyntaxType: "Record expressions ending with '|}' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'bar'",
RecordExpressionBarIncorrectStartSyntaxType: "Record expressions starting with '{|' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'bar'",
RecordExpressionHashIncorrectStartSyntaxType: "Record expressions starting with '#{' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'hash'",
RecordNoProto: "'__proto__' is not allowed in Record expressions",
RestTrailingComma: "Unexpected trailing comma after rest element",
SloppyFunction: "In non-strict mode code, functions can only be declared at top level, inside a block, or as the body of an if statement",
StaticPrototype: "Classes may not have static property named prototype",
StrictDelete: "Deleting local variable in strict mode",
StrictEvalArguments: "Assigning to '%0' in strict mode",
StrictEvalArgumentsBinding: "Binding '%0' in strict mode",
StrictFunction: "In strict mode code, functions can only be declared at top level or inside a block",
StrictNumericEscape: "The only valid numeric escape in strict mode is '\\0'",
StrictOctalLiteral: "Legacy octal literals are not allowed in strict mode",
StrictWith: "'with' in strict mode",
SuperNotAllowed: "super() is only valid inside a class constructor of a subclass. Maybe a typo in the method name ('constructor') or not extending another class?",
SuperPrivateField: "Private fields can't be accessed on super",
TrailingDecorator: "Decorators must be attached to a class element",
TupleExpressionBarIncorrectEndSyntaxType: "Tuple expressions ending with '|]' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'bar'",
TupleExpressionBarIncorrectStartSyntaxType: "Tuple expressions starting with '[|' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'bar'",
TupleExpressionHashIncorrectStartSyntaxType: "Tuple expressions starting with '#[' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'hash'",
UnexpectedArgumentPlaceholder: "Unexpected argument placeholder",
UnexpectedAwaitAfterPipelineBody: 'Unexpected "await" after pipeline body; await must have parentheses in minimal proposal',
UnexpectedDigitAfterHash: "Unexpected digit after hash token",
UnexpectedImportExport: "'import' and 'export' may only appear at the top level",
UnexpectedKeyword: "Unexpected keyword '%0'",
UnexpectedLeadingDecorator: "Leading decorators must be attached to a class declaration",
UnexpectedLexicalDeclaration: "Lexical declaration cannot appear in a single-statement context",
UnexpectedNewTarget: "new.target can only be used in functions",
UnexpectedNumericSeparator: "A numeric separator is only allowed between two digits",
UnexpectedPrivateField: "Private names can only be used as the name of a class element (i.e. class C { #p = 42; #m() {} } )\n or a property of member expression (i.e. this.#p).",
UnexpectedReservedWord: "Unexpected reserved word '%0'",
UnexpectedSuper: "super is only allowed in object methods and classes",
UnexpectedToken: "Unexpected token '%0'",
UnexpectedTokenUnaryExponentiation: "Illegal expression. Wrap left hand side or entire exponentiation in parentheses.",
UnsupportedBind: "Binding should be performed on object property.",
UnsupportedDecoratorExport: "A decorated export must export a class declaration",
UnsupportedDefaultExport: "Only expressions, functions or classes are allowed as the `default` export.",
UnsupportedImport: "import can only be used in import() or import.meta",
UnsupportedMetaProperty: "The only valid meta property for %0 is %0.%1",
UnsupportedParameterDecorator: "Decorators cannot be used to decorate parameters",
UnsupportedPropertyDecorator: "Decorators cannot be used to decorate object literal properties",
UnsupportedSuper: "super can only be used with function calls (i.e. super()) or in property accesses (i.e. super.prop or super[prop])",
UnterminatedComment: "Unterminated comment",
UnterminatedRegExp: "Unterminated regular expression",
UnterminatedString: "Unterminated string constant",
UnterminatedTemplate: "Unterminated template",
VarRedeclaration: "Identifier '%0' has already been declared",
YieldBindingIdentifier: "Can not use 'yield' as identifier inside a generator",
YieldInParameter: "Yield expression is not allowed in formal parameters",
ZeroDigitNumericSeparator: "Numeric separator can not be used after leading 0"
});
exports.ErrorMessages = ErrorMessages;

View File

@@ -1,56 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "Errors", {
enumerable: true,
get: function () {
return _errorMessage.ErrorMessages;
}
});
exports.default = void 0;
var _location = require("../util/location");
var _comments = _interopRequireDefault(require("./comments"));
var _errorMessage = require("./error-message.js");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
class ParserError extends _comments.default {
getLocationForPosition(pos) {
let loc;
if (pos === this.state.start) loc = this.state.startLoc;else if (pos === this.state.lastTokStart) loc = this.state.lastTokStartLoc;else if (pos === this.state.end) loc = this.state.endLoc;else if (pos === this.state.lastTokEnd) loc = this.state.lastTokEndLoc;else loc = (0, _location.getLineInfo)(this.input, pos);
return loc;
}
raise(pos, errorTemplate, ...params) {
return this.raiseWithData(pos, undefined, errorTemplate, ...params);
}
raiseWithData(pos, data, errorTemplate, ...params) {
const loc = this.getLocationForPosition(pos);
const message = errorTemplate.replace(/%(\d+)/g, (_, i) => params[i]) + ` (${loc.line}:${loc.column})`;
return this._raise(Object.assign({
loc,
pos
}, data), message);
}
_raise(errorContext, message) {
const err = new SyntaxError(message);
Object.assign(err, errorContext);
if (this.options.errorRecovery) {
if (!this.isLookahead) this.state.errors.push(err);
return err;
} else {
throw err;
}
}
}
exports.default = ParserError;

File diff suppressed because it is too large Load Diff

View File

@@ -1,79 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _options = require("../options");
var _statement = _interopRequireDefault(require("./statement"));
var _scopeflags = require("../util/scopeflags");
var _scope = _interopRequireDefault(require("../util/scope"));
var _classScope = _interopRequireDefault(require("../util/class-scope"));
var _expressionScope = _interopRequireDefault(require("../util/expression-scope"));
var _productionParameter = _interopRequireWildcard(require("../util/production-parameter"));
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
class Parser extends _statement.default {
constructor(options, input) {
options = (0, _options.getOptions)(options);
super(options, input);
const ScopeHandler = this.getScopeHandler();
this.options = options;
this.inModule = this.options.sourceType === "module";
this.scope = new ScopeHandler(this.raise.bind(this), this.inModule);
this.prodParam = new _productionParameter.default();
this.classScope = new _classScope.default(this.raise.bind(this));
this.expressionScope = new _expressionScope.default(this.raise.bind(this));
this.plugins = pluginsMap(this.options.plugins);
this.filename = options.sourceFilename;
}
getScopeHandler() {
return _scope.default;
}
parse() {
let paramFlags = _productionParameter.PARAM;
if (this.hasPlugin("topLevelAwait") && this.inModule) {
paramFlags |= _productionParameter.PARAM_AWAIT;
}
this.scope.enter(_scopeflags.SCOPE_PROGRAM);
this.prodParam.enter(paramFlags);
const file = this.startNode();
const program = this.startNode();
this.nextToken();
file.errors = null;
this.parseTopLevel(file, program);
file.errors = this.state.errors;
return file;
}
}
exports.default = Parser;
function pluginsMap(plugins) {
const pluginMap = new Map();
for (let _i = 0; _i < plugins.length; _i++) {
const plugin = plugins[_i];
const [name, options] = Array.isArray(plugin) ? plugin : [plugin, {}];
if (!pluginMap.has(name)) pluginMap.set(name, options || {});
}
return pluginMap;
}

View File

@@ -1,358 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _types = require("../tokenizer/types");
var _identifier = require("../util/identifier");
var _node = require("./node");
var _scopeflags = require("../util/scopeflags");
var _util = require("./util");
var _error = require("./error");
const unwrapParenthesizedExpression = node => {
return node.type === "ParenthesizedExpression" ? unwrapParenthesizedExpression(node.expression) : node;
};
class LValParser extends _node.NodeUtils {
toAssignable(node) {
let parenthesized = undefined;
if (node.type === "ParenthesizedExpression" || node.extra?.parenthesized) {
parenthesized = unwrapParenthesizedExpression(node);
if (parenthesized.type !== "Identifier" && parenthesized.type !== "MemberExpression") {
this.raise(node.start, _error.Errors.InvalidParenthesizedAssignment);
}
}
switch (node.type) {
case "Identifier":
case "ObjectPattern":
case "ArrayPattern":
case "AssignmentPattern":
break;
case "ObjectExpression":
node.type = "ObjectPattern";
for (let i = 0, length = node.properties.length, last = length - 1; i < length; i++) {
const prop = node.properties[i];
const isLast = i === last;
this.toAssignableObjectExpressionProp(prop, isLast);
if (isLast && prop.type === "RestElement" && node.extra?.trailingComma) {
this.raiseRestNotLast(node.extra.trailingComma);
}
}
break;
case "ObjectProperty":
this.toAssignable(node.value);
break;
case "SpreadElement":
{
this.checkToRestConversion(node);
node.type = "RestElement";
const arg = node.argument;
this.toAssignable(arg);
break;
}
case "ArrayExpression":
node.type = "ArrayPattern";
this.toAssignableList(node.elements, node.extra?.trailingComma);
break;
case "AssignmentExpression":
if (node.operator !== "=") {
this.raise(node.left.end, _error.Errors.MissingEqInAssignment);
}
node.type = "AssignmentPattern";
delete node.operator;
this.toAssignable(node.left);
break;
case "ParenthesizedExpression":
this.toAssignable(parenthesized);
break;
default:
}
return node;
}
toAssignableObjectExpressionProp(prop, isLast) {
if (prop.type === "ObjectMethod") {
const error = prop.kind === "get" || prop.kind === "set" ? _error.Errors.PatternHasAccessor : _error.Errors.PatternHasMethod;
this.raise(prop.key.start, error);
} else if (prop.type === "SpreadElement" && !isLast) {
this.raiseRestNotLast(prop.start);
} else {
this.toAssignable(prop);
}
}
toAssignableList(exprList, trailingCommaPos) {
let end = exprList.length;
if (end) {
const last = exprList[end - 1];
if (last?.type === "RestElement") {
--end;
} else if (last?.type === "SpreadElement") {
last.type = "RestElement";
const arg = last.argument;
this.toAssignable(arg);
if (arg.type !== "Identifier" && arg.type !== "MemberExpression" && arg.type !== "ArrayPattern" && arg.type !== "ObjectPattern") {
this.unexpected(arg.start);
}
if (trailingCommaPos) {
this.raiseTrailingCommaAfterRest(trailingCommaPos);
}
--end;
}
}
for (let i = 0; i < end; i++) {
const elt = exprList[i];
if (elt) {
this.toAssignable(elt);
if (elt.type === "RestElement") {
this.raiseRestNotLast(elt.start);
}
}
}
return exprList;
}
toReferencedList(exprList, isParenthesizedExpr) {
return exprList;
}
toReferencedListDeep(exprList, isParenthesizedExpr) {
this.toReferencedList(exprList, isParenthesizedExpr);
for (let _i = 0; _i < exprList.length; _i++) {
const expr = exprList[_i];
if (expr?.type === "ArrayExpression") {
this.toReferencedListDeep(expr.elements);
}
}
}
parseSpread(refExpressionErrors, refNeedsArrowPos) {
const node = this.startNode();
this.next();
node.argument = this.parseMaybeAssignAllowIn(refExpressionErrors, undefined, refNeedsArrowPos);
return this.finishNode(node, "SpreadElement");
}
parseRestBinding() {
const node = this.startNode();
this.next();
node.argument = this.parseBindingAtom();
return this.finishNode(node, "RestElement");
}
parseBindingAtom() {
switch (this.state.type) {
case _types.types.bracketL:
{
const node = this.startNode();
this.next();
node.elements = this.parseBindingList(_types.types.bracketR, 93, true);
return this.finishNode(node, "ArrayPattern");
}
case _types.types.braceL:
return this.parseObjectLike(_types.types.braceR, true);
}
return this.parseIdentifier();
}
parseBindingList(close, closeCharCode, allowEmpty, allowModifiers) {
const elts = [];
let first = true;
while (!this.eat(close)) {
if (first) {
first = false;
} else {
this.expect(_types.types.comma);
}
if (allowEmpty && this.match(_types.types.comma)) {
elts.push(null);
} else if (this.eat(close)) {
break;
} else if (this.match(_types.types.ellipsis)) {
elts.push(this.parseAssignableListItemTypes(this.parseRestBinding()));
this.checkCommaAfterRest(closeCharCode);
this.expect(close);
break;
} else {
const decorators = [];
if (this.match(_types.types.at) && this.hasPlugin("decorators")) {
this.raise(this.state.start, _error.Errors.UnsupportedParameterDecorator);
}
while (this.match(_types.types.at)) {
decorators.push(this.parseDecorator());
}
elts.push(this.parseAssignableListItem(allowModifiers, decorators));
}
}
return elts;
}
parseAssignableListItem(allowModifiers, decorators) {
const left = this.parseMaybeDefault();
this.parseAssignableListItemTypes(left);
const elt = this.parseMaybeDefault(left.start, left.loc.start, left);
if (decorators.length) {
left.decorators = decorators;
}
return elt;
}
parseAssignableListItemTypes(param) {
return param;
}
parseMaybeDefault(startPos, startLoc, left) {
startLoc = startLoc ?? this.state.startLoc;
startPos = startPos ?? this.state.start;
left = left ?? this.parseBindingAtom();
if (!this.eat(_types.types.eq)) return left;
const node = this.startNodeAt(startPos, startLoc);
node.left = left;
node.right = this.parseMaybeAssignAllowIn();
return this.finishNode(node, "AssignmentPattern");
}
checkLVal(expr, bindingType = _scopeflags.BIND_NONE, checkClashes, contextDescription, disallowLetBinding, strictModeChanged = false) {
switch (expr.type) {
case "Identifier":
if (this.state.strict && (strictModeChanged ? (0, _identifier.isStrictBindReservedWord)(expr.name, this.inModule) : (0, _identifier.isStrictBindOnlyReservedWord)(expr.name))) {
this.raise(expr.start, bindingType === _scopeflags.BIND_NONE ? _error.Errors.StrictEvalArguments : _error.Errors.StrictEvalArgumentsBinding, expr.name);
}
if (checkClashes) {
const key = `_${expr.name}`;
if (checkClashes[key]) {
this.raise(expr.start, _error.Errors.ParamDupe);
} else {
checkClashes[key] = true;
}
}
if (disallowLetBinding && expr.name === "let") {
this.raise(expr.start, _error.Errors.LetInLexicalBinding);
}
if (!(bindingType & _scopeflags.BIND_NONE)) {
this.scope.declareName(expr.name, bindingType, expr.start);
}
break;
case "MemberExpression":
if (bindingType !== _scopeflags.BIND_NONE) {
this.raise(expr.start, _error.Errors.InvalidPropertyBindingPattern);
}
break;
case "ObjectPattern":
for (let _i2 = 0, _expr$properties = expr.properties; _i2 < _expr$properties.length; _i2++) {
let prop = _expr$properties[_i2];
if (prop.type === "ObjectProperty") prop = prop.value;else if (prop.type === "ObjectMethod") continue;
this.checkLVal(prop, bindingType, checkClashes, "object destructuring pattern", disallowLetBinding);
}
break;
case "ArrayPattern":
for (let _i3 = 0, _expr$elements = expr.elements; _i3 < _expr$elements.length; _i3++) {
const elem = _expr$elements[_i3];
if (elem) {
this.checkLVal(elem, bindingType, checkClashes, "array destructuring pattern", disallowLetBinding);
}
}
break;
case "AssignmentPattern":
this.checkLVal(expr.left, bindingType, checkClashes, "assignment pattern");
break;
case "RestElement":
this.checkLVal(expr.argument, bindingType, checkClashes, "rest element");
break;
case "ParenthesizedExpression":
this.checkLVal(expr.expression, bindingType, checkClashes, "parenthesized expression");
break;
default:
{
this.raise(expr.start, bindingType === _scopeflags.BIND_NONE ? _error.Errors.InvalidLhs : _error.Errors.InvalidLhsBinding, contextDescription);
}
}
}
checkToRestConversion(node) {
if (node.argument.type !== "Identifier" && node.argument.type !== "MemberExpression") {
this.raise(node.argument.start, _error.Errors.InvalidRestAssignmentPattern);
}
}
checkCommaAfterRest(close) {
if (this.match(_types.types.comma)) {
if (this.lookaheadCharCode() === close) {
this.raiseTrailingCommaAfterRest(this.state.start);
} else {
this.raiseRestNotLast(this.state.start);
}
}
}
raiseRestNotLast(pos) {
throw this.raise(pos, _error.Errors.ElementAfterRest);
}
raiseTrailingCommaAfterRest(pos) {
this.raise(pos, _error.Errors.RestTrailingComma);
}
}
exports.default = LValParser;

View File

@@ -1,98 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.NodeUtils = void 0;
var _util = _interopRequireDefault(require("./util"));
var _location = require("../util/location");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
class Node {
constructor(parser, pos, loc) {
this.type = void 0;
this.start = void 0;
this.end = void 0;
this.loc = void 0;
this.range = void 0;
this.leadingComments = void 0;
this.trailingComments = void 0;
this.innerComments = void 0;
this.extra = void 0;
this.type = "";
this.start = pos;
this.end = 0;
this.loc = new _location.SourceLocation(loc);
if (parser?.options.ranges) this.range = [pos, 0];
if (parser?.filename) this.loc.filename = parser.filename;
}
__clone() {
const newNode = new Node();
const keys = Object.keys(this);
for (let i = 0, length = keys.length; i < length; i++) {
const key = keys[i];
if (key !== "leadingComments" && key !== "trailingComments" && key !== "innerComments") {
newNode[key] = this[key];
}
}
return newNode;
}
}
class NodeUtils extends _util.default {
startNode() {
return new Node(this, this.state.start, this.state.startLoc);
}
startNodeAt(pos, loc) {
return new Node(this, pos, loc);
}
startNodeAtNode(type) {
return this.startNodeAt(type.start, type.loc.start);
}
finishNode(node, type) {
return this.finishNodeAt(node, type, this.state.lastTokEnd, this.state.lastTokEndLoc);
}
finishNodeAt(node, type, pos, loc) {
if (process.env.NODE_ENV !== "production" && node.end > 0) {
throw new Error("Do not call finishNode*() twice on the same node." + " Instead use resetEndLocation() or change type directly.");
}
node.type = type;
node.end = pos;
node.loc.end = loc;
if (this.options.ranges) node.range[1] = pos;
this.processComment(node);
return node;
}
resetStartLocation(node, start, startLoc) {
node.start = start;
node.loc.start = startLoc;
if (this.options.ranges) node.range[0] = start;
}
resetEndLocation(node, end = this.state.lastTokEnd, endLoc = this.state.lastTokEndLoc) {
node.end = end;
node.loc.end = endLoc;
if (this.options.ranges) node.range[1] = end;
}
resetStartLocationFromNode(node, locationNode) {
this.resetStartLocation(node, locationNode.start, locationNode.loc.start);
}
}
exports.NodeUtils = NodeUtils;

File diff suppressed because it is too large Load Diff

View File

@@ -1,206 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.ExpressionErrors = exports.default = void 0;
var _types = require("../tokenizer/types");
var _tokenizer = _interopRequireDefault(require("../tokenizer"));
var _state = _interopRequireDefault(require("../tokenizer/state"));
var _whitespace = require("../util/whitespace");
var _identifier = require("../util/identifier");
var _error = require("./error");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
class UtilParser extends _tokenizer.default {
addExtra(node, key, val) {
if (!node) return;
const extra = node.extra = node.extra || {};
extra[key] = val;
}
isRelational(op) {
return this.match(_types.types.relational) && this.state.value === op;
}
expectRelational(op) {
if (this.isRelational(op)) {
this.next();
} else {
this.unexpected(null, _types.types.relational);
}
}
isContextual(name) {
return this.match(_types.types.name) && this.state.value === name && !this.state.containsEsc;
}
isUnparsedContextual(nameStart, name) {
const nameEnd = nameStart + name.length;
return this.input.slice(nameStart, nameEnd) === name && (nameEnd === this.input.length || !(0, _identifier.isIdentifierChar)(this.input.charCodeAt(nameEnd)));
}
isLookaheadContextual(name) {
const next = this.nextTokenStart();
return this.isUnparsedContextual(next, name);
}
eatContextual(name) {
return this.isContextual(name) && this.eat(_types.types.name);
}
expectContextual(name, message) {
if (!this.eatContextual(name)) this.unexpected(null, message);
}
canInsertSemicolon() {
return this.match(_types.types.eof) || this.match(_types.types.braceR) || this.hasPrecedingLineBreak();
}
hasPrecedingLineBreak() {
return _whitespace.lineBreak.test(this.input.slice(this.state.lastTokEnd, this.state.start));
}
isLineTerminator() {
return this.eat(_types.types.semi) || this.canInsertSemicolon();
}
semicolon() {
if (!this.isLineTerminator()) this.unexpected(null, _types.types.semi);
}
expect(type, pos) {
this.eat(type) || this.unexpected(pos, type);
}
assertNoSpace(message = "Unexpected space.") {
if (this.state.start > this.state.lastTokEnd) {
this.raise(this.state.lastTokEnd, message);
}
}
unexpected(pos, messageOrType = "Unexpected token") {
if (typeof messageOrType !== "string") {
messageOrType = `Unexpected token, expected "${messageOrType.label}"`;
}
throw this.raise(pos != null ? pos : this.state.start, messageOrType);
}
expectPlugin(name, pos) {
if (!this.hasPlugin(name)) {
throw this.raiseWithData(pos != null ? pos : this.state.start, {
missingPlugin: [name]
}, `This experimental syntax requires enabling the parser plugin: '${name}'`);
}
return true;
}
expectOnePlugin(names, pos) {
if (!names.some(n => this.hasPlugin(n))) {
throw this.raiseWithData(pos != null ? pos : this.state.start, {
missingPlugin: names
}, `This experimental syntax requires enabling one of the following parser plugin(s): '${names.join(", ")}'`);
}
}
tryParse(fn, oldState = this.state.clone()) {
const abortSignal = {
node: null
};
try {
const node = fn((node = null) => {
abortSignal.node = node;
throw abortSignal;
});
if (this.state.errors.length > oldState.errors.length) {
const failState = this.state;
this.state = oldState;
return {
node,
error: failState.errors[oldState.errors.length],
thrown: false,
aborted: false,
failState
};
}
return {
node,
error: null,
thrown: false,
aborted: false,
failState: null
};
} catch (error) {
const failState = this.state;
this.state = oldState;
if (error instanceof SyntaxError) {
return {
node: null,
error,
thrown: true,
aborted: false,
failState
};
}
if (error === abortSignal) {
return {
node: abortSignal.node,
error: null,
thrown: false,
aborted: true,
failState
};
}
throw error;
}
}
checkExpressionErrors(refExpressionErrors, andThrow) {
if (!refExpressionErrors) return false;
const {
shorthandAssign,
doubleProto
} = refExpressionErrors;
if (!andThrow) return shorthandAssign >= 0 || doubleProto >= 0;
if (shorthandAssign >= 0) {
this.unexpected(shorthandAssign);
}
if (doubleProto >= 0) {
this.raise(doubleProto, _error.Errors.DuplicateProto);
}
}
isLiteralPropertyName() {
return this.match(_types.types.name) || !!this.state.type.keyword || this.match(_types.types.string) || this.match(_types.types.num) || this.match(_types.types.bigint) || this.match(_types.types.decimal);
}
}
exports.default = UtilParser;
class ExpressionErrors {
constructor() {
this.shorthandAssign = -1;
this.doubleProto = -1;
}
}
exports.ExpressionErrors = ExpressionErrors;

View File

@@ -1,108 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.hasPlugin = hasPlugin;
exports.getPluginOption = getPluginOption;
exports.validatePlugins = validatePlugins;
exports.mixinPluginNames = exports.mixinPlugins = void 0;
var _estree = _interopRequireDefault(require("./plugins/estree"));
var _flow = _interopRequireDefault(require("./plugins/flow"));
var _jsx = _interopRequireDefault(require("./plugins/jsx"));
var _typescript = _interopRequireDefault(require("./plugins/typescript"));
var _placeholders = _interopRequireDefault(require("./plugins/placeholders"));
var _v8intrinsic = _interopRequireDefault(require("./plugins/v8intrinsic"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function hasPlugin(plugins, name) {
return plugins.some(plugin => {
if (Array.isArray(plugin)) {
return plugin[0] === name;
} else {
return plugin === name;
}
});
}
function getPluginOption(plugins, name, option) {
const plugin = plugins.find(plugin => {
if (Array.isArray(plugin)) {
return plugin[0] === name;
} else {
return plugin === name;
}
});
if (plugin && Array.isArray(plugin)) {
return plugin[1][option];
}
return null;
}
const PIPELINE_PROPOSALS = ["minimal", "smart", "fsharp"];
const RECORD_AND_TUPLE_SYNTAX_TYPES = ["hash", "bar"];
function validatePlugins(plugins) {
if (hasPlugin(plugins, "decorators")) {
if (hasPlugin(plugins, "decorators-legacy")) {
throw new Error("Cannot use the decorators and decorators-legacy plugin together");
}
const decoratorsBeforeExport = getPluginOption(plugins, "decorators", "decoratorsBeforeExport");
if (decoratorsBeforeExport == null) {
throw new Error("The 'decorators' plugin requires a 'decoratorsBeforeExport' option," + " whose value must be a boolean. If you are migrating from" + " Babylon/Babel 6 or want to use the old decorators proposal, you" + " should use the 'decorators-legacy' plugin instead of 'decorators'.");
} else if (typeof decoratorsBeforeExport !== "boolean") {
throw new Error("'decoratorsBeforeExport' must be a boolean.");
}
}
if (hasPlugin(plugins, "flow") && hasPlugin(plugins, "typescript")) {
throw new Error("Cannot combine flow and typescript plugins.");
}
if (hasPlugin(plugins, "placeholders") && hasPlugin(plugins, "v8intrinsic")) {
throw new Error("Cannot combine placeholders and v8intrinsic plugins.");
}
if (hasPlugin(plugins, "pipelineOperator") && !PIPELINE_PROPOSALS.includes(getPluginOption(plugins, "pipelineOperator", "proposal"))) {
throw new Error("'pipelineOperator' requires 'proposal' option whose value should be one of: " + PIPELINE_PROPOSALS.map(p => `'${p}'`).join(", "));
}
if (hasPlugin(plugins, "moduleAttributes")) {
if (hasPlugin(plugins, "importAssertions")) {
throw new Error("Cannot combine importAssertions and moduleAttributes plugins.");
}
const moduleAttributesVerionPluginOption = getPluginOption(plugins, "moduleAttributes", "version");
if (moduleAttributesVerionPluginOption !== "may-2020") {
throw new Error("The 'moduleAttributes' plugin requires a 'version' option," + " representing the last proposal update. Currently, the" + " only supported value is 'may-2020'.");
}
}
if (hasPlugin(plugins, "recordAndTuple") && !RECORD_AND_TUPLE_SYNTAX_TYPES.includes(getPluginOption(plugins, "recordAndTuple", "syntaxType"))) {
throw new Error("'recordAndTuple' requires 'syntaxType' option whose value should be one of: " + RECORD_AND_TUPLE_SYNTAX_TYPES.map(p => `'${p}'`).join(", "));
}
}
const mixinPlugins = {
estree: _estree.default,
jsx: _jsx.default,
flow: _flow.default,
typescript: _typescript.default,
v8intrinsic: _v8intrinsic.default,
placeholders: _placeholders.default
};
exports.mixinPlugins = mixinPlugins;
const mixinPluginNames = Object.keys(mixinPlugins);
exports.mixinPluginNames = mixinPluginNames;

View File

@@ -1,297 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _types = require("../tokenizer/types");
var N = _interopRequireWildcard(require("../types"));
var _scopeflags = require("../util/scopeflags");
var _error = require("../parser/error");
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function isSimpleProperty(node) {
return node != null && node.type === "Property" && node.kind === "init" && node.method === false;
}
var _default = superClass => class extends superClass {
estreeParseRegExpLiteral({
pattern,
flags
}) {
let regex = null;
try {
regex = new RegExp(pattern, flags);
} catch (e) {}
const node = this.estreeParseLiteral(regex);
node.regex = {
pattern,
flags
};
return node;
}
estreeParseBigIntLiteral(value) {
const bigInt = typeof BigInt !== "undefined" ? BigInt(value) : null;
const node = this.estreeParseLiteral(bigInt);
node.bigint = String(node.value || value);
return node;
}
estreeParseDecimalLiteral(value) {
const decimal = null;
const node = this.estreeParseLiteral(decimal);
node.decimal = String(node.value || value);
return node;
}
estreeParseLiteral(value) {
return this.parseLiteral(value, "Literal");
}
directiveToStmt(directive) {
const directiveLiteral = directive.value;
const stmt = this.startNodeAt(directive.start, directive.loc.start);
const expression = this.startNodeAt(directiveLiteral.start, directiveLiteral.loc.start);
expression.value = directiveLiteral.value;
expression.raw = directiveLiteral.extra.raw;
stmt.expression = this.finishNodeAt(expression, "Literal", directiveLiteral.end, directiveLiteral.loc.end);
stmt.directive = directiveLiteral.extra.raw.slice(1, -1);
return this.finishNodeAt(stmt, "ExpressionStatement", directive.end, directive.loc.end);
}
initFunction(node, isAsync) {
super.initFunction(node, isAsync);
node.expression = false;
}
checkDeclaration(node) {
if (isSimpleProperty(node)) {
this.checkDeclaration(node.value);
} else {
super.checkDeclaration(node);
}
}
getObjectOrClassMethodParams(method) {
return method.value.params;
}
checkLVal(expr, bindingType = _scopeflags.BIND_NONE, checkClashes, contextDescription, disallowLetBinding) {
switch (expr.type) {
case "ObjectPattern":
expr.properties.forEach(prop => {
this.checkLVal(prop.type === "Property" ? prop.value : prop, bindingType, checkClashes, "object destructuring pattern", disallowLetBinding);
});
break;
default:
super.checkLVal(expr, bindingType, checkClashes, contextDescription, disallowLetBinding);
}
}
checkProto(prop, isRecord, protoRef, refExpressionErrors) {
if (prop.method) {
return;
}
super.checkProto(prop, isRecord, protoRef, refExpressionErrors);
}
isValidDirective(stmt) {
return stmt.type === "ExpressionStatement" && stmt.expression.type === "Literal" && typeof stmt.expression.value === "string" && !stmt.expression.extra?.parenthesized;
}
stmtToDirective(stmt) {
const directive = super.stmtToDirective(stmt);
const value = stmt.expression.value;
directive.value.value = value;
return directive;
}
parseBlockBody(node, allowDirectives, topLevel, end) {
super.parseBlockBody(node, allowDirectives, topLevel, end);
const directiveStatements = node.directives.map(d => this.directiveToStmt(d));
node.body = directiveStatements.concat(node.body);
delete node.directives;
}
pushClassMethod(classBody, method, isGenerator, isAsync, isConstructor, allowsDirectSuper) {
this.parseMethod(method, isGenerator, isAsync, isConstructor, allowsDirectSuper, "ClassMethod", true);
if (method.typeParameters) {
method.value.typeParameters = method.typeParameters;
delete method.typeParameters;
}
classBody.body.push(method);
}
parseExprAtom(refExpressionErrors) {
switch (this.state.type) {
case _types.types.num:
case _types.types.string:
return this.estreeParseLiteral(this.state.value);
case _types.types.regexp:
return this.estreeParseRegExpLiteral(this.state.value);
case _types.types.bigint:
return this.estreeParseBigIntLiteral(this.state.value);
case _types.types.decimal:
return this.estreeParseDecimalLiteral(this.state.value);
case _types.types._null:
return this.estreeParseLiteral(null);
case _types.types._true:
return this.estreeParseLiteral(true);
case _types.types._false:
return this.estreeParseLiteral(false);
default:
return super.parseExprAtom(refExpressionErrors);
}
}
parseLiteral(value, type, startPos, startLoc) {
const node = super.parseLiteral(value, type, startPos, startLoc);
node.raw = node.extra.raw;
delete node.extra;
return node;
}
parseFunctionBody(node, allowExpression, isMethod = false) {
super.parseFunctionBody(node, allowExpression, isMethod);
node.expression = node.body.type !== "BlockStatement";
}
parseMethod(node, isGenerator, isAsync, isConstructor, allowDirectSuper, type, inClassScope = false) {
let funcNode = this.startNode();
funcNode.kind = node.kind;
funcNode = super.parseMethod(funcNode, isGenerator, isAsync, isConstructor, allowDirectSuper, type, inClassScope);
funcNode.type = "FunctionExpression";
delete funcNode.kind;
node.value = funcNode;
type = type === "ClassMethod" ? "MethodDefinition" : type;
return this.finishNode(node, type);
}
parseObjectMethod(prop, isGenerator, isAsync, isPattern, isAccessor) {
const node = super.parseObjectMethod(prop, isGenerator, isAsync, isPattern, isAccessor);
if (node) {
node.type = "Property";
if (node.kind === "method") node.kind = "init";
node.shorthand = false;
}
return node;
}
parseObjectProperty(prop, startPos, startLoc, isPattern, refExpressionErrors) {
const node = super.parseObjectProperty(prop, startPos, startLoc, isPattern, refExpressionErrors);
if (node) {
node.kind = "init";
node.type = "Property";
}
return node;
}
toAssignable(node) {
if (isSimpleProperty(node)) {
this.toAssignable(node.value);
return node;
}
return super.toAssignable(node);
}
toAssignableObjectExpressionProp(prop, isLast) {
if (prop.kind === "get" || prop.kind === "set") {
throw this.raise(prop.key.start, _error.Errors.PatternHasAccessor);
} else if (prop.method) {
throw this.raise(prop.key.start, _error.Errors.PatternHasMethod);
} else {
super.toAssignableObjectExpressionProp(prop, isLast);
}
}
finishCallExpression(node, optional) {
super.finishCallExpression(node, optional);
if (node.callee.type === "Import") {
node.type = "ImportExpression";
node.source = node.arguments[0];
delete node.arguments;
delete node.callee;
}
return node;
}
toReferencedArguments(node) {
if (node.type === "ImportExpression") {
return;
}
super.toReferencedArguments(node);
}
parseExport(node) {
super.parseExport(node);
switch (node.type) {
case "ExportAllDeclaration":
node.exported = null;
break;
case "ExportNamedDeclaration":
if (node.specifiers.length === 1 && node.specifiers[0].type === "ExportNamespaceSpecifier") {
node.type = "ExportAllDeclaration";
node.exported = node.specifiers[0].exported;
delete node.specifiers;
}
break;
}
return node;
}
parseSubscript(base, startPos, startLoc, noCalls, state) {
const node = super.parseSubscript(base, startPos, startLoc, noCalls, state);
if (state.optionalChainMember) {
if (node.type === "OptionalMemberExpression" || node.type === "OptionalCallExpression") {
node.type = node.type.substring(8);
}
if (state.stop) {
const chain = this.startNodeAtNode(node);
chain.expression = node;
return this.finishNode(chain, "ChainExpression");
}
} else if (node.type === "MemberExpression" || node.type === "CallExpression") {
node.optional = false;
}
return node;
}
};
exports.default = _default;

File diff suppressed because it is too large Load Diff

View File

@@ -1,526 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _xhtml = _interopRequireDefault(require("./xhtml"));
var _types = require("../../tokenizer/types");
var _context = require("../../tokenizer/context");
var N = _interopRequireWildcard(require("../../types"));
var _identifier = require("../../util/identifier");
var _whitespace = require("../../util/whitespace");
var _error = require("../../parser/error");
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const HEX_NUMBER = /^[\da-fA-F]+$/;
const DECIMAL_NUMBER = /^\d+$/;
const JsxErrors = Object.freeze({
AttributeIsEmpty: "JSX attributes must only be assigned a non-empty expression",
MissingClosingTagFragment: "Expected corresponding JSX closing tag for <>",
MissingClosingTagElement: "Expected corresponding JSX closing tag for <%0>",
UnsupportedJsxValue: "JSX value should be either an expression or a quoted JSX text",
UnterminatedJsxContent: "Unterminated JSX contents",
UnwrappedAdjacentJSXElements: "Adjacent JSX elements must be wrapped in an enclosing tag. Did you want a JSX fragment <>...</>?"
});
_context.types.j_oTag = new _context.TokContext("<tag", false);
_context.types.j_cTag = new _context.TokContext("</tag", false);
_context.types.j_expr = new _context.TokContext("<tag>...</tag>", true, true);
_types.types.jsxName = new _types.TokenType("jsxName");
_types.types.jsxText = new _types.TokenType("jsxText", {
beforeExpr: true
});
_types.types.jsxTagStart = new _types.TokenType("jsxTagStart", {
startsExpr: true
});
_types.types.jsxTagEnd = new _types.TokenType("jsxTagEnd");
_types.types.jsxTagStart.updateContext = function () {
this.state.context.push(_context.types.j_expr);
this.state.context.push(_context.types.j_oTag);
this.state.exprAllowed = false;
};
_types.types.jsxTagEnd.updateContext = function (prevType) {
const out = this.state.context.pop();
if (out === _context.types.j_oTag && prevType === _types.types.slash || out === _context.types.j_cTag) {
this.state.context.pop();
this.state.exprAllowed = this.curContext() === _context.types.j_expr;
} else {
this.state.exprAllowed = true;
}
};
function isFragment(object) {
return object ? object.type === "JSXOpeningFragment" || object.type === "JSXClosingFragment" : false;
}
function getQualifiedJSXName(object) {
if (object.type === "JSXIdentifier") {
return object.name;
}
if (object.type === "JSXNamespacedName") {
return object.namespace.name + ":" + object.name.name;
}
if (object.type === "JSXMemberExpression") {
return getQualifiedJSXName(object.object) + "." + getQualifiedJSXName(object.property);
}
throw new Error("Node had unexpected type: " + object.type);
}
var _default = superClass => class extends superClass {
jsxReadToken() {
let out = "";
let chunkStart = this.state.pos;
for (;;) {
if (this.state.pos >= this.length) {
throw this.raise(this.state.start, JsxErrors.UnterminatedJsxContent);
}
const ch = this.input.charCodeAt(this.state.pos);
switch (ch) {
case 60:
case 123:
if (this.state.pos === this.state.start) {
if (ch === 60 && this.state.exprAllowed) {
++this.state.pos;
return this.finishToken(_types.types.jsxTagStart);
}
return super.getTokenFromCode(ch);
}
out += this.input.slice(chunkStart, this.state.pos);
return this.finishToken(_types.types.jsxText, out);
case 38:
out += this.input.slice(chunkStart, this.state.pos);
out += this.jsxReadEntity();
chunkStart = this.state.pos;
break;
default:
if ((0, _whitespace.isNewLine)(ch)) {
out += this.input.slice(chunkStart, this.state.pos);
out += this.jsxReadNewLine(true);
chunkStart = this.state.pos;
} else {
++this.state.pos;
}
}
}
}
jsxReadNewLine(normalizeCRLF) {
const ch = this.input.charCodeAt(this.state.pos);
let out;
++this.state.pos;
if (ch === 13 && this.input.charCodeAt(this.state.pos) === 10) {
++this.state.pos;
out = normalizeCRLF ? "\n" : "\r\n";
} else {
out = String.fromCharCode(ch);
}
++this.state.curLine;
this.state.lineStart = this.state.pos;
return out;
}
jsxReadString(quote) {
let out = "";
let chunkStart = ++this.state.pos;
for (;;) {
if (this.state.pos >= this.length) {
throw this.raise(this.state.start, _error.Errors.UnterminatedString);
}
const ch = this.input.charCodeAt(this.state.pos);
if (ch === quote) break;
if (ch === 38) {
out += this.input.slice(chunkStart, this.state.pos);
out += this.jsxReadEntity();
chunkStart = this.state.pos;
} else if ((0, _whitespace.isNewLine)(ch)) {
out += this.input.slice(chunkStart, this.state.pos);
out += this.jsxReadNewLine(false);
chunkStart = this.state.pos;
} else {
++this.state.pos;
}
}
out += this.input.slice(chunkStart, this.state.pos++);
return this.finishToken(_types.types.string, out);
}
jsxReadEntity() {
let str = "";
let count = 0;
let entity;
let ch = this.input[this.state.pos];
const startPos = ++this.state.pos;
while (this.state.pos < this.length && count++ < 10) {
ch = this.input[this.state.pos++];
if (ch === ";") {
if (str[0] === "#") {
if (str[1] === "x") {
str = str.substr(2);
if (HEX_NUMBER.test(str)) {
entity = String.fromCodePoint(parseInt(str, 16));
}
} else {
str = str.substr(1);
if (DECIMAL_NUMBER.test(str)) {
entity = String.fromCodePoint(parseInt(str, 10));
}
}
} else {
entity = _xhtml.default[str];
}
break;
}
str += ch;
}
if (!entity) {
this.state.pos = startPos;
return "&";
}
return entity;
}
jsxReadWord() {
let ch;
const start = this.state.pos;
do {
ch = this.input.charCodeAt(++this.state.pos);
} while ((0, _identifier.isIdentifierChar)(ch) || ch === 45);
return this.finishToken(_types.types.jsxName, this.input.slice(start, this.state.pos));
}
jsxParseIdentifier() {
const node = this.startNode();
if (this.match(_types.types.jsxName)) {
node.name = this.state.value;
} else if (this.state.type.keyword) {
node.name = this.state.type.keyword;
} else {
this.unexpected();
}
this.next();
return this.finishNode(node, "JSXIdentifier");
}
jsxParseNamespacedName() {
const startPos = this.state.start;
const startLoc = this.state.startLoc;
const name = this.jsxParseIdentifier();
if (!this.eat(_types.types.colon)) return name;
const node = this.startNodeAt(startPos, startLoc);
node.namespace = name;
node.name = this.jsxParseIdentifier();
return this.finishNode(node, "JSXNamespacedName");
}
jsxParseElementName() {
const startPos = this.state.start;
const startLoc = this.state.startLoc;
let node = this.jsxParseNamespacedName();
if (node.type === "JSXNamespacedName") {
return node;
}
while (this.eat(_types.types.dot)) {
const newNode = this.startNodeAt(startPos, startLoc);
newNode.object = node;
newNode.property = this.jsxParseIdentifier();
node = this.finishNode(newNode, "JSXMemberExpression");
}
return node;
}
jsxParseAttributeValue() {
let node;
switch (this.state.type) {
case _types.types.braceL:
node = this.startNode();
this.next();
node = this.jsxParseExpressionContainer(node);
if (node.expression.type === "JSXEmptyExpression") {
this.raise(node.start, JsxErrors.AttributeIsEmpty);
}
return node;
case _types.types.jsxTagStart:
case _types.types.string:
return this.parseExprAtom();
default:
throw this.raise(this.state.start, JsxErrors.UnsupportedJsxValue);
}
}
jsxParseEmptyExpression() {
const node = this.startNodeAt(this.state.lastTokEnd, this.state.lastTokEndLoc);
return this.finishNodeAt(node, "JSXEmptyExpression", this.state.start, this.state.startLoc);
}
jsxParseSpreadChild(node) {
this.next();
node.expression = this.parseExpression();
this.expect(_types.types.braceR);
return this.finishNode(node, "JSXSpreadChild");
}
jsxParseExpressionContainer(node) {
if (this.match(_types.types.braceR)) {
node.expression = this.jsxParseEmptyExpression();
} else {
node.expression = this.parseExpression();
}
this.expect(_types.types.braceR);
return this.finishNode(node, "JSXExpressionContainer");
}
jsxParseAttribute() {
const node = this.startNode();
if (this.eat(_types.types.braceL)) {
this.expect(_types.types.ellipsis);
node.argument = this.parseMaybeAssignAllowIn();
this.expect(_types.types.braceR);
return this.finishNode(node, "JSXSpreadAttribute");
}
node.name = this.jsxParseNamespacedName();
node.value = this.eat(_types.types.eq) ? this.jsxParseAttributeValue() : null;
return this.finishNode(node, "JSXAttribute");
}
jsxParseOpeningElementAt(startPos, startLoc) {
const node = this.startNodeAt(startPos, startLoc);
if (this.match(_types.types.jsxTagEnd)) {
this.expect(_types.types.jsxTagEnd);
return this.finishNode(node, "JSXOpeningFragment");
}
node.name = this.jsxParseElementName();
return this.jsxParseOpeningElementAfterName(node);
}
jsxParseOpeningElementAfterName(node) {
const attributes = [];
while (!this.match(_types.types.slash) && !this.match(_types.types.jsxTagEnd)) {
attributes.push(this.jsxParseAttribute());
}
node.attributes = attributes;
node.selfClosing = this.eat(_types.types.slash);
this.expect(_types.types.jsxTagEnd);
return this.finishNode(node, "JSXOpeningElement");
}
jsxParseClosingElementAt(startPos, startLoc) {
const node = this.startNodeAt(startPos, startLoc);
if (this.match(_types.types.jsxTagEnd)) {
this.expect(_types.types.jsxTagEnd);
return this.finishNode(node, "JSXClosingFragment");
}
node.name = this.jsxParseElementName();
this.expect(_types.types.jsxTagEnd);
return this.finishNode(node, "JSXClosingElement");
}
jsxParseElementAt(startPos, startLoc) {
const node = this.startNodeAt(startPos, startLoc);
const children = [];
const openingElement = this.jsxParseOpeningElementAt(startPos, startLoc);
let closingElement = null;
if (!openingElement.selfClosing) {
contents: for (;;) {
switch (this.state.type) {
case _types.types.jsxTagStart:
startPos = this.state.start;
startLoc = this.state.startLoc;
this.next();
if (this.eat(_types.types.slash)) {
closingElement = this.jsxParseClosingElementAt(startPos, startLoc);
break contents;
}
children.push(this.jsxParseElementAt(startPos, startLoc));
break;
case _types.types.jsxText:
children.push(this.parseExprAtom());
break;
case _types.types.braceL:
{
const node = this.startNode();
this.next();
if (this.match(_types.types.ellipsis)) {
children.push(this.jsxParseSpreadChild(node));
} else {
children.push(this.jsxParseExpressionContainer(node));
}
break;
}
default:
throw this.unexpected();
}
}
if (isFragment(openingElement) && !isFragment(closingElement)) {
this.raise(closingElement.start, JsxErrors.MissingClosingTagFragment);
} else if (!isFragment(openingElement) && isFragment(closingElement)) {
this.raise(closingElement.start, JsxErrors.MissingClosingTagElement, getQualifiedJSXName(openingElement.name));
} else if (!isFragment(openingElement) && !isFragment(closingElement)) {
if (getQualifiedJSXName(closingElement.name) !== getQualifiedJSXName(openingElement.name)) {
this.raise(closingElement.start, JsxErrors.MissingClosingTagElement, getQualifiedJSXName(openingElement.name));
}
}
}
if (isFragment(openingElement)) {
node.openingFragment = openingElement;
node.closingFragment = closingElement;
} else {
node.openingElement = openingElement;
node.closingElement = closingElement;
}
node.children = children;
if (this.isRelational("<")) {
throw this.raise(this.state.start, JsxErrors.UnwrappedAdjacentJSXElements);
}
return isFragment(openingElement) ? this.finishNode(node, "JSXFragment") : this.finishNode(node, "JSXElement");
}
jsxParseElement() {
const startPos = this.state.start;
const startLoc = this.state.startLoc;
this.next();
return this.jsxParseElementAt(startPos, startLoc);
}
parseExprAtom(refExpressionErrors) {
if (this.match(_types.types.jsxText)) {
return this.parseLiteral(this.state.value, "JSXText");
} else if (this.match(_types.types.jsxTagStart)) {
return this.jsxParseElement();
} else if (this.isRelational("<") && this.input.charCodeAt(this.state.pos) !== 33) {
this.finishToken(_types.types.jsxTagStart);
return this.jsxParseElement();
} else {
return super.parseExprAtom(refExpressionErrors);
}
}
getTokenFromCode(code) {
if (this.state.inPropertyName) return super.getTokenFromCode(code);
const context = this.curContext();
if (context === _context.types.j_expr) {
return this.jsxReadToken();
}
if (context === _context.types.j_oTag || context === _context.types.j_cTag) {
if ((0, _identifier.isIdentifierStart)(code)) {
return this.jsxReadWord();
}
if (code === 62) {
++this.state.pos;
return this.finishToken(_types.types.jsxTagEnd);
}
if ((code === 34 || code === 39) && context === _context.types.j_oTag) {
return this.jsxReadString(code);
}
}
if (code === 60 && this.state.exprAllowed && this.input.charCodeAt(this.state.pos + 1) !== 33) {
++this.state.pos;
return this.finishToken(_types.types.jsxTagStart);
}
return super.getTokenFromCode(code);
}
updateContext(prevType) {
if (this.match(_types.types.braceL)) {
const curContext = this.curContext();
if (curContext === _context.types.j_oTag) {
this.state.context.push(_context.types.braceExpression);
} else if (curContext === _context.types.j_expr) {
this.state.context.push(_context.types.templateQuasi);
} else {
super.updateContext(prevType);
}
this.state.exprAllowed = true;
} else if (this.match(_types.types.slash) && prevType === _types.types.jsxTagStart) {
this.state.context.length -= 2;
this.state.context.push(_context.types.j_cTag);
this.state.exprAllowed = false;
} else {
return super.updateContext(prevType);
}
}
};
exports.default = _default;

View File

@@ -1,263 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
const entities = {
quot: "\u0022",
amp: "&",
apos: "\u0027",
lt: "<",
gt: ">",
nbsp: "\u00A0",
iexcl: "\u00A1",
cent: "\u00A2",
pound: "\u00A3",
curren: "\u00A4",
yen: "\u00A5",
brvbar: "\u00A6",
sect: "\u00A7",
uml: "\u00A8",
copy: "\u00A9",
ordf: "\u00AA",
laquo: "\u00AB",
not: "\u00AC",
shy: "\u00AD",
reg: "\u00AE",
macr: "\u00AF",
deg: "\u00B0",
plusmn: "\u00B1",
sup2: "\u00B2",
sup3: "\u00B3",
acute: "\u00B4",
micro: "\u00B5",
para: "\u00B6",
middot: "\u00B7",
cedil: "\u00B8",
sup1: "\u00B9",
ordm: "\u00BA",
raquo: "\u00BB",
frac14: "\u00BC",
frac12: "\u00BD",
frac34: "\u00BE",
iquest: "\u00BF",
Agrave: "\u00C0",
Aacute: "\u00C1",
Acirc: "\u00C2",
Atilde: "\u00C3",
Auml: "\u00C4",
Aring: "\u00C5",
AElig: "\u00C6",
Ccedil: "\u00C7",
Egrave: "\u00C8",
Eacute: "\u00C9",
Ecirc: "\u00CA",
Euml: "\u00CB",
Igrave: "\u00CC",
Iacute: "\u00CD",
Icirc: "\u00CE",
Iuml: "\u00CF",
ETH: "\u00D0",
Ntilde: "\u00D1",
Ograve: "\u00D2",
Oacute: "\u00D3",
Ocirc: "\u00D4",
Otilde: "\u00D5",
Ouml: "\u00D6",
times: "\u00D7",
Oslash: "\u00D8",
Ugrave: "\u00D9",
Uacute: "\u00DA",
Ucirc: "\u00DB",
Uuml: "\u00DC",
Yacute: "\u00DD",
THORN: "\u00DE",
szlig: "\u00DF",
agrave: "\u00E0",
aacute: "\u00E1",
acirc: "\u00E2",
atilde: "\u00E3",
auml: "\u00E4",
aring: "\u00E5",
aelig: "\u00E6",
ccedil: "\u00E7",
egrave: "\u00E8",
eacute: "\u00E9",
ecirc: "\u00EA",
euml: "\u00EB",
igrave: "\u00EC",
iacute: "\u00ED",
icirc: "\u00EE",
iuml: "\u00EF",
eth: "\u00F0",
ntilde: "\u00F1",
ograve: "\u00F2",
oacute: "\u00F3",
ocirc: "\u00F4",
otilde: "\u00F5",
ouml: "\u00F6",
divide: "\u00F7",
oslash: "\u00F8",
ugrave: "\u00F9",
uacute: "\u00FA",
ucirc: "\u00FB",
uuml: "\u00FC",
yacute: "\u00FD",
thorn: "\u00FE",
yuml: "\u00FF",
OElig: "\u0152",
oelig: "\u0153",
Scaron: "\u0160",
scaron: "\u0161",
Yuml: "\u0178",
fnof: "\u0192",
circ: "\u02C6",
tilde: "\u02DC",
Alpha: "\u0391",
Beta: "\u0392",
Gamma: "\u0393",
Delta: "\u0394",
Epsilon: "\u0395",
Zeta: "\u0396",
Eta: "\u0397",
Theta: "\u0398",
Iota: "\u0399",
Kappa: "\u039A",
Lambda: "\u039B",
Mu: "\u039C",
Nu: "\u039D",
Xi: "\u039E",
Omicron: "\u039F",
Pi: "\u03A0",
Rho: "\u03A1",
Sigma: "\u03A3",
Tau: "\u03A4",
Upsilon: "\u03A5",
Phi: "\u03A6",
Chi: "\u03A7",
Psi: "\u03A8",
Omega: "\u03A9",
alpha: "\u03B1",
beta: "\u03B2",
gamma: "\u03B3",
delta: "\u03B4",
epsilon: "\u03B5",
zeta: "\u03B6",
eta: "\u03B7",
theta: "\u03B8",
iota: "\u03B9",
kappa: "\u03BA",
lambda: "\u03BB",
mu: "\u03BC",
nu: "\u03BD",
xi: "\u03BE",
omicron: "\u03BF",
pi: "\u03C0",
rho: "\u03C1",
sigmaf: "\u03C2",
sigma: "\u03C3",
tau: "\u03C4",
upsilon: "\u03C5",
phi: "\u03C6",
chi: "\u03C7",
psi: "\u03C8",
omega: "\u03C9",
thetasym: "\u03D1",
upsih: "\u03D2",
piv: "\u03D6",
ensp: "\u2002",
emsp: "\u2003",
thinsp: "\u2009",
zwnj: "\u200C",
zwj: "\u200D",
lrm: "\u200E",
rlm: "\u200F",
ndash: "\u2013",
mdash: "\u2014",
lsquo: "\u2018",
rsquo: "\u2019",
sbquo: "\u201A",
ldquo: "\u201C",
rdquo: "\u201D",
bdquo: "\u201E",
dagger: "\u2020",
Dagger: "\u2021",
bull: "\u2022",
hellip: "\u2026",
permil: "\u2030",
prime: "\u2032",
Prime: "\u2033",
lsaquo: "\u2039",
rsaquo: "\u203A",
oline: "\u203E",
frasl: "\u2044",
euro: "\u20AC",
image: "\u2111",
weierp: "\u2118",
real: "\u211C",
trade: "\u2122",
alefsym: "\u2135",
larr: "\u2190",
uarr: "\u2191",
rarr: "\u2192",
darr: "\u2193",
harr: "\u2194",
crarr: "\u21B5",
lArr: "\u21D0",
uArr: "\u21D1",
rArr: "\u21D2",
dArr: "\u21D3",
hArr: "\u21D4",
forall: "\u2200",
part: "\u2202",
exist: "\u2203",
empty: "\u2205",
nabla: "\u2207",
isin: "\u2208",
notin: "\u2209",
ni: "\u220B",
prod: "\u220F",
sum: "\u2211",
minus: "\u2212",
lowast: "\u2217",
radic: "\u221A",
prop: "\u221D",
infin: "\u221E",
ang: "\u2220",
and: "\u2227",
or: "\u2228",
cap: "\u2229",
cup: "\u222A",
int: "\u222B",
there4: "\u2234",
sim: "\u223C",
cong: "\u2245",
asymp: "\u2248",
ne: "\u2260",
equiv: "\u2261",
le: "\u2264",
ge: "\u2265",
sub: "\u2282",
sup: "\u2283",
nsub: "\u2284",
sube: "\u2286",
supe: "\u2287",
oplus: "\u2295",
otimes: "\u2297",
perp: "\u22A5",
sdot: "\u22C5",
lceil: "\u2308",
rceil: "\u2309",
lfloor: "\u230A",
rfloor: "\u230B",
lang: "\u2329",
rang: "\u232A",
loz: "\u25CA",
spades: "\u2660",
clubs: "\u2663",
hearts: "\u2665",
diams: "\u2666"
};
var _default = entities;
exports.default = _default;

View File

@@ -1,219 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _types = require("../tokenizer/types");
var N = _interopRequireWildcard(require("../types"));
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
_types.types.placeholder = new _types.TokenType("%%", {
startsExpr: true
});
var _default = superClass => class extends superClass {
parsePlaceholder(expectedNode) {
if (this.match(_types.types.placeholder)) {
const node = this.startNode();
this.next();
this.assertNoSpace("Unexpected space in placeholder.");
node.name = super.parseIdentifier(true);
this.assertNoSpace("Unexpected space in placeholder.");
this.expect(_types.types.placeholder);
return this.finishPlaceholder(node, expectedNode);
}
}
finishPlaceholder(node, expectedNode) {
const isFinished = !!(node.expectedNode && node.type === "Placeholder");
node.expectedNode = expectedNode;
return isFinished ? node : this.finishNode(node, "Placeholder");
}
getTokenFromCode(code) {
if (code === 37 && this.input.charCodeAt(this.state.pos + 1) === 37) {
return this.finishOp(_types.types.placeholder, 2);
}
return super.getTokenFromCode(...arguments);
}
parseExprAtom() {
return this.parsePlaceholder("Expression") || super.parseExprAtom(...arguments);
}
parseIdentifier() {
return this.parsePlaceholder("Identifier") || super.parseIdentifier(...arguments);
}
checkReservedWord(word) {
if (word !== undefined) super.checkReservedWord(...arguments);
}
parseBindingAtom() {
return this.parsePlaceholder("Pattern") || super.parseBindingAtom(...arguments);
}
checkLVal(expr) {
if (expr.type !== "Placeholder") super.checkLVal(...arguments);
}
toAssignable(node) {
if (node && node.type === "Placeholder" && node.expectedNode === "Expression") {
node.expectedNode = "Pattern";
return node;
}
return super.toAssignable(...arguments);
}
verifyBreakContinue(node) {
if (node.label && node.label.type === "Placeholder") return;
super.verifyBreakContinue(...arguments);
}
parseExpressionStatement(node, expr) {
if (expr.type !== "Placeholder" || expr.extra && expr.extra.parenthesized) {
return super.parseExpressionStatement(...arguments);
}
if (this.match(_types.types.colon)) {
const stmt = node;
stmt.label = this.finishPlaceholder(expr, "Identifier");
this.next();
stmt.body = this.parseStatement("label");
return this.finishNode(stmt, "LabeledStatement");
}
this.semicolon();
node.name = expr.name;
return this.finishPlaceholder(node, "Statement");
}
parseBlock() {
return this.parsePlaceholder("BlockStatement") || super.parseBlock(...arguments);
}
parseFunctionId() {
return this.parsePlaceholder("Identifier") || super.parseFunctionId(...arguments);
}
parseClass(node, isStatement, optionalId) {
const type = isStatement ? "ClassDeclaration" : "ClassExpression";
this.next();
this.takeDecorators(node);
const oldStrict = this.state.strict;
const placeholder = this.parsePlaceholder("Identifier");
if (placeholder) {
if (this.match(_types.types._extends) || this.match(_types.types.placeholder) || this.match(_types.types.braceL)) {
node.id = placeholder;
} else if (optionalId || !isStatement) {
node.id = null;
node.body = this.finishPlaceholder(placeholder, "ClassBody");
return this.finishNode(node, type);
} else {
this.unexpected(null, "A class name is required");
}
} else {
this.parseClassId(node, isStatement, optionalId);
}
this.parseClassSuper(node);
node.body = this.parsePlaceholder("ClassBody") || this.parseClassBody(!!node.superClass, oldStrict);
return this.finishNode(node, type);
}
parseExport(node) {
const placeholder = this.parsePlaceholder("Identifier");
if (!placeholder) return super.parseExport(...arguments);
if (!this.isContextual("from") && !this.match(_types.types.comma)) {
node.specifiers = [];
node.source = null;
node.declaration = this.finishPlaceholder(placeholder, "Declaration");
return this.finishNode(node, "ExportNamedDeclaration");
}
this.expectPlugin("exportDefaultFrom");
const specifier = this.startNode();
specifier.exported = placeholder;
node.specifiers = [this.finishNode(specifier, "ExportDefaultSpecifier")];
return super.parseExport(node);
}
isExportDefaultSpecifier() {
if (this.match(_types.types._default)) {
const next = this.nextTokenStart();
if (this.isUnparsedContextual(next, "from")) {
if (this.input.startsWith(_types.types.placeholder.label, this.nextTokenStartSince(next + 4))) {
return true;
}
}
}
return super.isExportDefaultSpecifier();
}
maybeParseExportDefaultSpecifier(node) {
if (node.specifiers && node.specifiers.length > 0) {
return true;
}
return super.maybeParseExportDefaultSpecifier(...arguments);
}
checkExport(node) {
const {
specifiers
} = node;
if (specifiers?.length) {
node.specifiers = specifiers.filter(node => node.exported.type === "Placeholder");
}
super.checkExport(node);
node.specifiers = specifiers;
}
parseImport(node) {
const placeholder = this.parsePlaceholder("Identifier");
if (!placeholder) return super.parseImport(...arguments);
node.specifiers = [];
if (!this.isContextual("from") && !this.match(_types.types.comma)) {
node.source = this.finishPlaceholder(placeholder, "StringLiteral");
this.semicolon();
return this.finishNode(node, "ImportDeclaration");
}
const specifier = this.startNodeAtNode(placeholder);
specifier.local = placeholder;
this.finishNode(specifier, "ImportDefaultSpecifier");
node.specifiers.push(specifier);
if (this.eat(_types.types.comma)) {
const hasStarImport = this.maybeParseStarImportSpecifier(node);
if (!hasStarImport) this.parseNamedImportSpecifiers(node);
}
this.expectContextual("from");
node.source = this.parseImportSource();
this.semicolon();
return this.finishNode(node, "ImportDeclaration");
}
parseImportSource() {
return this.parsePlaceholder("StringLiteral") || super.parseImportSource(...arguments);
}
};
exports.default = _default;

File diff suppressed because it is too large Load Diff

View File

@@ -1,94 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _scope = _interopRequireWildcard(require("../../util/scope"));
var _scopeflags = require("../../util/scopeflags");
var N = _interopRequireWildcard(require("../../types"));
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
class TypeScriptScope extends _scope.Scope {
constructor(...args) {
super(...args);
this.types = [];
this.enums = [];
this.constEnums = [];
this.classes = [];
this.exportOnlyBindings = [];
}
}
class TypeScriptScopeHandler extends _scope.default {
createScope(flags) {
return new TypeScriptScope(flags);
}
declareName(name, bindingType, pos) {
const scope = this.currentScope();
if (bindingType & _scopeflags.BIND_FLAGS_TS_EXPORT_ONLY) {
this.maybeExportDefined(scope, name);
scope.exportOnlyBindings.push(name);
return;
}
super.declareName(...arguments);
if (bindingType & _scopeflags.BIND_KIND_TYPE) {
if (!(bindingType & _scopeflags.BIND_KIND_VALUE)) {
this.checkRedeclarationInScope(scope, name, bindingType, pos);
this.maybeExportDefined(scope, name);
}
scope.types.push(name);
}
if (bindingType & _scopeflags.BIND_FLAGS_TS_ENUM) scope.enums.push(name);
if (bindingType & _scopeflags.BIND_FLAGS_TS_CONST_ENUM) scope.constEnums.push(name);
if (bindingType & _scopeflags.BIND_FLAGS_CLASS) scope.classes.push(name);
}
isRedeclaredInScope(scope, name, bindingType) {
if (scope.enums.indexOf(name) > -1) {
if (bindingType & _scopeflags.BIND_FLAGS_TS_ENUM) {
const isConst = !!(bindingType & _scopeflags.BIND_FLAGS_TS_CONST_ENUM);
const wasConst = scope.constEnums.indexOf(name) > -1;
return isConst !== wasConst;
}
return true;
}
if (bindingType & _scopeflags.BIND_FLAGS_CLASS && scope.classes.indexOf(name) > -1) {
if (scope.lexical.indexOf(name) > -1) {
return !!(bindingType & _scopeflags.BIND_KIND_VALUE);
} else {
return false;
}
}
if (bindingType & _scopeflags.BIND_KIND_TYPE && scope.types.indexOf(name) > -1) {
return true;
}
return super.isRedeclaredInScope(...arguments);
}
checkLocalExport(id) {
if (this.scopeStack[0].types.indexOf(id.name) === -1 && this.scopeStack[0].exportOnlyBindings.indexOf(id.name) === -1) {
super.checkLocalExport(id);
}
}
}
exports.default = TypeScriptScopeHandler;

View File

@@ -1,43 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _types = require("../tokenizer/types");
var N = _interopRequireWildcard(require("../types"));
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
var _default = superClass => class extends superClass {
parseV8Intrinsic() {
if (this.match(_types.types.modulo)) {
const v8IntrinsicStart = this.state.start;
const node = this.startNode();
this.eat(_types.types.modulo);
if (this.match(_types.types.name)) {
const name = this.parseIdentifierName(this.state.start);
const identifier = this.createIdentifier(node, name);
identifier.type = "V8IntrinsicIdentifier";
if (this.match(_types.types.parenL)) {
return identifier;
}
}
this.unexpected(v8IntrinsicStart);
}
}
parseExprAtom() {
return this.parseV8Intrinsic() || super.parseExprAtom(...arguments);
}
};
exports.default = _default;

View File

@@ -1,110 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.types = exports.TokContext = void 0;
var _types = require("./types");
class TokContext {
constructor(token, isExpr, preserveSpace, override) {
this.token = void 0;
this.isExpr = void 0;
this.preserveSpace = void 0;
this.override = void 0;
this.token = token;
this.isExpr = !!isExpr;
this.preserveSpace = !!preserveSpace;
this.override = override;
}
}
exports.TokContext = TokContext;
const types = {
braceStatement: new TokContext("{", false),
braceExpression: new TokContext("{", true),
recordExpression: new TokContext("#{", true),
templateQuasi: new TokContext("${", false),
parenStatement: new TokContext("(", false),
parenExpression: new TokContext("(", true),
template: new TokContext("`", true, true, p => p.readTmplToken()),
functionExpression: new TokContext("function", true),
functionStatement: new TokContext("function", false)
};
exports.types = types;
_types.types.parenR.updateContext = _types.types.braceR.updateContext = function () {
if (this.state.context.length === 1) {
this.state.exprAllowed = true;
return;
}
let out = this.state.context.pop();
if (out === types.braceStatement && this.curContext().token === "function") {
out = this.state.context.pop();
}
this.state.exprAllowed = !out.isExpr;
};
_types.types.name.updateContext = function (prevType) {
let allowed = false;
if (prevType !== _types.types.dot) {
if (this.state.value === "of" && !this.state.exprAllowed && prevType !== _types.types._function && prevType !== _types.types._class) {
allowed = true;
}
}
this.state.exprAllowed = allowed;
if (this.state.isIterator) {
this.state.isIterator = false;
}
};
_types.types.braceL.updateContext = function (prevType) {
this.state.context.push(this.braceIsBlock(prevType) ? types.braceStatement : types.braceExpression);
this.state.exprAllowed = true;
};
_types.types.dollarBraceL.updateContext = function () {
this.state.context.push(types.templateQuasi);
this.state.exprAllowed = true;
};
_types.types.parenL.updateContext = function (prevType) {
const statementParens = prevType === _types.types._if || prevType === _types.types._for || prevType === _types.types._with || prevType === _types.types._while;
this.state.context.push(statementParens ? types.parenStatement : types.parenExpression);
this.state.exprAllowed = true;
};
_types.types.incDec.updateContext = function () {};
_types.types._function.updateContext = _types.types._class.updateContext = function (prevType) {
if (prevType.beforeExpr && prevType !== _types.types.semi && prevType !== _types.types._else && !(prevType === _types.types._return && this.hasPrecedingLineBreak()) && !((prevType === _types.types.colon || prevType === _types.types.braceL) && this.curContext() === types.b_stat)) {
this.state.context.push(types.functionExpression);
} else {
this.state.context.push(types.functionStatement);
}
this.state.exprAllowed = false;
};
_types.types.backQuote.updateContext = function () {
if (this.curContext() === types.template) {
this.state.context.pop();
} else {
this.state.context.push(types.template);
}
this.state.exprAllowed = false;
};
_types.types.braceHashL.updateContext = function () {
this.state.context.push(types.recordExpression);
this.state.exprAllowed = true;
};

File diff suppressed because it is too large Load Diff

View File

@@ -1,99 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var N = _interopRequireWildcard(require("../types"));
var _location = require("../util/location");
var _context = require("./context");
var _types2 = require("./types");
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
class State {
constructor() {
this.strict = void 0;
this.curLine = void 0;
this.startLoc = void 0;
this.endLoc = void 0;
this.errors = [];
this.potentialArrowAt = -1;
this.noArrowAt = [];
this.noArrowParamsConversionAt = [];
this.maybeInArrowParameters = false;
this.inPipeline = false;
this.inType = false;
this.noAnonFunctionType = false;
this.inPropertyName = false;
this.hasFlowComment = false;
this.isIterator = false;
this.isDeclareContext = false;
this.topicContext = {
maxNumOfResolvableTopics: 0,
maxTopicIndex: null
};
this.soloAwait = false;
this.inFSharpPipelineDirectBody = false;
this.labels = [];
this.decoratorStack = [[]];
this.comments = [];
this.trailingComments = [];
this.leadingComments = [];
this.commentStack = [];
this.commentPreviousNode = null;
this.pos = 0;
this.lineStart = 0;
this.type = _types2.types.eof;
this.value = null;
this.start = 0;
this.end = 0;
this.lastTokEndLoc = null;
this.lastTokStartLoc = null;
this.lastTokStart = 0;
this.lastTokEnd = 0;
this.context = [_context.types.braceStatement];
this.exprAllowed = true;
this.containsEsc = false;
this.octalPositions = [];
this.exportedIdentifiers = [];
this.tokensLength = 0;
}
init(options) {
this.strict = options.strictMode === false ? false : options.sourceType === "module";
this.curLine = options.startLine;
this.startLoc = this.endLoc = this.curPosition();
}
curPosition() {
return new _location.Position(this.curLine, this.pos - this.lineStart);
}
clone(skipArrays) {
const state = new State();
const keys = Object.keys(this);
for (let i = 0, length = keys.length; i < length; i++) {
const key = keys[i];
let val = this[key];
if (!skipArrays && Array.isArray(val)) {
val = val.slice();
}
state[key] = val;
}
return state;
}
}
exports.default = State;

View File

@@ -1,296 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.types = exports.keywords = exports.TokenType = void 0;
const beforeExpr = true;
const startsExpr = true;
const isLoop = true;
const isAssign = true;
const prefix = true;
const postfix = true;
class TokenType {
constructor(label, conf = {}) {
this.label = void 0;
this.keyword = void 0;
this.beforeExpr = void 0;
this.startsExpr = void 0;
this.rightAssociative = void 0;
this.isLoop = void 0;
this.isAssign = void 0;
this.prefix = void 0;
this.postfix = void 0;
this.binop = void 0;
this.updateContext = void 0;
this.label = label;
this.keyword = conf.keyword;
this.beforeExpr = !!conf.beforeExpr;
this.startsExpr = !!conf.startsExpr;
this.rightAssociative = !!conf.rightAssociative;
this.isLoop = !!conf.isLoop;
this.isAssign = !!conf.isAssign;
this.prefix = !!conf.prefix;
this.postfix = !!conf.postfix;
this.binop = conf.binop != null ? conf.binop : null;
this.updateContext = null;
}
}
exports.TokenType = TokenType;
const keywords = new Map();
exports.keywords = keywords;
function createKeyword(name, options = {}) {
options.keyword = name;
const token = new TokenType(name, options);
keywords.set(name, token);
return token;
}
function createBinop(name, binop) {
return new TokenType(name, {
beforeExpr,
binop
});
}
const types = {
num: new TokenType("num", {
startsExpr
}),
bigint: new TokenType("bigint", {
startsExpr
}),
decimal: new TokenType("decimal", {
startsExpr
}),
regexp: new TokenType("regexp", {
startsExpr
}),
string: new TokenType("string", {
startsExpr
}),
name: new TokenType("name", {
startsExpr
}),
eof: new TokenType("eof"),
bracketL: new TokenType("[", {
beforeExpr,
startsExpr
}),
bracketHashL: new TokenType("#[", {
beforeExpr,
startsExpr
}),
bracketBarL: new TokenType("[|", {
beforeExpr,
startsExpr
}),
bracketR: new TokenType("]"),
bracketBarR: new TokenType("|]"),
braceL: new TokenType("{", {
beforeExpr,
startsExpr
}),
braceBarL: new TokenType("{|", {
beforeExpr,
startsExpr
}),
braceHashL: new TokenType("#{", {
beforeExpr,
startsExpr
}),
braceR: new TokenType("}"),
braceBarR: new TokenType("|}"),
parenL: new TokenType("(", {
beforeExpr,
startsExpr
}),
parenR: new TokenType(")"),
comma: new TokenType(",", {
beforeExpr
}),
semi: new TokenType(";", {
beforeExpr
}),
colon: new TokenType(":", {
beforeExpr
}),
doubleColon: new TokenType("::", {
beforeExpr
}),
dot: new TokenType("."),
question: new TokenType("?", {
beforeExpr
}),
questionDot: new TokenType("?."),
arrow: new TokenType("=>", {
beforeExpr
}),
template: new TokenType("template"),
ellipsis: new TokenType("...", {
beforeExpr
}),
backQuote: new TokenType("`", {
startsExpr
}),
dollarBraceL: new TokenType("${", {
beforeExpr,
startsExpr
}),
at: new TokenType("@"),
hash: new TokenType("#", {
startsExpr
}),
interpreterDirective: new TokenType("#!..."),
eq: new TokenType("=", {
beforeExpr,
isAssign
}),
assign: new TokenType("_=", {
beforeExpr,
isAssign
}),
incDec: new TokenType("++/--", {
prefix,
postfix,
startsExpr
}),
bang: new TokenType("!", {
beforeExpr,
prefix,
startsExpr
}),
tilde: new TokenType("~", {
beforeExpr,
prefix,
startsExpr
}),
pipeline: createBinop("|>", 0),
nullishCoalescing: createBinop("??", 1),
logicalOR: createBinop("||", 1),
logicalAND: createBinop("&&", 2),
bitwiseOR: createBinop("|", 3),
bitwiseXOR: createBinop("^", 4),
bitwiseAND: createBinop("&", 5),
equality: createBinop("==/!=/===/!==", 6),
relational: createBinop("</>/<=/>=", 7),
bitShift: createBinop("<</>>/>>>", 8),
plusMin: new TokenType("+/-", {
beforeExpr,
binop: 9,
prefix,
startsExpr
}),
modulo: new TokenType("%", {
beforeExpr,
binop: 10,
startsExpr
}),
star: new TokenType("*", {
binop: 10
}),
slash: createBinop("/", 10),
exponent: new TokenType("**", {
beforeExpr,
binop: 11,
rightAssociative: true
}),
_break: createKeyword("break"),
_case: createKeyword("case", {
beforeExpr
}),
_catch: createKeyword("catch"),
_continue: createKeyword("continue"),
_debugger: createKeyword("debugger"),
_default: createKeyword("default", {
beforeExpr
}),
_do: createKeyword("do", {
isLoop,
beforeExpr
}),
_else: createKeyword("else", {
beforeExpr
}),
_finally: createKeyword("finally"),
_for: createKeyword("for", {
isLoop
}),
_function: createKeyword("function", {
startsExpr
}),
_if: createKeyword("if"),
_return: createKeyword("return", {
beforeExpr
}),
_switch: createKeyword("switch"),
_throw: createKeyword("throw", {
beforeExpr,
prefix,
startsExpr
}),
_try: createKeyword("try"),
_var: createKeyword("var"),
_const: createKeyword("const"),
_while: createKeyword("while", {
isLoop
}),
_with: createKeyword("with"),
_new: createKeyword("new", {
beforeExpr,
startsExpr
}),
_this: createKeyword("this", {
startsExpr
}),
_super: createKeyword("super", {
startsExpr
}),
_class: createKeyword("class", {
startsExpr
}),
_extends: createKeyword("extends", {
beforeExpr
}),
_export: createKeyword("export"),
_import: createKeyword("import", {
startsExpr
}),
_null: createKeyword("null", {
startsExpr
}),
_true: createKeyword("true", {
startsExpr
}),
_false: createKeyword("false", {
startsExpr
}),
_in: createKeyword("in", {
beforeExpr,
binop: 7
}),
_instanceof: createKeyword("instanceof", {
beforeExpr,
binop: 7
}),
_typeof: createKeyword("typeof", {
beforeExpr,
prefix,
startsExpr
}),
_void: createKeyword("void", {
beforeExpr,
prefix,
startsExpr
}),
_delete: createKeyword("delete", {
beforeExpr,
prefix,
startsExpr
})
};
exports.types = types;

View File

View File

@@ -1,99 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = exports.ClassScope = void 0;
var _scopeflags = require("./scopeflags");
var _error = require("../parser/error");
class ClassScope {
constructor() {
this.privateNames = new Set();
this.loneAccessors = new Map();
this.undefinedPrivateNames = new Map();
}
}
exports.ClassScope = ClassScope;
class ClassScopeHandler {
constructor(raise) {
this.stack = [];
this.undefinedPrivateNames = new Map();
this.raise = raise;
}
current() {
return this.stack[this.stack.length - 1];
}
enter() {
this.stack.push(new ClassScope());
}
exit() {
const oldClassScope = this.stack.pop();
const current = this.current();
for (let _i = 0, _Array$from = Array.from(oldClassScope.undefinedPrivateNames); _i < _Array$from.length; _i++) {
const [name, pos] = _Array$from[_i];
if (current) {
if (!current.undefinedPrivateNames.has(name)) {
current.undefinedPrivateNames.set(name, pos);
}
} else {
this.raise(pos, _error.Errors.InvalidPrivateFieldResolution, name);
}
}
}
declarePrivateName(name, elementType, pos) {
const classScope = this.current();
let redefined = classScope.privateNames.has(name);
if (elementType & _scopeflags.CLASS_ELEMENT_KIND_ACCESSOR) {
const accessor = redefined && classScope.loneAccessors.get(name);
if (accessor) {
const oldStatic = accessor & _scopeflags.CLASS_ELEMENT_FLAG_STATIC;
const newStatic = elementType & _scopeflags.CLASS_ELEMENT_FLAG_STATIC;
const oldKind = accessor & _scopeflags.CLASS_ELEMENT_KIND_ACCESSOR;
const newKind = elementType & _scopeflags.CLASS_ELEMENT_KIND_ACCESSOR;
redefined = oldKind === newKind || oldStatic !== newStatic;
if (!redefined) classScope.loneAccessors.delete(name);
} else if (!redefined) {
classScope.loneAccessors.set(name, elementType);
}
}
if (redefined) {
this.raise(pos, _error.Errors.PrivateNameRedeclaration, name);
}
classScope.privateNames.add(name);
classScope.undefinedPrivateNames.delete(name);
}
usePrivateName(name, pos) {
let classScope;
for (let _i2 = 0, _this$stack = this.stack; _i2 < _this$stack.length; _i2++) {
classScope = _this$stack[_i2];
if (classScope.privateNames.has(name)) return;
}
if (classScope) {
classScope.undefinedPrivateNames.set(name, pos);
} else {
this.raise(pos, _error.Errors.InvalidPrivateFieldResolution, name);
}
}
}
exports.default = ClassScopeHandler;

View File

@@ -1,138 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.newParameterDeclarationScope = newParameterDeclarationScope;
exports.newArrowHeadScope = newArrowHeadScope;
exports.newAsyncArrowScope = newAsyncArrowScope;
exports.newExpressionScope = newExpressionScope;
exports.default = void 0;
const kExpression = 0,
kMaybeArrowParameterDeclaration = 1,
kMaybeAsyncArrowParameterDeclaration = 2,
kParameterDeclaration = 3;
class ExpressionScope {
constructor(type = kExpression) {
this.type = void 0;
this.type = type;
}
canBeArrowParameterDeclaration() {
return this.type === kMaybeAsyncArrowParameterDeclaration || this.type === kMaybeArrowParameterDeclaration;
}
isCertainlyParameterDeclaration() {
return this.type === kParameterDeclaration;
}
}
class ArrowHeadParsingScope extends ExpressionScope {
constructor(type) {
super(type);
this.errors = new Map();
}
recordDeclarationError(pos, message) {
this.errors.set(pos, message);
}
clearDeclarationError(pos) {
this.errors.delete(pos);
}
iterateErrors(iterator) {
this.errors.forEach(iterator);
}
}
class ExpressionScopeHandler {
constructor(raise) {
this.stack = [new ExpressionScope()];
this.raise = raise;
}
enter(scope) {
this.stack.push(scope);
}
exit() {
this.stack.pop();
}
recordParameterInitializerError(pos, message) {
const {
stack
} = this;
let i = stack.length - 1;
let scope = stack[i];
while (!scope.isCertainlyParameterDeclaration()) {
if (scope.canBeArrowParameterDeclaration()) {
scope.recordDeclarationError(pos, message);
} else {
return;
}
scope = stack[--i];
}
this.raise(pos, message);
}
recordAsyncArrowParametersError(pos, message) {
const {
stack
} = this;
let i = stack.length - 1;
let scope = stack[i];
while (scope.canBeArrowParameterDeclaration()) {
if (scope.type === kMaybeAsyncArrowParameterDeclaration) {
scope.recordDeclarationError(pos, message);
}
scope = stack[--i];
}
}
validateAsPattern() {
const {
stack
} = this;
const currentScope = stack[stack.length - 1];
if (!currentScope.canBeArrowParameterDeclaration()) return;
currentScope.iterateErrors((message, pos) => {
this.raise(pos, message);
let i = stack.length - 2;
let scope = stack[i];
while (scope.canBeArrowParameterDeclaration()) {
scope.clearDeclarationError(pos);
scope = stack[--i];
}
});
}
}
exports.default = ExpressionScopeHandler;
function newParameterDeclarationScope() {
return new ExpressionScope(kParameterDeclaration);
}
function newArrowHeadScope() {
return new ArrowHeadParsingScope(kMaybeArrowParameterDeclaration);
}
function newAsyncArrowScope() {
return new ArrowHeadParsingScope(kMaybeAsyncArrowParameterDeclaration);
}
function newExpressionScope() {
return new ExpressionScope();
}

View File

@@ -1,58 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.isIteratorStart = isIteratorStart;
Object.defineProperty(exports, "isIdentifierStart", {
enumerable: true,
get: function () {
return _helperValidatorIdentifier.isIdentifierStart;
}
});
Object.defineProperty(exports, "isIdentifierChar", {
enumerable: true,
get: function () {
return _helperValidatorIdentifier.isIdentifierChar;
}
});
Object.defineProperty(exports, "isReservedWord", {
enumerable: true,
get: function () {
return _helperValidatorIdentifier.isReservedWord;
}
});
Object.defineProperty(exports, "isStrictBindOnlyReservedWord", {
enumerable: true,
get: function () {
return _helperValidatorIdentifier.isStrictBindOnlyReservedWord;
}
});
Object.defineProperty(exports, "isStrictBindReservedWord", {
enumerable: true,
get: function () {
return _helperValidatorIdentifier.isStrictBindReservedWord;
}
});
Object.defineProperty(exports, "isStrictReservedWord", {
enumerable: true,
get: function () {
return _helperValidatorIdentifier.isStrictReservedWord;
}
});
Object.defineProperty(exports, "isKeyword", {
enumerable: true,
get: function () {
return _helperValidatorIdentifier.isKeyword;
}
});
exports.keywordRelationalOperator = void 0;
var _helperValidatorIdentifier = require("@babel/helper-validator-identifier");
const keywordRelationalOperator = /^in(stanceof)?$/;
exports.keywordRelationalOperator = keywordRelationalOperator;
function isIteratorStart(current, next) {
return current === 64 && next === 64;
}

View File

@@ -1,49 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getLineInfo = getLineInfo;
exports.SourceLocation = exports.Position = void 0;
var _whitespace = require("./whitespace");
class Position {
constructor(line, col) {
this.line = void 0;
this.column = void 0;
this.line = line;
this.column = col;
}
}
exports.Position = Position;
class SourceLocation {
constructor(start, end) {
this.start = void 0;
this.end = void 0;
this.filename = void 0;
this.identifierName = void 0;
this.start = start;
this.end = end;
}
}
exports.SourceLocation = SourceLocation;
function getLineInfo(input, offset) {
let line = 1;
let lineStart = 0;
let match;
_whitespace.lineBreakG.lastIndex = 0;
while ((match = _whitespace.lineBreakG.exec(input)) && match.index < offset) {
line++;
lineStart = _whitespace.lineBreakG.lastIndex;
}
return new Position(line, offset - lineStart);
}

View File

@@ -1,58 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.functionFlags = functionFlags;
exports.default = exports.PARAM_IN = exports.PARAM_RETURN = exports.PARAM_AWAIT = exports.PARAM_YIELD = exports.PARAM = void 0;
const PARAM = 0b0000,
PARAM_YIELD = 0b0001,
PARAM_AWAIT = 0b0010,
PARAM_RETURN = 0b0100,
PARAM_IN = 0b1000;
exports.PARAM_IN = PARAM_IN;
exports.PARAM_RETURN = PARAM_RETURN;
exports.PARAM_AWAIT = PARAM_AWAIT;
exports.PARAM_YIELD = PARAM_YIELD;
exports.PARAM = PARAM;
class ProductionParameterHandler {
constructor() {
this.stacks = [];
}
enter(flags) {
this.stacks.push(flags);
}
exit() {
this.stacks.pop();
}
currentFlags() {
return this.stacks[this.stacks.length - 1];
}
get hasAwait() {
return (this.currentFlags() & PARAM_AWAIT) > 0;
}
get hasYield() {
return (this.currentFlags() & PARAM_YIELD) > 0;
}
get hasReturn() {
return (this.currentFlags() & PARAM_RETURN) > 0;
}
get hasIn() {
return (this.currentFlags() & PARAM_IN) > 0;
}
}
exports.default = ProductionParameterHandler;
function functionFlags(isAsync, isGenerator) {
return (isAsync ? PARAM_AWAIT : 0) | (isGenerator ? PARAM_YIELD : 0);
}

View File

@@ -1,168 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = exports.Scope = void 0;
var _scopeflags = require("./scopeflags");
var N = _interopRequireWildcard(require("../types"));
var _error = require("../parser/error");
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
class Scope {
constructor(flags) {
this.flags = void 0;
this.var = [];
this.lexical = [];
this.functions = [];
this.flags = flags;
}
}
exports.Scope = Scope;
class ScopeHandler {
constructor(raise, inModule) {
this.scopeStack = [];
this.undefinedExports = new Map();
this.undefinedPrivateNames = new Map();
this.raise = raise;
this.inModule = inModule;
}
get inFunction() {
return (this.currentVarScope().flags & _scopeflags.SCOPE_FUNCTION) > 0;
}
get allowSuper() {
return (this.currentThisScope().flags & _scopeflags.SCOPE_SUPER) > 0;
}
get allowDirectSuper() {
return (this.currentThisScope().flags & _scopeflags.SCOPE_DIRECT_SUPER) > 0;
}
get inClass() {
return (this.currentThisScope().flags & _scopeflags.SCOPE_CLASS) > 0;
}
get inNonArrowFunction() {
return (this.currentThisScope().flags & _scopeflags.SCOPE_FUNCTION) > 0;
}
get treatFunctionsAsVar() {
return this.treatFunctionsAsVarInScope(this.currentScope());
}
createScope(flags) {
return new Scope(flags);
}
enter(flags) {
this.scopeStack.push(this.createScope(flags));
}
exit() {
this.scopeStack.pop();
}
treatFunctionsAsVarInScope(scope) {
return !!(scope.flags & _scopeflags.SCOPE_FUNCTION || !this.inModule && scope.flags & _scopeflags.SCOPE_PROGRAM);
}
declareName(name, bindingType, pos) {
let scope = this.currentScope();
if (bindingType & _scopeflags.BIND_SCOPE_LEXICAL || bindingType & _scopeflags.BIND_SCOPE_FUNCTION) {
this.checkRedeclarationInScope(scope, name, bindingType, pos);
if (bindingType & _scopeflags.BIND_SCOPE_FUNCTION) {
scope.functions.push(name);
} else {
scope.lexical.push(name);
}
if (bindingType & _scopeflags.BIND_SCOPE_LEXICAL) {
this.maybeExportDefined(scope, name);
}
} else if (bindingType & _scopeflags.BIND_SCOPE_VAR) {
for (let i = this.scopeStack.length - 1; i >= 0; --i) {
scope = this.scopeStack[i];
this.checkRedeclarationInScope(scope, name, bindingType, pos);
scope.var.push(name);
this.maybeExportDefined(scope, name);
if (scope.flags & _scopeflags.SCOPE_VAR) break;
}
}
if (this.inModule && scope.flags & _scopeflags.SCOPE_PROGRAM) {
this.undefinedExports.delete(name);
}
}
maybeExportDefined(scope, name) {
if (this.inModule && scope.flags & _scopeflags.SCOPE_PROGRAM) {
this.undefinedExports.delete(name);
}
}
checkRedeclarationInScope(scope, name, bindingType, pos) {
if (this.isRedeclaredInScope(scope, name, bindingType)) {
this.raise(pos, _error.Errors.VarRedeclaration, name);
}
}
isRedeclaredInScope(scope, name, bindingType) {
if (!(bindingType & _scopeflags.BIND_KIND_VALUE)) return false;
if (bindingType & _scopeflags.BIND_SCOPE_LEXICAL) {
return scope.lexical.indexOf(name) > -1 || scope.functions.indexOf(name) > -1 || scope.var.indexOf(name) > -1;
}
if (bindingType & _scopeflags.BIND_SCOPE_FUNCTION) {
return scope.lexical.indexOf(name) > -1 || !this.treatFunctionsAsVarInScope(scope) && scope.var.indexOf(name) > -1;
}
return scope.lexical.indexOf(name) > -1 && !(scope.flags & _scopeflags.SCOPE_SIMPLE_CATCH && scope.lexical[0] === name) || !this.treatFunctionsAsVarInScope(scope) && scope.functions.indexOf(name) > -1;
}
checkLocalExport(id) {
if (this.scopeStack[0].lexical.indexOf(id.name) === -1 && this.scopeStack[0].var.indexOf(id.name) === -1 && this.scopeStack[0].functions.indexOf(id.name) === -1) {
this.undefinedExports.set(id.name, id.start);
}
}
currentScope() {
return this.scopeStack[this.scopeStack.length - 1];
}
currentVarScope() {
for (let i = this.scopeStack.length - 1;; i--) {
const scope = this.scopeStack[i];
if (scope.flags & _scopeflags.SCOPE_VAR) {
return scope;
}
}
}
currentThisScope() {
for (let i = this.scopeStack.length - 1;; i--) {
const scope = this.scopeStack[i];
if ((scope.flags & _scopeflags.SCOPE_VAR || scope.flags & _scopeflags.SCOPE_CLASS) && !(scope.flags & _scopeflags.SCOPE_ARROW)) {
return scope;
}
}
}
}
exports.default = ScopeHandler;

View File

@@ -1,90 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.CLASS_ELEMENT_OTHER = exports.CLASS_ELEMENT_INSTANCE_SETTER = exports.CLASS_ELEMENT_INSTANCE_GETTER = exports.CLASS_ELEMENT_STATIC_SETTER = exports.CLASS_ELEMENT_STATIC_GETTER = exports.CLASS_ELEMENT_KIND_ACCESSOR = exports.CLASS_ELEMENT_KIND_SETTER = exports.CLASS_ELEMENT_KIND_GETTER = exports.CLASS_ELEMENT_FLAG_STATIC = exports.BIND_TS_NAMESPACE = exports.BIND_TS_CONST_ENUM = exports.BIND_OUTSIDE = exports.BIND_NONE = exports.BIND_TS_AMBIENT = exports.BIND_TS_ENUM = exports.BIND_TS_TYPE = exports.BIND_TS_INTERFACE = exports.BIND_FUNCTION = exports.BIND_VAR = exports.BIND_LEXICAL = exports.BIND_CLASS = exports.BIND_FLAGS_TS_EXPORT_ONLY = exports.BIND_FLAGS_TS_CONST_ENUM = exports.BIND_FLAGS_TS_ENUM = exports.BIND_FLAGS_CLASS = exports.BIND_FLAGS_NONE = exports.BIND_SCOPE_OUTSIDE = exports.BIND_SCOPE_FUNCTION = exports.BIND_SCOPE_LEXICAL = exports.BIND_SCOPE_VAR = exports.BIND_KIND_TYPE = exports.BIND_KIND_VALUE = exports.SCOPE_VAR = exports.SCOPE_TS_MODULE = exports.SCOPE_CLASS = exports.SCOPE_DIRECT_SUPER = exports.SCOPE_SUPER = exports.SCOPE_SIMPLE_CATCH = exports.SCOPE_ARROW = exports.SCOPE_FUNCTION = exports.SCOPE_PROGRAM = exports.SCOPE_OTHER = void 0;
const SCOPE_OTHER = 0b00000000,
SCOPE_PROGRAM = 0b00000001,
SCOPE_FUNCTION = 0b00000010,
SCOPE_ARROW = 0b00000100,
SCOPE_SIMPLE_CATCH = 0b00001000,
SCOPE_SUPER = 0b00010000,
SCOPE_DIRECT_SUPER = 0b00100000,
SCOPE_CLASS = 0b01000000,
SCOPE_TS_MODULE = 0b10000000,
SCOPE_VAR = SCOPE_PROGRAM | SCOPE_FUNCTION | SCOPE_TS_MODULE;
exports.SCOPE_VAR = SCOPE_VAR;
exports.SCOPE_TS_MODULE = SCOPE_TS_MODULE;
exports.SCOPE_CLASS = SCOPE_CLASS;
exports.SCOPE_DIRECT_SUPER = SCOPE_DIRECT_SUPER;
exports.SCOPE_SUPER = SCOPE_SUPER;
exports.SCOPE_SIMPLE_CATCH = SCOPE_SIMPLE_CATCH;
exports.SCOPE_ARROW = SCOPE_ARROW;
exports.SCOPE_FUNCTION = SCOPE_FUNCTION;
exports.SCOPE_PROGRAM = SCOPE_PROGRAM;
exports.SCOPE_OTHER = SCOPE_OTHER;
const BIND_KIND_VALUE = 0b00000_0000_01,
BIND_KIND_TYPE = 0b00000_0000_10,
BIND_SCOPE_VAR = 0b00000_0001_00,
BIND_SCOPE_LEXICAL = 0b00000_0010_00,
BIND_SCOPE_FUNCTION = 0b00000_0100_00,
BIND_SCOPE_OUTSIDE = 0b00000_1000_00,
BIND_FLAGS_NONE = 0b00001_0000_00,
BIND_FLAGS_CLASS = 0b00010_0000_00,
BIND_FLAGS_TS_ENUM = 0b00100_0000_00,
BIND_FLAGS_TS_CONST_ENUM = 0b01000_0000_00,
BIND_FLAGS_TS_EXPORT_ONLY = 0b10000_0000_00;
exports.BIND_FLAGS_TS_EXPORT_ONLY = BIND_FLAGS_TS_EXPORT_ONLY;
exports.BIND_FLAGS_TS_CONST_ENUM = BIND_FLAGS_TS_CONST_ENUM;
exports.BIND_FLAGS_TS_ENUM = BIND_FLAGS_TS_ENUM;
exports.BIND_FLAGS_CLASS = BIND_FLAGS_CLASS;
exports.BIND_FLAGS_NONE = BIND_FLAGS_NONE;
exports.BIND_SCOPE_OUTSIDE = BIND_SCOPE_OUTSIDE;
exports.BIND_SCOPE_FUNCTION = BIND_SCOPE_FUNCTION;
exports.BIND_SCOPE_LEXICAL = BIND_SCOPE_LEXICAL;
exports.BIND_SCOPE_VAR = BIND_SCOPE_VAR;
exports.BIND_KIND_TYPE = BIND_KIND_TYPE;
exports.BIND_KIND_VALUE = BIND_KIND_VALUE;
const BIND_CLASS = BIND_KIND_VALUE | BIND_KIND_TYPE | BIND_SCOPE_LEXICAL | BIND_FLAGS_CLASS,
BIND_LEXICAL = BIND_KIND_VALUE | 0 | BIND_SCOPE_LEXICAL | 0,
BIND_VAR = BIND_KIND_VALUE | 0 | BIND_SCOPE_VAR | 0,
BIND_FUNCTION = BIND_KIND_VALUE | 0 | BIND_SCOPE_FUNCTION | 0,
BIND_TS_INTERFACE = 0 | BIND_KIND_TYPE | 0 | BIND_FLAGS_CLASS,
BIND_TS_TYPE = 0 | BIND_KIND_TYPE | 0 | 0,
BIND_TS_ENUM = BIND_KIND_VALUE | BIND_KIND_TYPE | BIND_SCOPE_LEXICAL | BIND_FLAGS_TS_ENUM,
BIND_TS_AMBIENT = 0 | 0 | 0 | BIND_FLAGS_TS_EXPORT_ONLY,
BIND_NONE = 0 | 0 | 0 | BIND_FLAGS_NONE,
BIND_OUTSIDE = BIND_KIND_VALUE | 0 | 0 | BIND_FLAGS_NONE,
BIND_TS_CONST_ENUM = BIND_TS_ENUM | BIND_FLAGS_TS_CONST_ENUM,
BIND_TS_NAMESPACE = 0 | 0 | 0 | BIND_FLAGS_TS_EXPORT_ONLY;
exports.BIND_TS_NAMESPACE = BIND_TS_NAMESPACE;
exports.BIND_TS_CONST_ENUM = BIND_TS_CONST_ENUM;
exports.BIND_OUTSIDE = BIND_OUTSIDE;
exports.BIND_NONE = BIND_NONE;
exports.BIND_TS_AMBIENT = BIND_TS_AMBIENT;
exports.BIND_TS_ENUM = BIND_TS_ENUM;
exports.BIND_TS_TYPE = BIND_TS_TYPE;
exports.BIND_TS_INTERFACE = BIND_TS_INTERFACE;
exports.BIND_FUNCTION = BIND_FUNCTION;
exports.BIND_VAR = BIND_VAR;
exports.BIND_LEXICAL = BIND_LEXICAL;
exports.BIND_CLASS = BIND_CLASS;
const CLASS_ELEMENT_FLAG_STATIC = 0b1_00,
CLASS_ELEMENT_KIND_GETTER = 0b0_10,
CLASS_ELEMENT_KIND_SETTER = 0b0_01,
CLASS_ELEMENT_KIND_ACCESSOR = CLASS_ELEMENT_KIND_GETTER | CLASS_ELEMENT_KIND_SETTER;
exports.CLASS_ELEMENT_KIND_ACCESSOR = CLASS_ELEMENT_KIND_ACCESSOR;
exports.CLASS_ELEMENT_KIND_SETTER = CLASS_ELEMENT_KIND_SETTER;
exports.CLASS_ELEMENT_KIND_GETTER = CLASS_ELEMENT_KIND_GETTER;
exports.CLASS_ELEMENT_FLAG_STATIC = CLASS_ELEMENT_FLAG_STATIC;
const CLASS_ELEMENT_STATIC_GETTER = CLASS_ELEMENT_KIND_GETTER | CLASS_ELEMENT_FLAG_STATIC,
CLASS_ELEMENT_STATIC_SETTER = CLASS_ELEMENT_KIND_SETTER | CLASS_ELEMENT_FLAG_STATIC,
CLASS_ELEMENT_INSTANCE_GETTER = CLASS_ELEMENT_KIND_GETTER,
CLASS_ELEMENT_INSTANCE_SETTER = CLASS_ELEMENT_KIND_SETTER,
CLASS_ELEMENT_OTHER = 0;
exports.CLASS_ELEMENT_OTHER = CLASS_ELEMENT_OTHER;
exports.CLASS_ELEMENT_INSTANCE_SETTER = CLASS_ELEMENT_INSTANCE_SETTER;
exports.CLASS_ELEMENT_INSTANCE_GETTER = CLASS_ELEMENT_INSTANCE_GETTER;
exports.CLASS_ELEMENT_STATIC_SETTER = CLASS_ELEMENT_STATIC_SETTER;
exports.CLASS_ELEMENT_STATIC_GETTER = CLASS_ELEMENT_STATIC_GETTER;

View File

@@ -1,58 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.isNewLine = isNewLine;
exports.isWhitespace = isWhitespace;
exports.skipWhiteSpace = exports.lineBreakG = exports.lineBreak = void 0;
const lineBreak = /\r\n?|[\n\u2028\u2029]/;
exports.lineBreak = lineBreak;
const lineBreakG = new RegExp(lineBreak.source, "g");
exports.lineBreakG = lineBreakG;
function isNewLine(code) {
switch (code) {
case 10:
case 13:
case 8232:
case 8233:
return true;
default:
return false;
}
}
const skipWhiteSpace = /(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g;
exports.skipWhiteSpace = skipWhiteSpace;
function isWhitespace(code) {
switch (code) {
case 0x0009:
case 0x000b:
case 0x000c:
case 32:
case 160:
case 5760:
case 0x2000:
case 0x2001:
case 0x2002:
case 0x2003:
case 0x2004:
case 0x2005:
case 0x2006:
case 0x2007:
case 0x2008:
case 0x2009:
case 0x200a:
case 0x202f:
case 0x205f:
case 0x3000:
case 0xfeff:
return true;
default:
return false;
}
}

View File

@@ -1,35 +1,33 @@
{
"_args": [
[
"@babel/parser@7.12.5",
"@babel/parser@7.12.11",
"J:\\Github\\CURD-TS"
]
],
"_development": true,
"_from": "@babel/parser@7.12.5",
"_id": "@babel/parser@7.12.5",
"_from": "@babel/parser@7.12.11",
"_id": "@babel/parser@7.12.11",
"_inBundle": false,
"_integrity": "sha1-tK8y3dRzwL+mQ71/8HKLjnG4HqA=",
"_integrity": "sha1-nONZW810vFxGaQXobFNbiyUBHnk=",
"_location": "/@babel/parser",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "@babel/parser@7.12.5",
"raw": "@babel/parser@7.12.11",
"name": "@babel/parser",
"escapedName": "@babel%2fparser",
"scope": "@babel",
"rawSpec": "7.12.5",
"rawSpec": "7.12.11",
"saveSpec": null,
"fetchSpec": "7.12.5"
"fetchSpec": "7.12.11"
},
"_requiredBy": [
"/@vue/compiler-core",
"/@vue/compiler-sfc",
"/vite"
"/@vue/compiler-sfc"
],
"_resolved": "http://192.168.250.101:4873/@babel%2fparser/-/parser-7.12.5.tgz",
"_spec": "7.12.5",
"_resolved": "http://192.168.250.101:4873/@babel%2fparser/-/parser-7.12.11.tgz",
"_spec": "7.12.11",
"_where": "J:\\Github\\CURD-TS",
"author": {
"name": "Sebastian McKenzie",
@@ -43,9 +41,9 @@
},
"description": "A JavaScript parser",
"devDependencies": {
"@babel/code-frame": "7.10.4",
"@babel/helper-fixtures": "7.10.5",
"@babel/helper-validator-identifier": "7.10.4",
"@babel/code-frame": "7.12.11",
"@babel/helper-fixtures": "7.12.10",
"@babel/helper-validator-identifier": "7.12.11",
"charcodes": "^0.2.0"
},
"engines": {
@@ -77,5 +75,5 @@
"directory": "packages/babel-parser"
},
"types": "typings/babel-parser.d.ts",
"version": "7.12.5"
"version": "7.12.11"
}

View File

@@ -8,144 +8,155 @@
/**
* Parse the provided code as an entire ECMAScript program.
*/
export function parse(input: string, options?: ParserOptions): import('@babel/types').File;
export function parse(
input: string,
options?: ParserOptions
): import("@babel/types").File;
/**
* Parse the provided code as a single expression.
*/
export function parseExpression(input: string, options?: ParserOptions): import('@babel/types').Expression;
export function parseExpression(
input: string,
options?: ParserOptions
): import("@babel/types").Expression;
export interface ParserOptions {
/**
* By default, import and export declarations can only appear at a program's top level.
* Setting this option to true allows them anywhere where a statement is allowed.
*/
allowImportExportEverywhere?: boolean;
/**
* By default, import and export declarations can only appear at a program's top level.
* Setting this option to true allows them anywhere where a statement is allowed.
*/
allowImportExportEverywhere?: boolean;
/**
* By default, await use is not allowed outside of an async function.
* Set this to true to accept such code.
*/
allowAwaitOutsideFunction?: boolean;
/**
* By default, await use is not allowed outside of an async function.
* Set this to true to accept such code.
*/
allowAwaitOutsideFunction?: boolean;
/**
* By default, a return statement at the top level raises an error.
* Set this to true to accept such code.
*/
allowReturnOutsideFunction?: boolean;
/**
* By default, a return statement at the top level raises an error.
* Set this to true to accept such code.
*/
allowReturnOutsideFunction?: boolean;
allowSuperOutsideMethod?: boolean;
allowSuperOutsideMethod?: boolean;
/**
* By default, exported identifiers must refer to a declared variable.
* Set this to true to allow export statements to reference undeclared variables.
*/
allowUndeclaredExports?: boolean;
/**
* By default, exported identifiers must refer to a declared variable.
* Set this to true to allow export statements to reference undeclared variables.
*/
allowUndeclaredExports?: boolean;
/**
* Indicate the mode the code should be parsed in.
* Can be one of "script", "module", or "unambiguous". Defaults to "script".
* "unambiguous" will make @babel/parser attempt to guess, based on the presence
* of ES6 import or export statements.
* Files with ES6 imports and exports are considered "module" and are otherwise "script".
*/
sourceType?: 'script' | 'module' | 'unambiguous';
/**
* Indicate the mode the code should be parsed in.
* Can be one of "script", "module", or "unambiguous". Defaults to "script".
* "unambiguous" will make @babel/parser attempt to guess, based on the presence
* of ES6 import or export statements.
* Files with ES6 imports and exports are considered "module" and are otherwise "script".
*/
sourceType?: "script" | "module" | "unambiguous";
/**
* Correlate output AST nodes with their source filename.
* Useful when generating code and source maps from the ASTs of multiple input files.
*/
sourceFilename?: string;
/**
* Correlate output AST nodes with their source filename.
* Useful when generating code and source maps from the ASTs of multiple input files.
*/
sourceFilename?: string;
/**
* By default, the first line of code parsed is treated as line 1.
* You can provide a line number to alternatively start with.
* Useful for integration with other source tools.
*/
startLine?: number;
/**
* By default, the first line of code parsed is treated as line 1.
* You can provide a line number to alternatively start with.
* Useful for integration with other source tools.
*/
startLine?: number;
/**
* Array containing the plugins that you want to enable.
*/
plugins?: ParserPlugin[];
/**
* Array containing the plugins that you want to enable.
*/
plugins?: ParserPlugin[];
/**
* Should the parser work in strict mode.
* Defaults to true if sourceType === 'module'. Otherwise, false.
*/
strictMode?: boolean;
/**
* Should the parser work in strict mode.
* Defaults to true if sourceType === 'module'. Otherwise, false.
*/
strictMode?: boolean;
/**
* Adds a ranges property to each node: [node.start, node.end]
*/
ranges?: boolean;
/**
* Adds a ranges property to each node: [node.start, node.end]
*/
ranges?: boolean;
/**
* Adds all parsed tokens to a tokens property on the File node.
*/
tokens?: boolean;
/**
* Adds all parsed tokens to a tokens property on the File node.
*/
tokens?: boolean;
/**
* By default, the parser adds information about parentheses by setting
* `extra.parenthesized` to `true` as needed.
* When this option is `true` the parser creates `ParenthesizedExpression`
* AST nodes instead of using the `extra` property.
*/
createParenthesizedExpressions?: boolean;
/**
* By default, the parser adds information about parentheses by setting
* `extra.parenthesized` to `true` as needed.
* When this option is `true` the parser creates `ParenthesizedExpression`
* AST nodes instead of using the `extra` property.
*/
createParenthesizedExpressions?: boolean;
}
export type ParserPlugin =
'asyncGenerators' |
'bigInt' |
'classPrivateMethods' |
'classPrivateProperties' |
'classProperties' |
'classStaticBlock' |
'decimal' |
'decorators' |
'decorators-legacy' |
'doExpressions' |
'dynamicImport' |
'estree' |
'exportDefaultFrom' |
'exportNamespaceFrom' | // deprecated
'flow' |
'flowComments' |
'functionBind' |
'functionSent' |
'importMeta' |
'jsx' |
'logicalAssignment' |
'importAssertions' |
'moduleStringNames' |
'nullishCoalescingOperator' |
'numericSeparator' |
'objectRestSpread' |
'optionalCatchBinding' |
'optionalChaining' |
'partialApplication' |
'pipelineOperator' |
'placeholders' |
'privateIn' |
'throwExpressions' |
'topLevelAwait' |
'typescript' |
'v8intrinsic' |
ParserPluginWithOptions;
| "asyncGenerators"
| "bigInt"
| "classPrivateMethods"
| "classPrivateProperties"
| "classProperties"
| "classStaticBlock"
| "decimal"
| "decorators"
| "decorators-legacy"
| "doExpressions"
| "dynamicImport"
| "estree"
| "exportDefaultFrom"
| "exportNamespaceFrom" // deprecated
| "flow"
| "flowComments"
| "functionBind"
| "functionSent"
| "importMeta"
| "jsx"
| "logicalAssignment"
| "importAssertions"
| "moduleStringNames"
| "nullishCoalescingOperator"
| "numericSeparator"
| "objectRestSpread"
| "optionalCatchBinding"
| "optionalChaining"
| "partialApplication"
| "pipelineOperator"
| "placeholders"
| "privateIn"
| "throwExpressions"
| "topLevelAwait"
| "typescript"
| "v8intrinsic"
| ParserPluginWithOptions;
export type ParserPluginWithOptions =
['decorators', DecoratorsPluginOptions] |
['pipelineOperator', PipelineOperatorPluginOptions] |
['flow', FlowPluginOptions];
| ["decorators", DecoratorsPluginOptions]
| ["pipelineOperator", PipelineOperatorPluginOptions]
| ["recordAndTuple", RecordAndTuplePluginOptions]
| ["flow", FlowPluginOptions];
export interface DecoratorsPluginOptions {
decoratorsBeforeExport?: boolean;
decoratorsBeforeExport?: boolean;
}
export interface PipelineOperatorPluginOptions {
proposal: 'minimal' | 'smart';
proposal: "fsharp" | "minimal" | "smart";
}
export interface RecordAndTuplePluginOptions {
syntaxType: "bar" | "hash";
}
export interface FlowPluginOptions {
all?: boolean;
all?: boolean;
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -12,7 +12,7 @@ var _removeTypeDuplicates = _interopRequireDefault(require("../../modifications/
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function createTSUnionType(typeAnnotations) {
const types = typeAnnotations.map(type => type.typeAnnotations);
const types = typeAnnotations.map(type => type.typeAnnotation);
const flattened = (0, _removeTypeDuplicates.default)(types);
if (flattened.length === 1) {

View File

@@ -7,6 +7,8 @@ exports.default = cloneNode;
var _definitions = require("../definitions");
var _generated = require("../validators/generated");
const has = Function.call.bind(Object.prototype.hasOwnProperty);
function cloneIfNode(obj, deep, withoutLoc) {
@@ -31,10 +33,10 @@ function cloneNode(node, deep = true, withoutLoc = false) {
type
} = node;
const newNode = {
type
type: node.type
};
if (type === "Identifier") {
if ((0, _generated.isIdentifier)(node)) {
newNode.name = node.name;
if (has(node, "optional") && typeof node.optional === "boolean") {
@@ -50,7 +52,7 @@ function cloneNode(node, deep = true, withoutLoc = false) {
for (const field of Object.keys(_definitions.NODE_FIELDS[type])) {
if (has(node, field)) {
if (deep) {
newNode[field] = type === "File" && field === "comments" ? maybeCloneComments(node.comments, deep, withoutLoc) : cloneIfNodeOrArray(node[field], true, withoutLoc);
newNode[field] = (0, _generated.isFile)(node) && field === "comments" ? maybeCloneComments(node.comments, deep, withoutLoc) : cloneIfNodeOrArray(node[field], true, withoutLoc);
} else {
newNode[field] = node[field];
}

View File

@@ -3,10 +3,13 @@
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = toExpression;
exports.default = void 0;
var _generated = require("../validators/generated");
var _default = toExpression;
exports.default = _default;
function toExpression(node) {
if ((0, _generated.isExpressionStatement)(node)) {
node = node.expression;

View File

@@ -3,12 +3,15 @@
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = toStatement;
exports.default = void 0;
var _generated = require("../validators/generated");
var _generated2 = require("../builders/generated");
var _default = toStatement;
exports.default = _default;
function toStatement(node, ignore) {
if ((0, _generated.isStatement)(node)) {
return node;

View File

@@ -3,7 +3,7 @@
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = valueToNode;
exports.default = void 0;
var _isPlainObject = _interopRequireDefault(require("lodash/isPlainObject"));
@@ -15,6 +15,9 @@ var _generated = require("../builders/generated");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _default = valueToNode;
exports.default = _default;
function valueToNode(value) {
if (value === undefined) {
return (0, _generated.identifier)("undefined");

View File

@@ -409,7 +409,7 @@ exports.patternLikeCommon = patternLikeCommon;
})) return;
}
if (((0, _helperValidatorIdentifier.isKeyword)(node.name) || (0, _helperValidatorIdentifier.isReservedWord)(node.name)) && node.name !== "this") {
if (((0, _helperValidatorIdentifier.isKeyword)(node.name) || (0, _helperValidatorIdentifier.isReservedWord)(node.name, false)) && node.name !== "this") {
throw new TypeError(`"${node.name}" is not a valid identifier`);
}
}
@@ -1052,6 +1052,7 @@ exports.patternLikeCommon = patternLikeCommon;
source: {
validate: (0, _utils.assertNodeType)("StringLiteral")
},
exportKind: (0, _utils.validateOptional)((0, _utils.assertOneOf)("type", "value")),
assertions: {
optional: true,
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertNodeType)("ImportAttribute"))
@@ -1471,7 +1472,7 @@ exports.classMethodOrDeclareMethodCommon = classMethodOrDeclareMethodCommon;
validate: (0, _utils.assertNodeType)("Expression")
},
arguments: {
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Expression", "SpreadElement", "JSXNamespacedName")))
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Expression", "SpreadElement", "JSXNamespacedName", "ArgumentPlaceholder")))
},
optional: {
validate: !process.env.BABEL_TYPES_8_BREAKING ? (0, _utils.assertValueType)("boolean") : (0, _utils.chain)((0, _utils.assertValueType)("boolean"), (0, _utils.assertOptionalChainStart)())

View File

@@ -96,6 +96,10 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj;
validate: (0, _utils.assertNodeType)("Expression"),
optional: true
},
typeAnnotation: {
validate: (0, _utils.assertNodeType)("TypeAnnotation", "TSTypeAnnotation", "Noop"),
optional: true
},
decorators: {
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Decorator"))),
optional: true

View File

@@ -266,7 +266,8 @@ defineInterfaceishType("InterfaceDeclaration");
static: (0, _utils.validate)((0, _utils.assertValueType)("boolean")),
proto: (0, _utils.validate)((0, _utils.assertValueType)("boolean")),
optional: (0, _utils.validate)((0, _utils.assertValueType)("boolean")),
variance: (0, _utils.validateOptionalType)("Variance")
variance: (0, _utils.validateOptionalType)("Variance"),
method: (0, _utils.validate)((0, _utils.assertValueType)("boolean"))
}
});
(0, _utils.default)("ObjectTypeSpreadProperty", {
@@ -401,7 +402,7 @@ defineInterfaceishType("InterfaceDeclaration");
aliases: ["EnumBody"],
visitor: ["members"],
fields: {
explicit: (0, _utils.validate)((0, _utils.assertValueType)("boolean")),
explicitType: (0, _utils.validate)((0, _utils.assertValueType)("boolean")),
members: (0, _utils.validateArrayOfType)("EnumBooleanMember")
}
});
@@ -409,7 +410,7 @@ defineInterfaceishType("InterfaceDeclaration");
aliases: ["EnumBody"],
visitor: ["members"],
fields: {
explicit: (0, _utils.validate)((0, _utils.assertValueType)("boolean")),
explicitType: (0, _utils.validate)((0, _utils.assertValueType)("boolean")),
members: (0, _utils.validateArrayOfType)("EnumNumberMember")
}
});
@@ -417,7 +418,7 @@ defineInterfaceishType("InterfaceDeclaration");
aliases: ["EnumBody"],
visitor: ["members"],
fields: {
explicit: (0, _utils.validate)((0, _utils.assertValueType)("boolean")),
explicitType: (0, _utils.validate)((0, _utils.assertValueType)("boolean")),
members: (0, _utils.validateArrayOfType)(["EnumStringMember", "EnumDefaultedMember"])
}
});

View File

@@ -224,11 +224,11 @@ function assertOptionalChainStart() {
}
function chain(...fns) {
function validate(...args) {
const validate = function (...args) {
for (const fn of fns) {
fn(...args);
}
}
};
validate.chainOf = fns;
return validate;

File diff suppressed because one or more lines are too long

View File

@@ -442,6 +442,20 @@ Object.keys(_generated2).forEach(function (key) {
});
});
var _uppercase = require("./builders/generated/uppercase");
Object.keys(_uppercase).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
if (key in exports && exports[key] === _uppercase[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _uppercase[key];
}
});
});
var _cloneNode = _interopRequireDefault(require("./clone/cloneNode"));
var _clone = _interopRequireDefault(require("./clone/clone"));
@@ -544,7 +558,19 @@ var _getBindingIdentifiers = _interopRequireDefault(require("./retrievers/getBin
var _getOuterBindingIdentifiers = _interopRequireDefault(require("./retrievers/getOuterBindingIdentifiers"));
var _traverse = _interopRequireDefault(require("./traverse/traverse"));
var _traverse = _interopRequireWildcard(require("./traverse/traverse"));
Object.keys(_traverse).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
if (key in exports && exports[key] === _traverse[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _traverse[key];
}
});
});
var _traverseFast = _interopRequireDefault(require("./traverse/traverseFast"));
@@ -600,6 +626,24 @@ Object.keys(_generated4).forEach(function (key) {
});
});
var _generated5 = require("./ast-types/generated");
Object.keys(_generated5).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
if (key in exports && exports[key] === _generated5[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _generated5[key];
}
});
});
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const react = {

File diff suppressed because it is too large Load Diff

View File

@@ -7,6 +7,10 @@ exports.default = removeTypeDuplicates;
var _generated = require("../../validators/generated");
function getQualifiedName(node) {
return (0, _generated.isIdentifier)(node) ? node.name : `${node.id.name}.${getQualifiedName(node.qualification)}`;
}
function removeTypeDuplicates(nodes) {
const generics = {};
const bases = {};
@@ -40,7 +44,7 @@ function removeTypeDuplicates(nodes) {
}
if ((0, _generated.isGenericTypeAnnotation)(node)) {
const name = node.id.name;
const name = getQualifiedName(node.id);
if (generics[name]) {
let existing = generics[name];

View File

@@ -21,7 +21,7 @@ function removeTypeDuplicates(nodes) {
continue;
}
if ((0, _generated.isTSAnyKeyword)(node.type)) {
if ((0, _generated.isTSAnyKeyword)(node)) {
return [node];
}

View File

@@ -28,7 +28,7 @@ function getBindingIdentifiers(node, duplicates, outerOnly) {
continue;
}
if ((0, _generated.isExportDeclaration)(id)) {
if ((0, _generated.isExportDeclaration)(id) && !(0, _generated.isExportAllDeclaration)(id)) {
if ((0, _generated.isDeclaration)(id.declaration)) {
search.push(id.declaration);
}

View File

@@ -3,12 +3,15 @@
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = getOuterBindingIdentifiers;
exports.default = void 0;
var _getBindingIdentifiers = _interopRequireDefault(require("./getBindingIdentifiers"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _default = getOuterBindingIdentifiers;
exports.default = _default;
function getOuterBindingIdentifiers(node, duplicates) {
return (0, _getBindingIdentifiers.default)(node, duplicates, true);
}

View File

@@ -3933,7 +3933,7 @@ function isExpression(node, opts) {
if (!node) return false;
const nodeType = node.type;
if (nodeType === "Expression" || "ArrayExpression" === nodeType || "AssignmentExpression" === nodeType || "BinaryExpression" === nodeType || "CallExpression" === nodeType || "ConditionalExpression" === nodeType || "FunctionExpression" === nodeType || "Identifier" === nodeType || "StringLiteral" === nodeType || "NumericLiteral" === nodeType || "NullLiteral" === nodeType || "BooleanLiteral" === nodeType || "RegExpLiteral" === nodeType || "LogicalExpression" === nodeType || "MemberExpression" === nodeType || "NewExpression" === nodeType || "ObjectExpression" === nodeType || "SequenceExpression" === nodeType || "ParenthesizedExpression" === nodeType || "ThisExpression" === nodeType || "UnaryExpression" === nodeType || "UpdateExpression" === nodeType || "ArrowFunctionExpression" === nodeType || "ClassExpression" === nodeType || "MetaProperty" === nodeType || "Super" === nodeType || "TaggedTemplateExpression" === nodeType || "TemplateLiteral" === nodeType || "YieldExpression" === nodeType || "AwaitExpression" === nodeType || "Import" === nodeType || "BigIntLiteral" === nodeType || "OptionalMemberExpression" === nodeType || "OptionalCallExpression" === nodeType || "TypeCastExpression" === nodeType || "JSXElement" === nodeType || "JSXFragment" === nodeType || "BindExpression" === nodeType || "PipelinePrimaryTopicReference" === nodeType || "DoExpression" === nodeType || "RecordExpression" === nodeType || "TupleExpression" === nodeType || "DecimalLiteral" === nodeType || "TSAsExpression" === nodeType || "TSTypeAssertion" === nodeType || "TSNonNullExpression" === nodeType || nodeType === "Placeholder" && ("Expression" === node.expectedNode || "Identifier" === node.expectedNode || "StringLiteral" === node.expectedNode)) {
if ("ArrayExpression" === nodeType || "AssignmentExpression" === nodeType || "BinaryExpression" === nodeType || "CallExpression" === nodeType || "ConditionalExpression" === nodeType || "FunctionExpression" === nodeType || "Identifier" === nodeType || "StringLiteral" === nodeType || "NumericLiteral" === nodeType || "NullLiteral" === nodeType || "BooleanLiteral" === nodeType || "RegExpLiteral" === nodeType || "LogicalExpression" === nodeType || "MemberExpression" === nodeType || "NewExpression" === nodeType || "ObjectExpression" === nodeType || "SequenceExpression" === nodeType || "ParenthesizedExpression" === nodeType || "ThisExpression" === nodeType || "UnaryExpression" === nodeType || "UpdateExpression" === nodeType || "ArrowFunctionExpression" === nodeType || "ClassExpression" === nodeType || "MetaProperty" === nodeType || "Super" === nodeType || "TaggedTemplateExpression" === nodeType || "TemplateLiteral" === nodeType || "YieldExpression" === nodeType || "AwaitExpression" === nodeType || "Import" === nodeType || "BigIntLiteral" === nodeType || "OptionalMemberExpression" === nodeType || "OptionalCallExpression" === nodeType || "TypeCastExpression" === nodeType || "JSXElement" === nodeType || "JSXFragment" === nodeType || "BindExpression" === nodeType || "PipelinePrimaryTopicReference" === nodeType || "DoExpression" === nodeType || "RecordExpression" === nodeType || "TupleExpression" === nodeType || "DecimalLiteral" === nodeType || "TSAsExpression" === nodeType || "TSTypeAssertion" === nodeType || "TSNonNullExpression" === nodeType || nodeType === "Placeholder" && ("Expression" === node.expectedNode || "Identifier" === node.expectedNode || "StringLiteral" === node.expectedNode)) {
if (typeof opts === "undefined") {
return true;
} else {
@@ -3948,7 +3948,7 @@ function isBinary(node, opts) {
if (!node) return false;
const nodeType = node.type;
if (nodeType === "Binary" || "BinaryExpression" === nodeType || "LogicalExpression" === nodeType) {
if ("BinaryExpression" === nodeType || "LogicalExpression" === nodeType) {
if (typeof opts === "undefined") {
return true;
} else {
@@ -3963,7 +3963,7 @@ function isScopable(node, opts) {
if (!node) return false;
const nodeType = node.type;
if (nodeType === "Scopable" || "BlockStatement" === nodeType || "CatchClause" === nodeType || "DoWhileStatement" === nodeType || "ForInStatement" === nodeType || "ForStatement" === nodeType || "FunctionDeclaration" === nodeType || "FunctionExpression" === nodeType || "Program" === nodeType || "ObjectMethod" === nodeType || "SwitchStatement" === nodeType || "WhileStatement" === nodeType || "ArrowFunctionExpression" === nodeType || "ClassExpression" === nodeType || "ClassDeclaration" === nodeType || "ForOfStatement" === nodeType || "ClassMethod" === nodeType || "ClassPrivateMethod" === nodeType || "StaticBlock" === nodeType || "TSModuleBlock" === nodeType || nodeType === "Placeholder" && "BlockStatement" === node.expectedNode) {
if ("BlockStatement" === nodeType || "CatchClause" === nodeType || "DoWhileStatement" === nodeType || "ForInStatement" === nodeType || "ForStatement" === nodeType || "FunctionDeclaration" === nodeType || "FunctionExpression" === nodeType || "Program" === nodeType || "ObjectMethod" === nodeType || "SwitchStatement" === nodeType || "WhileStatement" === nodeType || "ArrowFunctionExpression" === nodeType || "ClassExpression" === nodeType || "ClassDeclaration" === nodeType || "ForOfStatement" === nodeType || "ClassMethod" === nodeType || "ClassPrivateMethod" === nodeType || "StaticBlock" === nodeType || "TSModuleBlock" === nodeType || nodeType === "Placeholder" && "BlockStatement" === node.expectedNode) {
if (typeof opts === "undefined") {
return true;
} else {
@@ -3978,7 +3978,7 @@ function isBlockParent(node, opts) {
if (!node) return false;
const nodeType = node.type;
if (nodeType === "BlockParent" || "BlockStatement" === nodeType || "CatchClause" === nodeType || "DoWhileStatement" === nodeType || "ForInStatement" === nodeType || "ForStatement" === nodeType || "FunctionDeclaration" === nodeType || "FunctionExpression" === nodeType || "Program" === nodeType || "ObjectMethod" === nodeType || "SwitchStatement" === nodeType || "WhileStatement" === nodeType || "ArrowFunctionExpression" === nodeType || "ForOfStatement" === nodeType || "ClassMethod" === nodeType || "ClassPrivateMethod" === nodeType || "StaticBlock" === nodeType || "TSModuleBlock" === nodeType || nodeType === "Placeholder" && "BlockStatement" === node.expectedNode) {
if ("BlockStatement" === nodeType || "CatchClause" === nodeType || "DoWhileStatement" === nodeType || "ForInStatement" === nodeType || "ForStatement" === nodeType || "FunctionDeclaration" === nodeType || "FunctionExpression" === nodeType || "Program" === nodeType || "ObjectMethod" === nodeType || "SwitchStatement" === nodeType || "WhileStatement" === nodeType || "ArrowFunctionExpression" === nodeType || "ForOfStatement" === nodeType || "ClassMethod" === nodeType || "ClassPrivateMethod" === nodeType || "StaticBlock" === nodeType || "TSModuleBlock" === nodeType || nodeType === "Placeholder" && "BlockStatement" === node.expectedNode) {
if (typeof opts === "undefined") {
return true;
} else {
@@ -3993,7 +3993,7 @@ function isBlock(node, opts) {
if (!node) return false;
const nodeType = node.type;
if (nodeType === "Block" || "BlockStatement" === nodeType || "Program" === nodeType || "TSModuleBlock" === nodeType || nodeType === "Placeholder" && "BlockStatement" === node.expectedNode) {
if ("BlockStatement" === nodeType || "Program" === nodeType || "TSModuleBlock" === nodeType || nodeType === "Placeholder" && "BlockStatement" === node.expectedNode) {
if (typeof opts === "undefined") {
return true;
} else {
@@ -4008,7 +4008,7 @@ function isStatement(node, opts) {
if (!node) return false;
const nodeType = node.type;
if (nodeType === "Statement" || "BlockStatement" === nodeType || "BreakStatement" === nodeType || "ContinueStatement" === nodeType || "DebuggerStatement" === nodeType || "DoWhileStatement" === nodeType || "EmptyStatement" === nodeType || "ExpressionStatement" === nodeType || "ForInStatement" === nodeType || "ForStatement" === nodeType || "FunctionDeclaration" === nodeType || "IfStatement" === nodeType || "LabeledStatement" === nodeType || "ReturnStatement" === nodeType || "SwitchStatement" === nodeType || "ThrowStatement" === nodeType || "TryStatement" === nodeType || "VariableDeclaration" === nodeType || "WhileStatement" === nodeType || "WithStatement" === nodeType || "ClassDeclaration" === nodeType || "ExportAllDeclaration" === nodeType || "ExportDefaultDeclaration" === nodeType || "ExportNamedDeclaration" === nodeType || "ForOfStatement" === nodeType || "ImportDeclaration" === nodeType || "DeclareClass" === nodeType || "DeclareFunction" === nodeType || "DeclareInterface" === nodeType || "DeclareModule" === nodeType || "DeclareModuleExports" === nodeType || "DeclareTypeAlias" === nodeType || "DeclareOpaqueType" === nodeType || "DeclareVariable" === nodeType || "DeclareExportDeclaration" === nodeType || "DeclareExportAllDeclaration" === nodeType || "InterfaceDeclaration" === nodeType || "OpaqueType" === nodeType || "TypeAlias" === nodeType || "EnumDeclaration" === nodeType || "TSDeclareFunction" === nodeType || "TSInterfaceDeclaration" === nodeType || "TSTypeAliasDeclaration" === nodeType || "TSEnumDeclaration" === nodeType || "TSModuleDeclaration" === nodeType || "TSImportEqualsDeclaration" === nodeType || "TSExportAssignment" === nodeType || "TSNamespaceExportDeclaration" === nodeType || nodeType === "Placeholder" && ("Statement" === node.expectedNode || "Declaration" === node.expectedNode || "BlockStatement" === node.expectedNode)) {
if ("BlockStatement" === nodeType || "BreakStatement" === nodeType || "ContinueStatement" === nodeType || "DebuggerStatement" === nodeType || "DoWhileStatement" === nodeType || "EmptyStatement" === nodeType || "ExpressionStatement" === nodeType || "ForInStatement" === nodeType || "ForStatement" === nodeType || "FunctionDeclaration" === nodeType || "IfStatement" === nodeType || "LabeledStatement" === nodeType || "ReturnStatement" === nodeType || "SwitchStatement" === nodeType || "ThrowStatement" === nodeType || "TryStatement" === nodeType || "VariableDeclaration" === nodeType || "WhileStatement" === nodeType || "WithStatement" === nodeType || "ClassDeclaration" === nodeType || "ExportAllDeclaration" === nodeType || "ExportDefaultDeclaration" === nodeType || "ExportNamedDeclaration" === nodeType || "ForOfStatement" === nodeType || "ImportDeclaration" === nodeType || "DeclareClass" === nodeType || "DeclareFunction" === nodeType || "DeclareInterface" === nodeType || "DeclareModule" === nodeType || "DeclareModuleExports" === nodeType || "DeclareTypeAlias" === nodeType || "DeclareOpaqueType" === nodeType || "DeclareVariable" === nodeType || "DeclareExportDeclaration" === nodeType || "DeclareExportAllDeclaration" === nodeType || "InterfaceDeclaration" === nodeType || "OpaqueType" === nodeType || "TypeAlias" === nodeType || "EnumDeclaration" === nodeType || "TSDeclareFunction" === nodeType || "TSInterfaceDeclaration" === nodeType || "TSTypeAliasDeclaration" === nodeType || "TSEnumDeclaration" === nodeType || "TSModuleDeclaration" === nodeType || "TSImportEqualsDeclaration" === nodeType || "TSExportAssignment" === nodeType || "TSNamespaceExportDeclaration" === nodeType || nodeType === "Placeholder" && ("Statement" === node.expectedNode || "Declaration" === node.expectedNode || "BlockStatement" === node.expectedNode)) {
if (typeof opts === "undefined") {
return true;
} else {
@@ -4023,7 +4023,7 @@ function isTerminatorless(node, opts) {
if (!node) return false;
const nodeType = node.type;
if (nodeType === "Terminatorless" || "BreakStatement" === nodeType || "ContinueStatement" === nodeType || "ReturnStatement" === nodeType || "ThrowStatement" === nodeType || "YieldExpression" === nodeType || "AwaitExpression" === nodeType) {
if ("BreakStatement" === nodeType || "ContinueStatement" === nodeType || "ReturnStatement" === nodeType || "ThrowStatement" === nodeType || "YieldExpression" === nodeType || "AwaitExpression" === nodeType) {
if (typeof opts === "undefined") {
return true;
} else {
@@ -4038,7 +4038,7 @@ function isCompletionStatement(node, opts) {
if (!node) return false;
const nodeType = node.type;
if (nodeType === "CompletionStatement" || "BreakStatement" === nodeType || "ContinueStatement" === nodeType || "ReturnStatement" === nodeType || "ThrowStatement" === nodeType) {
if ("BreakStatement" === nodeType || "ContinueStatement" === nodeType || "ReturnStatement" === nodeType || "ThrowStatement" === nodeType) {
if (typeof opts === "undefined") {
return true;
} else {
@@ -4053,7 +4053,7 @@ function isConditional(node, opts) {
if (!node) return false;
const nodeType = node.type;
if (nodeType === "Conditional" || "ConditionalExpression" === nodeType || "IfStatement" === nodeType) {
if ("ConditionalExpression" === nodeType || "IfStatement" === nodeType) {
if (typeof opts === "undefined") {
return true;
} else {
@@ -4068,7 +4068,7 @@ function isLoop(node, opts) {
if (!node) return false;
const nodeType = node.type;
if (nodeType === "Loop" || "DoWhileStatement" === nodeType || "ForInStatement" === nodeType || "ForStatement" === nodeType || "WhileStatement" === nodeType || "ForOfStatement" === nodeType) {
if ("DoWhileStatement" === nodeType || "ForInStatement" === nodeType || "ForStatement" === nodeType || "WhileStatement" === nodeType || "ForOfStatement" === nodeType) {
if (typeof opts === "undefined") {
return true;
} else {
@@ -4083,7 +4083,7 @@ function isWhile(node, opts) {
if (!node) return false;
const nodeType = node.type;
if (nodeType === "While" || "DoWhileStatement" === nodeType || "WhileStatement" === nodeType) {
if ("DoWhileStatement" === nodeType || "WhileStatement" === nodeType) {
if (typeof opts === "undefined") {
return true;
} else {
@@ -4098,7 +4098,7 @@ function isExpressionWrapper(node, opts) {
if (!node) return false;
const nodeType = node.type;
if (nodeType === "ExpressionWrapper" || "ExpressionStatement" === nodeType || "ParenthesizedExpression" === nodeType || "TypeCastExpression" === nodeType) {
if ("ExpressionStatement" === nodeType || "ParenthesizedExpression" === nodeType || "TypeCastExpression" === nodeType) {
if (typeof opts === "undefined") {
return true;
} else {
@@ -4113,7 +4113,7 @@ function isFor(node, opts) {
if (!node) return false;
const nodeType = node.type;
if (nodeType === "For" || "ForInStatement" === nodeType || "ForStatement" === nodeType || "ForOfStatement" === nodeType) {
if ("ForInStatement" === nodeType || "ForStatement" === nodeType || "ForOfStatement" === nodeType) {
if (typeof opts === "undefined") {
return true;
} else {
@@ -4128,7 +4128,7 @@ function isForXStatement(node, opts) {
if (!node) return false;
const nodeType = node.type;
if (nodeType === "ForXStatement" || "ForInStatement" === nodeType || "ForOfStatement" === nodeType) {
if ("ForInStatement" === nodeType || "ForOfStatement" === nodeType) {
if (typeof opts === "undefined") {
return true;
} else {
@@ -4143,7 +4143,7 @@ function isFunction(node, opts) {
if (!node) return false;
const nodeType = node.type;
if (nodeType === "Function" || "FunctionDeclaration" === nodeType || "FunctionExpression" === nodeType || "ObjectMethod" === nodeType || "ArrowFunctionExpression" === nodeType || "ClassMethod" === nodeType || "ClassPrivateMethod" === nodeType) {
if ("FunctionDeclaration" === nodeType || "FunctionExpression" === nodeType || "ObjectMethod" === nodeType || "ArrowFunctionExpression" === nodeType || "ClassMethod" === nodeType || "ClassPrivateMethod" === nodeType) {
if (typeof opts === "undefined") {
return true;
} else {
@@ -4158,7 +4158,7 @@ function isFunctionParent(node, opts) {
if (!node) return false;
const nodeType = node.type;
if (nodeType === "FunctionParent" || "FunctionDeclaration" === nodeType || "FunctionExpression" === nodeType || "ObjectMethod" === nodeType || "ArrowFunctionExpression" === nodeType || "ClassMethod" === nodeType || "ClassPrivateMethod" === nodeType) {
if ("FunctionDeclaration" === nodeType || "FunctionExpression" === nodeType || "ObjectMethod" === nodeType || "ArrowFunctionExpression" === nodeType || "ClassMethod" === nodeType || "ClassPrivateMethod" === nodeType) {
if (typeof opts === "undefined") {
return true;
} else {
@@ -4173,7 +4173,7 @@ function isPureish(node, opts) {
if (!node) return false;
const nodeType = node.type;
if (nodeType === "Pureish" || "FunctionDeclaration" === nodeType || "FunctionExpression" === nodeType || "StringLiteral" === nodeType || "NumericLiteral" === nodeType || "NullLiteral" === nodeType || "BooleanLiteral" === nodeType || "RegExpLiteral" === nodeType || "ArrowFunctionExpression" === nodeType || "BigIntLiteral" === nodeType || "DecimalLiteral" === nodeType || nodeType === "Placeholder" && "StringLiteral" === node.expectedNode) {
if ("FunctionDeclaration" === nodeType || "FunctionExpression" === nodeType || "StringLiteral" === nodeType || "NumericLiteral" === nodeType || "NullLiteral" === nodeType || "BooleanLiteral" === nodeType || "RegExpLiteral" === nodeType || "ArrowFunctionExpression" === nodeType || "BigIntLiteral" === nodeType || "DecimalLiteral" === nodeType || nodeType === "Placeholder" && "StringLiteral" === node.expectedNode) {
if (typeof opts === "undefined") {
return true;
} else {
@@ -4188,7 +4188,7 @@ function isDeclaration(node, opts) {
if (!node) return false;
const nodeType = node.type;
if (nodeType === "Declaration" || "FunctionDeclaration" === nodeType || "VariableDeclaration" === nodeType || "ClassDeclaration" === nodeType || "ExportAllDeclaration" === nodeType || "ExportDefaultDeclaration" === nodeType || "ExportNamedDeclaration" === nodeType || "ImportDeclaration" === nodeType || "DeclareClass" === nodeType || "DeclareFunction" === nodeType || "DeclareInterface" === nodeType || "DeclareModule" === nodeType || "DeclareModuleExports" === nodeType || "DeclareTypeAlias" === nodeType || "DeclareOpaqueType" === nodeType || "DeclareVariable" === nodeType || "DeclareExportDeclaration" === nodeType || "DeclareExportAllDeclaration" === nodeType || "InterfaceDeclaration" === nodeType || "OpaqueType" === nodeType || "TypeAlias" === nodeType || "EnumDeclaration" === nodeType || "TSDeclareFunction" === nodeType || "TSInterfaceDeclaration" === nodeType || "TSTypeAliasDeclaration" === nodeType || "TSEnumDeclaration" === nodeType || "TSModuleDeclaration" === nodeType || nodeType === "Placeholder" && "Declaration" === node.expectedNode) {
if ("FunctionDeclaration" === nodeType || "VariableDeclaration" === nodeType || "ClassDeclaration" === nodeType || "ExportAllDeclaration" === nodeType || "ExportDefaultDeclaration" === nodeType || "ExportNamedDeclaration" === nodeType || "ImportDeclaration" === nodeType || "DeclareClass" === nodeType || "DeclareFunction" === nodeType || "DeclareInterface" === nodeType || "DeclareModule" === nodeType || "DeclareModuleExports" === nodeType || "DeclareTypeAlias" === nodeType || "DeclareOpaqueType" === nodeType || "DeclareVariable" === nodeType || "DeclareExportDeclaration" === nodeType || "DeclareExportAllDeclaration" === nodeType || "InterfaceDeclaration" === nodeType || "OpaqueType" === nodeType || "TypeAlias" === nodeType || "EnumDeclaration" === nodeType || "TSDeclareFunction" === nodeType || "TSInterfaceDeclaration" === nodeType || "TSTypeAliasDeclaration" === nodeType || "TSEnumDeclaration" === nodeType || "TSModuleDeclaration" === nodeType || nodeType === "Placeholder" && "Declaration" === node.expectedNode) {
if (typeof opts === "undefined") {
return true;
} else {
@@ -4203,7 +4203,7 @@ function isPatternLike(node, opts) {
if (!node) return false;
const nodeType = node.type;
if (nodeType === "PatternLike" || "Identifier" === nodeType || "RestElement" === nodeType || "AssignmentPattern" === nodeType || "ArrayPattern" === nodeType || "ObjectPattern" === nodeType || nodeType === "Placeholder" && ("Pattern" === node.expectedNode || "Identifier" === node.expectedNode)) {
if ("Identifier" === nodeType || "RestElement" === nodeType || "AssignmentPattern" === nodeType || "ArrayPattern" === nodeType || "ObjectPattern" === nodeType || nodeType === "Placeholder" && ("Pattern" === node.expectedNode || "Identifier" === node.expectedNode)) {
if (typeof opts === "undefined") {
return true;
} else {
@@ -4218,7 +4218,7 @@ function isLVal(node, opts) {
if (!node) return false;
const nodeType = node.type;
if (nodeType === "LVal" || "Identifier" === nodeType || "MemberExpression" === nodeType || "RestElement" === nodeType || "AssignmentPattern" === nodeType || "ArrayPattern" === nodeType || "ObjectPattern" === nodeType || "TSParameterProperty" === nodeType || nodeType === "Placeholder" && ("Pattern" === node.expectedNode || "Identifier" === node.expectedNode)) {
if ("Identifier" === nodeType || "MemberExpression" === nodeType || "RestElement" === nodeType || "AssignmentPattern" === nodeType || "ArrayPattern" === nodeType || "ObjectPattern" === nodeType || "TSParameterProperty" === nodeType || nodeType === "Placeholder" && ("Pattern" === node.expectedNode || "Identifier" === node.expectedNode)) {
if (typeof opts === "undefined") {
return true;
} else {
@@ -4233,7 +4233,7 @@ function isTSEntityName(node, opts) {
if (!node) return false;
const nodeType = node.type;
if (nodeType === "TSEntityName" || "Identifier" === nodeType || "TSQualifiedName" === nodeType || nodeType === "Placeholder" && "Identifier" === node.expectedNode) {
if ("Identifier" === nodeType || "TSQualifiedName" === nodeType || nodeType === "Placeholder" && "Identifier" === node.expectedNode) {
if (typeof opts === "undefined") {
return true;
} else {
@@ -4248,7 +4248,7 @@ function isLiteral(node, opts) {
if (!node) return false;
const nodeType = node.type;
if (nodeType === "Literal" || "StringLiteral" === nodeType || "NumericLiteral" === nodeType || "NullLiteral" === nodeType || "BooleanLiteral" === nodeType || "RegExpLiteral" === nodeType || "TemplateLiteral" === nodeType || "BigIntLiteral" === nodeType || "DecimalLiteral" === nodeType || nodeType === "Placeholder" && "StringLiteral" === node.expectedNode) {
if ("StringLiteral" === nodeType || "NumericLiteral" === nodeType || "NullLiteral" === nodeType || "BooleanLiteral" === nodeType || "RegExpLiteral" === nodeType || "TemplateLiteral" === nodeType || "BigIntLiteral" === nodeType || "DecimalLiteral" === nodeType || nodeType === "Placeholder" && "StringLiteral" === node.expectedNode) {
if (typeof opts === "undefined") {
return true;
} else {
@@ -4263,7 +4263,7 @@ function isImmutable(node, opts) {
if (!node) return false;
const nodeType = node.type;
if (nodeType === "Immutable" || "StringLiteral" === nodeType || "NumericLiteral" === nodeType || "NullLiteral" === nodeType || "BooleanLiteral" === nodeType || "BigIntLiteral" === nodeType || "JSXAttribute" === nodeType || "JSXClosingElement" === nodeType || "JSXElement" === nodeType || "JSXExpressionContainer" === nodeType || "JSXSpreadChild" === nodeType || "JSXOpeningElement" === nodeType || "JSXText" === nodeType || "JSXFragment" === nodeType || "JSXOpeningFragment" === nodeType || "JSXClosingFragment" === nodeType || "DecimalLiteral" === nodeType || nodeType === "Placeholder" && "StringLiteral" === node.expectedNode) {
if ("StringLiteral" === nodeType || "NumericLiteral" === nodeType || "NullLiteral" === nodeType || "BooleanLiteral" === nodeType || "BigIntLiteral" === nodeType || "JSXAttribute" === nodeType || "JSXClosingElement" === nodeType || "JSXElement" === nodeType || "JSXExpressionContainer" === nodeType || "JSXSpreadChild" === nodeType || "JSXOpeningElement" === nodeType || "JSXText" === nodeType || "JSXFragment" === nodeType || "JSXOpeningFragment" === nodeType || "JSXClosingFragment" === nodeType || "DecimalLiteral" === nodeType || nodeType === "Placeholder" && "StringLiteral" === node.expectedNode) {
if (typeof opts === "undefined") {
return true;
} else {
@@ -4278,7 +4278,7 @@ function isUserWhitespacable(node, opts) {
if (!node) return false;
const nodeType = node.type;
if (nodeType === "UserWhitespacable" || "ObjectMethod" === nodeType || "ObjectProperty" === nodeType || "ObjectTypeInternalSlot" === nodeType || "ObjectTypeCallProperty" === nodeType || "ObjectTypeIndexer" === nodeType || "ObjectTypeProperty" === nodeType || "ObjectTypeSpreadProperty" === nodeType) {
if ("ObjectMethod" === nodeType || "ObjectProperty" === nodeType || "ObjectTypeInternalSlot" === nodeType || "ObjectTypeCallProperty" === nodeType || "ObjectTypeIndexer" === nodeType || "ObjectTypeProperty" === nodeType || "ObjectTypeSpreadProperty" === nodeType) {
if (typeof opts === "undefined") {
return true;
} else {
@@ -4293,7 +4293,7 @@ function isMethod(node, opts) {
if (!node) return false;
const nodeType = node.type;
if (nodeType === "Method" || "ObjectMethod" === nodeType || "ClassMethod" === nodeType || "ClassPrivateMethod" === nodeType) {
if ("ObjectMethod" === nodeType || "ClassMethod" === nodeType || "ClassPrivateMethod" === nodeType) {
if (typeof opts === "undefined") {
return true;
} else {
@@ -4308,7 +4308,7 @@ function isObjectMember(node, opts) {
if (!node) return false;
const nodeType = node.type;
if (nodeType === "ObjectMember" || "ObjectMethod" === nodeType || "ObjectProperty" === nodeType) {
if ("ObjectMethod" === nodeType || "ObjectProperty" === nodeType) {
if (typeof opts === "undefined") {
return true;
} else {
@@ -4323,7 +4323,7 @@ function isProperty(node, opts) {
if (!node) return false;
const nodeType = node.type;
if (nodeType === "Property" || "ObjectProperty" === nodeType || "ClassProperty" === nodeType || "ClassPrivateProperty" === nodeType) {
if ("ObjectProperty" === nodeType || "ClassProperty" === nodeType || "ClassPrivateProperty" === nodeType) {
if (typeof opts === "undefined") {
return true;
} else {
@@ -4338,7 +4338,7 @@ function isUnaryLike(node, opts) {
if (!node) return false;
const nodeType = node.type;
if (nodeType === "UnaryLike" || "UnaryExpression" === nodeType || "SpreadElement" === nodeType) {
if ("UnaryExpression" === nodeType || "SpreadElement" === nodeType) {
if (typeof opts === "undefined") {
return true;
} else {
@@ -4353,7 +4353,7 @@ function isPattern(node, opts) {
if (!node) return false;
const nodeType = node.type;
if (nodeType === "Pattern" || "AssignmentPattern" === nodeType || "ArrayPattern" === nodeType || "ObjectPattern" === nodeType || nodeType === "Placeholder" && "Pattern" === node.expectedNode) {
if ("AssignmentPattern" === nodeType || "ArrayPattern" === nodeType || "ObjectPattern" === nodeType || nodeType === "Placeholder" && "Pattern" === node.expectedNode) {
if (typeof opts === "undefined") {
return true;
} else {
@@ -4368,7 +4368,7 @@ function isClass(node, opts) {
if (!node) return false;
const nodeType = node.type;
if (nodeType === "Class" || "ClassExpression" === nodeType || "ClassDeclaration" === nodeType) {
if ("ClassExpression" === nodeType || "ClassDeclaration" === nodeType) {
if (typeof opts === "undefined") {
return true;
} else {
@@ -4383,7 +4383,7 @@ function isModuleDeclaration(node, opts) {
if (!node) return false;
const nodeType = node.type;
if (nodeType === "ModuleDeclaration" || "ExportAllDeclaration" === nodeType || "ExportDefaultDeclaration" === nodeType || "ExportNamedDeclaration" === nodeType || "ImportDeclaration" === nodeType) {
if ("ExportAllDeclaration" === nodeType || "ExportDefaultDeclaration" === nodeType || "ExportNamedDeclaration" === nodeType || "ImportDeclaration" === nodeType) {
if (typeof opts === "undefined") {
return true;
} else {
@@ -4398,7 +4398,7 @@ function isExportDeclaration(node, opts) {
if (!node) return false;
const nodeType = node.type;
if (nodeType === "ExportDeclaration" || "ExportAllDeclaration" === nodeType || "ExportDefaultDeclaration" === nodeType || "ExportNamedDeclaration" === nodeType) {
if ("ExportAllDeclaration" === nodeType || "ExportDefaultDeclaration" === nodeType || "ExportNamedDeclaration" === nodeType) {
if (typeof opts === "undefined") {
return true;
} else {
@@ -4413,7 +4413,7 @@ function isModuleSpecifier(node, opts) {
if (!node) return false;
const nodeType = node.type;
if (nodeType === "ModuleSpecifier" || "ExportSpecifier" === nodeType || "ImportDefaultSpecifier" === nodeType || "ImportNamespaceSpecifier" === nodeType || "ImportSpecifier" === nodeType || "ExportNamespaceSpecifier" === nodeType || "ExportDefaultSpecifier" === nodeType) {
if ("ExportSpecifier" === nodeType || "ImportDefaultSpecifier" === nodeType || "ImportNamespaceSpecifier" === nodeType || "ImportSpecifier" === nodeType || "ExportNamespaceSpecifier" === nodeType || "ExportDefaultSpecifier" === nodeType) {
if (typeof opts === "undefined") {
return true;
} else {
@@ -4428,7 +4428,7 @@ function isFlow(node, opts) {
if (!node) return false;
const nodeType = node.type;
if (nodeType === "Flow" || "AnyTypeAnnotation" === nodeType || "ArrayTypeAnnotation" === nodeType || "BooleanTypeAnnotation" === nodeType || "BooleanLiteralTypeAnnotation" === nodeType || "NullLiteralTypeAnnotation" === nodeType || "ClassImplements" === nodeType || "DeclareClass" === nodeType || "DeclareFunction" === nodeType || "DeclareInterface" === nodeType || "DeclareModule" === nodeType || "DeclareModuleExports" === nodeType || "DeclareTypeAlias" === nodeType || "DeclareOpaqueType" === nodeType || "DeclareVariable" === nodeType || "DeclareExportDeclaration" === nodeType || "DeclareExportAllDeclaration" === nodeType || "DeclaredPredicate" === nodeType || "ExistsTypeAnnotation" === nodeType || "FunctionTypeAnnotation" === nodeType || "FunctionTypeParam" === nodeType || "GenericTypeAnnotation" === nodeType || "InferredPredicate" === nodeType || "InterfaceExtends" === nodeType || "InterfaceDeclaration" === nodeType || "InterfaceTypeAnnotation" === nodeType || "IntersectionTypeAnnotation" === nodeType || "MixedTypeAnnotation" === nodeType || "EmptyTypeAnnotation" === nodeType || "NullableTypeAnnotation" === nodeType || "NumberLiteralTypeAnnotation" === nodeType || "NumberTypeAnnotation" === nodeType || "ObjectTypeAnnotation" === nodeType || "ObjectTypeInternalSlot" === nodeType || "ObjectTypeCallProperty" === nodeType || "ObjectTypeIndexer" === nodeType || "ObjectTypeProperty" === nodeType || "ObjectTypeSpreadProperty" === nodeType || "OpaqueType" === nodeType || "QualifiedTypeIdentifier" === nodeType || "StringLiteralTypeAnnotation" === nodeType || "StringTypeAnnotation" === nodeType || "SymbolTypeAnnotation" === nodeType || "ThisTypeAnnotation" === nodeType || "TupleTypeAnnotation" === nodeType || "TypeofTypeAnnotation" === nodeType || "TypeAlias" === nodeType || "TypeAnnotation" === nodeType || "TypeCastExpression" === nodeType || "TypeParameter" === nodeType || "TypeParameterDeclaration" === nodeType || "TypeParameterInstantiation" === nodeType || "UnionTypeAnnotation" === nodeType || "Variance" === nodeType || "VoidTypeAnnotation" === nodeType) {
if ("AnyTypeAnnotation" === nodeType || "ArrayTypeAnnotation" === nodeType || "BooleanTypeAnnotation" === nodeType || "BooleanLiteralTypeAnnotation" === nodeType || "NullLiteralTypeAnnotation" === nodeType || "ClassImplements" === nodeType || "DeclareClass" === nodeType || "DeclareFunction" === nodeType || "DeclareInterface" === nodeType || "DeclareModule" === nodeType || "DeclareModuleExports" === nodeType || "DeclareTypeAlias" === nodeType || "DeclareOpaqueType" === nodeType || "DeclareVariable" === nodeType || "DeclareExportDeclaration" === nodeType || "DeclareExportAllDeclaration" === nodeType || "DeclaredPredicate" === nodeType || "ExistsTypeAnnotation" === nodeType || "FunctionTypeAnnotation" === nodeType || "FunctionTypeParam" === nodeType || "GenericTypeAnnotation" === nodeType || "InferredPredicate" === nodeType || "InterfaceExtends" === nodeType || "InterfaceDeclaration" === nodeType || "InterfaceTypeAnnotation" === nodeType || "IntersectionTypeAnnotation" === nodeType || "MixedTypeAnnotation" === nodeType || "EmptyTypeAnnotation" === nodeType || "NullableTypeAnnotation" === nodeType || "NumberLiteralTypeAnnotation" === nodeType || "NumberTypeAnnotation" === nodeType || "ObjectTypeAnnotation" === nodeType || "ObjectTypeInternalSlot" === nodeType || "ObjectTypeCallProperty" === nodeType || "ObjectTypeIndexer" === nodeType || "ObjectTypeProperty" === nodeType || "ObjectTypeSpreadProperty" === nodeType || "OpaqueType" === nodeType || "QualifiedTypeIdentifier" === nodeType || "StringLiteralTypeAnnotation" === nodeType || "StringTypeAnnotation" === nodeType || "SymbolTypeAnnotation" === nodeType || "ThisTypeAnnotation" === nodeType || "TupleTypeAnnotation" === nodeType || "TypeofTypeAnnotation" === nodeType || "TypeAlias" === nodeType || "TypeAnnotation" === nodeType || "TypeCastExpression" === nodeType || "TypeParameter" === nodeType || "TypeParameterDeclaration" === nodeType || "TypeParameterInstantiation" === nodeType || "UnionTypeAnnotation" === nodeType || "Variance" === nodeType || "VoidTypeAnnotation" === nodeType) {
if (typeof opts === "undefined") {
return true;
} else {
@@ -4443,7 +4443,7 @@ function isFlowType(node, opts) {
if (!node) return false;
const nodeType = node.type;
if (nodeType === "FlowType" || "AnyTypeAnnotation" === nodeType || "ArrayTypeAnnotation" === nodeType || "BooleanTypeAnnotation" === nodeType || "BooleanLiteralTypeAnnotation" === nodeType || "NullLiteralTypeAnnotation" === nodeType || "ExistsTypeAnnotation" === nodeType || "FunctionTypeAnnotation" === nodeType || "GenericTypeAnnotation" === nodeType || "InterfaceTypeAnnotation" === nodeType || "IntersectionTypeAnnotation" === nodeType || "MixedTypeAnnotation" === nodeType || "EmptyTypeAnnotation" === nodeType || "NullableTypeAnnotation" === nodeType || "NumberLiteralTypeAnnotation" === nodeType || "NumberTypeAnnotation" === nodeType || "ObjectTypeAnnotation" === nodeType || "StringLiteralTypeAnnotation" === nodeType || "StringTypeAnnotation" === nodeType || "SymbolTypeAnnotation" === nodeType || "ThisTypeAnnotation" === nodeType || "TupleTypeAnnotation" === nodeType || "TypeofTypeAnnotation" === nodeType || "UnionTypeAnnotation" === nodeType || "VoidTypeAnnotation" === nodeType) {
if ("AnyTypeAnnotation" === nodeType || "ArrayTypeAnnotation" === nodeType || "BooleanTypeAnnotation" === nodeType || "BooleanLiteralTypeAnnotation" === nodeType || "NullLiteralTypeAnnotation" === nodeType || "ExistsTypeAnnotation" === nodeType || "FunctionTypeAnnotation" === nodeType || "GenericTypeAnnotation" === nodeType || "InterfaceTypeAnnotation" === nodeType || "IntersectionTypeAnnotation" === nodeType || "MixedTypeAnnotation" === nodeType || "EmptyTypeAnnotation" === nodeType || "NullableTypeAnnotation" === nodeType || "NumberLiteralTypeAnnotation" === nodeType || "NumberTypeAnnotation" === nodeType || "ObjectTypeAnnotation" === nodeType || "StringLiteralTypeAnnotation" === nodeType || "StringTypeAnnotation" === nodeType || "SymbolTypeAnnotation" === nodeType || "ThisTypeAnnotation" === nodeType || "TupleTypeAnnotation" === nodeType || "TypeofTypeAnnotation" === nodeType || "UnionTypeAnnotation" === nodeType || "VoidTypeAnnotation" === nodeType) {
if (typeof opts === "undefined") {
return true;
} else {
@@ -4458,7 +4458,7 @@ function isFlowBaseAnnotation(node, opts) {
if (!node) return false;
const nodeType = node.type;
if (nodeType === "FlowBaseAnnotation" || "AnyTypeAnnotation" === nodeType || "BooleanTypeAnnotation" === nodeType || "NullLiteralTypeAnnotation" === nodeType || "MixedTypeAnnotation" === nodeType || "EmptyTypeAnnotation" === nodeType || "NumberTypeAnnotation" === nodeType || "StringTypeAnnotation" === nodeType || "SymbolTypeAnnotation" === nodeType || "ThisTypeAnnotation" === nodeType || "VoidTypeAnnotation" === nodeType) {
if ("AnyTypeAnnotation" === nodeType || "BooleanTypeAnnotation" === nodeType || "NullLiteralTypeAnnotation" === nodeType || "MixedTypeAnnotation" === nodeType || "EmptyTypeAnnotation" === nodeType || "NumberTypeAnnotation" === nodeType || "StringTypeAnnotation" === nodeType || "SymbolTypeAnnotation" === nodeType || "ThisTypeAnnotation" === nodeType || "VoidTypeAnnotation" === nodeType) {
if (typeof opts === "undefined") {
return true;
} else {
@@ -4473,7 +4473,7 @@ function isFlowDeclaration(node, opts) {
if (!node) return false;
const nodeType = node.type;
if (nodeType === "FlowDeclaration" || "DeclareClass" === nodeType || "DeclareFunction" === nodeType || "DeclareInterface" === nodeType || "DeclareModule" === nodeType || "DeclareModuleExports" === nodeType || "DeclareTypeAlias" === nodeType || "DeclareOpaqueType" === nodeType || "DeclareVariable" === nodeType || "DeclareExportDeclaration" === nodeType || "DeclareExportAllDeclaration" === nodeType || "InterfaceDeclaration" === nodeType || "OpaqueType" === nodeType || "TypeAlias" === nodeType) {
if ("DeclareClass" === nodeType || "DeclareFunction" === nodeType || "DeclareInterface" === nodeType || "DeclareModule" === nodeType || "DeclareModuleExports" === nodeType || "DeclareTypeAlias" === nodeType || "DeclareOpaqueType" === nodeType || "DeclareVariable" === nodeType || "DeclareExportDeclaration" === nodeType || "DeclareExportAllDeclaration" === nodeType || "InterfaceDeclaration" === nodeType || "OpaqueType" === nodeType || "TypeAlias" === nodeType) {
if (typeof opts === "undefined") {
return true;
} else {
@@ -4488,7 +4488,7 @@ function isFlowPredicate(node, opts) {
if (!node) return false;
const nodeType = node.type;
if (nodeType === "FlowPredicate" || "DeclaredPredicate" === nodeType || "InferredPredicate" === nodeType) {
if ("DeclaredPredicate" === nodeType || "InferredPredicate" === nodeType) {
if (typeof opts === "undefined") {
return true;
} else {
@@ -4503,7 +4503,7 @@ function isEnumBody(node, opts) {
if (!node) return false;
const nodeType = node.type;
if (nodeType === "EnumBody" || "EnumBooleanBody" === nodeType || "EnumNumberBody" === nodeType || "EnumStringBody" === nodeType || "EnumSymbolBody" === nodeType) {
if ("EnumBooleanBody" === nodeType || "EnumNumberBody" === nodeType || "EnumStringBody" === nodeType || "EnumSymbolBody" === nodeType) {
if (typeof opts === "undefined") {
return true;
} else {
@@ -4518,7 +4518,7 @@ function isEnumMember(node, opts) {
if (!node) return false;
const nodeType = node.type;
if (nodeType === "EnumMember" || "EnumBooleanMember" === nodeType || "EnumNumberMember" === nodeType || "EnumStringMember" === nodeType || "EnumDefaultedMember" === nodeType) {
if ("EnumBooleanMember" === nodeType || "EnumNumberMember" === nodeType || "EnumStringMember" === nodeType || "EnumDefaultedMember" === nodeType) {
if (typeof opts === "undefined") {
return true;
} else {
@@ -4533,7 +4533,7 @@ function isJSX(node, opts) {
if (!node) return false;
const nodeType = node.type;
if (nodeType === "JSX" || "JSXAttribute" === nodeType || "JSXClosingElement" === nodeType || "JSXElement" === nodeType || "JSXEmptyExpression" === nodeType || "JSXExpressionContainer" === nodeType || "JSXSpreadChild" === nodeType || "JSXIdentifier" === nodeType || "JSXMemberExpression" === nodeType || "JSXNamespacedName" === nodeType || "JSXOpeningElement" === nodeType || "JSXSpreadAttribute" === nodeType || "JSXText" === nodeType || "JSXFragment" === nodeType || "JSXOpeningFragment" === nodeType || "JSXClosingFragment" === nodeType) {
if ("JSXAttribute" === nodeType || "JSXClosingElement" === nodeType || "JSXElement" === nodeType || "JSXEmptyExpression" === nodeType || "JSXExpressionContainer" === nodeType || "JSXSpreadChild" === nodeType || "JSXIdentifier" === nodeType || "JSXMemberExpression" === nodeType || "JSXNamespacedName" === nodeType || "JSXOpeningElement" === nodeType || "JSXSpreadAttribute" === nodeType || "JSXText" === nodeType || "JSXFragment" === nodeType || "JSXOpeningFragment" === nodeType || "JSXClosingFragment" === nodeType) {
if (typeof opts === "undefined") {
return true;
} else {
@@ -4548,7 +4548,7 @@ function isPrivate(node, opts) {
if (!node) return false;
const nodeType = node.type;
if (nodeType === "Private" || "ClassPrivateProperty" === nodeType || "ClassPrivateMethod" === nodeType || "PrivateName" === nodeType) {
if ("ClassPrivateProperty" === nodeType || "ClassPrivateMethod" === nodeType || "PrivateName" === nodeType) {
if (typeof opts === "undefined") {
return true;
} else {
@@ -4563,7 +4563,7 @@ function isTSTypeElement(node, opts) {
if (!node) return false;
const nodeType = node.type;
if (nodeType === "TSTypeElement" || "TSCallSignatureDeclaration" === nodeType || "TSConstructSignatureDeclaration" === nodeType || "TSPropertySignature" === nodeType || "TSMethodSignature" === nodeType || "TSIndexSignature" === nodeType) {
if ("TSCallSignatureDeclaration" === nodeType || "TSConstructSignatureDeclaration" === nodeType || "TSPropertySignature" === nodeType || "TSMethodSignature" === nodeType || "TSIndexSignature" === nodeType) {
if (typeof opts === "undefined") {
return true;
} else {
@@ -4578,7 +4578,7 @@ function isTSType(node, opts) {
if (!node) return false;
const nodeType = node.type;
if (nodeType === "TSType" || "TSAnyKeyword" === nodeType || "TSBooleanKeyword" === nodeType || "TSBigIntKeyword" === nodeType || "TSIntrinsicKeyword" === nodeType || "TSNeverKeyword" === nodeType || "TSNullKeyword" === nodeType || "TSNumberKeyword" === nodeType || "TSObjectKeyword" === nodeType || "TSStringKeyword" === nodeType || "TSSymbolKeyword" === nodeType || "TSUndefinedKeyword" === nodeType || "TSUnknownKeyword" === nodeType || "TSVoidKeyword" === nodeType || "TSThisType" === nodeType || "TSFunctionType" === nodeType || "TSConstructorType" === nodeType || "TSTypeReference" === nodeType || "TSTypePredicate" === nodeType || "TSTypeQuery" === nodeType || "TSTypeLiteral" === nodeType || "TSArrayType" === nodeType || "TSTupleType" === nodeType || "TSOptionalType" === nodeType || "TSRestType" === nodeType || "TSUnionType" === nodeType || "TSIntersectionType" === nodeType || "TSConditionalType" === nodeType || "TSInferType" === nodeType || "TSParenthesizedType" === nodeType || "TSTypeOperator" === nodeType || "TSIndexedAccessType" === nodeType || "TSMappedType" === nodeType || "TSLiteralType" === nodeType || "TSExpressionWithTypeArguments" === nodeType || "TSImportType" === nodeType) {
if ("TSAnyKeyword" === nodeType || "TSBooleanKeyword" === nodeType || "TSBigIntKeyword" === nodeType || "TSIntrinsicKeyword" === nodeType || "TSNeverKeyword" === nodeType || "TSNullKeyword" === nodeType || "TSNumberKeyword" === nodeType || "TSObjectKeyword" === nodeType || "TSStringKeyword" === nodeType || "TSSymbolKeyword" === nodeType || "TSUndefinedKeyword" === nodeType || "TSUnknownKeyword" === nodeType || "TSVoidKeyword" === nodeType || "TSThisType" === nodeType || "TSFunctionType" === nodeType || "TSConstructorType" === nodeType || "TSTypeReference" === nodeType || "TSTypePredicate" === nodeType || "TSTypeQuery" === nodeType || "TSTypeLiteral" === nodeType || "TSArrayType" === nodeType || "TSTupleType" === nodeType || "TSOptionalType" === nodeType || "TSRestType" === nodeType || "TSUnionType" === nodeType || "TSIntersectionType" === nodeType || "TSConditionalType" === nodeType || "TSInferType" === nodeType || "TSParenthesizedType" === nodeType || "TSTypeOperator" === nodeType || "TSIndexedAccessType" === nodeType || "TSMappedType" === nodeType || "TSLiteralType" === nodeType || "TSExpressionWithTypeArguments" === nodeType || "TSImportType" === nodeType) {
if (typeof opts === "undefined") {
return true;
} else {
@@ -4593,7 +4593,7 @@ function isTSBaseType(node, opts) {
if (!node) return false;
const nodeType = node.type;
if (nodeType === "TSBaseType" || "TSAnyKeyword" === nodeType || "TSBooleanKeyword" === nodeType || "TSBigIntKeyword" === nodeType || "TSIntrinsicKeyword" === nodeType || "TSNeverKeyword" === nodeType || "TSNullKeyword" === nodeType || "TSNumberKeyword" === nodeType || "TSObjectKeyword" === nodeType || "TSStringKeyword" === nodeType || "TSSymbolKeyword" === nodeType || "TSUndefinedKeyword" === nodeType || "TSUnknownKeyword" === nodeType || "TSVoidKeyword" === nodeType || "TSThisType" === nodeType || "TSLiteralType" === nodeType) {
if ("TSAnyKeyword" === nodeType || "TSBooleanKeyword" === nodeType || "TSBigIntKeyword" === nodeType || "TSIntrinsicKeyword" === nodeType || "TSNeverKeyword" === nodeType || "TSNullKeyword" === nodeType || "TSNumberKeyword" === nodeType || "TSObjectKeyword" === nodeType || "TSStringKeyword" === nodeType || "TSSymbolKeyword" === nodeType || "TSUndefinedKeyword" === nodeType || "TSUnknownKeyword" === nodeType || "TSVoidKeyword" === nodeType || "TSThisType" === nodeType || "TSLiteralType" === nodeType) {
if (typeof opts === "undefined") {
return true;
} else {

View File

@@ -22,13 +22,6 @@ function isReferenced(node, parent, grandparent) {
case "ArrowFunctionExpression":
return parent.body === node;
case "ExportSpecifier":
if (parent.source) {
return false;
}
return parent.local === node;
case "PrivateName":
return false;
@@ -83,6 +76,13 @@ function isReferenced(node, parent, grandparent) {
case "ExportDefaultSpecifier":
return false;
case "ExportSpecifier":
if (grandparent == null ? void 0 : grandparent.source) {
return false;
}
return parent.local === node;
case "ImportDefaultSpecifier":
case "ImportNamespaceSpecifier":
case "ImportSpecifier":

View File

@@ -11,9 +11,7 @@ function isValidIdentifier(name, reserved = true) {
if (typeof name !== "string") return false;
if (reserved) {
if ((0, _helperValidatorIdentifier.isKeyword)(name) || (0, _helperValidatorIdentifier.isStrictReservedWord)(name)) {
return false;
} else if (name === "await") {
if ((0, _helperValidatorIdentifier.isKeyword)(name) || (0, _helperValidatorIdentifier.isStrictReservedWord)(name, true)) {
return false;
}
}

View File

@@ -1,34 +1,33 @@
{
"_args": [
[
"@babel/types@7.12.6",
"@babel/types@7.12.11",
"J:\\Github\\CURD-TS"
]
],
"_development": true,
"_from": "@babel/types@7.12.6",
"_id": "@babel/types@7.12.6",
"_from": "@babel/types@7.12.11",
"_id": "@babel/types@7.12.11",
"_inBundle": false,
"_integrity": "sha1-rg5V7xzOH7yIHNJvgjTrPmV+3JY=",
"_integrity": "sha1-qG5NceMKm27hAlkERsmGYliSg84=",
"_location": "/@babel/types",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "@babel/types@7.12.6",
"raw": "@babel/types@7.12.11",
"name": "@babel/types",
"escapedName": "@babel%2ftypes",
"scope": "@babel",
"rawSpec": "7.12.6",
"rawSpec": "7.12.11",
"saveSpec": null,
"fetchSpec": "7.12.6"
"fetchSpec": "7.12.11"
},
"_requiredBy": [
"/@vue/compiler-core",
"/@vue/compiler-sfc"
],
"_resolved": "http://192.168.250.101:4873/@babel%2ftypes/-/types-7.12.6.tgz",
"_spec": "7.12.6",
"_resolved": "http://192.168.250.101:4873/@babel%2ftypes/-/types-7.12.11.tgz",
"_spec": "7.12.11",
"_where": "J:\\Github\\CURD-TS",
"author": {
"name": "Sebastian McKenzie",
@@ -38,14 +37,15 @@
"url": "https://github.com/babel/babel/issues"
},
"dependencies": {
"@babel/helper-validator-identifier": "^7.10.4",
"@babel/helper-validator-identifier": "^7.12.11",
"lodash": "^4.17.19",
"to-fast-properties": "^2.0.0"
},
"description": "Babel Types is a Lodash-esque utility library for AST nodes",
"devDependencies": {
"@babel/generator": "7.12.5",
"@babel/parser": "7.12.5",
"@babel/generator": "7.12.11",
"@babel/parser": "7.12.11",
"@types/lodash": "^4.14.162",
"chalk": "^4.1.0"
},
"homepage": "https://babeljs.io/",
@@ -60,6 +60,12 @@
"url": "git+https://github.com/babel/babel.git",
"directory": "packages/babel-types"
},
"types": "lib/index.d.ts",
"version": "7.12.6"
"typesVersions": {
"<3.7": {
"lib/index.d.ts": [
"lib/index-ts3.7.d.ts"
]
}
},
"version": "7.12.11"
}

View File

@@ -1,29 +0,0 @@
"use strict";
const path = require("path");
const chalk = require("chalk");
const generateBuilders = require("./generators/generateBuilders");
const generateValidators = require("./generators/generateValidators");
const generateAsserts = require("./generators/generateAsserts");
const generateConstants = require("./generators/generateConstants");
const format = require("../../../scripts/utils/formatCode");
const writeFile = require("../../../scripts/utils/writeFileAndMkDir");
const baseDir = path.join(__dirname, "../src");
console.log("Generating @babel/types dynamic functions");
const buildersFile = path.join(baseDir, "builders/generated/index.js");
writeFile(buildersFile, format(generateBuilders(), buildersFile));
console.log(` ${chalk.green("✔")} Generated builders`);
const validatorsFile = path.join(baseDir, "validators/generated/index.js");
writeFile(validatorsFile, format(generateValidators(), validatorsFile));
console.log(` ${chalk.green("✔")} Generated validators`);
const assertsFile = path.join(baseDir, "asserts/generated/index.js");
writeFile(assertsFile, format(generateAsserts(), assertsFile));
console.log(` ${chalk.green("✔")} Generated asserts`);
const constantsFile = path.join(baseDir, "constants/generated/index.js");
writeFile(constantsFile, format(generateConstants(), constantsFile));
console.log(` ${chalk.green("✔")} Generated constants`);

View File

@@ -98,7 +98,7 @@ for (const type in t.NODE_FIELDS) {
// Flow chokes on super() and import() :/
if (type !== "Super" && type !== "Import") {
lines.push(
`declare function ${toFunctionName(type)}(${args.join(
`declare export function ${toFunctionName(type)}(${args.join(
", "
)}): ${NODE_PREFIX}${type};`
);
@@ -113,81 +113,94 @@ for (const type in t.NODE_FIELDS) {
}
}
for (let i = 0; i < t.TYPES.length; i++) {
let decl = `declare function is${t.TYPES[i]}(node: ?Object, opts?: ?Object): boolean`;
for (const typeName of t.TYPES) {
const isDeprecated = !!t.DEPRECATED_KEYS[typeName];
const realName = isDeprecated ? t.DEPRECATED_KEYS[typeName] : typeName;
if (t.NODE_FIELDS[t.TYPES[i]]) {
decl += ` %checks (node instanceof ${NODE_PREFIX}${t.TYPES[i]})`;
let decl = `declare export function is${typeName}(node: ?Object, opts?: ?Object): boolean`;
if (t.NODE_FIELDS[realName]) {
decl += ` %checks (node instanceof ${NODE_PREFIX}${realName})`;
}
lines.push(decl);
lines.push(
`declare export function assert${typeName}(node: ?Object, opts?: ?Object): void`
);
}
lines.push(
`declare export var VISITOR_KEYS: { [type: string]: string[] }`,
// assert/
`declare export function assertNode(obj: any): void`,
// builders/
// eslint-disable-next-line max-len
`declare function createTypeAnnotationBasedOnTypeof(type: 'string' | 'number' | 'undefined' | 'boolean' | 'function' | 'object' | 'symbol'): ${NODE_PREFIX}TypeAnnotation`,
`declare export function createTypeAnnotationBasedOnTypeof(type: 'string' | 'number' | 'undefined' | 'boolean' | 'function' | 'object' | 'symbol'): ${NODE_PREFIX}TypeAnnotation`,
// eslint-disable-next-line max-len
`declare function createUnionTypeAnnotation(types: Array<${NODE_PREFIX}FlowType>): ${NODE_PREFIX}UnionTypeAnnotation`,
`declare export function createUnionTypeAnnotation(types: Array<${NODE_PREFIX}FlowType>): ${NODE_PREFIX}UnionTypeAnnotation`,
// eslint-disable-next-line max-len
`declare function createFlowUnionType(types: Array<${NODE_PREFIX}FlowType>): ${NODE_PREFIX}UnionTypeAnnotation`,
`declare export function createFlowUnionType(types: Array<${NODE_PREFIX}FlowType>): ${NODE_PREFIX}UnionTypeAnnotation`,
// this smells like "internal API"
// eslint-disable-next-line max-len
`declare function buildChildren(node: { children: Array<${NODE_PREFIX}JSXText | ${NODE_PREFIX}JSXExpressionContainer | ${NODE_PREFIX}JSXSpreadChild | ${NODE_PREFIX}JSXElement | ${NODE_PREFIX}JSXFragment | ${NODE_PREFIX}JSXEmptyExpression> }): Array<${NODE_PREFIX}JSXText | ${NODE_PREFIX}JSXExpressionContainer | ${NODE_PREFIX}JSXSpreadChild | ${NODE_PREFIX}JSXElement | ${NODE_PREFIX}JSXFragment>`,
`declare export function buildChildren(node: { children: Array<${NODE_PREFIX}JSXText | ${NODE_PREFIX}JSXExpressionContainer | ${NODE_PREFIX}JSXSpreadChild | ${NODE_PREFIX}JSXElement | ${NODE_PREFIX}JSXFragment | ${NODE_PREFIX}JSXEmptyExpression> }): Array<${NODE_PREFIX}JSXText | ${NODE_PREFIX}JSXExpressionContainer | ${NODE_PREFIX}JSXSpreadChild | ${NODE_PREFIX}JSXElement | ${NODE_PREFIX}JSXFragment>`,
// clone/
`declare function clone<T>(n: T): T;`,
`declare function cloneDeep<T>(n: T): T;`,
`declare function cloneDeepWithoutLoc<T>(n: T): T;`,
`declare function cloneNode<T>(n: T, deep?: boolean, withoutLoc?: boolean): T;`,
`declare function cloneWithoutLoc<T>(n: T): T;`,
`declare export function clone<T>(n: T): T;`,
`declare export function cloneDeep<T>(n: T): T;`,
`declare export function cloneDeepWithoutLoc<T>(n: T): T;`,
`declare export function cloneNode<T>(n: T, deep?: boolean, withoutLoc?: boolean): T;`,
`declare export function cloneWithoutLoc<T>(n: T): T;`,
// comments/
`declare type CommentTypeShorthand = 'leading' | 'inner' | 'trailing'`,
// eslint-disable-next-line max-len
`declare function addComment<T: Node>(node: T, type: CommentTypeShorthand, content: string, line?: boolean): T`,
`declare export function addComment<T: BabelNode>(node: T, type: CommentTypeShorthand, content: string, line?: boolean): T`,
// eslint-disable-next-line max-len
`declare function addComments<T: Node>(node: T, type: CommentTypeShorthand, comments: Array<Comment>): T`,
`declare function inheritInnerComments(node: Node, parent: Node): void`,
`declare function inheritLeadingComments(node: Node, parent: Node): void`,
`declare function inheritsComments<T: Node>(node: T, parent: Node): void`,
`declare function inheritTrailingComments(node: Node, parent: Node): void`,
`declare function removeComments<T: Node>(node: T): T`,
`declare export function addComments<T: BabelNode>(node: T, type: CommentTypeShorthand, comments: Array<Comment>): T`,
`declare export function inheritInnerComments(node: BabelNode, parent: BabelNode): void`,
`declare export function inheritLeadingComments(node: BabelNode, parent: BabelNode): void`,
`declare export function inheritsComments<T: BabelNode>(node: T, parent: BabelNode): void`,
`declare export function inheritTrailingComments(node: BabelNode, parent: BabelNode): void`,
`declare export function removeComments<T: BabelNode>(node: T): T`,
// converters/
`declare function ensureBlock(node: ${NODE_PREFIX}, key: string): ${NODE_PREFIX}BlockStatement`,
`declare function toBindingIdentifierName(name?: ?string): string`,
`declare export function ensureBlock(node: ${NODE_PREFIX}, key: string): ${NODE_PREFIX}BlockStatement`,
`declare export function toBindingIdentifierName(name?: ?string): string`,
// eslint-disable-next-line max-len
`declare function toBlock(node: ${NODE_PREFIX}Statement | ${NODE_PREFIX}Expression, parent?: ${NODE_PREFIX}Function | null): ${NODE_PREFIX}BlockStatement`,
`declare export function toBlock(node: ${NODE_PREFIX}Statement | ${NODE_PREFIX}Expression, parent?: ${NODE_PREFIX}Function | null): ${NODE_PREFIX}BlockStatement`,
// eslint-disable-next-line max-len
`declare function toComputedKey(node: ${NODE_PREFIX}Method | ${NODE_PREFIX}Property, key?: ${NODE_PREFIX}Expression | ${NODE_PREFIX}Identifier): ${NODE_PREFIX}Expression`,
`declare export function toComputedKey(node: ${NODE_PREFIX}Method | ${NODE_PREFIX}Property, key?: ${NODE_PREFIX}Expression | ${NODE_PREFIX}Identifier): ${NODE_PREFIX}Expression`,
// eslint-disable-next-line max-len
`declare function toExpression(node: ${NODE_PREFIX}ExpressionStatement | ${NODE_PREFIX}Expression | ${NODE_PREFIX}Class | ${NODE_PREFIX}Function): ${NODE_PREFIX}Expression`,
`declare function toIdentifier(name?: ?string): string`,
`declare export function toExpression(node: ${NODE_PREFIX}ExpressionStatement | ${NODE_PREFIX}Expression | ${NODE_PREFIX}Class | ${NODE_PREFIX}Function): ${NODE_PREFIX}Expression`,
`declare export function toIdentifier(name?: ?string): string`,
// eslint-disable-next-line max-len
`declare function toKeyAlias(node: ${NODE_PREFIX}Method | ${NODE_PREFIX}Property, key?: ${NODE_PREFIX}): string`,
`declare export function toKeyAlias(node: ${NODE_PREFIX}Method | ${NODE_PREFIX}Property, key?: ${NODE_PREFIX}): string`,
// toSequenceExpression relies on types that aren't declared in flow
// eslint-disable-next-line max-len
`declare function toStatement(node: ${NODE_PREFIX}Statement | ${NODE_PREFIX}Class | ${NODE_PREFIX}Function | ${NODE_PREFIX}AssignmentExpression, ignore?: boolean): ${NODE_PREFIX}Statement | void`,
`declare function valueToNode(value: any): ${NODE_PREFIX}Expression`,
`declare export function toStatement(node: ${NODE_PREFIX}Statement | ${NODE_PREFIX}Class | ${NODE_PREFIX}Function | ${NODE_PREFIX}AssignmentExpression, ignore?: boolean): ${NODE_PREFIX}Statement | void`,
`declare export function valueToNode(value: any): ${NODE_PREFIX}Expression`,
// modifications/
// eslint-disable-next-line max-len
`declare function removeTypeDuplicates(types: Array<${NODE_PREFIX}FlowType>): Array<${NODE_PREFIX}FlowType>`,
`declare export function removeTypeDuplicates(types: Array<${NODE_PREFIX}FlowType>): Array<${NODE_PREFIX}FlowType>`,
// eslint-disable-next-line max-len
`declare function appendToMemberExpression(member: ${NODE_PREFIX}MemberExpression, append: ${NODE_PREFIX}, computed?: boolean): ${NODE_PREFIX}MemberExpression`,
`declare export function appendToMemberExpression(member: ${NODE_PREFIX}MemberExpression, append: ${NODE_PREFIX}, computed?: boolean): ${NODE_PREFIX}MemberExpression`,
// eslint-disable-next-line max-len
`declare function inherits<T: Node>(child: T, parent: ${NODE_PREFIX} | null | void): T`,
`declare export function inherits<T: BabelNode>(child: T, parent: ${NODE_PREFIX} | null | void): T`,
// eslint-disable-next-line max-len
`declare function prependToMemberExpression(member: ${NODE_PREFIX}MemberExpression, prepend: ${NODE_PREFIX}Expression): ${NODE_PREFIX}MemberExpression`,
`declare function removeProperties<T>(n: T, opts: ?{}): void;`,
`declare function removePropertiesDeep<T>(n: T, opts: ?{}): T;`,
`declare export function prependToMemberExpression(member: ${NODE_PREFIX}MemberExpression, prepend: ${NODE_PREFIX}Expression): ${NODE_PREFIX}MemberExpression`,
`declare export function removeProperties<T>(n: T, opts: ?{}): void;`,
`declare export function removePropertiesDeep<T>(n: T, opts: ?{}): T;`,
// retrievers/
// eslint-disable-next-line max-len
`declare function getBindingIdentifiers(node: ${NODE_PREFIX}, duplicates: boolean, outerOnly?: boolean): { [key: string]: ${NODE_PREFIX}Identifier | Array<${NODE_PREFIX}Identifier> }`,
`declare export var getBindingIdentifiers: {
(node: ${NODE_PREFIX}, duplicates?: boolean, outerOnly?: boolean): { [key: string]: ${NODE_PREFIX}Identifier | Array<${NODE_PREFIX}Identifier> },
keys: { [type: string]: string[] }
}`,
// eslint-disable-next-line max-len
`declare function getOuterBindingIdentifiers(node: Node, duplicates: boolean): { [key: string]: ${NODE_PREFIX}Identifier | Array<${NODE_PREFIX}Identifier> }`,
`declare export function getOuterBindingIdentifiers(node: BabelNode, duplicates?: boolean): { [key: string]: ${NODE_PREFIX}Identifier | Array<${NODE_PREFIX}Identifier> }`,
// traverse/
`declare type TraversalAncestors = Array<{
@@ -201,36 +214,36 @@ lines.push(
exit?: TraversalHandler<T>,
};`.replace(/(^|\n) {2}/g, "$1"),
// eslint-disable-next-line
`declare function traverse<T>(n: BabelNode, TraversalHandler<T> | TraversalHandlers<T>, state?: T): void;`,
`declare function traverseFast<T>(n: Node, h: TraversalHandler<T>, state?: T): void;`,
`declare export function traverse<T>(n: BabelNode, TraversalHandler<T> | TraversalHandlers<T>, state?: T): void;`,
`declare export function traverseFast<T>(n: BabelNode, h: TraversalHandler<T>, state?: T): void;`,
// utils/
// cleanJSXElementLiteralChild is not exported
// inherit is not exported
`declare function shallowEqual(actual: Object, expected: Object): boolean`,
`declare export function shallowEqual(actual: Object, expected: Object): boolean`,
// validators/
// eslint-disable-next-line max-len
`declare function buildMatchMemberExpression(match: string, allowPartial?: boolean): (?BabelNode) => boolean`,
`declare function is(type: string, n: BabelNode, opts: Object): boolean;`,
`declare function isBinding(node: BabelNode, parent: BabelNode, grandparent?: BabelNode): boolean`,
`declare function isBlockScoped(node: BabelNode): boolean`,
`declare function isImmutable(node: BabelNode): boolean`,
`declare function isLet(node: BabelNode): boolean`,
`declare function isNode(node: ?Object): boolean`,
`declare function isNodesEquivalent(a: any, b: any): boolean`,
`declare function isPlaceholderType(placeholderType: string, targetType: string): boolean`,
`declare function isReferenced(node: BabelNode, parent: BabelNode, grandparent?: BabelNode): boolean`,
`declare function isScope(node: BabelNode, parent: BabelNode): boolean`,
`declare function isSpecifierDefault(specifier: BabelNodeModuleSpecifier): boolean`,
`declare function isType(nodetype: ?string, targetType: string): boolean`,
`declare function isValidES3Identifier(name: string): boolean`,
`declare function isValidES3Identifier(name: string): boolean`,
`declare function isValidIdentifier(name: string): boolean`,
`declare function isVar(node: BabelNode): boolean`,
`declare export function buildMatchMemberExpression(match: string, allowPartial?: boolean): (?BabelNode) => boolean`,
`declare export function is(type: string, n: BabelNode, opts: Object): boolean;`,
`declare export function isBinding(node: BabelNode, parent: BabelNode, grandparent?: BabelNode): boolean`,
`declare export function isBlockScoped(node: BabelNode): boolean`,
`declare export function isImmutable(node: BabelNode): boolean`,
`declare export function isLet(node: BabelNode): boolean`,
`declare export function isNode(node: ?Object): boolean`,
`declare export function isNodesEquivalent(a: any, b: any): boolean`,
`declare export function isPlaceholderType(placeholderType: string, targetType: string): boolean`,
`declare export function isReferenced(node: BabelNode, parent: BabelNode, grandparent?: BabelNode): boolean`,
`declare export function isScope(node: BabelNode, parent: BabelNode): boolean`,
`declare export function isSpecifierDefault(specifier: BabelNodeModuleSpecifier): boolean`,
`declare export function isType(nodetype: ?string, targetType: string): boolean`,
`declare export function isValidES3Identifier(name: string): boolean`,
`declare export function isValidES3Identifier(name: string): boolean`,
`declare export function isValidIdentifier(name: string): boolean`,
`declare export function isVar(node: BabelNode): boolean`,
// eslint-disable-next-line max-len
`declare function matchesPattern(node: ?BabelNode, match: string | Array<string>, allowPartial?: boolean): boolean`,
`declare function validate(n: BabelNode, key: string, value: mixed): void;`
`declare export function matchesPattern(node: ?BabelNode, match: string | Array<string>, allowPartial?: boolean): boolean`,
`declare export function validate(n: BabelNode, key: string, value: mixed): void;`
);
for (const type in t.FLIPPED_ALIAS_KEYS) {

View File

@@ -1,44 +0,0 @@
"use strict";
const definitions = require("../../lib/definitions");
function addAssertHelper(type) {
return `export function assert${type}(node: Object, opts?: Object = {}): void {
assert("${type}", node, opts) }
`;
}
module.exports = function generateAsserts() {
let output = `// @flow
/*
* This file is auto-generated! Do not modify it directly.
* To re-generate run 'make build'
*/
import is from "../../validators/is";
function assert(type: string, node: Object, opts?: Object): void {
if (!is(type, node, opts)) {
throw new Error(
\`Expected type "\${type}" with option \${JSON.stringify((opts: any))}, \` +
\`but instead got "\${node.type}".\`,
);
}
}\n\n`;
Object.keys(definitions.VISITOR_KEYS).forEach(type => {
output += addAssertHelper(type);
});
Object.keys(definitions.FLIPPED_ALIAS_KEYS).forEach(type => {
output += addAssertHelper(type);
});
Object.keys(definitions.DEPRECATED_KEYS).forEach(type => {
const newType = definitions.DEPRECATED_KEYS[type];
output += `export function assert${type}(node: Object, opts: Object): void {
console.trace("The node type ${type} has been renamed to ${newType}");
assert("${type}", node, opts);
}\n`;
});
return output;
};

View File

@@ -1,57 +0,0 @@
"use strict";
const definitions = require("../../lib/definitions");
const formatBuilderName = require("../utils/formatBuilderName");
const lowerFirst = require("../utils/lowerFirst");
module.exports = function generateBuilders() {
let output = `// @flow
/*
* This file is auto-generated! Do not modify it directly.
* To re-generate run 'make build'
*/
import builder from "../builder";\n\n`;
const reservedNames = new Set(["super", "import"]);
Object.keys(definitions.BUILDER_KEYS).forEach(type => {
const formatedBuilderName = formatBuilderName(type);
const formatedBuilderNameLocal = reservedNames.has(formatedBuilderName)
? `_${formatedBuilderName}`
: formatedBuilderName;
output += `${
formatedBuilderNameLocal === formatedBuilderName ? "export " : ""
}function ${formatedBuilderNameLocal}(...args: Array<any>): Object { return builder("${type}", ...args); }\n`;
// This is needed for backwards compatibility.
// arrayExpression -> ArrayExpression
output += `export { ${formatedBuilderNameLocal} as ${type} };\n`;
if (formatedBuilderNameLocal !== formatedBuilderName) {
output += `export { ${formatedBuilderNameLocal} as ${formatedBuilderName} };\n`;
}
// This is needed for backwards compatibility.
// It should be removed in the next major version.
// JSXIdentifier -> jSXIdentifier
if (/^[A-Z]{2}/.test(type)) {
output += `export { ${formatedBuilderNameLocal} as ${lowerFirst(
type
)} }\n`;
}
});
Object.keys(definitions.DEPRECATED_KEYS).forEach(type => {
const newType = definitions.DEPRECATED_KEYS[type];
output += `export function ${type}(...args: Array<any>): Object {
console.trace("The node type ${type} has been renamed to ${newType}");
return builder("${type}", ...args);
}
export { ${type} as ${formatBuilderName(type)} };\n`;
// This is needed for backwards compatibility.
// It should be removed in the next major version.
// JSXIdentifier -> jSXIdentifier
if (/^[A-Z]{2}/.test(type)) {
output += `export { ${type} as ${lowerFirst(type)} }\n`;
}
});
return output;
};

View File

@@ -1,17 +0,0 @@
"use strict";
const definitions = require("../../lib/definitions");
module.exports = function generateConstants() {
let output = `// @flow
/*
* This file is auto-generated! Do not modify it directly.
* To re-generate run 'make build'
*/
import { FLIPPED_ALIAS_KEYS } from "../../definitions";\n\n`;
Object.keys(definitions.FLIPPED_ALIAS_KEYS).forEach(type => {
output += `export const ${type.toUpperCase()}_TYPES = FLIPPED_ALIAS_KEYS["${type}"];\n`;
});
return output;
};

View File

@@ -1,78 +0,0 @@
"use strict";
const definitions = require("../../lib/definitions");
const has = Function.call.bind(Object.prototype.hasOwnProperty);
function joinComparisons(leftArr, right) {
return (
leftArr.map(JSON.stringify).join(` === ${right} || `) + ` === ${right}`
);
}
function addIsHelper(type, aliasKeys, deprecated) {
const targetType = JSON.stringify(type);
let aliasSource = "";
if (aliasKeys) {
aliasSource = " || " + joinComparisons(aliasKeys, "nodeType");
}
let placeholderSource = "";
const placeholderTypes = [];
if (
definitions.PLACEHOLDERS.includes(type) &&
has(definitions.FLIPPED_ALIAS_KEYS, type)
) {
placeholderTypes.push(type);
}
if (has(definitions.PLACEHOLDERS_FLIPPED_ALIAS, type)) {
placeholderTypes.push(...definitions.PLACEHOLDERS_FLIPPED_ALIAS[type]);
}
if (placeholderTypes.length > 0) {
placeholderSource =
' || nodeType === "Placeholder" && (' +
joinComparisons(placeholderTypes, "node.expectedNode") +
")";
}
return `export function is${type}(node: ?Object, opts?: Object): boolean {
${deprecated || ""}
if (!node) return false;
const nodeType = node.type;
if (nodeType === ${targetType}${aliasSource}${placeholderSource}) {
if (typeof opts === "undefined") {
return true;
} else {
return shallowEqual(node, opts);
}
}
return false;
}
`;
}
module.exports = function generateValidators() {
let output = `// @flow
/*
* This file is auto-generated! Do not modify it directly.
* To re-generate run 'make build'
*/
import shallowEqual from "../../utils/shallowEqual";\n\n`;
Object.keys(definitions.VISITOR_KEYS).forEach(type => {
output += addIsHelper(type);
});
Object.keys(definitions.FLIPPED_ALIAS_KEYS).forEach(type => {
output += addIsHelper(type, definitions.FLIPPED_ALIAS_KEYS[type]);
});
Object.keys(definitions.DEPRECATED_KEYS).forEach(type => {
const newType = definitions.DEPRECATED_KEYS[type];
const deprecated = `console.trace("The node type ${type} has been renamed to ${newType}");`;
output += addIsHelper(type, null, deprecated);
});
return output;
};

Some files were not shown because too many files have changed in this diff Show More