forked from tsai/budibase
1267 changed files with 43 additions and 69412 deletions
@ -1,6 +1,43 @@ |
|||||
node_modules/ |
|
||||
myapps/ |
# Logs |
||||
config.js |
logs |
||||
/builder/* |
*.log |
||||
!/builder/assets/ |
|
||||
public/ |
# Runtime data |
||||
|
pids |
||||
|
*.pid |
||||
|
*.seed |
||||
|
|
||||
|
# Directory for instrumented libs generated by jscoverage/JSCover |
||||
|
lib-cov |
||||
|
|
||||
|
# Coverage directory used by tools like istanbul |
||||
|
coverage |
||||
|
|
||||
|
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) |
||||
|
.grunt |
||||
|
|
||||
|
# node-waf configuration |
||||
|
.lock-wscript |
||||
|
|
||||
|
# Compiled binary addons (http://nodejs.org/api/addons.html) |
||||
|
build/Release |
||||
|
.eslintcache |
||||
|
|
||||
|
# Dependency directory |
||||
|
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git |
||||
|
node_modules |
||||
|
node_modules_ubuntu |
||||
|
node_modules_windows |
||||
|
|
||||
|
# OSX |
||||
|
.DS_Store |
||||
|
|
||||
|
# flow-typed |
||||
|
flow-typed/npm/* |
||||
|
!flow-typed/npm/module_vx.x.x.js |
||||
|
|
||||
|
|
||||
|
.idea |
||||
|
npm-debug.log.* |
||||
|
dist |
||||
|
|||||
@ -1 +0,0 @@ |
|||||
../@babel/cli/bin/babel.js |
|
||||
@ -1 +0,0 @@ |
|||||
../@babel/cli/bin/babel-external-helpers.js |
|
||||
@ -1 +0,0 @@ |
|||||
../cross-env/dist/bin/cross-env.js |
|
||||
@ -1 +0,0 @@ |
|||||
../cross-env/dist/bin/cross-env-shell.js |
|
||||
@ -1 +0,0 @@ |
|||||
../jest/bin/jest.js |
|
||||
@ -1 +0,0 @@ |
|||||
../rimraf/bin.js |
|
||||
@ -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. |
|
||||
@ -1,19 +0,0 @@ |
|||||
# @babel/template |
|
||||
|
|
||||
> Generate an AST from a string template. |
|
||||
|
|
||||
See our website [@babel/template](https://babeljs.io/docs/en/next/babel-template.html) for more information or the [issues](https://github.com/babel/babel/issues?utf8=%E2%9C%93&q=is%3Aissue+label%3A%22pkg%3A%20template%22+is%3Aopen) associated with this package. |
|
||||
|
|
||||
## Install |
|
||||
|
|
||||
Using npm: |
|
||||
|
|
||||
```sh |
|
||||
npm install --save-dev @babel/template |
|
||||
``` |
|
||||
|
|
||||
or using yarn: |
|
||||
|
|
||||
```sh |
|
||||
yarn add @babel/template --dev |
|
||||
``` |
|
||||
@ -1,83 +0,0 @@ |
|||||
"use strict"; |
|
||||
|
|
||||
Object.defineProperty(exports, "__esModule", { |
|
||||
value: true |
|
||||
}); |
|
||||
exports.default = createTemplateBuilder; |
|
||||
|
|
||||
var _options = require("./options"); |
|
||||
|
|
||||
var _string = _interopRequireDefault(require("./string")); |
|
||||
|
|
||||
var _literal = _interopRequireDefault(require("./literal")); |
|
||||
|
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
|
||||
|
|
||||
const NO_PLACEHOLDER = (0, _options.validate)({ |
|
||||
placeholderPattern: false |
|
||||
}); |
|
||||
|
|
||||
function createTemplateBuilder(formatter, defaultOpts) { |
|
||||
const templateFnCache = new WeakMap(); |
|
||||
const templateAstCache = new WeakMap(); |
|
||||
const cachedOpts = defaultOpts || (0, _options.validate)(null); |
|
||||
return Object.assign((tpl, ...args) => { |
|
||||
if (typeof tpl === "string") { |
|
||||
if (args.length > 1) throw new Error("Unexpected extra params."); |
|
||||
return extendedTrace((0, _string.default)(formatter, tpl, (0, _options.merge)(cachedOpts, (0, _options.validate)(args[0])))); |
|
||||
} else if (Array.isArray(tpl)) { |
|
||||
let builder = templateFnCache.get(tpl); |
|
||||
|
|
||||
if (!builder) { |
|
||||
builder = (0, _literal.default)(formatter, tpl, cachedOpts); |
|
||||
templateFnCache.set(tpl, builder); |
|
||||
} |
|
||||
|
|
||||
return extendedTrace(builder(args)); |
|
||||
} else if (typeof tpl === "object" && tpl) { |
|
||||
if (args.length > 0) throw new Error("Unexpected extra params."); |
|
||||
return createTemplateBuilder(formatter, (0, _options.merge)(cachedOpts, (0, _options.validate)(tpl))); |
|
||||
} |
|
||||
|
|
||||
throw new Error(`Unexpected template param ${typeof tpl}`); |
|
||||
}, { |
|
||||
ast: (tpl, ...args) => { |
|
||||
if (typeof tpl === "string") { |
|
||||
if (args.length > 1) throw new Error("Unexpected extra params."); |
|
||||
return (0, _string.default)(formatter, tpl, (0, _options.merge)((0, _options.merge)(cachedOpts, (0, _options.validate)(args[0])), NO_PLACEHOLDER))(); |
|
||||
} else if (Array.isArray(tpl)) { |
|
||||
let builder = templateAstCache.get(tpl); |
|
||||
|
|
||||
if (!builder) { |
|
||||
builder = (0, _literal.default)(formatter, tpl, (0, _options.merge)(cachedOpts, NO_PLACEHOLDER)); |
|
||||
templateAstCache.set(tpl, builder); |
|
||||
} |
|
||||
|
|
||||
return builder(args)(); |
|
||||
} |
|
||||
|
|
||||
throw new Error(`Unexpected template param ${typeof tpl}`); |
|
||||
} |
|
||||
}); |
|
||||
} |
|
||||
|
|
||||
function extendedTrace(fn) { |
|
||||
let rootStack = ""; |
|
||||
|
|
||||
try { |
|
||||
throw new Error(); |
|
||||
} catch (error) { |
|
||||
if (error.stack) { |
|
||||
rootStack = error.stack.split("\n").slice(3).join("\n"); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
return arg => { |
|
||||
try { |
|
||||
return fn(arg); |
|
||||
} catch (err) { |
|
||||
err.stack += `\n =============\n${rootStack}`; |
|
||||
throw err; |
|
||||
} |
|
||||
}; |
|
||||
} |
|
||||
@ -1,63 +0,0 @@ |
|||||
"use strict"; |
|
||||
|
|
||||
Object.defineProperty(exports, "__esModule", { |
|
||||
value: true |
|
||||
}); |
|
||||
exports.program = exports.expression = exports.statement = exports.statements = exports.smart = void 0; |
|
||||
|
|
||||
function makeStatementFormatter(fn) { |
|
||||
return { |
|
||||
code: str => `/* @babel/template */;\n${str}`, |
|
||||
validate: () => {}, |
|
||||
unwrap: ast => { |
|
||||
return fn(ast.program.body.slice(1)); |
|
||||
} |
|
||||
}; |
|
||||
} |
|
||||
|
|
||||
const smart = makeStatementFormatter(body => { |
|
||||
if (body.length > 1) { |
|
||||
return body; |
|
||||
} else { |
|
||||
return body[0]; |
|
||||
} |
|
||||
}); |
|
||||
exports.smart = smart; |
|
||||
const statements = makeStatementFormatter(body => body); |
|
||||
exports.statements = statements; |
|
||||
const statement = makeStatementFormatter(body => { |
|
||||
if (body.length === 0) { |
|
||||
throw new Error("Found nothing to return."); |
|
||||
} |
|
||||
|
|
||||
if (body.length > 1) { |
|
||||
throw new Error("Found multiple statements but wanted one"); |
|
||||
} |
|
||||
|
|
||||
return body[0]; |
|
||||
}); |
|
||||
exports.statement = statement; |
|
||||
const expression = { |
|
||||
code: str => `(\n${str}\n)`, |
|
||||
validate: ({ |
|
||||
program |
|
||||
}) => { |
|
||||
if (program.body.length > 1) { |
|
||||
throw new Error("Found multiple statements but wanted one"); |
|
||||
} |
|
||||
|
|
||||
const expression = program.body[0].expression; |
|
||||
|
|
||||
if (expression.start === 0) { |
|
||||
throw new Error("Parse result included parens."); |
|
||||
} |
|
||||
}, |
|
||||
unwrap: ast => ast.program.body[0].expression |
|
||||
}; |
|
||||
exports.expression = expression; |
|
||||
const program = { |
|
||||
code: str => str, |
|
||||
validate: () => {}, |
|
||||
unwrap: ast => ast.program |
|
||||
}; |
|
||||
exports.program = program; |
|
||||
@ -1,38 +0,0 @@ |
|||||
"use strict"; |
|
||||
|
|
||||
Object.defineProperty(exports, "__esModule", { |
|
||||
value: true |
|
||||
}); |
|
||||
exports.default = exports.program = exports.expression = exports.statements = exports.statement = exports.smart = void 0; |
|
||||
|
|
||||
var formatters = _interopRequireWildcard(require("./formatters")); |
|
||||
|
|
||||
var _builder = _interopRequireDefault(require("./builder")); |
|
||||
|
|
||||
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; } |
|
||||
|
|
||||
const smart = (0, _builder.default)(formatters.smart); |
|
||||
exports.smart = smart; |
|
||||
const statement = (0, _builder.default)(formatters.statement); |
|
||||
exports.statement = statement; |
|
||||
const statements = (0, _builder.default)(formatters.statements); |
|
||||
exports.statements = statements; |
|
||||
const expression = (0, _builder.default)(formatters.expression); |
|
||||
exports.expression = expression; |
|
||||
const program = (0, _builder.default)(formatters.program); |
|
||||
exports.program = program; |
|
||||
|
|
||||
var _default = Object.assign(smart.bind(undefined), { |
|
||||
smart, |
|
||||
statement, |
|
||||
statements, |
|
||||
expression, |
|
||||
program, |
|
||||
ast: smart.ast |
|
||||
}); |
|
||||
|
|
||||
exports.default = _default; |
|
||||
@ -1,82 +0,0 @@ |
|||||
"use strict"; |
|
||||
|
|
||||
Object.defineProperty(exports, "__esModule", { |
|
||||
value: true |
|
||||
}); |
|
||||
exports.default = literalTemplate; |
|
||||
|
|
||||
var _options = require("./options"); |
|
||||
|
|
||||
var _parse = _interopRequireDefault(require("./parse")); |
|
||||
|
|
||||
var _populate = _interopRequireDefault(require("./populate")); |
|
||||
|
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
|
||||
|
|
||||
function literalTemplate(formatter, tpl, opts) { |
|
||||
const { |
|
||||
metadata, |
|
||||
names |
|
||||
} = buildLiteralData(formatter, tpl, opts); |
|
||||
return arg => { |
|
||||
const defaultReplacements = arg.reduce((acc, replacement, i) => { |
|
||||
acc[names[i]] = replacement; |
|
||||
return acc; |
|
||||
}, {}); |
|
||||
return arg => { |
|
||||
const replacements = (0, _options.normalizeReplacements)(arg); |
|
||||
|
|
||||
if (replacements) { |
|
||||
Object.keys(replacements).forEach(key => { |
|
||||
if (Object.prototype.hasOwnProperty.call(defaultReplacements, key)) { |
|
||||
throw new Error("Unexpected replacement overlap."); |
|
||||
} |
|
||||
}); |
|
||||
} |
|
||||
|
|
||||
return formatter.unwrap((0, _populate.default)(metadata, replacements ? Object.assign(replacements, defaultReplacements) : defaultReplacements)); |
|
||||
}; |
|
||||
}; |
|
||||
} |
|
||||
|
|
||||
function buildLiteralData(formatter, tpl, opts) { |
|
||||
let names; |
|
||||
let nameSet; |
|
||||
let metadata; |
|
||||
let prefix = ""; |
|
||||
|
|
||||
do { |
|
||||
prefix += "$"; |
|
||||
const result = buildTemplateCode(tpl, prefix); |
|
||||
names = result.names; |
|
||||
nameSet = new Set(names); |
|
||||
metadata = (0, _parse.default)(formatter, formatter.code(result.code), { |
|
||||
parser: opts.parser, |
|
||||
placeholderWhitelist: new Set(result.names.concat(opts.placeholderWhitelist ? Array.from(opts.placeholderWhitelist) : [])), |
|
||||
placeholderPattern: opts.placeholderPattern, |
|
||||
preserveComments: opts.preserveComments, |
|
||||
syntacticPlaceholders: opts.syntacticPlaceholders |
|
||||
}); |
|
||||
} while (metadata.placeholders.some(placeholder => placeholder.isDuplicate && nameSet.has(placeholder.name))); |
|
||||
|
|
||||
return { |
|
||||
metadata, |
|
||||
names |
|
||||
}; |
|
||||
} |
|
||||
|
|
||||
function buildTemplateCode(tpl, prefix) { |
|
||||
const names = []; |
|
||||
let code = tpl[0]; |
|
||||
|
|
||||
for (let i = 1; i < tpl.length; i++) { |
|
||||
const value = `${prefix}${i - 1}`; |
|
||||
names.push(value); |
|
||||
code += value + tpl[i]; |
|
||||
} |
|
||||
|
|
||||
return { |
|
||||
names, |
|
||||
code |
|
||||
}; |
|
||||
} |
|
||||
@ -1,82 +0,0 @@ |
|||||
"use strict"; |
|
||||
|
|
||||
Object.defineProperty(exports, "__esModule", { |
|
||||
value: true |
|
||||
}); |
|
||||
exports.merge = merge; |
|
||||
exports.validate = validate; |
|
||||
exports.normalizeReplacements = normalizeReplacements; |
|
||||
|
|
||||
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } |
|
||||
|
|
||||
function merge(a, b) { |
|
||||
const { |
|
||||
placeholderWhitelist = a.placeholderWhitelist, |
|
||||
placeholderPattern = a.placeholderPattern, |
|
||||
preserveComments = a.preserveComments, |
|
||||
syntacticPlaceholders = a.syntacticPlaceholders |
|
||||
} = b; |
|
||||
return { |
|
||||
parser: Object.assign({}, a.parser, {}, b.parser), |
|
||||
placeholderWhitelist, |
|
||||
placeholderPattern, |
|
||||
preserveComments, |
|
||||
syntacticPlaceholders |
|
||||
}; |
|
||||
} |
|
||||
|
|
||||
function validate(opts) { |
|
||||
if (opts != null && typeof opts !== "object") { |
|
||||
throw new Error("Unknown template options."); |
|
||||
} |
|
||||
|
|
||||
const _ref = opts || {}, |
|
||||
{ |
|
||||
placeholderWhitelist, |
|
||||
placeholderPattern, |
|
||||
preserveComments, |
|
||||
syntacticPlaceholders |
|
||||
} = _ref, |
|
||||
parser = _objectWithoutPropertiesLoose(_ref, ["placeholderWhitelist", "placeholderPattern", "preserveComments", "syntacticPlaceholders"]); |
|
||||
|
|
||||
if (placeholderWhitelist != null && !(placeholderWhitelist instanceof Set)) { |
|
||||
throw new Error("'.placeholderWhitelist' must be a Set, null, or undefined"); |
|
||||
} |
|
||||
|
|
||||
if (placeholderPattern != null && !(placeholderPattern instanceof RegExp) && placeholderPattern !== false) { |
|
||||
throw new Error("'.placeholderPattern' must be a RegExp, false, null, or undefined"); |
|
||||
} |
|
||||
|
|
||||
if (preserveComments != null && typeof preserveComments !== "boolean") { |
|
||||
throw new Error("'.preserveComments' must be a boolean, null, or undefined"); |
|
||||
} |
|
||||
|
|
||||
if (syntacticPlaceholders != null && typeof syntacticPlaceholders !== "boolean") { |
|
||||
throw new Error("'.syntacticPlaceholders' must be a boolean, null, or undefined"); |
|
||||
} |
|
||||
|
|
||||
if (syntacticPlaceholders === true && (placeholderWhitelist != null || placeholderPattern != null)) { |
|
||||
throw new Error("'.placeholderWhitelist' and '.placeholderPattern' aren't compatible" + " with '.syntacticPlaceholders: true'"); |
|
||||
} |
|
||||
|
|
||||
return { |
|
||||
parser, |
|
||||
placeholderWhitelist: placeholderWhitelist || undefined, |
|
||||
placeholderPattern: placeholderPattern == null ? undefined : placeholderPattern, |
|
||||
preserveComments: preserveComments == null ? undefined : preserveComments, |
|
||||
syntacticPlaceholders: syntacticPlaceholders == null ? undefined : syntacticPlaceholders |
|
||||
}; |
|
||||
} |
|
||||
|
|
||||
function normalizeReplacements(replacements) { |
|
||||
if (Array.isArray(replacements)) { |
|
||||
return replacements.reduce((acc, replacement, i) => { |
|
||||
acc["$" + i] = replacement; |
|
||||
return acc; |
|
||||
}, {}); |
|
||||
} else if (typeof replacements === "object" || replacements == null) { |
|
||||
return replacements || undefined; |
|
||||
} |
|
||||
|
|
||||
throw new Error("Template replacements must be an array, object, null, or undefined"); |
|
||||
} |
|
||||
@ -1,171 +0,0 @@ |
|||||
"use strict"; |
|
||||
|
|
||||
Object.defineProperty(exports, "__esModule", { |
|
||||
value: true |
|
||||
}); |
|
||||
exports.default = parseAndBuildMetadata; |
|
||||
|
|
||||
var t = _interopRequireWildcard(require("@babel/types")); |
|
||||
|
|
||||
var _parser = require("@babel/parser"); |
|
||||
|
|
||||
var _codeFrame = require("@babel/code-frame"); |
|
||||
|
|
||||
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; } |
|
||||
|
|
||||
const PATTERN = /^[_$A-Z0-9]+$/; |
|
||||
|
|
||||
function parseAndBuildMetadata(formatter, code, opts) { |
|
||||
const ast = parseWithCodeFrame(code, opts.parser); |
|
||||
const { |
|
||||
placeholderWhitelist, |
|
||||
placeholderPattern, |
|
||||
preserveComments, |
|
||||
syntacticPlaceholders |
|
||||
} = opts; |
|
||||
t.removePropertiesDeep(ast, { |
|
||||
preserveComments |
|
||||
}); |
|
||||
formatter.validate(ast); |
|
||||
const syntactic = { |
|
||||
placeholders: [], |
|
||||
placeholderNames: new Set() |
|
||||
}; |
|
||||
const legacy = { |
|
||||
placeholders: [], |
|
||||
placeholderNames: new Set() |
|
||||
}; |
|
||||
const isLegacyRef = { |
|
||||
value: undefined |
|
||||
}; |
|
||||
t.traverse(ast, placeholderVisitorHandler, { |
|
||||
syntactic, |
|
||||
legacy, |
|
||||
isLegacyRef, |
|
||||
placeholderWhitelist, |
|
||||
placeholderPattern, |
|
||||
syntacticPlaceholders |
|
||||
}); |
|
||||
return Object.assign({ |
|
||||
ast |
|
||||
}, isLegacyRef.value ? legacy : syntactic); |
|
||||
} |
|
||||
|
|
||||
function placeholderVisitorHandler(node, ancestors, state) { |
|
||||
let name; |
|
||||
|
|
||||
if (t.isPlaceholder(node)) { |
|
||||
if (state.syntacticPlaceholders === false) { |
|
||||
throw new Error("%%foo%%-style placeholders can't be used when " + "'.syntacticPlaceholders' is false."); |
|
||||
} else { |
|
||||
name = node.name.name; |
|
||||
state.isLegacyRef.value = false; |
|
||||
} |
|
||||
} else if (state.isLegacyRef.value === false || state.syntacticPlaceholders) { |
|
||||
return; |
|
||||
} else if (t.isIdentifier(node) || t.isJSXIdentifier(node)) { |
|
||||
name = node.name; |
|
||||
state.isLegacyRef.value = true; |
|
||||
} else if (t.isStringLiteral(node)) { |
|
||||
name = node.value; |
|
||||
state.isLegacyRef.value = true; |
|
||||
} else { |
|
||||
return; |
|
||||
} |
|
||||
|
|
||||
if (!state.isLegacyRef.value && (state.placeholderPattern != null || state.placeholderWhitelist != null)) { |
|
||||
throw new Error("'.placeholderWhitelist' and '.placeholderPattern' aren't compatible" + " with '.syntacticPlaceholders: true'"); |
|
||||
} |
|
||||
|
|
||||
if (state.isLegacyRef.value && (state.placeholderPattern === false || !(state.placeholderPattern || PATTERN).test(name)) && (!state.placeholderWhitelist || !state.placeholderWhitelist.has(name))) { |
|
||||
return; |
|
||||
} |
|
||||
|
|
||||
ancestors = ancestors.slice(); |
|
||||
const { |
|
||||
node: parent, |
|
||||
key |
|
||||
} = ancestors[ancestors.length - 1]; |
|
||||
let type; |
|
||||
|
|
||||
if (t.isStringLiteral(node) || t.isPlaceholder(node, { |
|
||||
expectedNode: "StringLiteral" |
|
||||
})) { |
|
||||
type = "string"; |
|
||||
} else if (t.isNewExpression(parent) && key === "arguments" || t.isCallExpression(parent) && key === "arguments" || t.isFunction(parent) && key === "params") { |
|
||||
type = "param"; |
|
||||
} else if (t.isExpressionStatement(parent) && !t.isPlaceholder(node)) { |
|
||||
type = "statement"; |
|
||||
ancestors = ancestors.slice(0, -1); |
|
||||
} else if (t.isStatement(node) && t.isPlaceholder(node)) { |
|
||||
type = "statement"; |
|
||||
} else { |
|
||||
type = "other"; |
|
||||
} |
|
||||
|
|
||||
const { |
|
||||
placeholders, |
|
||||
placeholderNames |
|
||||
} = state.isLegacyRef.value ? state.legacy : state.syntactic; |
|
||||
placeholders.push({ |
|
||||
name, |
|
||||
type, |
|
||||
resolve: ast => resolveAncestors(ast, ancestors), |
|
||||
isDuplicate: placeholderNames.has(name) |
|
||||
}); |
|
||||
placeholderNames.add(name); |
|
||||
} |
|
||||
|
|
||||
function resolveAncestors(ast, ancestors) { |
|
||||
let parent = ast; |
|
||||
|
|
||||
for (let i = 0; i < ancestors.length - 1; i++) { |
|
||||
const { |
|
||||
key, |
|
||||
index |
|
||||
} = ancestors[i]; |
|
||||
|
|
||||
if (index === undefined) { |
|
||||
parent = parent[key]; |
|
||||
} else { |
|
||||
parent = parent[key][index]; |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
const { |
|
||||
key, |
|
||||
index |
|
||||
} = ancestors[ancestors.length - 1]; |
|
||||
return { |
|
||||
parent, |
|
||||
key, |
|
||||
index |
|
||||
}; |
|
||||
} |
|
||||
|
|
||||
function parseWithCodeFrame(code, parserOpts) { |
|
||||
parserOpts = Object.assign({ |
|
||||
allowReturnOutsideFunction: true, |
|
||||
allowSuperOutsideMethod: true, |
|
||||
sourceType: "module" |
|
||||
}, parserOpts, { |
|
||||
plugins: (parserOpts.plugins || []).concat("placeholders") |
|
||||
}); |
|
||||
|
|
||||
try { |
|
||||
return (0, _parser.parse)(code, parserOpts); |
|
||||
} catch (err) { |
|
||||
const loc = err.loc; |
|
||||
|
|
||||
if (loc) { |
|
||||
err.message += "\n" + (0, _codeFrame.codeFrameColumns)(code, { |
|
||||
start: loc |
|
||||
}); |
|
||||
err.code = "BABEL_TEMPLATE_PARSE_ERROR"; |
|
||||
} |
|
||||
|
|
||||
throw err; |
|
||||
} |
|
||||
} |
|
||||
@ -1,127 +0,0 @@ |
|||||
"use strict"; |
|
||||
|
|
||||
Object.defineProperty(exports, "__esModule", { |
|
||||
value: true |
|
||||
}); |
|
||||
exports.default = populatePlaceholders; |
|
||||
|
|
||||
var t = _interopRequireWildcard(require("@babel/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; } |
|
||||
|
|
||||
function populatePlaceholders(metadata, replacements) { |
|
||||
const ast = t.cloneNode(metadata.ast); |
|
||||
|
|
||||
if (replacements) { |
|
||||
metadata.placeholders.forEach(placeholder => { |
|
||||
if (!Object.prototype.hasOwnProperty.call(replacements, placeholder.name)) { |
|
||||
const placeholderName = placeholder.name; |
|
||||
throw new Error(`Error: No substitution given for "${placeholderName}". If this is not meant to be a
|
|
||||
placeholder you may want to consider passing one of the following options to @babel/template: |
|
||||
- { placeholderPattern: false, placeholderWhitelist: new Set(['${placeholderName}'])} |
|
||||
- { placeholderPattern: /^${placeholderName}$/ }`);
|
|
||||
} |
|
||||
}); |
|
||||
Object.keys(replacements).forEach(key => { |
|
||||
if (!metadata.placeholderNames.has(key)) { |
|
||||
throw new Error(`Unknown substitution "${key}" given`); |
|
||||
} |
|
||||
}); |
|
||||
} |
|
||||
|
|
||||
metadata.placeholders.slice().reverse().forEach(placeholder => { |
|
||||
try { |
|
||||
applyReplacement(placeholder, ast, replacements && replacements[placeholder.name] || null); |
|
||||
} catch (e) { |
|
||||
e.message = `@babel/template placeholder "${placeholder.name}": ${e.message}`; |
|
||||
throw e; |
|
||||
} |
|
||||
}); |
|
||||
return ast; |
|
||||
} |
|
||||
|
|
||||
function applyReplacement(placeholder, ast, replacement) { |
|
||||
if (placeholder.isDuplicate) { |
|
||||
if (Array.isArray(replacement)) { |
|
||||
replacement = replacement.map(node => t.cloneNode(node)); |
|
||||
} else if (typeof replacement === "object") { |
|
||||
replacement = t.cloneNode(replacement); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
const { |
|
||||
parent, |
|
||||
key, |
|
||||
index |
|
||||
} = placeholder.resolve(ast); |
|
||||
|
|
||||
if (placeholder.type === "string") { |
|
||||
if (typeof replacement === "string") { |
|
||||
replacement = t.stringLiteral(replacement); |
|
||||
} |
|
||||
|
|
||||
if (!replacement || !t.isStringLiteral(replacement)) { |
|
||||
throw new Error("Expected string substitution"); |
|
||||
} |
|
||||
} else if (placeholder.type === "statement") { |
|
||||
if (index === undefined) { |
|
||||
if (!replacement) { |
|
||||
replacement = t.emptyStatement(); |
|
||||
} else if (Array.isArray(replacement)) { |
|
||||
replacement = t.blockStatement(replacement); |
|
||||
} else if (typeof replacement === "string") { |
|
||||
replacement = t.expressionStatement(t.identifier(replacement)); |
|
||||
} else if (!t.isStatement(replacement)) { |
|
||||
replacement = t.expressionStatement(replacement); |
|
||||
} |
|
||||
} else { |
|
||||
if (replacement && !Array.isArray(replacement)) { |
|
||||
if (typeof replacement === "string") { |
|
||||
replacement = t.identifier(replacement); |
|
||||
} |
|
||||
|
|
||||
if (!t.isStatement(replacement)) { |
|
||||
replacement = t.expressionStatement(replacement); |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
} else if (placeholder.type === "param") { |
|
||||
if (typeof replacement === "string") { |
|
||||
replacement = t.identifier(replacement); |
|
||||
} |
|
||||
|
|
||||
if (index === undefined) throw new Error("Assertion failure."); |
|
||||
} else { |
|
||||
if (typeof replacement === "string") { |
|
||||
replacement = t.identifier(replacement); |
|
||||
} |
|
||||
|
|
||||
if (Array.isArray(replacement)) { |
|
||||
throw new Error("Cannot replace single expression with an array."); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
if (index === undefined) { |
|
||||
t.validate(parent, key, replacement); |
|
||||
parent[key] = replacement; |
|
||||
} else { |
|
||||
const items = parent[key].slice(); |
|
||||
|
|
||||
if (placeholder.type === "statement" || placeholder.type === "param") { |
|
||||
if (replacement == null) { |
|
||||
items.splice(index, 1); |
|
||||
} else if (Array.isArray(replacement)) { |
|
||||
items.splice(index, 1, ...replacement); |
|
||||
} else { |
|
||||
items[index] = replacement; |
|
||||
} |
|
||||
} else { |
|
||||
items[index] = replacement; |
|
||||
} |
|
||||
|
|
||||
t.validate(parent, key, items); |
|
||||
parent[key] = items; |
|
||||
} |
|
||||
} |
|
||||
@ -1,24 +0,0 @@ |
|||||
"use strict"; |
|
||||
|
|
||||
Object.defineProperty(exports, "__esModule", { |
|
||||
value: true |
|
||||
}); |
|
||||
exports.default = stringTemplate; |
|
||||
|
|
||||
var _options = require("./options"); |
|
||||
|
|
||||
var _parse = _interopRequireDefault(require("./parse")); |
|
||||
|
|
||||
var _populate = _interopRequireDefault(require("./populate")); |
|
||||
|
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
|
||||
|
|
||||
function stringTemplate(formatter, code, opts) { |
|
||||
code = formatter.code(code); |
|
||||
let metadata; |
|
||||
return arg => { |
|
||||
const replacements = (0, _options.normalizeReplacements)(arg); |
|
||||
if (!metadata) metadata = (0, _parse.default)(formatter, code, opts); |
|
||||
return formatter.unwrap((0, _populate.default)(metadata, replacements)); |
|
||||
}; |
|
||||
} |
|
||||
@ -1 +0,0 @@ |
|||||
../@babel/parser/bin/babel-parser.js |
|
||||
@ -1,19 +0,0 @@ |
|||||
{ |
|
||||
"name": "@babel/template", |
|
||||
"version": "7.8.6", |
|
||||
"description": "Generate an AST from a string template.", |
|
||||
"author": "Sebastian McKenzie <sebmck@gmail.com>", |
|
||||
"homepage": "https://babeljs.io/", |
|
||||
"license": "MIT", |
|
||||
"publishConfig": { |
|
||||
"access": "public" |
|
||||
}, |
|
||||
"repository": "https://github.com/babel/babel/tree/master/packages/babel-template", |
|
||||
"main": "lib/index.js", |
|
||||
"dependencies": { |
|
||||
"@babel/code-frame": "^7.8.3", |
|
||||
"@babel/parser": "^7.8.6", |
|
||||
"@babel/types": "^7.8.6" |
|
||||
}, |
|
||||
"gitHead": "750d3dde3bd2d390819820fd22c05441da78751b" |
|
||||
} |
|
||||
@ -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. |
|
||||
@ -1,19 +0,0 @@ |
|||||
# @babel/types |
|
||||
|
|
||||
> Babel Types is a Lodash-esque utility library for AST nodes |
|
||||
|
|
||||
See our website [@babel/types](https://babeljs.io/docs/en/next/babel-types.html) for more information or the [issues](https://github.com/babel/babel/issues?utf8=%E2%9C%93&q=is%3Aissue+label%3A%22pkg%3A%20types%22+is%3Aopen) associated with this package. |
|
||||
|
|
||||
## Install |
|
||||
|
|
||||
Using npm: |
|
||||
|
|
||||
```sh |
|
||||
npm install --save-dev @babel/types |
|
||||
``` |
|
||||
|
|
||||
or using yarn: |
|
||||
|
|
||||
```sh |
|
||||
yarn add @babel/types --dev |
|
||||
``` |
|
||||
@ -1,17 +0,0 @@ |
|||||
"use strict"; |
|
||||
|
|
||||
Object.defineProperty(exports, "__esModule", { |
|
||||
value: true |
|
||||
}); |
|
||||
exports.default = assertNode; |
|
||||
|
|
||||
var _isNode = _interopRequireDefault(require("../validators/isNode")); |
|
||||
|
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
|
||||
|
|
||||
function assertNode(node) { |
|
||||
if (!(0, _isNode.default)(node)) { |
|
||||
const type = node && node.type || JSON.stringify(node); |
|
||||
throw new TypeError(`Not a valid node of type "${type}"`); |
|
||||
} |
|
||||
} |
|
||||
File diff suppressed because it is too large
@ -1,42 +0,0 @@ |
|||||
"use strict"; |
|
||||
|
|
||||
Object.defineProperty(exports, "__esModule", { |
|
||||
value: true |
|
||||
}); |
|
||||
exports.default = builder; |
|
||||
|
|
||||
var _clone = _interopRequireDefault(require("lodash/clone")); |
|
||||
|
|
||||
var _definitions = require("../definitions"); |
|
||||
|
|
||||
var _validate = _interopRequireDefault(require("../validators/validate")); |
|
||||
|
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
|
||||
|
|
||||
function builder(type, ...args) { |
|
||||
const keys = _definitions.BUILDER_KEYS[type]; |
|
||||
const countArgs = args.length; |
|
||||
|
|
||||
if (countArgs > keys.length) { |
|
||||
throw new Error(`${type}: Too many arguments passed. Received ${countArgs} but can receive no more than ${keys.length}`); |
|
||||
} |
|
||||
|
|
||||
const node = { |
|
||||
type |
|
||||
}; |
|
||||
let i = 0; |
|
||||
keys.forEach(key => { |
|
||||
const field = _definitions.NODE_FIELDS[type][key]; |
|
||||
let arg; |
|
||||
if (i < countArgs) arg = args[i]; |
|
||||
if (arg === undefined) arg = (0, _clone.default)(field.default); |
|
||||
node[key] = arg; |
|
||||
i++; |
|
||||
}); |
|
||||
|
|
||||
for (const key of Object.keys(node)) { |
|
||||
(0, _validate.default)(node, key, node[key]); |
|
||||
} |
|
||||
|
|
||||
return node; |
|
||||
} |
|
||||
@ -1,28 +0,0 @@ |
|||||
"use strict"; |
|
||||
|
|
||||
Object.defineProperty(exports, "__esModule", { |
|
||||
value: true |
|
||||
}); |
|
||||
exports.default = createTypeAnnotationBasedOnTypeof; |
|
||||
|
|
||||
var _generated = require("../generated"); |
|
||||
|
|
||||
function createTypeAnnotationBasedOnTypeof(type) { |
|
||||
if (type === "string") { |
|
||||
return (0, _generated.stringTypeAnnotation)(); |
|
||||
} else if (type === "number") { |
|
||||
return (0, _generated.numberTypeAnnotation)(); |
|
||||
} else if (type === "undefined") { |
|
||||
return (0, _generated.voidTypeAnnotation)(); |
|
||||
} else if (type === "boolean") { |
|
||||
return (0, _generated.booleanTypeAnnotation)(); |
|
||||
} else if (type === "function") { |
|
||||
return (0, _generated.genericTypeAnnotation)((0, _generated.identifier)("Function")); |
|
||||
} else if (type === "object") { |
|
||||
return (0, _generated.genericTypeAnnotation)((0, _generated.identifier)("Object")); |
|
||||
} else if (type === "symbol") { |
|
||||
return (0, _generated.genericTypeAnnotation)((0, _generated.identifier)("Symbol")); |
|
||||
} else { |
|
||||
throw new Error("Invalid typeof value"); |
|
||||
} |
|
||||
} |
|
||||
@ -1,22 +0,0 @@ |
|||||
"use strict"; |
|
||||
|
|
||||
Object.defineProperty(exports, "__esModule", { |
|
||||
value: true |
|
||||
}); |
|
||||
exports.default = createUnionTypeAnnotation; |
|
||||
|
|
||||
var _generated = require("../generated"); |
|
||||
|
|
||||
var _removeTypeDuplicates = _interopRequireDefault(require("../../modifications/flow/removeTypeDuplicates")); |
|
||||
|
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
|
||||
|
|
||||
function createUnionTypeAnnotation(types) { |
|
||||
const flattened = (0, _removeTypeDuplicates.default)(types); |
|
||||
|
|
||||
if (flattened.length === 1) { |
|
||||
return flattened[0]; |
|
||||
} else { |
|
||||
return (0, _generated.unionTypeAnnotation)(flattened); |
|
||||
} |
|
||||
} |
|
||||
File diff suppressed because it is too large
@ -1,31 +0,0 @@ |
|||||
"use strict"; |
|
||||
|
|
||||
Object.defineProperty(exports, "__esModule", { |
|
||||
value: true |
|
||||
}); |
|
||||
exports.default = buildChildren; |
|
||||
|
|
||||
var _generated = require("../../validators/generated"); |
|
||||
|
|
||||
var _cleanJSXElementLiteralChild = _interopRequireDefault(require("../../utils/react/cleanJSXElementLiteralChild")); |
|
||||
|
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
|
||||
|
|
||||
function buildChildren(node) { |
|
||||
const elements = []; |
|
||||
|
|
||||
for (let i = 0; i < node.children.length; i++) { |
|
||||
let child = node.children[i]; |
|
||||
|
|
||||
if ((0, _generated.isJSXText)(child)) { |
|
||||
(0, _cleanJSXElementLiteralChild.default)(child, elements); |
|
||||
continue; |
|
||||
} |
|
||||
|
|
||||
if ((0, _generated.isJSXExpressionContainer)(child)) child = child.expression; |
|
||||
if ((0, _generated.isJSXEmptyExpression)(child)) continue; |
|
||||
elements.push(child); |
|
||||
} |
|
||||
|
|
||||
return elements; |
|
||||
} |
|
||||
@ -1,14 +0,0 @@ |
|||||
"use strict"; |
|
||||
|
|
||||
Object.defineProperty(exports, "__esModule", { |
|
||||
value: true |
|
||||
}); |
|
||||
exports.default = clone; |
|
||||
|
|
||||
var _cloneNode = _interopRequireDefault(require("./cloneNode")); |
|
||||
|
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
|
||||
|
|
||||
function clone(node) { |
|
||||
return (0, _cloneNode.default)(node, false); |
|
||||
} |
|
||||
@ -1,14 +0,0 @@ |
|||||
"use strict"; |
|
||||
|
|
||||
Object.defineProperty(exports, "__esModule", { |
|
||||
value: true |
|
||||
}); |
|
||||
exports.default = cloneDeep; |
|
||||
|
|
||||
var _cloneNode = _interopRequireDefault(require("./cloneNode")); |
|
||||
|
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
|
||||
|
|
||||
function cloneDeep(node) { |
|
||||
return (0, _cloneNode.default)(node); |
|
||||
} |
|
||||
@ -1,14 +0,0 @@ |
|||||
"use strict"; |
|
||||
|
|
||||
Object.defineProperty(exports, "__esModule", { |
|
||||
value: true |
|
||||
}); |
|
||||
exports.default = cloneDeepWithoutLoc; |
|
||||
|
|
||||
var _cloneNode = _interopRequireDefault(require("./cloneNode")); |
|
||||
|
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
|
||||
|
|
||||
function cloneDeepWithoutLoc(node) { |
|
||||
return (0, _cloneNode.default)(node, true, true); |
|
||||
} |
|
||||
@ -1,101 +0,0 @@ |
|||||
"use strict"; |
|
||||
|
|
||||
Object.defineProperty(exports, "__esModule", { |
|
||||
value: true |
|
||||
}); |
|
||||
exports.default = cloneNode; |
|
||||
|
|
||||
var _definitions = require("../definitions"); |
|
||||
|
|
||||
const has = Function.call.bind(Object.prototype.hasOwnProperty); |
|
||||
|
|
||||
function cloneIfNode(obj, deep, withoutLoc) { |
|
||||
if (obj && typeof obj.type === "string") { |
|
||||
return cloneNode(obj, deep, withoutLoc); |
|
||||
} |
|
||||
|
|
||||
return obj; |
|
||||
} |
|
||||
|
|
||||
function cloneIfNodeOrArray(obj, deep, withoutLoc) { |
|
||||
if (Array.isArray(obj)) { |
|
||||
return obj.map(node => cloneIfNode(node, deep, withoutLoc)); |
|
||||
} |
|
||||
|
|
||||
return cloneIfNode(obj, deep, withoutLoc); |
|
||||
} |
|
||||
|
|
||||
function cloneNode(node, deep = true, withoutLoc = false) { |
|
||||
if (!node) return node; |
|
||||
const { |
|
||||
type |
|
||||
} = node; |
|
||||
const newNode = { |
|
||||
type |
|
||||
}; |
|
||||
|
|
||||
if (type === "Identifier") { |
|
||||
newNode.name = node.name; |
|
||||
|
|
||||
if (has(node, "optional") && typeof node.optional === "boolean") { |
|
||||
newNode.optional = node.optional; |
|
||||
} |
|
||||
|
|
||||
if (has(node, "typeAnnotation")) { |
|
||||
newNode.typeAnnotation = deep ? cloneIfNodeOrArray(node.typeAnnotation, true, withoutLoc) : node.typeAnnotation; |
|
||||
} |
|
||||
} else if (!has(_definitions.NODE_FIELDS, type)) { |
|
||||
throw new Error(`Unknown node type: "${type}"`); |
|
||||
} else { |
|
||||
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); |
|
||||
} else { |
|
||||
newNode[field] = node[field]; |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
if (has(node, "loc")) { |
|
||||
if (withoutLoc) { |
|
||||
newNode.loc = null; |
|
||||
} else { |
|
||||
newNode.loc = node.loc; |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
if (has(node, "leadingComments")) { |
|
||||
newNode.leadingComments = maybeCloneComments(node.leadingComments, deep, withoutLoc); |
|
||||
} |
|
||||
|
|
||||
if (has(node, "innerComments")) { |
|
||||
newNode.innerComments = maybeCloneComments(node.innerComments, deep, withoutLoc); |
|
||||
} |
|
||||
|
|
||||
if (has(node, "trailingComments")) { |
|
||||
newNode.trailingComments = maybeCloneComments(node.trailingComments, deep, withoutLoc); |
|
||||
} |
|
||||
|
|
||||
if (has(node, "extra")) { |
|
||||
newNode.extra = Object.assign({}, node.extra); |
|
||||
} |
|
||||
|
|
||||
return newNode; |
|
||||
} |
|
||||
|
|
||||
function cloneCommentsWithoutLoc(comments) { |
|
||||
return comments.map(({ |
|
||||
type, |
|
||||
value |
|
||||
}) => ({ |
|
||||
type, |
|
||||
value, |
|
||||
loc: null |
|
||||
})); |
|
||||
} |
|
||||
|
|
||||
function maybeCloneComments(comments, deep, withoutLoc) { |
|
||||
return deep && withoutLoc ? cloneCommentsWithoutLoc(comments) : comments; |
|
||||
} |
|
||||
@ -1,14 +0,0 @@ |
|||||
"use strict"; |
|
||||
|
|
||||
Object.defineProperty(exports, "__esModule", { |
|
||||
value: true |
|
||||
}); |
|
||||
exports.default = cloneWithoutLoc; |
|
||||
|
|
||||
var _cloneNode = _interopRequireDefault(require("./cloneNode")); |
|
||||
|
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
|
||||
|
|
||||
function cloneWithoutLoc(node) { |
|
||||
return (0, _cloneNode.default)(node, false, true); |
|
||||
} |
|
||||
@ -1,17 +0,0 @@ |
|||||
"use strict"; |
|
||||
|
|
||||
Object.defineProperty(exports, "__esModule", { |
|
||||
value: true |
|
||||
}); |
|
||||
exports.default = addComment; |
|
||||
|
|
||||
var _addComments = _interopRequireDefault(require("./addComments")); |
|
||||
|
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
|
||||
|
|
||||
function addComment(node, type, content, line) { |
|
||||
return (0, _addComments.default)(node, type, [{ |
|
||||
type: line ? "CommentLine" : "CommentBlock", |
|
||||
value: content |
|
||||
}]); |
|
||||
} |
|
||||
@ -1,23 +0,0 @@ |
|||||
"use strict"; |
|
||||
|
|
||||
Object.defineProperty(exports, "__esModule", { |
|
||||
value: true |
|
||||
}); |
|
||||
exports.default = addComments; |
|
||||
|
|
||||
function addComments(node, type, comments) { |
|
||||
if (!comments || !node) return node; |
|
||||
const key = `${type}Comments`; |
|
||||
|
|
||||
if (node[key]) { |
|
||||
if (type === "leading") { |
|
||||
node[key] = comments.concat(node[key]); |
|
||||
} else { |
|
||||
node[key] = node[key].concat(comments); |
|
||||
} |
|
||||
} else { |
|
||||
node[key] = comments; |
|
||||
} |
|
||||
|
|
||||
return node; |
|
||||
} |
|
||||
@ -1,14 +0,0 @@ |
|||||
"use strict"; |
|
||||
|
|
||||
Object.defineProperty(exports, "__esModule", { |
|
||||
value: true |
|
||||
}); |
|
||||
exports.default = inheritInnerComments; |
|
||||
|
|
||||
var _inherit = _interopRequireDefault(require("../utils/inherit")); |
|
||||
|
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
|
||||
|
|
||||
function inheritInnerComments(child, parent) { |
|
||||
(0, _inherit.default)("innerComments", child, parent); |
|
||||
} |
|
||||
@ -1,14 +0,0 @@ |
|||||
"use strict"; |
|
||||
|
|
||||
Object.defineProperty(exports, "__esModule", { |
|
||||
value: true |
|
||||
}); |
|
||||
exports.default = inheritLeadingComments; |
|
||||
|
|
||||
var _inherit = _interopRequireDefault(require("../utils/inherit")); |
|
||||
|
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
|
||||
|
|
||||
function inheritLeadingComments(child, parent) { |
|
||||
(0, _inherit.default)("leadingComments", child, parent); |
|
||||
} |
|
||||
@ -1,14 +0,0 @@ |
|||||
"use strict"; |
|
||||
|
|
||||
Object.defineProperty(exports, "__esModule", { |
|
||||
value: true |
|
||||
}); |
|
||||
exports.default = inheritTrailingComments; |
|
||||
|
|
||||
var _inherit = _interopRequireDefault(require("../utils/inherit")); |
|
||||
|
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
|
||||
|
|
||||
function inheritTrailingComments(child, parent) { |
|
||||
(0, _inherit.default)("trailingComments", child, parent); |
|
||||
} |
|
||||
@ -1,21 +0,0 @@ |
|||||
"use strict"; |
|
||||
|
|
||||
Object.defineProperty(exports, "__esModule", { |
|
||||
value: true |
|
||||
}); |
|
||||
exports.default = inheritsComments; |
|
||||
|
|
||||
var _inheritTrailingComments = _interopRequireDefault(require("./inheritTrailingComments")); |
|
||||
|
|
||||
var _inheritLeadingComments = _interopRequireDefault(require("./inheritLeadingComments")); |
|
||||
|
|
||||
var _inheritInnerComments = _interopRequireDefault(require("./inheritInnerComments")); |
|
||||
|
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
|
||||
|
|
||||
function inheritsComments(child, parent) { |
|
||||
(0, _inheritTrailingComments.default)(child, parent); |
|
||||
(0, _inheritLeadingComments.default)(child, parent); |
|
||||
(0, _inheritInnerComments.default)(child, parent); |
|
||||
return child; |
|
||||
} |
|
||||
@ -1,16 +0,0 @@ |
|||||
"use strict"; |
|
||||
|
|
||||
Object.defineProperty(exports, "__esModule", { |
|
||||
value: true |
|
||||
}); |
|
||||
exports.default = removeComments; |
|
||||
|
|
||||
var _constants = require("../constants"); |
|
||||
|
|
||||
function removeComments(node) { |
|
||||
_constants.COMMENT_KEYS.forEach(key => { |
|
||||
node[key] = null; |
|
||||
}); |
|
||||
|
|
||||
return node; |
|
||||
} |
|
||||
@ -1,97 +0,0 @@ |
|||||
"use strict"; |
|
||||
|
|
||||
Object.defineProperty(exports, "__esModule", { |
|
||||
value: true |
|
||||
}); |
|
||||
exports.TSTYPE_TYPES = exports.TSTYPEELEMENT_TYPES = exports.PRIVATE_TYPES = exports.JSX_TYPES = exports.ENUMMEMBER_TYPES = exports.ENUMBODY_TYPES = exports.FLOWPREDICATE_TYPES = exports.FLOWDECLARATION_TYPES = exports.FLOWBASEANNOTATION_TYPES = exports.FLOWTYPE_TYPES = exports.FLOW_TYPES = exports.MODULESPECIFIER_TYPES = exports.EXPORTDECLARATION_TYPES = exports.MODULEDECLARATION_TYPES = exports.CLASS_TYPES = exports.PATTERN_TYPES = exports.UNARYLIKE_TYPES = exports.PROPERTY_TYPES = exports.OBJECTMEMBER_TYPES = exports.METHOD_TYPES = exports.USERWHITESPACABLE_TYPES = exports.IMMUTABLE_TYPES = exports.LITERAL_TYPES = exports.TSENTITYNAME_TYPES = exports.LVAL_TYPES = exports.PATTERNLIKE_TYPES = exports.DECLARATION_TYPES = exports.PUREISH_TYPES = exports.FUNCTIONPARENT_TYPES = exports.FUNCTION_TYPES = exports.FORXSTATEMENT_TYPES = exports.FOR_TYPES = exports.EXPRESSIONWRAPPER_TYPES = exports.WHILE_TYPES = exports.LOOP_TYPES = exports.CONDITIONAL_TYPES = exports.COMPLETIONSTATEMENT_TYPES = exports.TERMINATORLESS_TYPES = exports.STATEMENT_TYPES = exports.BLOCK_TYPES = exports.BLOCKPARENT_TYPES = exports.SCOPABLE_TYPES = exports.BINARY_TYPES = exports.EXPRESSION_TYPES = void 0; |
|
||||
|
|
||||
var _definitions = require("../../definitions"); |
|
||||
|
|
||||
const EXPRESSION_TYPES = _definitions.FLIPPED_ALIAS_KEYS["Expression"]; |
|
||||
exports.EXPRESSION_TYPES = EXPRESSION_TYPES; |
|
||||
const BINARY_TYPES = _definitions.FLIPPED_ALIAS_KEYS["Binary"]; |
|
||||
exports.BINARY_TYPES = BINARY_TYPES; |
|
||||
const SCOPABLE_TYPES = _definitions.FLIPPED_ALIAS_KEYS["Scopable"]; |
|
||||
exports.SCOPABLE_TYPES = SCOPABLE_TYPES; |
|
||||
const BLOCKPARENT_TYPES = _definitions.FLIPPED_ALIAS_KEYS["BlockParent"]; |
|
||||
exports.BLOCKPARENT_TYPES = BLOCKPARENT_TYPES; |
|
||||
const BLOCK_TYPES = _definitions.FLIPPED_ALIAS_KEYS["Block"]; |
|
||||
exports.BLOCK_TYPES = BLOCK_TYPES; |
|
||||
const STATEMENT_TYPES = _definitions.FLIPPED_ALIAS_KEYS["Statement"]; |
|
||||
exports.STATEMENT_TYPES = STATEMENT_TYPES; |
|
||||
const TERMINATORLESS_TYPES = _definitions.FLIPPED_ALIAS_KEYS["Terminatorless"]; |
|
||||
exports.TERMINATORLESS_TYPES = TERMINATORLESS_TYPES; |
|
||||
const COMPLETIONSTATEMENT_TYPES = _definitions.FLIPPED_ALIAS_KEYS["CompletionStatement"]; |
|
||||
exports.COMPLETIONSTATEMENT_TYPES = COMPLETIONSTATEMENT_TYPES; |
|
||||
const CONDITIONAL_TYPES = _definitions.FLIPPED_ALIAS_KEYS["Conditional"]; |
|
||||
exports.CONDITIONAL_TYPES = CONDITIONAL_TYPES; |
|
||||
const LOOP_TYPES = _definitions.FLIPPED_ALIAS_KEYS["Loop"]; |
|
||||
exports.LOOP_TYPES = LOOP_TYPES; |
|
||||
const WHILE_TYPES = _definitions.FLIPPED_ALIAS_KEYS["While"]; |
|
||||
exports.WHILE_TYPES = WHILE_TYPES; |
|
||||
const EXPRESSIONWRAPPER_TYPES = _definitions.FLIPPED_ALIAS_KEYS["ExpressionWrapper"]; |
|
||||
exports.EXPRESSIONWRAPPER_TYPES = EXPRESSIONWRAPPER_TYPES; |
|
||||
const FOR_TYPES = _definitions.FLIPPED_ALIAS_KEYS["For"]; |
|
||||
exports.FOR_TYPES = FOR_TYPES; |
|
||||
const FORXSTATEMENT_TYPES = _definitions.FLIPPED_ALIAS_KEYS["ForXStatement"]; |
|
||||
exports.FORXSTATEMENT_TYPES = FORXSTATEMENT_TYPES; |
|
||||
const FUNCTION_TYPES = _definitions.FLIPPED_ALIAS_KEYS["Function"]; |
|
||||
exports.FUNCTION_TYPES = FUNCTION_TYPES; |
|
||||
const FUNCTIONPARENT_TYPES = _definitions.FLIPPED_ALIAS_KEYS["FunctionParent"]; |
|
||||
exports.FUNCTIONPARENT_TYPES = FUNCTIONPARENT_TYPES; |
|
||||
const PUREISH_TYPES = _definitions.FLIPPED_ALIAS_KEYS["Pureish"]; |
|
||||
exports.PUREISH_TYPES = PUREISH_TYPES; |
|
||||
const DECLARATION_TYPES = _definitions.FLIPPED_ALIAS_KEYS["Declaration"]; |
|
||||
exports.DECLARATION_TYPES = DECLARATION_TYPES; |
|
||||
const PATTERNLIKE_TYPES = _definitions.FLIPPED_ALIAS_KEYS["PatternLike"]; |
|
||||
exports.PATTERNLIKE_TYPES = PATTERNLIKE_TYPES; |
|
||||
const LVAL_TYPES = _definitions.FLIPPED_ALIAS_KEYS["LVal"]; |
|
||||
exports.LVAL_TYPES = LVAL_TYPES; |
|
||||
const TSENTITYNAME_TYPES = _definitions.FLIPPED_ALIAS_KEYS["TSEntityName"]; |
|
||||
exports.TSENTITYNAME_TYPES = TSENTITYNAME_TYPES; |
|
||||
const LITERAL_TYPES = _definitions.FLIPPED_ALIAS_KEYS["Literal"]; |
|
||||
exports.LITERAL_TYPES = LITERAL_TYPES; |
|
||||
const IMMUTABLE_TYPES = _definitions.FLIPPED_ALIAS_KEYS["Immutable"]; |
|
||||
exports.IMMUTABLE_TYPES = IMMUTABLE_TYPES; |
|
||||
const USERWHITESPACABLE_TYPES = _definitions.FLIPPED_ALIAS_KEYS["UserWhitespacable"]; |
|
||||
exports.USERWHITESPACABLE_TYPES = USERWHITESPACABLE_TYPES; |
|
||||
const METHOD_TYPES = _definitions.FLIPPED_ALIAS_KEYS["Method"]; |
|
||||
exports.METHOD_TYPES = METHOD_TYPES; |
|
||||
const OBJECTMEMBER_TYPES = _definitions.FLIPPED_ALIAS_KEYS["ObjectMember"]; |
|
||||
exports.OBJECTMEMBER_TYPES = OBJECTMEMBER_TYPES; |
|
||||
const PROPERTY_TYPES = _definitions.FLIPPED_ALIAS_KEYS["Property"]; |
|
||||
exports.PROPERTY_TYPES = PROPERTY_TYPES; |
|
||||
const UNARYLIKE_TYPES = _definitions.FLIPPED_ALIAS_KEYS["UnaryLike"]; |
|
||||
exports.UNARYLIKE_TYPES = UNARYLIKE_TYPES; |
|
||||
const PATTERN_TYPES = _definitions.FLIPPED_ALIAS_KEYS["Pattern"]; |
|
||||
exports.PATTERN_TYPES = PATTERN_TYPES; |
|
||||
const CLASS_TYPES = _definitions.FLIPPED_ALIAS_KEYS["Class"]; |
|
||||
exports.CLASS_TYPES = CLASS_TYPES; |
|
||||
const MODULEDECLARATION_TYPES = _definitions.FLIPPED_ALIAS_KEYS["ModuleDeclaration"]; |
|
||||
exports.MODULEDECLARATION_TYPES = MODULEDECLARATION_TYPES; |
|
||||
const EXPORTDECLARATION_TYPES = _definitions.FLIPPED_ALIAS_KEYS["ExportDeclaration"]; |
|
||||
exports.EXPORTDECLARATION_TYPES = EXPORTDECLARATION_TYPES; |
|
||||
const MODULESPECIFIER_TYPES = _definitions.FLIPPED_ALIAS_KEYS["ModuleSpecifier"]; |
|
||||
exports.MODULESPECIFIER_TYPES = MODULESPECIFIER_TYPES; |
|
||||
const FLOW_TYPES = _definitions.FLIPPED_ALIAS_KEYS["Flow"]; |
|
||||
exports.FLOW_TYPES = FLOW_TYPES; |
|
||||
const FLOWTYPE_TYPES = _definitions.FLIPPED_ALIAS_KEYS["FlowType"]; |
|
||||
exports.FLOWTYPE_TYPES = FLOWTYPE_TYPES; |
|
||||
const FLOWBASEANNOTATION_TYPES = _definitions.FLIPPED_ALIAS_KEYS["FlowBaseAnnotation"]; |
|
||||
exports.FLOWBASEANNOTATION_TYPES = FLOWBASEANNOTATION_TYPES; |
|
||||
const FLOWDECLARATION_TYPES = _definitions.FLIPPED_ALIAS_KEYS["FlowDeclaration"]; |
|
||||
exports.FLOWDECLARATION_TYPES = FLOWDECLARATION_TYPES; |
|
||||
const FLOWPREDICATE_TYPES = _definitions.FLIPPED_ALIAS_KEYS["FlowPredicate"]; |
|
||||
exports.FLOWPREDICATE_TYPES = FLOWPREDICATE_TYPES; |
|
||||
const ENUMBODY_TYPES = _definitions.FLIPPED_ALIAS_KEYS["EnumBody"]; |
|
||||
exports.ENUMBODY_TYPES = ENUMBODY_TYPES; |
|
||||
const ENUMMEMBER_TYPES = _definitions.FLIPPED_ALIAS_KEYS["EnumMember"]; |
|
||||
exports.ENUMMEMBER_TYPES = ENUMMEMBER_TYPES; |
|
||||
const JSX_TYPES = _definitions.FLIPPED_ALIAS_KEYS["JSX"]; |
|
||||
exports.JSX_TYPES = JSX_TYPES; |
|
||||
const PRIVATE_TYPES = _definitions.FLIPPED_ALIAS_KEYS["Private"]; |
|
||||
exports.PRIVATE_TYPES = PRIVATE_TYPES; |
|
||||
const TSTYPEELEMENT_TYPES = _definitions.FLIPPED_ALIAS_KEYS["TSTypeElement"]; |
|
||||
exports.TSTYPEELEMENT_TYPES = TSTYPEELEMENT_TYPES; |
|
||||
const TSTYPE_TYPES = _definitions.FLIPPED_ALIAS_KEYS["TSType"]; |
|
||||
exports.TSTYPE_TYPES = TSTYPE_TYPES; |
|
||||
@ -1,49 +0,0 @@ |
|||||
"use strict"; |
|
||||
|
|
||||
Object.defineProperty(exports, "__esModule", { |
|
||||
value: true |
|
||||
}); |
|
||||
exports.NOT_LOCAL_BINDING = exports.BLOCK_SCOPED_SYMBOL = exports.INHERIT_KEYS = exports.UNARY_OPERATORS = exports.STRING_UNARY_OPERATORS = exports.NUMBER_UNARY_OPERATORS = exports.BOOLEAN_UNARY_OPERATORS = exports.ASSIGNMENT_OPERATORS = exports.BINARY_OPERATORS = exports.NUMBER_BINARY_OPERATORS = exports.BOOLEAN_BINARY_OPERATORS = exports.COMPARISON_BINARY_OPERATORS = exports.EQUALITY_BINARY_OPERATORS = exports.BOOLEAN_NUMBER_BINARY_OPERATORS = exports.UPDATE_OPERATORS = exports.LOGICAL_OPERATORS = exports.COMMENT_KEYS = exports.FOR_INIT_KEYS = exports.FLATTENABLE_KEYS = exports.STATEMENT_OR_BLOCK_KEYS = void 0; |
|
||||
const STATEMENT_OR_BLOCK_KEYS = ["consequent", "body", "alternate"]; |
|
||||
exports.STATEMENT_OR_BLOCK_KEYS = STATEMENT_OR_BLOCK_KEYS; |
|
||||
const FLATTENABLE_KEYS = ["body", "expressions"]; |
|
||||
exports.FLATTENABLE_KEYS = FLATTENABLE_KEYS; |
|
||||
const FOR_INIT_KEYS = ["left", "init"]; |
|
||||
exports.FOR_INIT_KEYS = FOR_INIT_KEYS; |
|
||||
const COMMENT_KEYS = ["leadingComments", "trailingComments", "innerComments"]; |
|
||||
exports.COMMENT_KEYS = COMMENT_KEYS; |
|
||||
const LOGICAL_OPERATORS = ["||", "&&", "??"]; |
|
||||
exports.LOGICAL_OPERATORS = LOGICAL_OPERATORS; |
|
||||
const UPDATE_OPERATORS = ["++", "--"]; |
|
||||
exports.UPDATE_OPERATORS = UPDATE_OPERATORS; |
|
||||
const BOOLEAN_NUMBER_BINARY_OPERATORS = [">", "<", ">=", "<="]; |
|
||||
exports.BOOLEAN_NUMBER_BINARY_OPERATORS = BOOLEAN_NUMBER_BINARY_OPERATORS; |
|
||||
const EQUALITY_BINARY_OPERATORS = ["==", "===", "!=", "!=="]; |
|
||||
exports.EQUALITY_BINARY_OPERATORS = EQUALITY_BINARY_OPERATORS; |
|
||||
const COMPARISON_BINARY_OPERATORS = [...EQUALITY_BINARY_OPERATORS, "in", "instanceof"]; |
|
||||
exports.COMPARISON_BINARY_OPERATORS = COMPARISON_BINARY_OPERATORS; |
|
||||
const BOOLEAN_BINARY_OPERATORS = [...COMPARISON_BINARY_OPERATORS, ...BOOLEAN_NUMBER_BINARY_OPERATORS]; |
|
||||
exports.BOOLEAN_BINARY_OPERATORS = BOOLEAN_BINARY_OPERATORS; |
|
||||
const NUMBER_BINARY_OPERATORS = ["-", "/", "%", "*", "**", "&", "|", ">>", ">>>", "<<", "^"]; |
|
||||
exports.NUMBER_BINARY_OPERATORS = NUMBER_BINARY_OPERATORS; |
|
||||
const BINARY_OPERATORS = ["+", ...NUMBER_BINARY_OPERATORS, ...BOOLEAN_BINARY_OPERATORS]; |
|
||||
exports.BINARY_OPERATORS = BINARY_OPERATORS; |
|
||||
const ASSIGNMENT_OPERATORS = ["=", "+=", ...NUMBER_BINARY_OPERATORS.map(op => op + "="), ...LOGICAL_OPERATORS.map(op => op + "=")]; |
|
||||
exports.ASSIGNMENT_OPERATORS = ASSIGNMENT_OPERATORS; |
|
||||
const BOOLEAN_UNARY_OPERATORS = ["delete", "!"]; |
|
||||
exports.BOOLEAN_UNARY_OPERATORS = BOOLEAN_UNARY_OPERATORS; |
|
||||
const NUMBER_UNARY_OPERATORS = ["+", "-", "~"]; |
|
||||
exports.NUMBER_UNARY_OPERATORS = NUMBER_UNARY_OPERATORS; |
|
||||
const STRING_UNARY_OPERATORS = ["typeof"]; |
|
||||
exports.STRING_UNARY_OPERATORS = STRING_UNARY_OPERATORS; |
|
||||
const UNARY_OPERATORS = ["void", "throw", ...BOOLEAN_UNARY_OPERATORS, ...NUMBER_UNARY_OPERATORS, ...STRING_UNARY_OPERATORS]; |
|
||||
exports.UNARY_OPERATORS = UNARY_OPERATORS; |
|
||||
const INHERIT_KEYS = { |
|
||||
optional: ["typeAnnotation", "typeParameters", "returnType"], |
|
||||
force: ["start", "loc", "end"] |
|
||||
}; |
|
||||
exports.INHERIT_KEYS = INHERIT_KEYS; |
|
||||
const BLOCK_SCOPED_SYMBOL = Symbol.for("var used to be block scoped"); |
|
||||
exports.BLOCK_SCOPED_SYMBOL = BLOCK_SCOPED_SYMBOL; |
|
||||
const NOT_LOCAL_BINDING = Symbol.for("should not be considered a local binding"); |
|
||||
exports.NOT_LOCAL_BINDING = NOT_LOCAL_BINDING; |
|
||||
@ -1,14 +0,0 @@ |
|||||
"use strict"; |
|
||||
|
|
||||
Object.defineProperty(exports, "__esModule", { |
|
||||
value: true |
|
||||
}); |
|
||||
exports.default = ensureBlock; |
|
||||
|
|
||||
var _toBlock = _interopRequireDefault(require("./toBlock")); |
|
||||
|
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
|
||||
|
|
||||
function ensureBlock(node, key = "body") { |
|
||||
return node[key] = (0, _toBlock.default)(node[key], node); |
|
||||
} |
|
||||
@ -1,73 +0,0 @@ |
|||||
"use strict"; |
|
||||
|
|
||||
Object.defineProperty(exports, "__esModule", { |
|
||||
value: true |
|
||||
}); |
|
||||
exports.default = gatherSequenceExpressions; |
|
||||
|
|
||||
var _getBindingIdentifiers = _interopRequireDefault(require("../retrievers/getBindingIdentifiers")); |
|
||||
|
|
||||
var _generated = require("../validators/generated"); |
|
||||
|
|
||||
var _generated2 = require("../builders/generated"); |
|
||||
|
|
||||
var _cloneNode = _interopRequireDefault(require("../clone/cloneNode")); |
|
||||
|
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
|
||||
|
|
||||
function gatherSequenceExpressions(nodes, scope, declars) { |
|
||||
const exprs = []; |
|
||||
let ensureLastUndefined = true; |
|
||||
|
|
||||
for (const node of nodes) { |
|
||||
ensureLastUndefined = false; |
|
||||
|
|
||||
if ((0, _generated.isExpression)(node)) { |
|
||||
exprs.push(node); |
|
||||
} else if ((0, _generated.isExpressionStatement)(node)) { |
|
||||
exprs.push(node.expression); |
|
||||
} else if ((0, _generated.isVariableDeclaration)(node)) { |
|
||||
if (node.kind !== "var") return; |
|
||||
|
|
||||
for (const declar of node.declarations) { |
|
||||
const bindings = (0, _getBindingIdentifiers.default)(declar); |
|
||||
|
|
||||
for (const key of Object.keys(bindings)) { |
|
||||
declars.push({ |
|
||||
kind: node.kind, |
|
||||
id: (0, _cloneNode.default)(bindings[key]) |
|
||||
}); |
|
||||
} |
|
||||
|
|
||||
if (declar.init) { |
|
||||
exprs.push((0, _generated2.assignmentExpression)("=", declar.id, declar.init)); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
ensureLastUndefined = true; |
|
||||
} else if ((0, _generated.isIfStatement)(node)) { |
|
||||
const consequent = node.consequent ? gatherSequenceExpressions([node.consequent], scope, declars) : scope.buildUndefinedNode(); |
|
||||
const alternate = node.alternate ? gatherSequenceExpressions([node.alternate], scope, declars) : scope.buildUndefinedNode(); |
|
||||
if (!consequent || !alternate) return; |
|
||||
exprs.push((0, _generated2.conditionalExpression)(node.test, consequent, alternate)); |
|
||||
} else if ((0, _generated.isBlockStatement)(node)) { |
|
||||
const body = gatherSequenceExpressions(node.body, scope, declars); |
|
||||
if (!body) return; |
|
||||
exprs.push(body); |
|
||||
} else if ((0, _generated.isEmptyStatement)(node)) { |
|
||||
ensureLastUndefined = true; |
|
||||
} else { |
|
||||
return; |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
if (ensureLastUndefined) { |
|
||||
exprs.push(scope.buildUndefinedNode()); |
|
||||
} |
|
||||
|
|
||||
if (exprs.length === 1) { |
|
||||
return exprs[0]; |
|
||||
} else { |
|
||||
return (0, _generated2.sequenceExpression)(exprs); |
|
||||
} |
|
||||
} |
|
||||
@ -1,16 +0,0 @@ |
|||||
"use strict"; |
|
||||
|
|
||||
Object.defineProperty(exports, "__esModule", { |
|
||||
value: true |
|
||||
}); |
|
||||
exports.default = toBindingIdentifierName; |
|
||||
|
|
||||
var _toIdentifier = _interopRequireDefault(require("./toIdentifier")); |
|
||||
|
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
|
||||
|
|
||||
function toBindingIdentifierName(name) { |
|
||||
name = (0, _toIdentifier.default)(name); |
|
||||
if (name === "eval" || name === "arguments") name = "_" + name; |
|
||||
return name; |
|
||||
} |
|
||||
@ -1,34 +0,0 @@ |
|||||
"use strict"; |
|
||||
|
|
||||
Object.defineProperty(exports, "__esModule", { |
|
||||
value: true |
|
||||
}); |
|
||||
exports.default = toBlock; |
|
||||
|
|
||||
var _generated = require("../validators/generated"); |
|
||||
|
|
||||
var _generated2 = require("../builders/generated"); |
|
||||
|
|
||||
function toBlock(node, parent) { |
|
||||
if ((0, _generated.isBlockStatement)(node)) { |
|
||||
return node; |
|
||||
} |
|
||||
|
|
||||
let blockNodes = []; |
|
||||
|
|
||||
if ((0, _generated.isEmptyStatement)(node)) { |
|
||||
blockNodes = []; |
|
||||
} else { |
|
||||
if (!(0, _generated.isStatement)(node)) { |
|
||||
if ((0, _generated.isFunction)(parent)) { |
|
||||
node = (0, _generated2.returnStatement)(node); |
|
||||
} else { |
|
||||
node = (0, _generated2.expressionStatement)(node); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
blockNodes = [node]; |
|
||||
} |
|
||||
|
|
||||
return (0, _generated2.blockStatement)(blockNodes); |
|
||||
} |
|
||||
@ -1,15 +0,0 @@ |
|||||
"use strict"; |
|
||||
|
|
||||
Object.defineProperty(exports, "__esModule", { |
|
||||
value: true |
|
||||
}); |
|
||||
exports.default = toComputedKey; |
|
||||
|
|
||||
var _generated = require("../validators/generated"); |
|
||||
|
|
||||
var _generated2 = require("../builders/generated"); |
|
||||
|
|
||||
function toComputedKey(node, key = node.key || node.property) { |
|
||||
if (!node.computed && (0, _generated.isIdentifier)(key)) key = (0, _generated2.stringLiteral)(key.name); |
|
||||
return key; |
|
||||
} |
|
||||
@ -1,30 +0,0 @@ |
|||||
"use strict"; |
|
||||
|
|
||||
Object.defineProperty(exports, "__esModule", { |
|
||||
value: true |
|
||||
}); |
|
||||
exports.default = toExpression; |
|
||||
|
|
||||
var _generated = require("../validators/generated"); |
|
||||
|
|
||||
function toExpression(node) { |
|
||||
if ((0, _generated.isExpressionStatement)(node)) { |
|
||||
node = node.expression; |
|
||||
} |
|
||||
|
|
||||
if ((0, _generated.isExpression)(node)) { |
|
||||
return node; |
|
||||
} |
|
||||
|
|
||||
if ((0, _generated.isClass)(node)) { |
|
||||
node.type = "ClassExpression"; |
|
||||
} else if ((0, _generated.isFunction)(node)) { |
|
||||
node.type = "FunctionExpression"; |
|
||||
} |
|
||||
|
|
||||
if (!(0, _generated.isExpression)(node)) { |
|
||||
throw new Error(`cannot turn ${node.type} to an expression`); |
|
||||
} |
|
||||
|
|
||||
return node; |
|
||||
} |
|
||||
@ -1,25 +0,0 @@ |
|||||
"use strict"; |
|
||||
|
|
||||
Object.defineProperty(exports, "__esModule", { |
|
||||
value: true |
|
||||
}); |
|
||||
exports.default = toIdentifier; |
|
||||
|
|
||||
var _isValidIdentifier = _interopRequireDefault(require("../validators/isValidIdentifier")); |
|
||||
|
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
|
||||
|
|
||||
function toIdentifier(name) { |
|
||||
name = name + ""; |
|
||||
name = name.replace(/[^a-zA-Z0-9$_]/g, "-"); |
|
||||
name = name.replace(/^[-0-9]+/, ""); |
|
||||
name = name.replace(/[-\s]+(.)?/g, function (match, c) { |
|
||||
return c ? c.toUpperCase() : ""; |
|
||||
}); |
|
||||
|
|
||||
if (!(0, _isValidIdentifier.default)(name)) { |
|
||||
name = `_${name}`; |
|
||||
} |
|
||||
|
|
||||
return name || "_"; |
|
||||
} |
|
||||
@ -1,48 +0,0 @@ |
|||||
"use strict"; |
|
||||
|
|
||||
Object.defineProperty(exports, "__esModule", { |
|
||||
value: true |
|
||||
}); |
|
||||
exports.default = toKeyAlias; |
|
||||
|
|
||||
var _generated = require("../validators/generated"); |
|
||||
|
|
||||
var _cloneNode = _interopRequireDefault(require("../clone/cloneNode")); |
|
||||
|
|
||||
var _removePropertiesDeep = _interopRequireDefault(require("../modifications/removePropertiesDeep")); |
|
||||
|
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
|
||||
|
|
||||
function toKeyAlias(node, key = node.key) { |
|
||||
let alias; |
|
||||
|
|
||||
if (node.kind === "method") { |
|
||||
return toKeyAlias.increment() + ""; |
|
||||
} else if ((0, _generated.isIdentifier)(key)) { |
|
||||
alias = key.name; |
|
||||
} else if ((0, _generated.isStringLiteral)(key)) { |
|
||||
alias = JSON.stringify(key.value); |
|
||||
} else { |
|
||||
alias = JSON.stringify((0, _removePropertiesDeep.default)((0, _cloneNode.default)(key))); |
|
||||
} |
|
||||
|
|
||||
if (node.computed) { |
|
||||
alias = `[${alias}]`; |
|
||||
} |
|
||||
|
|
||||
if (node.static) { |
|
||||
alias = `static:${alias}`; |
|
||||
} |
|
||||
|
|
||||
return alias; |
|
||||
} |
|
||||
|
|
||||
toKeyAlias.uid = 0; |
|
||||
|
|
||||
toKeyAlias.increment = function () { |
|
||||
if (toKeyAlias.uid >= Number.MAX_SAFE_INTEGER) { |
|
||||
return toKeyAlias.uid = 0; |
|
||||
} else { |
|
||||
return toKeyAlias.uid++; |
|
||||
} |
|
||||
}; |
|
||||
@ -1,23 +0,0 @@ |
|||||
"use strict"; |
|
||||
|
|
||||
Object.defineProperty(exports, "__esModule", { |
|
||||
value: true |
|
||||
}); |
|
||||
exports.default = toSequenceExpression; |
|
||||
|
|
||||
var _gatherSequenceExpressions = _interopRequireDefault(require("./gatherSequenceExpressions")); |
|
||||
|
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
|
||||
|
|
||||
function toSequenceExpression(nodes, scope) { |
|
||||
if (!nodes || !nodes.length) return; |
|
||||
const declars = []; |
|
||||
const result = (0, _gatherSequenceExpressions.default)(nodes, scope, declars); |
|
||||
if (!result) return; |
|
||||
|
|
||||
for (const declar of declars) { |
|
||||
scope.push(declar); |
|
||||
} |
|
||||
|
|
||||
return result; |
|
||||
} |
|
||||
@ -1,44 +0,0 @@ |
|||||
"use strict"; |
|
||||
|
|
||||
Object.defineProperty(exports, "__esModule", { |
|
||||
value: true |
|
||||
}); |
|
||||
exports.default = toStatement; |
|
||||
|
|
||||
var _generated = require("../validators/generated"); |
|
||||
|
|
||||
var _generated2 = require("../builders/generated"); |
|
||||
|
|
||||
function toStatement(node, ignore) { |
|
||||
if ((0, _generated.isStatement)(node)) { |
|
||||
return node; |
|
||||
} |
|
||||
|
|
||||
let mustHaveId = false; |
|
||||
let newType; |
|
||||
|
|
||||
if ((0, _generated.isClass)(node)) { |
|
||||
mustHaveId = true; |
|
||||
newType = "ClassDeclaration"; |
|
||||
} else if ((0, _generated.isFunction)(node)) { |
|
||||
mustHaveId = true; |
|
||||
newType = "FunctionDeclaration"; |
|
||||
} else if ((0, _generated.isAssignmentExpression)(node)) { |
|
||||
return (0, _generated2.expressionStatement)(node); |
|
||||
} |
|
||||
|
|
||||
if (mustHaveId && !node.id) { |
|
||||
newType = false; |
|
||||
} |
|
||||
|
|
||||
if (!newType) { |
|
||||
if (ignore) { |
|
||||
return false; |
|
||||
} else { |
|
||||
throw new Error(`cannot turn ${node.type} to a statement`); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
node.type = newType; |
|
||||
return node; |
|
||||
} |
|
||||
@ -1,88 +0,0 @@ |
|||||
"use strict"; |
|
||||
|
|
||||
Object.defineProperty(exports, "__esModule", { |
|
||||
value: true |
|
||||
}); |
|
||||
exports.default = valueToNode; |
|
||||
|
|
||||
var _isPlainObject = _interopRequireDefault(require("lodash/isPlainObject")); |
|
||||
|
|
||||
var _isRegExp = _interopRequireDefault(require("lodash/isRegExp")); |
|
||||
|
|
||||
var _isValidIdentifier = _interopRequireDefault(require("../validators/isValidIdentifier")); |
|
||||
|
|
||||
var _generated = require("../builders/generated"); |
|
||||
|
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
|
||||
|
|
||||
function valueToNode(value) { |
|
||||
if (value === undefined) { |
|
||||
return (0, _generated.identifier)("undefined"); |
|
||||
} |
|
||||
|
|
||||
if (value === true || value === false) { |
|
||||
return (0, _generated.booleanLiteral)(value); |
|
||||
} |
|
||||
|
|
||||
if (value === null) { |
|
||||
return (0, _generated.nullLiteral)(); |
|
||||
} |
|
||||
|
|
||||
if (typeof value === "string") { |
|
||||
return (0, _generated.stringLiteral)(value); |
|
||||
} |
|
||||
|
|
||||
if (typeof value === "number") { |
|
||||
let result; |
|
||||
|
|
||||
if (Number.isFinite(value)) { |
|
||||
result = (0, _generated.numericLiteral)(Math.abs(value)); |
|
||||
} else { |
|
||||
let numerator; |
|
||||
|
|
||||
if (Number.isNaN(value)) { |
|
||||
numerator = (0, _generated.numericLiteral)(0); |
|
||||
} else { |
|
||||
numerator = (0, _generated.numericLiteral)(1); |
|
||||
} |
|
||||
|
|
||||
result = (0, _generated.binaryExpression)("/", numerator, (0, _generated.numericLiteral)(0)); |
|
||||
} |
|
||||
|
|
||||
if (value < 0 || Object.is(value, -0)) { |
|
||||
result = (0, _generated.unaryExpression)("-", result); |
|
||||
} |
|
||||
|
|
||||
return result; |
|
||||
} |
|
||||
|
|
||||
if ((0, _isRegExp.default)(value)) { |
|
||||
const pattern = value.source; |
|
||||
const flags = value.toString().match(/\/([a-z]+|)$/)[1]; |
|
||||
return (0, _generated.regExpLiteral)(pattern, flags); |
|
||||
} |
|
||||
|
|
||||
if (Array.isArray(value)) { |
|
||||
return (0, _generated.arrayExpression)(value.map(valueToNode)); |
|
||||
} |
|
||||
|
|
||||
if ((0, _isPlainObject.default)(value)) { |
|
||||
const props = []; |
|
||||
|
|
||||
for (const key of Object.keys(value)) { |
|
||||
let nodeKey; |
|
||||
|
|
||||
if ((0, _isValidIdentifier.default)(key)) { |
|
||||
nodeKey = (0, _generated.identifier)(key); |
|
||||
} else { |
|
||||
nodeKey = (0, _generated.stringLiteral)(key); |
|
||||
} |
|
||||
|
|
||||
props.push((0, _generated.objectProperty)(nodeKey, valueToNode(value[key]))); |
|
||||
} |
|
||||
|
|
||||
return (0, _generated.objectExpression)(props); |
|
||||
} |
|
||||
|
|
||||
throw new Error("don't know how to turn this value into a node"); |
|
||||
} |
|
||||
@ -1,858 +0,0 @@ |
|||||
"use strict"; |
|
||||
|
|
||||
Object.defineProperty(exports, "__esModule", { |
|
||||
value: true |
|
||||
}); |
|
||||
exports.patternLikeCommon = exports.functionDeclarationCommon = exports.functionTypeAnnotationCommon = exports.functionCommon = void 0; |
|
||||
|
|
||||
var _is = _interopRequireDefault(require("../validators/is")); |
|
||||
|
|
||||
var _isValidIdentifier = _interopRequireDefault(require("../validators/isValidIdentifier")); |
|
||||
|
|
||||
var _helperValidatorIdentifier = require("@babel/helper-validator-identifier"); |
|
||||
|
|
||||
var _constants = require("../constants"); |
|
||||
|
|
||||
var _utils = _interopRequireWildcard(require("./utils")); |
|
||||
|
|
||||
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 }; } |
|
||||
|
|
||||
(0, _utils.default)("ArrayExpression", { |
|
||||
fields: { |
|
||||
elements: { |
|
||||
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeOrValueType)("null", "Expression", "SpreadElement"))), |
|
||||
default: !process.env.BABEL_TYPES_8_BREAKING ? [] : undefined |
|
||||
} |
|
||||
}, |
|
||||
visitor: ["elements"], |
|
||||
aliases: ["Expression"] |
|
||||
}); |
|
||||
(0, _utils.default)("AssignmentExpression", { |
|
||||
fields: { |
|
||||
operator: { |
|
||||
validate: function () { |
|
||||
if (!process.env.BABEL_TYPES_8_BREAKING) { |
|
||||
return (0, _utils.assertValueType)("string"); |
|
||||
} |
|
||||
|
|
||||
const identifier = (0, _utils.assertOneOf)(..._constants.ASSIGNMENT_OPERATORS); |
|
||||
const pattern = (0, _utils.assertOneOf)("="); |
|
||||
return function (node, key, val) { |
|
||||
const validator = (0, _is.default)("Pattern", node.left) ? pattern : identifier; |
|
||||
validator(node, key, val); |
|
||||
}; |
|
||||
}() |
|
||||
}, |
|
||||
left: { |
|
||||
validate: !process.env.BABEL_TYPES_8_BREAKING ? (0, _utils.assertNodeType)("LVal") : (0, _utils.assertNodeType)("Identifier", "MemberExpression", "ArrayPattern", "ObjectPattern") |
|
||||
}, |
|
||||
right: { |
|
||||
validate: (0, _utils.assertNodeType)("Expression") |
|
||||
} |
|
||||
}, |
|
||||
builder: ["operator", "left", "right"], |
|
||||
visitor: ["left", "right"], |
|
||||
aliases: ["Expression"] |
|
||||
}); |
|
||||
(0, _utils.default)("BinaryExpression", { |
|
||||
builder: ["operator", "left", "right"], |
|
||||
fields: { |
|
||||
operator: { |
|
||||
validate: (0, _utils.assertOneOf)(..._constants.BINARY_OPERATORS) |
|
||||
}, |
|
||||
left: { |
|
||||
validate: (0, _utils.assertNodeType)("Expression") |
|
||||
}, |
|
||||
right: { |
|
||||
validate: (0, _utils.assertNodeType)("Expression") |
|
||||
} |
|
||||
}, |
|
||||
visitor: ["left", "right"], |
|
||||
aliases: ["Binary", "Expression"] |
|
||||
}); |
|
||||
(0, _utils.default)("InterpreterDirective", { |
|
||||
builder: ["value"], |
|
||||
fields: { |
|
||||
value: { |
|
||||
validate: (0, _utils.assertValueType)("string") |
|
||||
} |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("Directive", { |
|
||||
visitor: ["value"], |
|
||||
fields: { |
|
||||
value: { |
|
||||
validate: (0, _utils.assertNodeType)("DirectiveLiteral") |
|
||||
} |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("DirectiveLiteral", { |
|
||||
builder: ["value"], |
|
||||
fields: { |
|
||||
value: { |
|
||||
validate: (0, _utils.assertValueType)("string") |
|
||||
} |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("BlockStatement", { |
|
||||
builder: ["body", "directives"], |
|
||||
visitor: ["directives", "body"], |
|
||||
fields: { |
|
||||
directives: { |
|
||||
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Directive"))), |
|
||||
default: [] |
|
||||
}, |
|
||||
body: { |
|
||||
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Statement"))) |
|
||||
} |
|
||||
}, |
|
||||
aliases: ["Scopable", "BlockParent", "Block", "Statement"] |
|
||||
}); |
|
||||
(0, _utils.default)("BreakStatement", { |
|
||||
visitor: ["label"], |
|
||||
fields: { |
|
||||
label: { |
|
||||
validate: (0, _utils.assertNodeType)("Identifier"), |
|
||||
optional: true |
|
||||
} |
|
||||
}, |
|
||||
aliases: ["Statement", "Terminatorless", "CompletionStatement"] |
|
||||
}); |
|
||||
(0, _utils.default)("CallExpression", { |
|
||||
visitor: ["callee", "arguments", "typeParameters", "typeArguments"], |
|
||||
builder: ["callee", "arguments"], |
|
||||
aliases: ["Expression"], |
|
||||
fields: Object.assign({ |
|
||||
callee: { |
|
||||
validate: (0, _utils.assertNodeType)("Expression", "V8IntrinsicIdentifier") |
|
||||
}, |
|
||||
arguments: { |
|
||||
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Expression", "SpreadElement", "JSXNamespacedName", "ArgumentPlaceholder"))) |
|
||||
} |
|
||||
}, !process.env.BABEL_TYPES_8_BREAKING ? { |
|
||||
optional: { |
|
||||
validate: (0, _utils.assertOneOf)(true, false), |
|
||||
optional: true |
|
||||
} |
|
||||
} : {}, { |
|
||||
typeArguments: { |
|
||||
validate: (0, _utils.assertNodeType)("TypeParameterInstantiation"), |
|
||||
optional: true |
|
||||
}, |
|
||||
typeParameters: { |
|
||||
validate: (0, _utils.assertNodeType)("TSTypeParameterInstantiation"), |
|
||||
optional: true |
|
||||
} |
|
||||
}) |
|
||||
}); |
|
||||
(0, _utils.default)("CatchClause", { |
|
||||
visitor: ["param", "body"], |
|
||||
fields: { |
|
||||
param: { |
|
||||
validate: (0, _utils.assertNodeType)("Identifier", "ArrayPattern", "ObjectPattern"), |
|
||||
optional: true |
|
||||
}, |
|
||||
body: { |
|
||||
validate: (0, _utils.assertNodeType)("BlockStatement") |
|
||||
} |
|
||||
}, |
|
||||
aliases: ["Scopable", "BlockParent"] |
|
||||
}); |
|
||||
(0, _utils.default)("ConditionalExpression", { |
|
||||
visitor: ["test", "consequent", "alternate"], |
|
||||
fields: { |
|
||||
test: { |
|
||||
validate: (0, _utils.assertNodeType)("Expression") |
|
||||
}, |
|
||||
consequent: { |
|
||||
validate: (0, _utils.assertNodeType)("Expression") |
|
||||
}, |
|
||||
alternate: { |
|
||||
validate: (0, _utils.assertNodeType)("Expression") |
|
||||
} |
|
||||
}, |
|
||||
aliases: ["Expression", "Conditional"] |
|
||||
}); |
|
||||
(0, _utils.default)("ContinueStatement", { |
|
||||
visitor: ["label"], |
|
||||
fields: { |
|
||||
label: { |
|
||||
validate: (0, _utils.assertNodeType)("Identifier"), |
|
||||
optional: true |
|
||||
} |
|
||||
}, |
|
||||
aliases: ["Statement", "Terminatorless", "CompletionStatement"] |
|
||||
}); |
|
||||
(0, _utils.default)("DebuggerStatement", { |
|
||||
aliases: ["Statement"] |
|
||||
}); |
|
||||
(0, _utils.default)("DoWhileStatement", { |
|
||||
visitor: ["test", "body"], |
|
||||
fields: { |
|
||||
test: { |
|
||||
validate: (0, _utils.assertNodeType)("Expression") |
|
||||
}, |
|
||||
body: { |
|
||||
validate: (0, _utils.assertNodeType)("Statement") |
|
||||
} |
|
||||
}, |
|
||||
aliases: ["Statement", "BlockParent", "Loop", "While", "Scopable"] |
|
||||
}); |
|
||||
(0, _utils.default)("EmptyStatement", { |
|
||||
aliases: ["Statement"] |
|
||||
}); |
|
||||
(0, _utils.default)("ExpressionStatement", { |
|
||||
visitor: ["expression"], |
|
||||
fields: { |
|
||||
expression: { |
|
||||
validate: (0, _utils.assertNodeType)("Expression") |
|
||||
} |
|
||||
}, |
|
||||
aliases: ["Statement", "ExpressionWrapper"] |
|
||||
}); |
|
||||
(0, _utils.default)("File", { |
|
||||
builder: ["program", "comments", "tokens"], |
|
||||
visitor: ["program"], |
|
||||
fields: { |
|
||||
program: { |
|
||||
validate: (0, _utils.assertNodeType)("Program") |
|
||||
} |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("ForInStatement", { |
|
||||
visitor: ["left", "right", "body"], |
|
||||
aliases: ["Scopable", "Statement", "For", "BlockParent", "Loop", "ForXStatement"], |
|
||||
fields: { |
|
||||
left: { |
|
||||
validate: !process.env.BABEL_TYPES_8_BREAKING ? (0, _utils.assertNodeType)("VariableDeclaration", "LVal") : (0, _utils.assertNodeType)("VariableDeclaration", "Identifier", "MemberExpression", "ArrayPattern", "ObjectPattern") |
|
||||
}, |
|
||||
right: { |
|
||||
validate: (0, _utils.assertNodeType)("Expression") |
|
||||
}, |
|
||||
body: { |
|
||||
validate: (0, _utils.assertNodeType)("Statement") |
|
||||
} |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("ForStatement", { |
|
||||
visitor: ["init", "test", "update", "body"], |
|
||||
aliases: ["Scopable", "Statement", "For", "BlockParent", "Loop"], |
|
||||
fields: { |
|
||||
init: { |
|
||||
validate: (0, _utils.assertNodeType)("VariableDeclaration", "Expression"), |
|
||||
optional: true |
|
||||
}, |
|
||||
test: { |
|
||||
validate: (0, _utils.assertNodeType)("Expression"), |
|
||||
optional: true |
|
||||
}, |
|
||||
update: { |
|
||||
validate: (0, _utils.assertNodeType)("Expression"), |
|
||||
optional: true |
|
||||
}, |
|
||||
body: { |
|
||||
validate: (0, _utils.assertNodeType)("Statement") |
|
||||
} |
|
||||
} |
|
||||
}); |
|
||||
const functionCommon = { |
|
||||
params: { |
|
||||
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Identifier", "Pattern", "RestElement", "TSParameterProperty"))) |
|
||||
}, |
|
||||
generator: { |
|
||||
default: false |
|
||||
}, |
|
||||
async: { |
|
||||
default: false |
|
||||
} |
|
||||
}; |
|
||||
exports.functionCommon = functionCommon; |
|
||||
const functionTypeAnnotationCommon = { |
|
||||
returnType: { |
|
||||
validate: (0, _utils.assertNodeType)("TypeAnnotation", "TSTypeAnnotation", "Noop"), |
|
||||
optional: true |
|
||||
}, |
|
||||
typeParameters: { |
|
||||
validate: (0, _utils.assertNodeType)("TypeParameterDeclaration", "TSTypeParameterDeclaration", "Noop"), |
|
||||
optional: true |
|
||||
} |
|
||||
}; |
|
||||
exports.functionTypeAnnotationCommon = functionTypeAnnotationCommon; |
|
||||
const functionDeclarationCommon = Object.assign({}, functionCommon, { |
|
||||
declare: { |
|
||||
validate: (0, _utils.assertValueType)("boolean"), |
|
||||
optional: true |
|
||||
}, |
|
||||
id: { |
|
||||
validate: (0, _utils.assertNodeType)("Identifier"), |
|
||||
optional: true |
|
||||
} |
|
||||
}); |
|
||||
exports.functionDeclarationCommon = functionDeclarationCommon; |
|
||||
(0, _utils.default)("FunctionDeclaration", { |
|
||||
builder: ["id", "params", "body", "generator", "async"], |
|
||||
visitor: ["id", "params", "body", "returnType", "typeParameters"], |
|
||||
fields: Object.assign({}, functionDeclarationCommon, {}, functionTypeAnnotationCommon, { |
|
||||
body: { |
|
||||
validate: (0, _utils.assertNodeType)("BlockStatement") |
|
||||
} |
|
||||
}), |
|
||||
aliases: ["Scopable", "Function", "BlockParent", "FunctionParent", "Statement", "Pureish", "Declaration"], |
|
||||
validate: function () { |
|
||||
if (!process.env.BABEL_TYPES_8_BREAKING) return () => {}; |
|
||||
const identifier = (0, _utils.assertNodeType)("Identifier"); |
|
||||
return function (parent, key, node) { |
|
||||
if (!(0, _is.default)("ExportDefaultDeclaration", parent)) { |
|
||||
identifier(node, "id", node.id); |
|
||||
} |
|
||||
}; |
|
||||
}() |
|
||||
}); |
|
||||
(0, _utils.default)("FunctionExpression", { |
|
||||
inherits: "FunctionDeclaration", |
|
||||
aliases: ["Scopable", "Function", "BlockParent", "FunctionParent", "Expression", "Pureish"], |
|
||||
fields: Object.assign({}, functionCommon, {}, functionTypeAnnotationCommon, { |
|
||||
id: { |
|
||||
validate: (0, _utils.assertNodeType)("Identifier"), |
|
||||
optional: true |
|
||||
}, |
|
||||
body: { |
|
||||
validate: (0, _utils.assertNodeType)("BlockStatement") |
|
||||
} |
|
||||
}) |
|
||||
}); |
|
||||
const patternLikeCommon = { |
|
||||
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"))) |
|
||||
} |
|
||||
}; |
|
||||
exports.patternLikeCommon = patternLikeCommon; |
|
||||
(0, _utils.default)("Identifier", { |
|
||||
builder: ["name"], |
|
||||
visitor: ["typeAnnotation", "decorators"], |
|
||||
aliases: ["Expression", "PatternLike", "LVal", "TSEntityName"], |
|
||||
fields: Object.assign({}, patternLikeCommon, { |
|
||||
name: { |
|
||||
validate: (0, _utils.chain)((0, _utils.assertValueType)("string"), function (node, key, val) { |
|
||||
if (!process.env.BABEL_TYPES_8_BREAKING) return; |
|
||||
|
|
||||
if (!(0, _isValidIdentifier.default)(val, false)) { |
|
||||
throw new TypeError(`"${val}" is not a valid identifier name`); |
|
||||
} |
|
||||
}) |
|
||||
}, |
|
||||
optional: { |
|
||||
validate: (0, _utils.assertValueType)("boolean"), |
|
||||
optional: true |
|
||||
} |
|
||||
}), |
|
||||
|
|
||||
validate(parent, key, node) { |
|
||||
if (!process.env.BABEL_TYPES_8_BREAKING) return; |
|
||||
const match = /\.(\w+)$/.exec(key); |
|
||||
if (!match) return; |
|
||||
const [, parentKey] = match; |
|
||||
const nonComp = { |
|
||||
computed: false |
|
||||
}; |
|
||||
|
|
||||
if (parentKey === "property") { |
|
||||
if ((0, _is.default)("MemberExpression", parent, nonComp)) return; |
|
||||
if ((0, _is.default)("OptionalMemberExpression", parent, nonComp)) return; |
|
||||
} else if (parentKey === "key") { |
|
||||
if ((0, _is.default)("Property", parent, nonComp)) return; |
|
||||
if ((0, _is.default)("Method", parent, nonComp)) return; |
|
||||
} else if (parentKey === "exported") { |
|
||||
if ((0, _is.default)("ExportSpecifier", parent)) return; |
|
||||
} else if (parentKey === "imported") { |
|
||||
if ((0, _is.default)("ImportSpecifier", parent, { |
|
||||
imported: node |
|
||||
})) return; |
|
||||
} else if (parentKey === "meta") { |
|
||||
if ((0, _is.default)("MetaProperty", parent, { |
|
||||
meta: node |
|
||||
})) return; |
|
||||
} |
|
||||
|
|
||||
if (((0, _helperValidatorIdentifier.isKeyword)(node.name) || (0, _helperValidatorIdentifier.isReservedWord)(node.name)) && node.name !== "this") { |
|
||||
throw new TypeError(`"${node.name}" is not a valid identifier`); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
}); |
|
||||
(0, _utils.default)("IfStatement", { |
|
||||
visitor: ["test", "consequent", "alternate"], |
|
||||
aliases: ["Statement", "Conditional"], |
|
||||
fields: { |
|
||||
test: { |
|
||||
validate: (0, _utils.assertNodeType)("Expression") |
|
||||
}, |
|
||||
consequent: { |
|
||||
validate: (0, _utils.assertNodeType)("Statement") |
|
||||
}, |
|
||||
alternate: { |
|
||||
optional: true, |
|
||||
validate: (0, _utils.assertNodeType)("Statement") |
|
||||
} |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("LabeledStatement", { |
|
||||
visitor: ["label", "body"], |
|
||||
aliases: ["Statement"], |
|
||||
fields: { |
|
||||
label: { |
|
||||
validate: (0, _utils.assertNodeType)("Identifier") |
|
||||
}, |
|
||||
body: { |
|
||||
validate: (0, _utils.assertNodeType)("Statement") |
|
||||
} |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("StringLiteral", { |
|
||||
builder: ["value"], |
|
||||
fields: { |
|
||||
value: { |
|
||||
validate: (0, _utils.assertValueType)("string") |
|
||||
} |
|
||||
}, |
|
||||
aliases: ["Expression", "Pureish", "Literal", "Immutable"] |
|
||||
}); |
|
||||
(0, _utils.default)("NumericLiteral", { |
|
||||
builder: ["value"], |
|
||||
deprecatedAlias: "NumberLiteral", |
|
||||
fields: { |
|
||||
value: { |
|
||||
validate: (0, _utils.assertValueType)("number") |
|
||||
} |
|
||||
}, |
|
||||
aliases: ["Expression", "Pureish", "Literal", "Immutable"] |
|
||||
}); |
|
||||
(0, _utils.default)("NullLiteral", { |
|
||||
aliases: ["Expression", "Pureish", "Literal", "Immutable"] |
|
||||
}); |
|
||||
(0, _utils.default)("BooleanLiteral", { |
|
||||
builder: ["value"], |
|
||||
fields: { |
|
||||
value: { |
|
||||
validate: (0, _utils.assertValueType)("boolean") |
|
||||
} |
|
||||
}, |
|
||||
aliases: ["Expression", "Pureish", "Literal", "Immutable"] |
|
||||
}); |
|
||||
(0, _utils.default)("RegExpLiteral", { |
|
||||
builder: ["pattern", "flags"], |
|
||||
deprecatedAlias: "RegexLiteral", |
|
||||
aliases: ["Expression", "Pureish", "Literal"], |
|
||||
fields: { |
|
||||
pattern: { |
|
||||
validate: (0, _utils.assertValueType)("string") |
|
||||
}, |
|
||||
flags: { |
|
||||
validate: (0, _utils.chain)((0, _utils.assertValueType)("string"), function (node, key, val) { |
|
||||
if (!process.env.BABEL_TYPES_8_BREAKING) return; |
|
||||
const invalid = /[^gimsuy]/.exec(val); |
|
||||
|
|
||||
if (invalid) { |
|
||||
throw new TypeError(`"${invalid[0]}" is not a valid RegExp flag`); |
|
||||
} |
|
||||
}), |
|
||||
default: "" |
|
||||
} |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("LogicalExpression", { |
|
||||
builder: ["operator", "left", "right"], |
|
||||
visitor: ["left", "right"], |
|
||||
aliases: ["Binary", "Expression"], |
|
||||
fields: { |
|
||||
operator: { |
|
||||
validate: (0, _utils.assertOneOf)(..._constants.LOGICAL_OPERATORS) |
|
||||
}, |
|
||||
left: { |
|
||||
validate: (0, _utils.assertNodeType)("Expression") |
|
||||
}, |
|
||||
right: { |
|
||||
validate: (0, _utils.assertNodeType)("Expression") |
|
||||
} |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("MemberExpression", { |
|
||||
builder: ["object", "property", "computed", "optional"], |
|
||||
visitor: ["object", "property"], |
|
||||
aliases: ["Expression", "LVal"], |
|
||||
fields: Object.assign({ |
|
||||
object: { |
|
||||
validate: (0, _utils.assertNodeType)("Expression") |
|
||||
}, |
|
||||
property: { |
|
||||
validate: function () { |
|
||||
const normal = (0, _utils.assertNodeType)("Identifier", "PrivateName"); |
|
||||
const computed = (0, _utils.assertNodeType)("Expression"); |
|
||||
return function (node, key, val) { |
|
||||
const validator = node.computed ? computed : normal; |
|
||||
validator(node, key, val); |
|
||||
}; |
|
||||
}() |
|
||||
}, |
|
||||
computed: { |
|
||||
default: false |
|
||||
} |
|
||||
}, !process.env.BABEL_TYPES_8_BREAKING ? { |
|
||||
optional: { |
|
||||
validate: (0, _utils.assertOneOf)(true, false), |
|
||||
optional: true |
|
||||
} |
|
||||
} : {}) |
|
||||
}); |
|
||||
(0, _utils.default)("NewExpression", { |
|
||||
inherits: "CallExpression" |
|
||||
}); |
|
||||
(0, _utils.default)("Program", { |
|
||||
visitor: ["directives", "body"], |
|
||||
builder: ["body", "directives", "sourceType", "interpreter"], |
|
||||
fields: { |
|
||||
sourceFile: { |
|
||||
validate: (0, _utils.assertValueType)("string") |
|
||||
}, |
|
||||
sourceType: { |
|
||||
validate: (0, _utils.assertOneOf)("script", "module"), |
|
||||
default: "script" |
|
||||
}, |
|
||||
interpreter: { |
|
||||
validate: (0, _utils.assertNodeType)("InterpreterDirective"), |
|
||||
default: null, |
|
||||
optional: true |
|
||||
}, |
|
||||
directives: { |
|
||||
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Directive"))), |
|
||||
default: [] |
|
||||
}, |
|
||||
body: { |
|
||||
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Statement"))) |
|
||||
} |
|
||||
}, |
|
||||
aliases: ["Scopable", "BlockParent", "Block"] |
|
||||
}); |
|
||||
(0, _utils.default)("ObjectExpression", { |
|
||||
visitor: ["properties"], |
|
||||
aliases: ["Expression"], |
|
||||
fields: { |
|
||||
properties: { |
|
||||
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("ObjectMethod", "ObjectProperty", "SpreadElement"))) |
|
||||
} |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("ObjectMethod", { |
|
||||
builder: ["kind", "key", "params", "body", "computed", "generator", "async"], |
|
||||
fields: Object.assign({}, functionCommon, {}, functionTypeAnnotationCommon, { |
|
||||
kind: Object.assign({ |
|
||||
validate: (0, _utils.assertOneOf)("method", "get", "set") |
|
||||
}, !process.env.BABEL_TYPES_8_BREAKING ? { |
|
||||
default: "method" |
|
||||
} : {}), |
|
||||
computed: { |
|
||||
default: false |
|
||||
}, |
|
||||
key: { |
|
||||
validate: function () { |
|
||||
const normal = (0, _utils.assertNodeType)("Identifier", "StringLiteral", "NumericLiteral"); |
|
||||
const computed = (0, _utils.assertNodeType)("Expression"); |
|
||||
return function (node, key, val) { |
|
||||
const validator = node.computed ? computed : normal; |
|
||||
validator(node, key, val); |
|
||||
}; |
|
||||
}() |
|
||||
}, |
|
||||
decorators: { |
|
||||
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Decorator"))), |
|
||||
optional: true |
|
||||
}, |
|
||||
body: { |
|
||||
validate: (0, _utils.assertNodeType)("BlockStatement") |
|
||||
} |
|
||||
}), |
|
||||
visitor: ["key", "params", "body", "decorators", "returnType", "typeParameters"], |
|
||||
aliases: ["UserWhitespacable", "Function", "Scopable", "BlockParent", "FunctionParent", "Method", "ObjectMember"] |
|
||||
}); |
|
||||
(0, _utils.default)("ObjectProperty", { |
|
||||
builder: ["key", "value", "computed", "shorthand", ...(!process.env.BABEL_TYPES_8_BREAKING ? ["decorators"] : [])], |
|
||||
fields: { |
|
||||
computed: { |
|
||||
default: false |
|
||||
}, |
|
||||
key: { |
|
||||
validate: function () { |
|
||||
const normal = (0, _utils.assertNodeType)("Identifier", "StringLiteral", "NumericLiteral"); |
|
||||
const computed = (0, _utils.assertNodeType)("Expression"); |
|
||||
return function (node, key, val) { |
|
||||
const validator = node.computed ? computed : normal; |
|
||||
validator(node, key, val); |
|
||||
}; |
|
||||
}() |
|
||||
}, |
|
||||
value: { |
|
||||
validate: (0, _utils.assertNodeType)("Expression", "PatternLike") |
|
||||
}, |
|
||||
shorthand: { |
|
||||
validate: (0, _utils.chain)((0, _utils.assertValueType)("boolean"), function (node, key, val) { |
|
||||
if (!process.env.BABEL_TYPES_8_BREAKING) return; |
|
||||
|
|
||||
if (val && node.computed) { |
|
||||
throw new TypeError("Property shorthand of ObjectProperty cannot be true if computed is true"); |
|
||||
} |
|
||||
}, function (node, key, val) { |
|
||||
if (!process.env.BABEL_TYPES_8_BREAKING) return; |
|
||||
|
|
||||
if (val && !(0, _is.default)("Identifier", node.key)) { |
|
||||
throw new TypeError("Property shorthand of ObjectProperty cannot be true if key is not an Identifier"); |
|
||||
} |
|
||||
}), |
|
||||
default: false |
|
||||
}, |
|
||||
decorators: { |
|
||||
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Decorator"))), |
|
||||
optional: true |
|
||||
} |
|
||||
}, |
|
||||
visitor: ["key", "value", "decorators"], |
|
||||
aliases: ["UserWhitespacable", "Property", "ObjectMember"], |
|
||||
validate: function () { |
|
||||
const pattern = (0, _utils.assertNodeType)("Identifier", "Pattern"); |
|
||||
const expression = (0, _utils.assertNodeType)("Expression"); |
|
||||
return function (parent, key, node) { |
|
||||
if (!process.env.BABEL_TYPES_8_BREAKING) return; |
|
||||
const validator = (0, _is.default)("ObjectPattern", parent) ? pattern : expression; |
|
||||
validator(node, "value", node.value); |
|
||||
}; |
|
||||
}() |
|
||||
}); |
|
||||
(0, _utils.default)("RestElement", { |
|
||||
visitor: ["argument", "typeAnnotation"], |
|
||||
builder: ["argument"], |
|
||||
aliases: ["LVal", "PatternLike"], |
|
||||
deprecatedAlias: "RestProperty", |
|
||||
fields: Object.assign({}, patternLikeCommon, { |
|
||||
argument: { |
|
||||
validate: !process.env.BABEL_TYPES_8_BREAKING ? (0, _utils.assertNodeType)("LVal") : (0, _utils.assertNodeType)("Identifier", "Pattern", "MemberExpression") |
|
||||
} |
|
||||
}), |
|
||||
|
|
||||
validate(parent, key) { |
|
||||
if (!process.env.BABEL_TYPES_8_BREAKING) return; |
|
||||
const match = /(\w+)\[(\d+)\]/.exec(key); |
|
||||
if (!match) throw new Error("Internal Babel error: malformed key."); |
|
||||
const [, listKey, index] = match; |
|
||||
|
|
||||
if (parent[listKey].length > index + 1) { |
|
||||
throw new TypeError(`RestElement must be last element of ${listKey}`); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
}); |
|
||||
(0, _utils.default)("ReturnStatement", { |
|
||||
visitor: ["argument"], |
|
||||
aliases: ["Statement", "Terminatorless", "CompletionStatement"], |
|
||||
fields: { |
|
||||
argument: { |
|
||||
validate: (0, _utils.assertNodeType)("Expression"), |
|
||||
optional: true |
|
||||
} |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("SequenceExpression", { |
|
||||
visitor: ["expressions"], |
|
||||
fields: { |
|
||||
expressions: { |
|
||||
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Expression"))) |
|
||||
} |
|
||||
}, |
|
||||
aliases: ["Expression"] |
|
||||
}); |
|
||||
(0, _utils.default)("ParenthesizedExpression", { |
|
||||
visitor: ["expression"], |
|
||||
aliases: ["Expression", "ExpressionWrapper"], |
|
||||
fields: { |
|
||||
expression: { |
|
||||
validate: (0, _utils.assertNodeType)("Expression") |
|
||||
} |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("SwitchCase", { |
|
||||
visitor: ["test", "consequent"], |
|
||||
fields: { |
|
||||
test: { |
|
||||
validate: (0, _utils.assertNodeType)("Expression"), |
|
||||
optional: true |
|
||||
}, |
|
||||
consequent: { |
|
||||
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Statement"))) |
|
||||
} |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("SwitchStatement", { |
|
||||
visitor: ["discriminant", "cases"], |
|
||||
aliases: ["Statement", "BlockParent", "Scopable"], |
|
||||
fields: { |
|
||||
discriminant: { |
|
||||
validate: (0, _utils.assertNodeType)("Expression") |
|
||||
}, |
|
||||
cases: { |
|
||||
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("SwitchCase"))) |
|
||||
} |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("ThisExpression", { |
|
||||
aliases: ["Expression"] |
|
||||
}); |
|
||||
(0, _utils.default)("ThrowStatement", { |
|
||||
visitor: ["argument"], |
|
||||
aliases: ["Statement", "Terminatorless", "CompletionStatement"], |
|
||||
fields: { |
|
||||
argument: { |
|
||||
validate: (0, _utils.assertNodeType)("Expression") |
|
||||
} |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("TryStatement", { |
|
||||
visitor: ["block", "handler", "finalizer"], |
|
||||
aliases: ["Statement"], |
|
||||
fields: { |
|
||||
block: { |
|
||||
validate: (0, _utils.chain)((0, _utils.assertNodeType)("BlockStatement"), function (node) { |
|
||||
if (!process.env.BABEL_TYPES_8_BREAKING) return; |
|
||||
|
|
||||
if (!node.handler && !node.finalizer) { |
|
||||
throw new TypeError("TryStatement expects either a handler or finalizer, or both"); |
|
||||
} |
|
||||
}) |
|
||||
}, |
|
||||
handler: { |
|
||||
optional: true, |
|
||||
validate: (0, _utils.assertNodeType)("CatchClause") |
|
||||
}, |
|
||||
finalizer: { |
|
||||
optional: true, |
|
||||
validate: (0, _utils.assertNodeType)("BlockStatement") |
|
||||
} |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("UnaryExpression", { |
|
||||
builder: ["operator", "argument", "prefix"], |
|
||||
fields: { |
|
||||
prefix: { |
|
||||
default: true |
|
||||
}, |
|
||||
argument: { |
|
||||
validate: (0, _utils.assertNodeType)("Expression") |
|
||||
}, |
|
||||
operator: { |
|
||||
validate: (0, _utils.assertOneOf)(..._constants.UNARY_OPERATORS) |
|
||||
} |
|
||||
}, |
|
||||
visitor: ["argument"], |
|
||||
aliases: ["UnaryLike", "Expression"] |
|
||||
}); |
|
||||
(0, _utils.default)("UpdateExpression", { |
|
||||
builder: ["operator", "argument", "prefix"], |
|
||||
fields: { |
|
||||
prefix: { |
|
||||
default: false |
|
||||
}, |
|
||||
argument: { |
|
||||
validate: !process.env.BABEL_TYPES_8_BREAKING ? (0, _utils.assertNodeType)("Expression") : (0, _utils.assertNodeType)("Identifier", "MemberExpression") |
|
||||
}, |
|
||||
operator: { |
|
||||
validate: (0, _utils.assertOneOf)(..._constants.UPDATE_OPERATORS) |
|
||||
} |
|
||||
}, |
|
||||
visitor: ["argument"], |
|
||||
aliases: ["Expression"] |
|
||||
}); |
|
||||
(0, _utils.default)("VariableDeclaration", { |
|
||||
builder: ["kind", "declarations"], |
|
||||
visitor: ["declarations"], |
|
||||
aliases: ["Statement", "Declaration"], |
|
||||
fields: { |
|
||||
declare: { |
|
||||
validate: (0, _utils.assertValueType)("boolean"), |
|
||||
optional: true |
|
||||
}, |
|
||||
kind: { |
|
||||
validate: (0, _utils.assertOneOf)("var", "let", "const") |
|
||||
}, |
|
||||
declarations: { |
|
||||
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("VariableDeclarator"))) |
|
||||
} |
|
||||
}, |
|
||||
|
|
||||
validate(parent, key, node) { |
|
||||
if (!process.env.BABEL_TYPES_8_BREAKING) return; |
|
||||
if (!(0, _is.default)("ForXStatement", parent, { |
|
||||
left: node |
|
||||
})) return; |
|
||||
|
|
||||
if (node.declarations.length !== 1) { |
|
||||
throw new TypeError(`Exactly one VariableDeclarator is required in the VariableDeclaration of a ${parent.type}`); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
}); |
|
||||
(0, _utils.default)("VariableDeclarator", { |
|
||||
visitor: ["id", "init"], |
|
||||
fields: { |
|
||||
id: { |
|
||||
validate: function () { |
|
||||
if (!process.env.BABEL_TYPES_8_BREAKING) { |
|
||||
return (0, _utils.assertNodeType)("LVal"); |
|
||||
} |
|
||||
|
|
||||
const normal = (0, _utils.assertNodeType)("Identifier", "ArrayPattern", "ObjectPattern"); |
|
||||
const without = (0, _utils.assertNodeType)("Identifier"); |
|
||||
return function (node, key, val) { |
|
||||
const validator = node.init ? normal : without; |
|
||||
validator(node, key, val); |
|
||||
}; |
|
||||
}() |
|
||||
}, |
|
||||
definite: { |
|
||||
optional: true, |
|
||||
validate: (0, _utils.assertValueType)("boolean") |
|
||||
}, |
|
||||
init: { |
|
||||
optional: true, |
|
||||
validate: (0, _utils.assertNodeType)("Expression") |
|
||||
} |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("WhileStatement", { |
|
||||
visitor: ["test", "body"], |
|
||||
aliases: ["Statement", "BlockParent", "Loop", "While", "Scopable"], |
|
||||
fields: { |
|
||||
test: { |
|
||||
validate: (0, _utils.assertNodeType)("Expression") |
|
||||
}, |
|
||||
body: { |
|
||||
validate: (0, _utils.assertNodeType)("Statement") |
|
||||
} |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("WithStatement", { |
|
||||
visitor: ["object", "body"], |
|
||||
aliases: ["Statement"], |
|
||||
fields: { |
|
||||
object: { |
|
||||
validate: (0, _utils.assertNodeType)("Expression") |
|
||||
}, |
|
||||
body: { |
|
||||
validate: (0, _utils.assertNodeType)("Statement") |
|
||||
} |
|
||||
} |
|
||||
}); |
|
||||
@ -1,467 +0,0 @@ |
|||||
"use strict"; |
|
||||
|
|
||||
Object.defineProperty(exports, "__esModule", { |
|
||||
value: true |
|
||||
}); |
|
||||
exports.classMethodOrDeclareMethodCommon = exports.classMethodOrPropertyCommon = void 0; |
|
||||
|
|
||||
var _utils = _interopRequireWildcard(require("./utils")); |
|
||||
|
|
||||
var _core = require("./core"); |
|
||||
|
|
||||
var _is = _interopRequireDefault(require("../validators/is")); |
|
||||
|
|
||||
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; } |
|
||||
|
|
||||
(0, _utils.default)("AssignmentPattern", { |
|
||||
visitor: ["left", "right", "decorators"], |
|
||||
builder: ["left", "right"], |
|
||||
aliases: ["Pattern", "PatternLike", "LVal"], |
|
||||
fields: Object.assign({}, _core.patternLikeCommon, { |
|
||||
left: { |
|
||||
validate: (0, _utils.assertNodeType)("Identifier", "ObjectPattern", "ArrayPattern", "MemberExpression") |
|
||||
}, |
|
||||
right: { |
|
||||
validate: (0, _utils.assertNodeType)("Expression") |
|
||||
}, |
|
||||
decorators: { |
|
||||
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Decorator"))), |
|
||||
optional: true |
|
||||
} |
|
||||
}) |
|
||||
}); |
|
||||
(0, _utils.default)("ArrayPattern", { |
|
||||
visitor: ["elements", "typeAnnotation"], |
|
||||
builder: ["elements"], |
|
||||
aliases: ["Pattern", "PatternLike", "LVal"], |
|
||||
fields: Object.assign({}, _core.patternLikeCommon, { |
|
||||
elements: { |
|
||||
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeOrValueType)("null", "PatternLike"))) |
|
||||
}, |
|
||||
decorators: { |
|
||||
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Decorator"))), |
|
||||
optional: true |
|
||||
} |
|
||||
}) |
|
||||
}); |
|
||||
(0, _utils.default)("ArrowFunctionExpression", { |
|
||||
builder: ["params", "body", "async"], |
|
||||
visitor: ["params", "body", "returnType", "typeParameters"], |
|
||||
aliases: ["Scopable", "Function", "BlockParent", "FunctionParent", "Expression", "Pureish"], |
|
||||
fields: Object.assign({}, _core.functionCommon, {}, _core.functionTypeAnnotationCommon, { |
|
||||
expression: { |
|
||||
validate: (0, _utils.assertValueType)("boolean") |
|
||||
}, |
|
||||
body: { |
|
||||
validate: (0, _utils.assertNodeType)("BlockStatement", "Expression") |
|
||||
} |
|
||||
}) |
|
||||
}); |
|
||||
(0, _utils.default)("ClassBody", { |
|
||||
visitor: ["body"], |
|
||||
fields: { |
|
||||
body: { |
|
||||
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("ClassMethod", "ClassPrivateMethod", "ClassProperty", "ClassPrivateProperty", "TSDeclareMethod", "TSIndexSignature"))) |
|
||||
} |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("ClassExpression", { |
|
||||
builder: ["id", "superClass", "body", "decorators"], |
|
||||
visitor: ["id", "body", "superClass", "mixins", "typeParameters", "superTypeParameters", "implements", "decorators"], |
|
||||
aliases: ["Scopable", "Class", "Expression"], |
|
||||
fields: { |
|
||||
id: { |
|
||||
validate: (0, _utils.assertNodeType)("Identifier"), |
|
||||
optional: true |
|
||||
}, |
|
||||
typeParameters: { |
|
||||
validate: (0, _utils.assertNodeType)("TypeParameterDeclaration", "TSTypeParameterDeclaration", "Noop"), |
|
||||
optional: true |
|
||||
}, |
|
||||
body: { |
|
||||
validate: (0, _utils.assertNodeType)("ClassBody") |
|
||||
}, |
|
||||
superClass: { |
|
||||
optional: true, |
|
||||
validate: (0, _utils.assertNodeType)("Expression") |
|
||||
}, |
|
||||
superTypeParameters: { |
|
||||
validate: (0, _utils.assertNodeType)("TypeParameterInstantiation", "TSTypeParameterInstantiation"), |
|
||||
optional: true |
|
||||
}, |
|
||||
implements: { |
|
||||
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("TSExpressionWithTypeArguments", "ClassImplements"))), |
|
||||
optional: true |
|
||||
}, |
|
||||
decorators: { |
|
||||
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Decorator"))), |
|
||||
optional: true |
|
||||
} |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("ClassDeclaration", { |
|
||||
inherits: "ClassExpression", |
|
||||
aliases: ["Scopable", "Class", "Statement", "Declaration"], |
|
||||
fields: { |
|
||||
declare: { |
|
||||
validate: (0, _utils.assertValueType)("boolean"), |
|
||||
optional: true |
|
||||
}, |
|
||||
abstract: { |
|
||||
validate: (0, _utils.assertValueType)("boolean"), |
|
||||
optional: true |
|
||||
} |
|
||||
}, |
|
||||
validate: function () { |
|
||||
const identifier = (0, _utils.assertNodeType)("Identifier"); |
|
||||
return function (parent, key, node) { |
|
||||
if (!process.env.BABEL_TYPES_8_BREAKING) return; |
|
||||
|
|
||||
if (!(0, _is.default)("ExportDefaultDeclaration", parent)) { |
|
||||
identifier(node, "id", node.id); |
|
||||
} |
|
||||
}; |
|
||||
}() |
|
||||
}); |
|
||||
(0, _utils.default)("ExportAllDeclaration", { |
|
||||
visitor: ["source"], |
|
||||
aliases: ["Statement", "Declaration", "ModuleDeclaration", "ExportDeclaration"], |
|
||||
fields: { |
|
||||
source: { |
|
||||
validate: (0, _utils.assertNodeType)("StringLiteral") |
|
||||
} |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("ExportDefaultDeclaration", { |
|
||||
visitor: ["declaration"], |
|
||||
aliases: ["Statement", "Declaration", "ModuleDeclaration", "ExportDeclaration"], |
|
||||
fields: { |
|
||||
declaration: { |
|
||||
validate: (0, _utils.assertNodeType)("FunctionDeclaration", "TSDeclareFunction", "ClassDeclaration", "Expression") |
|
||||
} |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("ExportNamedDeclaration", { |
|
||||
visitor: ["declaration", "specifiers", "source"], |
|
||||
aliases: ["Statement", "Declaration", "ModuleDeclaration", "ExportDeclaration"], |
|
||||
fields: { |
|
||||
declaration: { |
|
||||
optional: true, |
|
||||
validate: (0, _utils.chain)((0, _utils.assertNodeType)("Declaration"), function (node, key, val) { |
|
||||
if (!process.env.BABEL_TYPES_8_BREAKING) return; |
|
||||
|
|
||||
if (val && node.specifiers.length) { |
|
||||
throw new TypeError("Only declaration or specifiers is allowed on ExportNamedDeclaration"); |
|
||||
} |
|
||||
}, function (node, key, val) { |
|
||||
if (!process.env.BABEL_TYPES_8_BREAKING) return; |
|
||||
|
|
||||
if (val && node.source) { |
|
||||
throw new TypeError("Cannot export a declaration from a source"); |
|
||||
} |
|
||||
}) |
|
||||
}, |
|
||||
specifiers: { |
|
||||
default: [], |
|
||||
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)(function () { |
|
||||
const sourced = (0, _utils.assertNodeType)("ExportSpecifier", "ExportDefaultSpecifier", "ExportNamespaceSpecifier"); |
|
||||
const sourceless = (0, _utils.assertNodeType)("ExportSpecifier"); |
|
||||
if (!process.env.BABEL_TYPES_8_BREAKING) return sourced; |
|
||||
return function (node, key, val) { |
|
||||
const validator = node.source ? sourced : sourceless; |
|
||||
validator(node, key, val); |
|
||||
}; |
|
||||
}())) |
|
||||
}, |
|
||||
source: { |
|
||||
validate: (0, _utils.assertNodeType)("StringLiteral"), |
|
||||
optional: true |
|
||||
}, |
|
||||
exportKind: (0, _utils.validateOptional)((0, _utils.assertOneOf)("type", "value")) |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("ExportSpecifier", { |
|
||||
visitor: ["local", "exported"], |
|
||||
aliases: ["ModuleSpecifier"], |
|
||||
fields: { |
|
||||
local: { |
|
||||
validate: (0, _utils.assertNodeType)("Identifier") |
|
||||
}, |
|
||||
exported: { |
|
||||
validate: (0, _utils.assertNodeType)("Identifier") |
|
||||
} |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("ForOfStatement", { |
|
||||
visitor: ["left", "right", "body"], |
|
||||
builder: ["left", "right", "body", "await"], |
|
||||
aliases: ["Scopable", "Statement", "For", "BlockParent", "Loop", "ForXStatement"], |
|
||||
fields: { |
|
||||
left: { |
|
||||
validate: function () { |
|
||||
if (!process.env.BABEL_TYPES_8_BREAKING) { |
|
||||
return (0, _utils.assertNodeType)("VariableDeclaration", "LVal"); |
|
||||
} |
|
||||
|
|
||||
const declaration = (0, _utils.assertNodeType)("VariableDeclaration"); |
|
||||
const lval = (0, _utils.assertNodeType)("Identifier", "MemberExpression", "ArrayPattern", "ObjectPattern"); |
|
||||
return function (node, key, val) { |
|
||||
if ((0, _is.default)("VariableDeclaration", val)) { |
|
||||
declaration(node, key, val); |
|
||||
} else { |
|
||||
lval(node, key, val); |
|
||||
} |
|
||||
}; |
|
||||
}() |
|
||||
}, |
|
||||
right: { |
|
||||
validate: (0, _utils.assertNodeType)("Expression") |
|
||||
}, |
|
||||
body: { |
|
||||
validate: (0, _utils.assertNodeType)("Statement") |
|
||||
}, |
|
||||
await: { |
|
||||
default: false |
|
||||
} |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("ImportDeclaration", { |
|
||||
visitor: ["specifiers", "source"], |
|
||||
aliases: ["Statement", "Declaration", "ModuleDeclaration"], |
|
||||
fields: { |
|
||||
specifiers: { |
|
||||
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("ImportSpecifier", "ImportDefaultSpecifier", "ImportNamespaceSpecifier"))) |
|
||||
}, |
|
||||
source: { |
|
||||
validate: (0, _utils.assertNodeType)("StringLiteral") |
|
||||
}, |
|
||||
importKind: { |
|
||||
validate: (0, _utils.assertOneOf)("type", "typeof", "value"), |
|
||||
optional: true |
|
||||
} |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("ImportDefaultSpecifier", { |
|
||||
visitor: ["local"], |
|
||||
aliases: ["ModuleSpecifier"], |
|
||||
fields: { |
|
||||
local: { |
|
||||
validate: (0, _utils.assertNodeType)("Identifier") |
|
||||
} |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("ImportNamespaceSpecifier", { |
|
||||
visitor: ["local"], |
|
||||
aliases: ["ModuleSpecifier"], |
|
||||
fields: { |
|
||||
local: { |
|
||||
validate: (0, _utils.assertNodeType)("Identifier") |
|
||||
} |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("ImportSpecifier", { |
|
||||
visitor: ["local", "imported"], |
|
||||
aliases: ["ModuleSpecifier"], |
|
||||
fields: { |
|
||||
local: { |
|
||||
validate: (0, _utils.assertNodeType)("Identifier") |
|
||||
}, |
|
||||
imported: { |
|
||||
validate: (0, _utils.assertNodeType)("Identifier") |
|
||||
}, |
|
||||
importKind: { |
|
||||
validate: (0, _utils.assertOneOf)("type", "typeof"), |
|
||||
optional: true |
|
||||
} |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("MetaProperty", { |
|
||||
visitor: ["meta", "property"], |
|
||||
aliases: ["Expression"], |
|
||||
fields: { |
|
||||
meta: { |
|
||||
validate: (0, _utils.chain)((0, _utils.assertNodeType)("Identifier"), function (node, key, val) { |
|
||||
if (!process.env.BABEL_TYPES_8_BREAKING) return; |
|
||||
let property; |
|
||||
|
|
||||
switch (val.name) { |
|
||||
case "function": |
|
||||
property = "sent"; |
|
||||
break; |
|
||||
|
|
||||
case "new": |
|
||||
property = "target"; |
|
||||
break; |
|
||||
|
|
||||
case "import": |
|
||||
property = "meta"; |
|
||||
break; |
|
||||
} |
|
||||
|
|
||||
if (!(0, _is.default)("Identifier", node.property, { |
|
||||
name: property |
|
||||
})) { |
|
||||
throw new TypeError("Unrecognised MetaProperty"); |
|
||||
} |
|
||||
}) |
|
||||
}, |
|
||||
property: { |
|
||||
validate: (0, _utils.assertNodeType)("Identifier") |
|
||||
} |
|
||||
} |
|
||||
}); |
|
||||
const classMethodOrPropertyCommon = { |
|
||||
abstract: { |
|
||||
validate: (0, _utils.assertValueType)("boolean"), |
|
||||
optional: true |
|
||||
}, |
|
||||
accessibility: { |
|
||||
validate: (0, _utils.assertOneOf)("public", "private", "protected"), |
|
||||
optional: true |
|
||||
}, |
|
||||
static: { |
|
||||
default: false |
|
||||
}, |
|
||||
computed: { |
|
||||
default: false |
|
||||
}, |
|
||||
optional: { |
|
||||
validate: (0, _utils.assertValueType)("boolean"), |
|
||||
optional: true |
|
||||
}, |
|
||||
key: { |
|
||||
validate: (0, _utils.chain)(function () { |
|
||||
const normal = (0, _utils.assertNodeType)("Identifier", "StringLiteral", "NumericLiteral"); |
|
||||
const computed = (0, _utils.assertNodeType)("Expression"); |
|
||||
return function (node, key, val) { |
|
||||
const validator = node.computed ? computed : normal; |
|
||||
validator(node, key, val); |
|
||||
}; |
|
||||
}(), (0, _utils.assertNodeType)("Identifier", "StringLiteral", "NumericLiteral", "Expression")) |
|
||||
} |
|
||||
}; |
|
||||
exports.classMethodOrPropertyCommon = classMethodOrPropertyCommon; |
|
||||
const classMethodOrDeclareMethodCommon = Object.assign({}, _core.functionCommon, {}, classMethodOrPropertyCommon, { |
|
||||
kind: { |
|
||||
validate: (0, _utils.assertOneOf)("get", "set", "method", "constructor"), |
|
||||
default: "method" |
|
||||
}, |
|
||||
access: { |
|
||||
validate: (0, _utils.chain)((0, _utils.assertValueType)("string"), (0, _utils.assertOneOf)("public", "private", "protected")), |
|
||||
optional: true |
|
||||
}, |
|
||||
decorators: { |
|
||||
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Decorator"))), |
|
||||
optional: true |
|
||||
} |
|
||||
}); |
|
||||
exports.classMethodOrDeclareMethodCommon = classMethodOrDeclareMethodCommon; |
|
||||
(0, _utils.default)("ClassMethod", { |
|
||||
aliases: ["Function", "Scopable", "BlockParent", "FunctionParent", "Method"], |
|
||||
builder: ["kind", "key", "params", "body", "computed", "static", "generator", "async"], |
|
||||
visitor: ["key", "params", "body", "decorators", "returnType", "typeParameters"], |
|
||||
fields: Object.assign({}, classMethodOrDeclareMethodCommon, {}, _core.functionTypeAnnotationCommon, { |
|
||||
body: { |
|
||||
validate: (0, _utils.assertNodeType)("BlockStatement") |
|
||||
} |
|
||||
}) |
|
||||
}); |
|
||||
(0, _utils.default)("ObjectPattern", { |
|
||||
visitor: ["properties", "typeAnnotation", "decorators"], |
|
||||
builder: ["properties"], |
|
||||
aliases: ["Pattern", "PatternLike", "LVal"], |
|
||||
fields: Object.assign({}, _core.patternLikeCommon, { |
|
||||
properties: { |
|
||||
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("RestElement", "ObjectProperty"))) |
|
||||
} |
|
||||
}) |
|
||||
}); |
|
||||
(0, _utils.default)("SpreadElement", { |
|
||||
visitor: ["argument"], |
|
||||
aliases: ["UnaryLike"], |
|
||||
deprecatedAlias: "SpreadProperty", |
|
||||
fields: { |
|
||||
argument: { |
|
||||
validate: (0, _utils.assertNodeType)("Expression") |
|
||||
} |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("Super", { |
|
||||
aliases: ["Expression"] |
|
||||
}); |
|
||||
(0, _utils.default)("TaggedTemplateExpression", { |
|
||||
visitor: ["tag", "quasi"], |
|
||||
aliases: ["Expression"], |
|
||||
fields: { |
|
||||
tag: { |
|
||||
validate: (0, _utils.assertNodeType)("Expression") |
|
||||
}, |
|
||||
quasi: { |
|
||||
validate: (0, _utils.assertNodeType)("TemplateLiteral") |
|
||||
}, |
|
||||
typeParameters: { |
|
||||
validate: (0, _utils.assertNodeType)("TypeParameterInstantiation", "TSTypeParameterInstantiation"), |
|
||||
optional: true |
|
||||
} |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("TemplateElement", { |
|
||||
builder: ["value", "tail"], |
|
||||
fields: { |
|
||||
value: { |
|
||||
validate: (0, _utils.assertShape)({ |
|
||||
raw: { |
|
||||
validate: (0, _utils.assertValueType)("string") |
|
||||
}, |
|
||||
cooked: { |
|
||||
validate: (0, _utils.assertValueType)("string"), |
|
||||
optional: true |
|
||||
} |
|
||||
}) |
|
||||
}, |
|
||||
tail: { |
|
||||
default: false |
|
||||
} |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("TemplateLiteral", { |
|
||||
visitor: ["quasis", "expressions"], |
|
||||
aliases: ["Expression", "Literal"], |
|
||||
fields: { |
|
||||
quasis: { |
|
||||
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("TemplateElement"))) |
|
||||
}, |
|
||||
expressions: { |
|
||||
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Expression")), function (node, key, val) { |
|
||||
if (node.quasis.length !== val.length + 1) { |
|
||||
throw new TypeError(`Number of ${node.type} quasis should be exactly one more than the number of expressions.\nExpected ${val.length + 1} quasis but got ${node.quasis.length}`); |
|
||||
} |
|
||||
}) |
|
||||
} |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("YieldExpression", { |
|
||||
builder: ["argument", "delegate"], |
|
||||
visitor: ["argument"], |
|
||||
aliases: ["Expression", "Terminatorless"], |
|
||||
fields: { |
|
||||
delegate: { |
|
||||
validate: (0, _utils.chain)((0, _utils.assertValueType)("boolean"), function (node, key, val) { |
|
||||
if (!process.env.BABEL_TYPES_8_BREAKING) return; |
|
||||
|
|
||||
if (val && !node.argument) { |
|
||||
throw new TypeError("Property delegate of YieldExpression cannot be true if there is no argument"); |
|
||||
} |
|
||||
}), |
|
||||
default: false |
|
||||
}, |
|
||||
argument: { |
|
||||
optional: true, |
|
||||
validate: (0, _utils.assertNodeType)("Expression") |
|
||||
} |
|
||||
} |
|
||||
}); |
|
||||
@ -1,241 +0,0 @@ |
|||||
"use strict"; |
|
||||
|
|
||||
var _utils = _interopRequireWildcard(require("./utils")); |
|
||||
|
|
||||
var _es = require("./es2015"); |
|
||||
|
|
||||
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; } |
|
||||
|
|
||||
(0, _utils.default)("ArgumentPlaceholder", {}); |
|
||||
(0, _utils.default)("AwaitExpression", { |
|
||||
builder: ["argument"], |
|
||||
visitor: ["argument"], |
|
||||
aliases: ["Expression", "Terminatorless"], |
|
||||
fields: { |
|
||||
argument: { |
|
||||
validate: (0, _utils.assertNodeType)("Expression") |
|
||||
} |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("BindExpression", { |
|
||||
visitor: ["object", "callee"], |
|
||||
aliases: ["Expression"], |
|
||||
fields: !process.env.BABEL_TYPES_8_BREAKING ? {} : { |
|
||||
object: { |
|
||||
validate: (0, _utils.assertNodeType)("Expression") |
|
||||
}, |
|
||||
callee: { |
|
||||
validate: (0, _utils.assertNodeType)("Expression") |
|
||||
} |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("ClassProperty", { |
|
||||
visitor: ["key", "value", "typeAnnotation", "decorators"], |
|
||||
builder: ["key", "value", "typeAnnotation", "decorators", "computed", "static"], |
|
||||
aliases: ["Property"], |
|
||||
fields: Object.assign({}, _es.classMethodOrPropertyCommon, { |
|
||||
value: { |
|
||||
validate: (0, _utils.assertNodeType)("Expression"), |
|
||||
optional: true |
|
||||
}, |
|
||||
definite: { |
|
||||
validate: (0, _utils.assertValueType)("boolean"), |
|
||||
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 |
|
||||
}, |
|
||||
readonly: { |
|
||||
validate: (0, _utils.assertValueType)("boolean"), |
|
||||
optional: true |
|
||||
}, |
|
||||
declare: { |
|
||||
validate: (0, _utils.assertValueType)("boolean"), |
|
||||
optional: true |
|
||||
} |
|
||||
}) |
|
||||
}); |
|
||||
(0, _utils.default)("OptionalMemberExpression", { |
|
||||
builder: ["object", "property", "computed", "optional"], |
|
||||
visitor: ["object", "property"], |
|
||||
aliases: ["Expression"], |
|
||||
fields: { |
|
||||
object: { |
|
||||
validate: (0, _utils.assertNodeType)("Expression") |
|
||||
}, |
|
||||
property: { |
|
||||
validate: function () { |
|
||||
const normal = (0, _utils.assertNodeType)("Identifier"); |
|
||||
const computed = (0, _utils.assertNodeType)("Expression"); |
|
||||
return function (node, key, val) { |
|
||||
const validator = node.computed ? computed : normal; |
|
||||
validator(node, key, val); |
|
||||
}; |
|
||||
}() |
|
||||
}, |
|
||||
computed: { |
|
||||
default: false |
|
||||
}, |
|
||||
optional: { |
|
||||
validate: !process.env.BABEL_TYPES_8_BREAKING ? (0, _utils.assertValueType)("boolean") : (0, _utils.chain)((0, _utils.assertValueType)("boolean"), (0, _utils.assertOptionalChainStart)()) |
|
||||
} |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("PipelineTopicExpression", { |
|
||||
builder: ["expression"], |
|
||||
visitor: ["expression"], |
|
||||
fields: { |
|
||||
expression: { |
|
||||
validate: (0, _utils.assertNodeType)("Expression") |
|
||||
} |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("PipelineBareFunction", { |
|
||||
builder: ["callee"], |
|
||||
visitor: ["callee"], |
|
||||
fields: { |
|
||||
callee: { |
|
||||
validate: (0, _utils.assertNodeType)("Expression") |
|
||||
} |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("PipelinePrimaryTopicReference", { |
|
||||
aliases: ["Expression"] |
|
||||
}); |
|
||||
(0, _utils.default)("OptionalCallExpression", { |
|
||||
visitor: ["callee", "arguments", "typeParameters", "typeArguments"], |
|
||||
builder: ["callee", "arguments", "optional"], |
|
||||
aliases: ["Expression"], |
|
||||
fields: { |
|
||||
callee: { |
|
||||
validate: (0, _utils.assertNodeType)("Expression") |
|
||||
}, |
|
||||
arguments: { |
|
||||
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Expression", "SpreadElement", "JSXNamespacedName"))) |
|
||||
}, |
|
||||
optional: { |
|
||||
validate: !process.env.BABEL_TYPES_8_BREAKING ? (0, _utils.assertValueType)("boolean") : (0, _utils.chain)((0, _utils.assertValueType)("boolean"), (0, _utils.assertOptionalChainStart)()) |
|
||||
}, |
|
||||
typeArguments: { |
|
||||
validate: (0, _utils.assertNodeType)("TypeParameterInstantiation"), |
|
||||
optional: true |
|
||||
}, |
|
||||
typeParameters: { |
|
||||
validate: (0, _utils.assertNodeType)("TSTypeParameterInstantiation"), |
|
||||
optional: true |
|
||||
} |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("ClassPrivateProperty", { |
|
||||
visitor: ["key", "value", "decorators"], |
|
||||
builder: ["key", "value", "decorators"], |
|
||||
aliases: ["Property", "Private"], |
|
||||
fields: { |
|
||||
key: { |
|
||||
validate: (0, _utils.assertNodeType)("PrivateName") |
|
||||
}, |
|
||||
value: { |
|
||||
validate: (0, _utils.assertNodeType)("Expression"), |
|
||||
optional: true |
|
||||
}, |
|
||||
decorators: { |
|
||||
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Decorator"))), |
|
||||
optional: true |
|
||||
} |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("ClassPrivateMethod", { |
|
||||
builder: ["kind", "key", "params", "body", "static"], |
|
||||
visitor: ["key", "params", "body", "decorators", "returnType", "typeParameters"], |
|
||||
aliases: ["Function", "Scopable", "BlockParent", "FunctionParent", "Method", "Private"], |
|
||||
fields: Object.assign({}, _es.classMethodOrDeclareMethodCommon, { |
|
||||
key: { |
|
||||
validate: (0, _utils.assertNodeType)("PrivateName") |
|
||||
}, |
|
||||
body: { |
|
||||
validate: (0, _utils.assertNodeType)("BlockStatement") |
|
||||
} |
|
||||
}) |
|
||||
}); |
|
||||
(0, _utils.default)("Import", { |
|
||||
aliases: ["Expression"] |
|
||||
}); |
|
||||
(0, _utils.default)("Decorator", { |
|
||||
visitor: ["expression"], |
|
||||
fields: { |
|
||||
expression: { |
|
||||
validate: (0, _utils.assertNodeType)("Expression") |
|
||||
} |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("DoExpression", { |
|
||||
visitor: ["body"], |
|
||||
aliases: ["Expression"], |
|
||||
fields: { |
|
||||
body: { |
|
||||
validate: (0, _utils.assertNodeType)("BlockStatement") |
|
||||
} |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("ExportDefaultSpecifier", { |
|
||||
visitor: ["exported"], |
|
||||
aliases: ["ModuleSpecifier"], |
|
||||
fields: { |
|
||||
exported: { |
|
||||
validate: (0, _utils.assertNodeType)("Identifier") |
|
||||
} |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("ExportNamespaceSpecifier", { |
|
||||
visitor: ["exported"], |
|
||||
aliases: ["ModuleSpecifier"], |
|
||||
fields: { |
|
||||
exported: { |
|
||||
validate: (0, _utils.assertNodeType)("Identifier") |
|
||||
} |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("PrivateName", { |
|
||||
visitor: ["id"], |
|
||||
aliases: ["Private"], |
|
||||
fields: { |
|
||||
id: { |
|
||||
validate: (0, _utils.assertNodeType)("Identifier") |
|
||||
} |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("BigIntLiteral", { |
|
||||
builder: ["value"], |
|
||||
fields: { |
|
||||
value: { |
|
||||
validate: (0, _utils.assertValueType)("string") |
|
||||
} |
|
||||
}, |
|
||||
aliases: ["Expression", "Pureish", "Literal", "Immutable"] |
|
||||
}); |
|
||||
(0, _utils.default)("RecordExpression", { |
|
||||
visitor: ["properties"], |
|
||||
aliases: ["Expression"], |
|
||||
fields: { |
|
||||
properties: { |
|
||||
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("ObjectProperty", "ObjectMethod", "SpreadElement"))) |
|
||||
} |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("TupleExpression", { |
|
||||
fields: { |
|
||||
elements: { |
|
||||
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeOrValueType)("null", "Expression", "SpreadElement"))), |
|
||||
default: [] |
|
||||
} |
|
||||
}, |
|
||||
visitor: ["elements"], |
|
||||
aliases: ["Expression"] |
|
||||
}); |
|
||||
@ -1,461 +0,0 @@ |
|||||
"use strict"; |
|
||||
|
|
||||
var _utils = _interopRequireWildcard(require("./utils")); |
|
||||
|
|
||||
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; } |
|
||||
|
|
||||
const defineInterfaceishType = (name, typeParameterType = "TypeParameterDeclaration") => { |
|
||||
(0, _utils.default)(name, { |
|
||||
builder: ["id", "typeParameters", "extends", "body"], |
|
||||
visitor: ["id", "typeParameters", "extends", "mixins", "implements", "body"], |
|
||||
aliases: ["Flow", "FlowDeclaration", "Statement", "Declaration"], |
|
||||
fields: { |
|
||||
id: (0, _utils.validateType)("Identifier"), |
|
||||
typeParameters: (0, _utils.validateOptionalType)(typeParameterType), |
|
||||
extends: (0, _utils.validateOptional)((0, _utils.arrayOfType)("InterfaceExtends")), |
|
||||
mixins: (0, _utils.validateOptional)((0, _utils.arrayOfType)("InterfaceExtends")), |
|
||||
implements: (0, _utils.validateOptional)((0, _utils.arrayOfType)("ClassImplements")), |
|
||||
body: (0, _utils.validateType)("ObjectTypeAnnotation") |
|
||||
} |
|
||||
}); |
|
||||
}; |
|
||||
|
|
||||
(0, _utils.default)("AnyTypeAnnotation", { |
|
||||
aliases: ["Flow", "FlowType", "FlowBaseAnnotation"] |
|
||||
}); |
|
||||
(0, _utils.default)("ArrayTypeAnnotation", { |
|
||||
visitor: ["elementType"], |
|
||||
aliases: ["Flow", "FlowType"], |
|
||||
fields: { |
|
||||
elementType: (0, _utils.validateType)("FlowType") |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("BooleanTypeAnnotation", { |
|
||||
aliases: ["Flow", "FlowType", "FlowBaseAnnotation"] |
|
||||
}); |
|
||||
(0, _utils.default)("BooleanLiteralTypeAnnotation", { |
|
||||
builder: ["value"], |
|
||||
aliases: ["Flow", "FlowType"], |
|
||||
fields: { |
|
||||
value: (0, _utils.validate)((0, _utils.assertValueType)("boolean")) |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("NullLiteralTypeAnnotation", { |
|
||||
aliases: ["Flow", "FlowType", "FlowBaseAnnotation"] |
|
||||
}); |
|
||||
(0, _utils.default)("ClassImplements", { |
|
||||
visitor: ["id", "typeParameters"], |
|
||||
aliases: ["Flow"], |
|
||||
fields: { |
|
||||
id: (0, _utils.validateType)("Identifier"), |
|
||||
typeParameters: (0, _utils.validateOptionalType)("TypeParameterInstantiation") |
|
||||
} |
|
||||
}); |
|
||||
defineInterfaceishType("DeclareClass"); |
|
||||
(0, _utils.default)("DeclareFunction", { |
|
||||
visitor: ["id"], |
|
||||
aliases: ["Flow", "FlowDeclaration", "Statement", "Declaration"], |
|
||||
fields: { |
|
||||
id: (0, _utils.validateType)("Identifier"), |
|
||||
predicate: (0, _utils.validateOptionalType)("DeclaredPredicate") |
|
||||
} |
|
||||
}); |
|
||||
defineInterfaceishType("DeclareInterface"); |
|
||||
(0, _utils.default)("DeclareModule", { |
|
||||
builder: ["id", "body", "kind"], |
|
||||
visitor: ["id", "body"], |
|
||||
aliases: ["Flow", "FlowDeclaration", "Statement", "Declaration"], |
|
||||
fields: { |
|
||||
id: (0, _utils.validateType)(["Identifier", "StringLiteral"]), |
|
||||
body: (0, _utils.validateType)("BlockStatement"), |
|
||||
kind: (0, _utils.validateOptional)((0, _utils.assertOneOf)("CommonJS", "ES")) |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("DeclareModuleExports", { |
|
||||
visitor: ["typeAnnotation"], |
|
||||
aliases: ["Flow", "FlowDeclaration", "Statement", "Declaration"], |
|
||||
fields: { |
|
||||
typeAnnotation: (0, _utils.validateType)("TypeAnnotation") |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("DeclareTypeAlias", { |
|
||||
visitor: ["id", "typeParameters", "right"], |
|
||||
aliases: ["Flow", "FlowDeclaration", "Statement", "Declaration"], |
|
||||
fields: { |
|
||||
id: (0, _utils.validateType)("Identifier"), |
|
||||
typeParameters: (0, _utils.validateOptionalType)("TypeParameterDeclaration"), |
|
||||
right: (0, _utils.validateType)("FlowType") |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("DeclareOpaqueType", { |
|
||||
visitor: ["id", "typeParameters", "supertype"], |
|
||||
aliases: ["Flow", "FlowDeclaration", "Statement", "Declaration"], |
|
||||
fields: { |
|
||||
id: (0, _utils.validateType)("Identifier"), |
|
||||
typeParameters: (0, _utils.validateOptionalType)("TypeParameterDeclaration"), |
|
||||
supertype: (0, _utils.validateOptionalType)("FlowType") |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("DeclareVariable", { |
|
||||
visitor: ["id"], |
|
||||
aliases: ["Flow", "FlowDeclaration", "Statement", "Declaration"], |
|
||||
fields: { |
|
||||
id: (0, _utils.validateType)("Identifier") |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("DeclareExportDeclaration", { |
|
||||
visitor: ["declaration", "specifiers", "source"], |
|
||||
aliases: ["Flow", "FlowDeclaration", "Statement", "Declaration"], |
|
||||
fields: { |
|
||||
declaration: (0, _utils.validateOptionalType)("Flow"), |
|
||||
specifiers: (0, _utils.validateOptional)((0, _utils.arrayOfType)(["ExportSpecifier", "ExportNamespaceSpecifier"])), |
|
||||
source: (0, _utils.validateOptionalType)("StringLiteral"), |
|
||||
default: (0, _utils.validateOptional)((0, _utils.assertValueType)("boolean")) |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("DeclareExportAllDeclaration", { |
|
||||
visitor: ["source"], |
|
||||
aliases: ["Flow", "FlowDeclaration", "Statement", "Declaration"], |
|
||||
fields: { |
|
||||
source: (0, _utils.validateType)("StringLiteral"), |
|
||||
exportKind: (0, _utils.validateOptional)((0, _utils.assertOneOf)("type", "value")) |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("DeclaredPredicate", { |
|
||||
visitor: ["value"], |
|
||||
aliases: ["Flow", "FlowPredicate"], |
|
||||
fields: { |
|
||||
value: (0, _utils.validateType)("Flow") |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("ExistsTypeAnnotation", { |
|
||||
aliases: ["Flow", "FlowType"] |
|
||||
}); |
|
||||
(0, _utils.default)("FunctionTypeAnnotation", { |
|
||||
visitor: ["typeParameters", "params", "rest", "returnType"], |
|
||||
aliases: ["Flow", "FlowType"], |
|
||||
fields: { |
|
||||
typeParameters: (0, _utils.validateOptionalType)("TypeParameterDeclaration"), |
|
||||
params: (0, _utils.validate)((0, _utils.arrayOfType)("FunctionTypeParam")), |
|
||||
rest: (0, _utils.validateOptionalType)("FunctionTypeParam"), |
|
||||
returnType: (0, _utils.validateType)("FlowType") |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("FunctionTypeParam", { |
|
||||
visitor: ["name", "typeAnnotation"], |
|
||||
aliases: ["Flow"], |
|
||||
fields: { |
|
||||
name: (0, _utils.validateOptionalType)("Identifier"), |
|
||||
typeAnnotation: (0, _utils.validateType)("FlowType"), |
|
||||
optional: (0, _utils.validateOptional)((0, _utils.assertValueType)("boolean")) |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("GenericTypeAnnotation", { |
|
||||
visitor: ["id", "typeParameters"], |
|
||||
aliases: ["Flow", "FlowType"], |
|
||||
fields: { |
|
||||
id: (0, _utils.validateType)(["Identifier", "QualifiedTypeIdentifier"]), |
|
||||
typeParameters: (0, _utils.validateOptionalType)("TypeParameterInstantiation") |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("InferredPredicate", { |
|
||||
aliases: ["Flow", "FlowPredicate"] |
|
||||
}); |
|
||||
(0, _utils.default)("InterfaceExtends", { |
|
||||
visitor: ["id", "typeParameters"], |
|
||||
aliases: ["Flow"], |
|
||||
fields: { |
|
||||
id: (0, _utils.validateType)(["Identifier", "QualifiedTypeIdentifier"]), |
|
||||
typeParameters: (0, _utils.validateOptionalType)("TypeParameterInstantiation") |
|
||||
} |
|
||||
}); |
|
||||
defineInterfaceishType("InterfaceDeclaration"); |
|
||||
(0, _utils.default)("InterfaceTypeAnnotation", { |
|
||||
visitor: ["extends", "body"], |
|
||||
aliases: ["Flow", "FlowType"], |
|
||||
fields: { |
|
||||
extends: (0, _utils.validateOptional)((0, _utils.arrayOfType)("InterfaceExtends")), |
|
||||
body: (0, _utils.validateType)("ObjectTypeAnnotation") |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("IntersectionTypeAnnotation", { |
|
||||
visitor: ["types"], |
|
||||
aliases: ["Flow", "FlowType"], |
|
||||
fields: { |
|
||||
types: (0, _utils.validate)((0, _utils.arrayOfType)("FlowType")) |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("MixedTypeAnnotation", { |
|
||||
aliases: ["Flow", "FlowType", "FlowBaseAnnotation"] |
|
||||
}); |
|
||||
(0, _utils.default)("EmptyTypeAnnotation", { |
|
||||
aliases: ["Flow", "FlowType", "FlowBaseAnnotation"] |
|
||||
}); |
|
||||
(0, _utils.default)("NullableTypeAnnotation", { |
|
||||
visitor: ["typeAnnotation"], |
|
||||
aliases: ["Flow", "FlowType"], |
|
||||
fields: { |
|
||||
typeAnnotation: (0, _utils.validateType)("FlowType") |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("NumberLiteralTypeAnnotation", { |
|
||||
builder: ["value"], |
|
||||
aliases: ["Flow", "FlowType"], |
|
||||
fields: { |
|
||||
value: (0, _utils.validate)((0, _utils.assertValueType)("number")) |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("NumberTypeAnnotation", { |
|
||||
aliases: ["Flow", "FlowType", "FlowBaseAnnotation"] |
|
||||
}); |
|
||||
(0, _utils.default)("ObjectTypeAnnotation", { |
|
||||
visitor: ["properties", "indexers", "callProperties", "internalSlots"], |
|
||||
aliases: ["Flow", "FlowType"], |
|
||||
builder: ["properties", "indexers", "callProperties", "internalSlots", "exact"], |
|
||||
fields: { |
|
||||
properties: (0, _utils.validate)((0, _utils.arrayOfType)(["ObjectTypeProperty", "ObjectTypeSpreadProperty"])), |
|
||||
indexers: (0, _utils.validateOptional)((0, _utils.arrayOfType)("ObjectTypeIndexer")), |
|
||||
callProperties: (0, _utils.validateOptional)((0, _utils.arrayOfType)("ObjectTypeCallProperty")), |
|
||||
internalSlots: (0, _utils.validateOptional)((0, _utils.arrayOfType)("ObjectTypeInternalSlot")), |
|
||||
exact: { |
|
||||
validate: (0, _utils.assertValueType)("boolean"), |
|
||||
default: false |
|
||||
}, |
|
||||
inexact: (0, _utils.validateOptional)((0, _utils.assertValueType)("boolean")) |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("ObjectTypeInternalSlot", { |
|
||||
visitor: ["id", "value", "optional", "static", "method"], |
|
||||
aliases: ["Flow", "UserWhitespacable"], |
|
||||
fields: { |
|
||||
id: (0, _utils.validateType)("Identifier"), |
|
||||
value: (0, _utils.validateType)("FlowType"), |
|
||||
optional: (0, _utils.validate)((0, _utils.assertValueType)("boolean")), |
|
||||
static: (0, _utils.validate)((0, _utils.assertValueType)("boolean")), |
|
||||
method: (0, _utils.validate)((0, _utils.assertValueType)("boolean")) |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("ObjectTypeCallProperty", { |
|
||||
visitor: ["value"], |
|
||||
aliases: ["Flow", "UserWhitespacable"], |
|
||||
fields: { |
|
||||
value: (0, _utils.validateType)("FlowType"), |
|
||||
static: (0, _utils.validate)((0, _utils.assertValueType)("boolean")) |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("ObjectTypeIndexer", { |
|
||||
visitor: ["id", "key", "value", "variance"], |
|
||||
aliases: ["Flow", "UserWhitespacable"], |
|
||||
fields: { |
|
||||
id: (0, _utils.validateOptionalType)("Identifier"), |
|
||||
key: (0, _utils.validateType)("FlowType"), |
|
||||
value: (0, _utils.validateType)("FlowType"), |
|
||||
static: (0, _utils.validate)((0, _utils.assertValueType)("boolean")), |
|
||||
variance: (0, _utils.validateOptionalType)("Variance") |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("ObjectTypeProperty", { |
|
||||
visitor: ["key", "value", "variance"], |
|
||||
aliases: ["Flow", "UserWhitespacable"], |
|
||||
fields: { |
|
||||
key: (0, _utils.validateType)(["Identifier", "StringLiteral"]), |
|
||||
value: (0, _utils.validateType)("FlowType"), |
|
||||
kind: (0, _utils.validate)((0, _utils.assertOneOf)("init", "get", "set")), |
|
||||
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") |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("ObjectTypeSpreadProperty", { |
|
||||
visitor: ["argument"], |
|
||||
aliases: ["Flow", "UserWhitespacable"], |
|
||||
fields: { |
|
||||
argument: (0, _utils.validateType)("FlowType") |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("OpaqueType", { |
|
||||
visitor: ["id", "typeParameters", "supertype", "impltype"], |
|
||||
aliases: ["Flow", "FlowDeclaration", "Statement", "Declaration"], |
|
||||
fields: { |
|
||||
id: (0, _utils.validateType)("Identifier"), |
|
||||
typeParameters: (0, _utils.validateOptionalType)("TypeParameterDeclaration"), |
|
||||
supertype: (0, _utils.validateOptionalType)("FlowType"), |
|
||||
impltype: (0, _utils.validateType)("FlowType") |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("QualifiedTypeIdentifier", { |
|
||||
visitor: ["id", "qualification"], |
|
||||
aliases: ["Flow"], |
|
||||
fields: { |
|
||||
id: (0, _utils.validateType)("Identifier"), |
|
||||
qualification: (0, _utils.validateType)(["Identifier", "QualifiedTypeIdentifier"]) |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("StringLiteralTypeAnnotation", { |
|
||||
builder: ["value"], |
|
||||
aliases: ["Flow", "FlowType"], |
|
||||
fields: { |
|
||||
value: (0, _utils.validate)((0, _utils.assertValueType)("string")) |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("StringTypeAnnotation", { |
|
||||
aliases: ["Flow", "FlowType", "FlowBaseAnnotation"] |
|
||||
}); |
|
||||
(0, _utils.default)("SymbolTypeAnnotation", { |
|
||||
aliases: ["Flow", "FlowType", "FlowBaseAnnotation"] |
|
||||
}); |
|
||||
(0, _utils.default)("ThisTypeAnnotation", { |
|
||||
aliases: ["Flow", "FlowType", "FlowBaseAnnotation"] |
|
||||
}); |
|
||||
(0, _utils.default)("TupleTypeAnnotation", { |
|
||||
visitor: ["types"], |
|
||||
aliases: ["Flow", "FlowType"], |
|
||||
fields: { |
|
||||
types: (0, _utils.validate)((0, _utils.arrayOfType)("FlowType")) |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("TypeofTypeAnnotation", { |
|
||||
visitor: ["argument"], |
|
||||
aliases: ["Flow", "FlowType"], |
|
||||
fields: { |
|
||||
argument: (0, _utils.validateType)("FlowType") |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("TypeAlias", { |
|
||||
visitor: ["id", "typeParameters", "right"], |
|
||||
aliases: ["Flow", "FlowDeclaration", "Statement", "Declaration"], |
|
||||
fields: { |
|
||||
id: (0, _utils.validateType)("Identifier"), |
|
||||
typeParameters: (0, _utils.validateOptionalType)("TypeParameterDeclaration"), |
|
||||
right: (0, _utils.validateType)("FlowType") |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("TypeAnnotation", { |
|
||||
aliases: ["Flow"], |
|
||||
visitor: ["typeAnnotation"], |
|
||||
fields: { |
|
||||
typeAnnotation: (0, _utils.validateType)("FlowType") |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("TypeCastExpression", { |
|
||||
visitor: ["expression", "typeAnnotation"], |
|
||||
aliases: ["Flow", "ExpressionWrapper", "Expression"], |
|
||||
fields: { |
|
||||
expression: (0, _utils.validateType)("Expression"), |
|
||||
typeAnnotation: (0, _utils.validateType)("TypeAnnotation") |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("TypeParameter", { |
|
||||
aliases: ["Flow"], |
|
||||
visitor: ["bound", "default", "variance"], |
|
||||
fields: { |
|
||||
name: (0, _utils.validate)((0, _utils.assertValueType)("string")), |
|
||||
bound: (0, _utils.validateOptionalType)("TypeAnnotation"), |
|
||||
default: (0, _utils.validateOptionalType)("FlowType"), |
|
||||
variance: (0, _utils.validateOptionalType)("Variance") |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("TypeParameterDeclaration", { |
|
||||
aliases: ["Flow"], |
|
||||
visitor: ["params"], |
|
||||
fields: { |
|
||||
params: (0, _utils.validate)((0, _utils.arrayOfType)("TypeParameter")) |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("TypeParameterInstantiation", { |
|
||||
aliases: ["Flow"], |
|
||||
visitor: ["params"], |
|
||||
fields: { |
|
||||
params: (0, _utils.validate)((0, _utils.arrayOfType)("FlowType")) |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("UnionTypeAnnotation", { |
|
||||
visitor: ["types"], |
|
||||
aliases: ["Flow", "FlowType"], |
|
||||
fields: { |
|
||||
types: (0, _utils.validate)((0, _utils.arrayOfType)("FlowType")) |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("Variance", { |
|
||||
aliases: ["Flow"], |
|
||||
builder: ["kind"], |
|
||||
fields: { |
|
||||
kind: (0, _utils.validate)((0, _utils.assertOneOf)("minus", "plus")) |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("VoidTypeAnnotation", { |
|
||||
aliases: ["Flow", "FlowType", "FlowBaseAnnotation"] |
|
||||
}); |
|
||||
(0, _utils.default)("EnumDeclaration", { |
|
||||
aliases: ["Statement", "Declaration"], |
|
||||
visitor: ["id", "body"], |
|
||||
fields: { |
|
||||
id: (0, _utils.validateType)("Identifier"), |
|
||||
body: (0, _utils.validateType)(["EnumBooleanBody", "EnumNumberBody", "EnumStringBody", "EnumSymbolBody"]) |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("EnumBooleanBody", { |
|
||||
aliases: ["EnumBody"], |
|
||||
visitor: ["members"], |
|
||||
fields: { |
|
||||
explicit: (0, _utils.validate)((0, _utils.assertValueType)("boolean")), |
|
||||
members: (0, _utils.validateArrayOfType)("EnumBooleanMember") |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("EnumNumberBody", { |
|
||||
aliases: ["EnumBody"], |
|
||||
visitor: ["members"], |
|
||||
fields: { |
|
||||
explicit: (0, _utils.validate)((0, _utils.assertValueType)("boolean")), |
|
||||
members: (0, _utils.validateArrayOfType)("EnumNumberMember") |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("EnumStringBody", { |
|
||||
aliases: ["EnumBody"], |
|
||||
visitor: ["members"], |
|
||||
fields: { |
|
||||
explicit: (0, _utils.validate)((0, _utils.assertValueType)("boolean")), |
|
||||
members: (0, _utils.validateArrayOfType)(["EnumStringMember", "EnumDefaultedMember"]) |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("EnumSymbolBody", { |
|
||||
aliases: ["EnumBody"], |
|
||||
visitor: ["members"], |
|
||||
fields: { |
|
||||
members: (0, _utils.validateArrayOfType)("EnumDefaultedMember") |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("EnumBooleanMember", { |
|
||||
aliases: ["EnumMember"], |
|
||||
visitor: ["id"], |
|
||||
fields: { |
|
||||
id: (0, _utils.validateType)("Identifier"), |
|
||||
init: (0, _utils.validateType)("BooleanLiteral") |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("EnumNumberMember", { |
|
||||
aliases: ["EnumMember"], |
|
||||
visitor: ["id", "init"], |
|
||||
fields: { |
|
||||
id: (0, _utils.validateType)("Identifier"), |
|
||||
init: (0, _utils.validateType)("NumericLiteral") |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("EnumStringMember", { |
|
||||
aliases: ["EnumMember"], |
|
||||
visitor: ["id", "init"], |
|
||||
fields: { |
|
||||
id: (0, _utils.validateType)("Identifier"), |
|
||||
init: (0, _utils.validateType)("StringLiteral") |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("EnumDefaultedMember", { |
|
||||
aliases: ["EnumMember"], |
|
||||
visitor: ["id"], |
|
||||
fields: { |
|
||||
id: (0, _utils.validateType)("Identifier") |
|
||||
} |
|
||||
}); |
|
||||
@ -1,99 +0,0 @@ |
|||||
"use strict"; |
|
||||
|
|
||||
Object.defineProperty(exports, "__esModule", { |
|
||||
value: true |
|
||||
}); |
|
||||
Object.defineProperty(exports, "VISITOR_KEYS", { |
|
||||
enumerable: true, |
|
||||
get: function () { |
|
||||
return _utils.VISITOR_KEYS; |
|
||||
} |
|
||||
}); |
|
||||
Object.defineProperty(exports, "ALIAS_KEYS", { |
|
||||
enumerable: true, |
|
||||
get: function () { |
|
||||
return _utils.ALIAS_KEYS; |
|
||||
} |
|
||||
}); |
|
||||
Object.defineProperty(exports, "FLIPPED_ALIAS_KEYS", { |
|
||||
enumerable: true, |
|
||||
get: function () { |
|
||||
return _utils.FLIPPED_ALIAS_KEYS; |
|
||||
} |
|
||||
}); |
|
||||
Object.defineProperty(exports, "NODE_FIELDS", { |
|
||||
enumerable: true, |
|
||||
get: function () { |
|
||||
return _utils.NODE_FIELDS; |
|
||||
} |
|
||||
}); |
|
||||
Object.defineProperty(exports, "BUILDER_KEYS", { |
|
||||
enumerable: true, |
|
||||
get: function () { |
|
||||
return _utils.BUILDER_KEYS; |
|
||||
} |
|
||||
}); |
|
||||
Object.defineProperty(exports, "DEPRECATED_KEYS", { |
|
||||
enumerable: true, |
|
||||
get: function () { |
|
||||
return _utils.DEPRECATED_KEYS; |
|
||||
} |
|
||||
}); |
|
||||
Object.defineProperty(exports, "NODE_PARENT_VALIDATIONS", { |
|
||||
enumerable: true, |
|
||||
get: function () { |
|
||||
return _utils.NODE_PARENT_VALIDATIONS; |
|
||||
} |
|
||||
}); |
|
||||
Object.defineProperty(exports, "PLACEHOLDERS", { |
|
||||
enumerable: true, |
|
||||
get: function () { |
|
||||
return _placeholders.PLACEHOLDERS; |
|
||||
} |
|
||||
}); |
|
||||
Object.defineProperty(exports, "PLACEHOLDERS_ALIAS", { |
|
||||
enumerable: true, |
|
||||
get: function () { |
|
||||
return _placeholders.PLACEHOLDERS_ALIAS; |
|
||||
} |
|
||||
}); |
|
||||
Object.defineProperty(exports, "PLACEHOLDERS_FLIPPED_ALIAS", { |
|
||||
enumerable: true, |
|
||||
get: function () { |
|
||||
return _placeholders.PLACEHOLDERS_FLIPPED_ALIAS; |
|
||||
} |
|
||||
}); |
|
||||
exports.TYPES = void 0; |
|
||||
|
|
||||
var _toFastProperties = _interopRequireDefault(require("to-fast-properties")); |
|
||||
|
|
||||
require("./core"); |
|
||||
|
|
||||
require("./es2015"); |
|
||||
|
|
||||
require("./flow"); |
|
||||
|
|
||||
require("./jsx"); |
|
||||
|
|
||||
require("./misc"); |
|
||||
|
|
||||
require("./experimental"); |
|
||||
|
|
||||
require("./typescript"); |
|
||||
|
|
||||
var _utils = require("./utils"); |
|
||||
|
|
||||
var _placeholders = require("./placeholders"); |
|
||||
|
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
|
||||
|
|
||||
(0, _toFastProperties.default)(_utils.VISITOR_KEYS); |
|
||||
(0, _toFastProperties.default)(_utils.ALIAS_KEYS); |
|
||||
(0, _toFastProperties.default)(_utils.FLIPPED_ALIAS_KEYS); |
|
||||
(0, _toFastProperties.default)(_utils.NODE_FIELDS); |
|
||||
(0, _toFastProperties.default)(_utils.BUILDER_KEYS); |
|
||||
(0, _toFastProperties.default)(_utils.DEPRECATED_KEYS); |
|
||||
(0, _toFastProperties.default)(_placeholders.PLACEHOLDERS_ALIAS); |
|
||||
(0, _toFastProperties.default)(_placeholders.PLACEHOLDERS_FLIPPED_ALIAS); |
|
||||
const TYPES = Object.keys(_utils.VISITOR_KEYS).concat(Object.keys(_utils.FLIPPED_ALIAS_KEYS)).concat(Object.keys(_utils.DEPRECATED_KEYS)); |
|
||||
exports.TYPES = TYPES; |
|
||||
@ -1,161 +0,0 @@ |
|||||
"use strict"; |
|
||||
|
|
||||
var _utils = _interopRequireWildcard(require("./utils")); |
|
||||
|
|
||||
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; } |
|
||||
|
|
||||
(0, _utils.default)("JSXAttribute", { |
|
||||
visitor: ["name", "value"], |
|
||||
aliases: ["JSX", "Immutable"], |
|
||||
fields: { |
|
||||
name: { |
|
||||
validate: (0, _utils.assertNodeType)("JSXIdentifier", "JSXNamespacedName") |
|
||||
}, |
|
||||
value: { |
|
||||
optional: true, |
|
||||
validate: (0, _utils.assertNodeType)("JSXElement", "JSXFragment", "StringLiteral", "JSXExpressionContainer") |
|
||||
} |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("JSXClosingElement", { |
|
||||
visitor: ["name"], |
|
||||
aliases: ["JSX", "Immutable"], |
|
||||
fields: { |
|
||||
name: { |
|
||||
validate: (0, _utils.assertNodeType)("JSXIdentifier", "JSXMemberExpression", "JSXNamespacedName") |
|
||||
} |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("JSXElement", { |
|
||||
builder: ["openingElement", "closingElement", "children", "selfClosing"], |
|
||||
visitor: ["openingElement", "children", "closingElement"], |
|
||||
aliases: ["JSX", "Immutable", "Expression"], |
|
||||
fields: { |
|
||||
openingElement: { |
|
||||
validate: (0, _utils.assertNodeType)("JSXOpeningElement") |
|
||||
}, |
|
||||
closingElement: { |
|
||||
optional: true, |
|
||||
validate: (0, _utils.assertNodeType)("JSXClosingElement") |
|
||||
}, |
|
||||
children: { |
|
||||
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("JSXText", "JSXExpressionContainer", "JSXSpreadChild", "JSXElement", "JSXFragment"))) |
|
||||
} |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("JSXEmptyExpression", { |
|
||||
aliases: ["JSX"] |
|
||||
}); |
|
||||
(0, _utils.default)("JSXExpressionContainer", { |
|
||||
visitor: ["expression"], |
|
||||
aliases: ["JSX", "Immutable"], |
|
||||
fields: { |
|
||||
expression: { |
|
||||
validate: (0, _utils.assertNodeType)("Expression", "JSXEmptyExpression") |
|
||||
} |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("JSXSpreadChild", { |
|
||||
visitor: ["expression"], |
|
||||
aliases: ["JSX", "Immutable"], |
|
||||
fields: { |
|
||||
expression: { |
|
||||
validate: (0, _utils.assertNodeType)("Expression") |
|
||||
} |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("JSXIdentifier", { |
|
||||
builder: ["name"], |
|
||||
aliases: ["JSX"], |
|
||||
fields: { |
|
||||
name: { |
|
||||
validate: (0, _utils.assertValueType)("string") |
|
||||
} |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("JSXMemberExpression", { |
|
||||
visitor: ["object", "property"], |
|
||||
aliases: ["JSX"], |
|
||||
fields: { |
|
||||
object: { |
|
||||
validate: (0, _utils.assertNodeType)("JSXMemberExpression", "JSXIdentifier") |
|
||||
}, |
|
||||
property: { |
|
||||
validate: (0, _utils.assertNodeType)("JSXIdentifier") |
|
||||
} |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("JSXNamespacedName", { |
|
||||
visitor: ["namespace", "name"], |
|
||||
aliases: ["JSX"], |
|
||||
fields: { |
|
||||
namespace: { |
|
||||
validate: (0, _utils.assertNodeType)("JSXIdentifier") |
|
||||
}, |
|
||||
name: { |
|
||||
validate: (0, _utils.assertNodeType)("JSXIdentifier") |
|
||||
} |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("JSXOpeningElement", { |
|
||||
builder: ["name", "attributes", "selfClosing"], |
|
||||
visitor: ["name", "attributes"], |
|
||||
aliases: ["JSX", "Immutable"], |
|
||||
fields: { |
|
||||
name: { |
|
||||
validate: (0, _utils.assertNodeType)("JSXIdentifier", "JSXMemberExpression", "JSXNamespacedName") |
|
||||
}, |
|
||||
selfClosing: { |
|
||||
default: false |
|
||||
}, |
|
||||
attributes: { |
|
||||
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("JSXAttribute", "JSXSpreadAttribute"))) |
|
||||
}, |
|
||||
typeParameters: { |
|
||||
validate: (0, _utils.assertNodeType)("TypeParameterInstantiation", "TSTypeParameterInstantiation"), |
|
||||
optional: true |
|
||||
} |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("JSXSpreadAttribute", { |
|
||||
visitor: ["argument"], |
|
||||
aliases: ["JSX"], |
|
||||
fields: { |
|
||||
argument: { |
|
||||
validate: (0, _utils.assertNodeType)("Expression") |
|
||||
} |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("JSXText", { |
|
||||
aliases: ["JSX", "Immutable"], |
|
||||
builder: ["value"], |
|
||||
fields: { |
|
||||
value: { |
|
||||
validate: (0, _utils.assertValueType)("string") |
|
||||
} |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("JSXFragment", { |
|
||||
builder: ["openingFragment", "closingFragment", "children"], |
|
||||
visitor: ["openingFragment", "children", "closingFragment"], |
|
||||
aliases: ["JSX", "Immutable", "Expression"], |
|
||||
fields: { |
|
||||
openingFragment: { |
|
||||
validate: (0, _utils.assertNodeType)("JSXOpeningFragment") |
|
||||
}, |
|
||||
closingFragment: { |
|
||||
validate: (0, _utils.assertNodeType)("JSXClosingFragment") |
|
||||
}, |
|
||||
children: { |
|
||||
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("JSXText", "JSXExpressionContainer", "JSXSpreadChild", "JSXElement", "JSXFragment"))) |
|
||||
} |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("JSXOpeningFragment", { |
|
||||
aliases: ["JSX", "Immutable"] |
|
||||
}); |
|
||||
(0, _utils.default)("JSXClosingFragment", { |
|
||||
aliases: ["JSX", "Immutable"] |
|
||||
}); |
|
||||
@ -1,33 +0,0 @@ |
|||||
"use strict"; |
|
||||
|
|
||||
var _utils = _interopRequireWildcard(require("./utils")); |
|
||||
|
|
||||
var _placeholders = require("./placeholders"); |
|
||||
|
|
||||
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; } |
|
||||
|
|
||||
(0, _utils.default)("Noop", { |
|
||||
visitor: [] |
|
||||
}); |
|
||||
(0, _utils.default)("Placeholder", { |
|
||||
visitor: [], |
|
||||
builder: ["expectedNode", "name"], |
|
||||
fields: { |
|
||||
name: { |
|
||||
validate: (0, _utils.assertNodeType)("Identifier") |
|
||||
}, |
|
||||
expectedNode: { |
|
||||
validate: (0, _utils.assertOneOf)(..._placeholders.PLACEHOLDERS) |
|
||||
} |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("V8IntrinsicIdentifier", { |
|
||||
builder: ["name"], |
|
||||
fields: { |
|
||||
name: { |
|
||||
validate: (0, _utils.assertValueType)("string") |
|
||||
} |
|
||||
} |
|
||||
}); |
|
||||
@ -1,33 +0,0 @@ |
|||||
"use strict"; |
|
||||
|
|
||||
Object.defineProperty(exports, "__esModule", { |
|
||||
value: true |
|
||||
}); |
|
||||
exports.PLACEHOLDERS_FLIPPED_ALIAS = exports.PLACEHOLDERS_ALIAS = exports.PLACEHOLDERS = void 0; |
|
||||
|
|
||||
var _utils = require("./utils"); |
|
||||
|
|
||||
const PLACEHOLDERS = ["Identifier", "StringLiteral", "Expression", "Statement", "Declaration", "BlockStatement", "ClassBody", "Pattern"]; |
|
||||
exports.PLACEHOLDERS = PLACEHOLDERS; |
|
||||
const PLACEHOLDERS_ALIAS = { |
|
||||
Declaration: ["Statement"], |
|
||||
Pattern: ["PatternLike", "LVal"] |
|
||||
}; |
|
||||
exports.PLACEHOLDERS_ALIAS = PLACEHOLDERS_ALIAS; |
|
||||
|
|
||||
for (const type of PLACEHOLDERS) { |
|
||||
const alias = _utils.ALIAS_KEYS[type]; |
|
||||
if (alias && alias.length) PLACEHOLDERS_ALIAS[type] = alias; |
|
||||
} |
|
||||
|
|
||||
const PLACEHOLDERS_FLIPPED_ALIAS = {}; |
|
||||
exports.PLACEHOLDERS_FLIPPED_ALIAS = PLACEHOLDERS_FLIPPED_ALIAS; |
|
||||
Object.keys(PLACEHOLDERS_ALIAS).forEach(type => { |
|
||||
PLACEHOLDERS_ALIAS[type].forEach(alias => { |
|
||||
if (!Object.hasOwnProperty.call(PLACEHOLDERS_FLIPPED_ALIAS, alias)) { |
|
||||
PLACEHOLDERS_FLIPPED_ALIAS[alias] = []; |
|
||||
} |
|
||||
|
|
||||
PLACEHOLDERS_FLIPPED_ALIAS[alias].push(type); |
|
||||
}); |
|
||||
}); |
|
||||
@ -1,417 +0,0 @@ |
|||||
"use strict"; |
|
||||
|
|
||||
var _utils = _interopRequireWildcard(require("./utils")); |
|
||||
|
|
||||
var _core = require("./core"); |
|
||||
|
|
||||
var _es = require("./es2015"); |
|
||||
|
|
||||
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; } |
|
||||
|
|
||||
const bool = (0, _utils.assertValueType)("boolean"); |
|
||||
const tSFunctionTypeAnnotationCommon = { |
|
||||
returnType: { |
|
||||
validate: (0, _utils.assertNodeType)("TSTypeAnnotation", "Noop"), |
|
||||
optional: true |
|
||||
}, |
|
||||
typeParameters: { |
|
||||
validate: (0, _utils.assertNodeType)("TSTypeParameterDeclaration", "Noop"), |
|
||||
optional: true |
|
||||
} |
|
||||
}; |
|
||||
(0, _utils.default)("TSParameterProperty", { |
|
||||
aliases: ["LVal"], |
|
||||
visitor: ["parameter"], |
|
||||
fields: { |
|
||||
accessibility: { |
|
||||
validate: (0, _utils.assertOneOf)("public", "private", "protected"), |
|
||||
optional: true |
|
||||
}, |
|
||||
readonly: { |
|
||||
validate: (0, _utils.assertValueType)("boolean"), |
|
||||
optional: true |
|
||||
}, |
|
||||
parameter: { |
|
||||
validate: (0, _utils.assertNodeType)("Identifier", "AssignmentPattern") |
|
||||
} |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("TSDeclareFunction", { |
|
||||
aliases: ["Statement", "Declaration"], |
|
||||
visitor: ["id", "typeParameters", "params", "returnType"], |
|
||||
fields: Object.assign({}, _core.functionDeclarationCommon, {}, tSFunctionTypeAnnotationCommon) |
|
||||
}); |
|
||||
(0, _utils.default)("TSDeclareMethod", { |
|
||||
visitor: ["decorators", "key", "typeParameters", "params", "returnType"], |
|
||||
fields: Object.assign({}, _es.classMethodOrDeclareMethodCommon, {}, tSFunctionTypeAnnotationCommon) |
|
||||
}); |
|
||||
(0, _utils.default)("TSQualifiedName", { |
|
||||
aliases: ["TSEntityName"], |
|
||||
visitor: ["left", "right"], |
|
||||
fields: { |
|
||||
left: (0, _utils.validateType)("TSEntityName"), |
|
||||
right: (0, _utils.validateType)("Identifier") |
|
||||
} |
|
||||
}); |
|
||||
const signatureDeclarationCommon = { |
|
||||
typeParameters: (0, _utils.validateOptionalType)("TSTypeParameterDeclaration"), |
|
||||
parameters: (0, _utils.validateArrayOfType)(["Identifier", "RestElement"]), |
|
||||
typeAnnotation: (0, _utils.validateOptionalType)("TSTypeAnnotation") |
|
||||
}; |
|
||||
const callConstructSignatureDeclaration = { |
|
||||
aliases: ["TSTypeElement"], |
|
||||
visitor: ["typeParameters", "parameters", "typeAnnotation"], |
|
||||
fields: signatureDeclarationCommon |
|
||||
}; |
|
||||
(0, _utils.default)("TSCallSignatureDeclaration", callConstructSignatureDeclaration); |
|
||||
(0, _utils.default)("TSConstructSignatureDeclaration", callConstructSignatureDeclaration); |
|
||||
const namedTypeElementCommon = { |
|
||||
key: (0, _utils.validateType)("Expression"), |
|
||||
computed: (0, _utils.validate)(bool), |
|
||||
optional: (0, _utils.validateOptional)(bool) |
|
||||
}; |
|
||||
(0, _utils.default)("TSPropertySignature", { |
|
||||
aliases: ["TSTypeElement"], |
|
||||
visitor: ["key", "typeAnnotation", "initializer"], |
|
||||
fields: Object.assign({}, namedTypeElementCommon, { |
|
||||
readonly: (0, _utils.validateOptional)(bool), |
|
||||
typeAnnotation: (0, _utils.validateOptionalType)("TSTypeAnnotation"), |
|
||||
initializer: (0, _utils.validateOptionalType)("Expression") |
|
||||
}) |
|
||||
}); |
|
||||
(0, _utils.default)("TSMethodSignature", { |
|
||||
aliases: ["TSTypeElement"], |
|
||||
visitor: ["key", "typeParameters", "parameters", "typeAnnotation"], |
|
||||
fields: Object.assign({}, signatureDeclarationCommon, {}, namedTypeElementCommon) |
|
||||
}); |
|
||||
(0, _utils.default)("TSIndexSignature", { |
|
||||
aliases: ["TSTypeElement"], |
|
||||
visitor: ["parameters", "typeAnnotation"], |
|
||||
fields: { |
|
||||
readonly: (0, _utils.validateOptional)(bool), |
|
||||
parameters: (0, _utils.validateArrayOfType)("Identifier"), |
|
||||
typeAnnotation: (0, _utils.validateOptionalType)("TSTypeAnnotation") |
|
||||
} |
|
||||
}); |
|
||||
const tsKeywordTypes = ["TSAnyKeyword", "TSBooleanKeyword", "TSBigIntKeyword", "TSNeverKeyword", "TSNullKeyword", "TSNumberKeyword", "TSObjectKeyword", "TSStringKeyword", "TSSymbolKeyword", "TSUndefinedKeyword", "TSUnknownKeyword", "TSVoidKeyword"]; |
|
||||
|
|
||||
for (const type of tsKeywordTypes) { |
|
||||
(0, _utils.default)(type, { |
|
||||
aliases: ["TSType"], |
|
||||
visitor: [], |
|
||||
fields: {} |
|
||||
}); |
|
||||
} |
|
||||
|
|
||||
(0, _utils.default)("TSThisType", { |
|
||||
aliases: ["TSType"], |
|
||||
visitor: [], |
|
||||
fields: {} |
|
||||
}); |
|
||||
const fnOrCtr = { |
|
||||
aliases: ["TSType"], |
|
||||
visitor: ["typeParameters", "parameters", "typeAnnotation"], |
|
||||
fields: signatureDeclarationCommon |
|
||||
}; |
|
||||
(0, _utils.default)("TSFunctionType", fnOrCtr); |
|
||||
(0, _utils.default)("TSConstructorType", fnOrCtr); |
|
||||
(0, _utils.default)("TSTypeReference", { |
|
||||
aliases: ["TSType"], |
|
||||
visitor: ["typeName", "typeParameters"], |
|
||||
fields: { |
|
||||
typeName: (0, _utils.validateType)("TSEntityName"), |
|
||||
typeParameters: (0, _utils.validateOptionalType)("TSTypeParameterInstantiation") |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("TSTypePredicate", { |
|
||||
aliases: ["TSType"], |
|
||||
visitor: ["parameterName", "typeAnnotation"], |
|
||||
builder: ["parameterName", "typeAnnotation", "asserts"], |
|
||||
fields: { |
|
||||
parameterName: (0, _utils.validateType)(["Identifier", "TSThisType"]), |
|
||||
typeAnnotation: (0, _utils.validateOptionalType)("TSTypeAnnotation"), |
|
||||
asserts: (0, _utils.validateOptional)(bool) |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("TSTypeQuery", { |
|
||||
aliases: ["TSType"], |
|
||||
visitor: ["exprName"], |
|
||||
fields: { |
|
||||
exprName: (0, _utils.validateType)(["TSEntityName", "TSImportType"]) |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("TSTypeLiteral", { |
|
||||
aliases: ["TSType"], |
|
||||
visitor: ["members"], |
|
||||
fields: { |
|
||||
members: (0, _utils.validateArrayOfType)("TSTypeElement") |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("TSArrayType", { |
|
||||
aliases: ["TSType"], |
|
||||
visitor: ["elementType"], |
|
||||
fields: { |
|
||||
elementType: (0, _utils.validateType)("TSType") |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("TSTupleType", { |
|
||||
aliases: ["TSType"], |
|
||||
visitor: ["elementTypes"], |
|
||||
fields: { |
|
||||
elementTypes: (0, _utils.validateArrayOfType)("TSType") |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("TSOptionalType", { |
|
||||
aliases: ["TSType"], |
|
||||
visitor: ["typeAnnotation"], |
|
||||
fields: { |
|
||||
typeAnnotation: (0, _utils.validateType)("TSType") |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("TSRestType", { |
|
||||
aliases: ["TSType"], |
|
||||
visitor: ["typeAnnotation"], |
|
||||
fields: { |
|
||||
typeAnnotation: (0, _utils.validateType)("TSType") |
|
||||
} |
|
||||
}); |
|
||||
const unionOrIntersection = { |
|
||||
aliases: ["TSType"], |
|
||||
visitor: ["types"], |
|
||||
fields: { |
|
||||
types: (0, _utils.validateArrayOfType)("TSType") |
|
||||
} |
|
||||
}; |
|
||||
(0, _utils.default)("TSUnionType", unionOrIntersection); |
|
||||
(0, _utils.default)("TSIntersectionType", unionOrIntersection); |
|
||||
(0, _utils.default)("TSConditionalType", { |
|
||||
aliases: ["TSType"], |
|
||||
visitor: ["checkType", "extendsType", "trueType", "falseType"], |
|
||||
fields: { |
|
||||
checkType: (0, _utils.validateType)("TSType"), |
|
||||
extendsType: (0, _utils.validateType)("TSType"), |
|
||||
trueType: (0, _utils.validateType)("TSType"), |
|
||||
falseType: (0, _utils.validateType)("TSType") |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("TSInferType", { |
|
||||
aliases: ["TSType"], |
|
||||
visitor: ["typeParameter"], |
|
||||
fields: { |
|
||||
typeParameter: (0, _utils.validateType)("TSTypeParameter") |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("TSParenthesizedType", { |
|
||||
aliases: ["TSType"], |
|
||||
visitor: ["typeAnnotation"], |
|
||||
fields: { |
|
||||
typeAnnotation: (0, _utils.validateType)("TSType") |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("TSTypeOperator", { |
|
||||
aliases: ["TSType"], |
|
||||
visitor: ["typeAnnotation"], |
|
||||
fields: { |
|
||||
operator: (0, _utils.validate)((0, _utils.assertValueType)("string")), |
|
||||
typeAnnotation: (0, _utils.validateType)("TSType") |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("TSIndexedAccessType", { |
|
||||
aliases: ["TSType"], |
|
||||
visitor: ["objectType", "indexType"], |
|
||||
fields: { |
|
||||
objectType: (0, _utils.validateType)("TSType"), |
|
||||
indexType: (0, _utils.validateType)("TSType") |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("TSMappedType", { |
|
||||
aliases: ["TSType"], |
|
||||
visitor: ["typeParameter", "typeAnnotation"], |
|
||||
fields: { |
|
||||
readonly: (0, _utils.validateOptional)(bool), |
|
||||
typeParameter: (0, _utils.validateType)("TSTypeParameter"), |
|
||||
optional: (0, _utils.validateOptional)(bool), |
|
||||
typeAnnotation: (0, _utils.validateOptionalType)("TSType") |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("TSLiteralType", { |
|
||||
aliases: ["TSType"], |
|
||||
visitor: ["literal"], |
|
||||
fields: { |
|
||||
literal: (0, _utils.validateType)(["NumericLiteral", "StringLiteral", "BooleanLiteral"]) |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("TSExpressionWithTypeArguments", { |
|
||||
aliases: ["TSType"], |
|
||||
visitor: ["expression", "typeParameters"], |
|
||||
fields: { |
|
||||
expression: (0, _utils.validateType)("TSEntityName"), |
|
||||
typeParameters: (0, _utils.validateOptionalType)("TSTypeParameterInstantiation") |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("TSInterfaceDeclaration", { |
|
||||
aliases: ["Statement", "Declaration"], |
|
||||
visitor: ["id", "typeParameters", "extends", "body"], |
|
||||
fields: { |
|
||||
declare: (0, _utils.validateOptional)(bool), |
|
||||
id: (0, _utils.validateType)("Identifier"), |
|
||||
typeParameters: (0, _utils.validateOptionalType)("TSTypeParameterDeclaration"), |
|
||||
extends: (0, _utils.validateOptional)((0, _utils.arrayOfType)("TSExpressionWithTypeArguments")), |
|
||||
body: (0, _utils.validateType)("TSInterfaceBody") |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("TSInterfaceBody", { |
|
||||
visitor: ["body"], |
|
||||
fields: { |
|
||||
body: (0, _utils.validateArrayOfType)("TSTypeElement") |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("TSTypeAliasDeclaration", { |
|
||||
aliases: ["Statement", "Declaration"], |
|
||||
visitor: ["id", "typeParameters", "typeAnnotation"], |
|
||||
fields: { |
|
||||
declare: (0, _utils.validateOptional)(bool), |
|
||||
id: (0, _utils.validateType)("Identifier"), |
|
||||
typeParameters: (0, _utils.validateOptionalType)("TSTypeParameterDeclaration"), |
|
||||
typeAnnotation: (0, _utils.validateType)("TSType") |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("TSAsExpression", { |
|
||||
aliases: ["Expression"], |
|
||||
visitor: ["expression", "typeAnnotation"], |
|
||||
fields: { |
|
||||
expression: (0, _utils.validateType)("Expression"), |
|
||||
typeAnnotation: (0, _utils.validateType)("TSType") |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("TSTypeAssertion", { |
|
||||
aliases: ["Expression"], |
|
||||
visitor: ["typeAnnotation", "expression"], |
|
||||
fields: { |
|
||||
typeAnnotation: (0, _utils.validateType)("TSType"), |
|
||||
expression: (0, _utils.validateType)("Expression") |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("TSEnumDeclaration", { |
|
||||
aliases: ["Statement", "Declaration"], |
|
||||
visitor: ["id", "members"], |
|
||||
fields: { |
|
||||
declare: (0, _utils.validateOptional)(bool), |
|
||||
const: (0, _utils.validateOptional)(bool), |
|
||||
id: (0, _utils.validateType)("Identifier"), |
|
||||
members: (0, _utils.validateArrayOfType)("TSEnumMember"), |
|
||||
initializer: (0, _utils.validateOptionalType)("Expression") |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("TSEnumMember", { |
|
||||
visitor: ["id", "initializer"], |
|
||||
fields: { |
|
||||
id: (0, _utils.validateType)(["Identifier", "StringLiteral"]), |
|
||||
initializer: (0, _utils.validateOptionalType)("Expression") |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("TSModuleDeclaration", { |
|
||||
aliases: ["Statement", "Declaration"], |
|
||||
visitor: ["id", "body"], |
|
||||
fields: { |
|
||||
declare: (0, _utils.validateOptional)(bool), |
|
||||
global: (0, _utils.validateOptional)(bool), |
|
||||
id: (0, _utils.validateType)(["Identifier", "StringLiteral"]), |
|
||||
body: (0, _utils.validateType)(["TSModuleBlock", "TSModuleDeclaration"]) |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("TSModuleBlock", { |
|
||||
aliases: ["Scopable", "Block", "BlockParent"], |
|
||||
visitor: ["body"], |
|
||||
fields: { |
|
||||
body: (0, _utils.validateArrayOfType)("Statement") |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("TSImportType", { |
|
||||
aliases: ["TSType"], |
|
||||
visitor: ["argument", "qualifier", "typeParameters"], |
|
||||
fields: { |
|
||||
argument: (0, _utils.validateType)("StringLiteral"), |
|
||||
qualifier: (0, _utils.validateOptionalType)("TSEntityName"), |
|
||||
typeParameters: (0, _utils.validateOptionalType)("TSTypeParameterInstantiation") |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("TSImportEqualsDeclaration", { |
|
||||
aliases: ["Statement"], |
|
||||
visitor: ["id", "moduleReference"], |
|
||||
fields: { |
|
||||
isExport: (0, _utils.validate)(bool), |
|
||||
id: (0, _utils.validateType)("Identifier"), |
|
||||
moduleReference: (0, _utils.validateType)(["TSEntityName", "TSExternalModuleReference"]) |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("TSExternalModuleReference", { |
|
||||
visitor: ["expression"], |
|
||||
fields: { |
|
||||
expression: (0, _utils.validateType)("StringLiteral") |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("TSNonNullExpression", { |
|
||||
aliases: ["Expression"], |
|
||||
visitor: ["expression"], |
|
||||
fields: { |
|
||||
expression: (0, _utils.validateType)("Expression") |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("TSExportAssignment", { |
|
||||
aliases: ["Statement"], |
|
||||
visitor: ["expression"], |
|
||||
fields: { |
|
||||
expression: (0, _utils.validateType)("Expression") |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("TSNamespaceExportDeclaration", { |
|
||||
aliases: ["Statement"], |
|
||||
visitor: ["id"], |
|
||||
fields: { |
|
||||
id: (0, _utils.validateType)("Identifier") |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("TSTypeAnnotation", { |
|
||||
visitor: ["typeAnnotation"], |
|
||||
fields: { |
|
||||
typeAnnotation: { |
|
||||
validate: (0, _utils.assertNodeType)("TSType") |
|
||||
} |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("TSTypeParameterInstantiation", { |
|
||||
visitor: ["params"], |
|
||||
fields: { |
|
||||
params: { |
|
||||
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("TSType"))) |
|
||||
} |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("TSTypeParameterDeclaration", { |
|
||||
visitor: ["params"], |
|
||||
fields: { |
|
||||
params: { |
|
||||
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("TSTypeParameter"))) |
|
||||
} |
|
||||
} |
|
||||
}); |
|
||||
(0, _utils.default)("TSTypeParameter", { |
|
||||
builder: ["constraint", "default", "name"], |
|
||||
visitor: ["constraint", "default"], |
|
||||
fields: { |
|
||||
name: { |
|
||||
validate: (0, _utils.assertValueType)("string") |
|
||||
}, |
|
||||
constraint: { |
|
||||
validate: (0, _utils.assertNodeType)("TSType"), |
|
||||
optional: true |
|
||||
}, |
|
||||
default: { |
|
||||
validate: (0, _utils.assertNodeType)("TSType"), |
|
||||
optional: true |
|
||||
} |
|
||||
} |
|
||||
}); |
|
||||
@ -1,315 +0,0 @@ |
|||||
"use strict"; |
|
||||
|
|
||||
Object.defineProperty(exports, "__esModule", { |
|
||||
value: true |
|
||||
}); |
|
||||
exports.validate = validate; |
|
||||
exports.typeIs = typeIs; |
|
||||
exports.validateType = validateType; |
|
||||
exports.validateOptional = validateOptional; |
|
||||
exports.validateOptionalType = validateOptionalType; |
|
||||
exports.arrayOf = arrayOf; |
|
||||
exports.arrayOfType = arrayOfType; |
|
||||
exports.validateArrayOfType = validateArrayOfType; |
|
||||
exports.assertEach = assertEach; |
|
||||
exports.assertOneOf = assertOneOf; |
|
||||
exports.assertNodeType = assertNodeType; |
|
||||
exports.assertNodeOrValueType = assertNodeOrValueType; |
|
||||
exports.assertValueType = assertValueType; |
|
||||
exports.assertShape = assertShape; |
|
||||
exports.assertOptionalChainStart = assertOptionalChainStart; |
|
||||
exports.chain = chain; |
|
||||
exports.default = defineType; |
|
||||
exports.NODE_PARENT_VALIDATIONS = exports.DEPRECATED_KEYS = exports.BUILDER_KEYS = exports.NODE_FIELDS = exports.FLIPPED_ALIAS_KEYS = exports.ALIAS_KEYS = exports.VISITOR_KEYS = void 0; |
|
||||
|
|
||||
var _is = _interopRequireDefault(require("../validators/is")); |
|
||||
|
|
||||
var _validate = require("../validators/validate"); |
|
||||
|
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
|
||||
|
|
||||
const VISITOR_KEYS = {}; |
|
||||
exports.VISITOR_KEYS = VISITOR_KEYS; |
|
||||
const ALIAS_KEYS = {}; |
|
||||
exports.ALIAS_KEYS = ALIAS_KEYS; |
|
||||
const FLIPPED_ALIAS_KEYS = {}; |
|
||||
exports.FLIPPED_ALIAS_KEYS = FLIPPED_ALIAS_KEYS; |
|
||||
const NODE_FIELDS = {}; |
|
||||
exports.NODE_FIELDS = NODE_FIELDS; |
|
||||
const BUILDER_KEYS = {}; |
|
||||
exports.BUILDER_KEYS = BUILDER_KEYS; |
|
||||
const DEPRECATED_KEYS = {}; |
|
||||
exports.DEPRECATED_KEYS = DEPRECATED_KEYS; |
|
||||
const NODE_PARENT_VALIDATIONS = {}; |
|
||||
exports.NODE_PARENT_VALIDATIONS = NODE_PARENT_VALIDATIONS; |
|
||||
|
|
||||
function getType(val) { |
|
||||
if (Array.isArray(val)) { |
|
||||
return "array"; |
|
||||
} else if (val === null) { |
|
||||
return "null"; |
|
||||
} else { |
|
||||
return typeof val; |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
function validate(validate) { |
|
||||
return { |
|
||||
validate |
|
||||
}; |
|
||||
} |
|
||||
|
|
||||
function typeIs(typeName) { |
|
||||
return typeof typeName === "string" ? assertNodeType(typeName) : assertNodeType(...typeName); |
|
||||
} |
|
||||
|
|
||||
function validateType(typeName) { |
|
||||
return validate(typeIs(typeName)); |
|
||||
} |
|
||||
|
|
||||
function validateOptional(validate) { |
|
||||
return { |
|
||||
validate, |
|
||||
optional: true |
|
||||
}; |
|
||||
} |
|
||||
|
|
||||
function validateOptionalType(typeName) { |
|
||||
return { |
|
||||
validate: typeIs(typeName), |
|
||||
optional: true |
|
||||
}; |
|
||||
} |
|
||||
|
|
||||
function arrayOf(elementType) { |
|
||||
return chain(assertValueType("array"), assertEach(elementType)); |
|
||||
} |
|
||||
|
|
||||
function arrayOfType(typeName) { |
|
||||
return arrayOf(typeIs(typeName)); |
|
||||
} |
|
||||
|
|
||||
function validateArrayOfType(typeName) { |
|
||||
return validate(arrayOfType(typeName)); |
|
||||
} |
|
||||
|
|
||||
function assertEach(callback) { |
|
||||
function validator(node, key, val) { |
|
||||
if (!Array.isArray(val)) return; |
|
||||
|
|
||||
for (let i = 0; i < val.length; i++) { |
|
||||
const subkey = `${key}[${i}]`; |
|
||||
const v = val[i]; |
|
||||
callback(node, subkey, v); |
|
||||
if (process.env.BABEL_TYPES_8_BREAKING) (0, _validate.validateChild)(node, subkey, v); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
validator.each = callback; |
|
||||
return validator; |
|
||||
} |
|
||||
|
|
||||
function assertOneOf(...values) { |
|
||||
function validate(node, key, val) { |
|
||||
if (values.indexOf(val) < 0) { |
|
||||
throw new TypeError(`Property ${key} expected value to be one of ${JSON.stringify(values)} but got ${JSON.stringify(val)}`); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
validate.oneOf = values; |
|
||||
return validate; |
|
||||
} |
|
||||
|
|
||||
function assertNodeType(...types) { |
|
||||
function validate(node, key, val) { |
|
||||
for (const type of types) { |
|
||||
if ((0, _is.default)(type, val)) { |
|
||||
(0, _validate.validateChild)(node, key, val); |
|
||||
return; |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
throw new TypeError(`Property ${key} of ${node.type} expected node to be of a type ${JSON.stringify(types)} but instead got ${JSON.stringify(val && val.type)}`); |
|
||||
} |
|
||||
|
|
||||
validate.oneOfNodeTypes = types; |
|
||||
return validate; |
|
||||
} |
|
||||
|
|
||||
function assertNodeOrValueType(...types) { |
|
||||
function validate(node, key, val) { |
|
||||
for (const type of types) { |
|
||||
if (getType(val) === type || (0, _is.default)(type, val)) { |
|
||||
(0, _validate.validateChild)(node, key, val); |
|
||||
return; |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
throw new TypeError(`Property ${key} of ${node.type} expected node to be of a type ${JSON.stringify(types)} but instead got ${JSON.stringify(val && val.type)}`); |
|
||||
} |
|
||||
|
|
||||
validate.oneOfNodeOrValueTypes = types; |
|
||||
return validate; |
|
||||
} |
|
||||
|
|
||||
function assertValueType(type) { |
|
||||
function validate(node, key, val) { |
|
||||
const valid = getType(val) === type; |
|
||||
|
|
||||
if (!valid) { |
|
||||
throw new TypeError(`Property ${key} expected type of ${type} but got ${getType(val)}`); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
validate.type = type; |
|
||||
return validate; |
|
||||
} |
|
||||
|
|
||||
function assertShape(shape) { |
|
||||
function validate(node, key, val) { |
|
||||
const errors = []; |
|
||||
|
|
||||
for (const property of Object.keys(shape)) { |
|
||||
try { |
|
||||
(0, _validate.validateField)(node, property, val[property], shape[property]); |
|
||||
} catch (error) { |
|
||||
if (error instanceof TypeError) { |
|
||||
errors.push(error.message); |
|
||||
continue; |
|
||||
} |
|
||||
|
|
||||
throw error; |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
if (errors.length) { |
|
||||
throw new TypeError(`Property ${key} of ${node.type} expected to have the following:\n${errors.join("\n")}`); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
validate.shapeOf = shape; |
|
||||
return validate; |
|
||||
} |
|
||||
|
|
||||
function assertOptionalChainStart() { |
|
||||
function validate(node) { |
|
||||
var _current; |
|
||||
|
|
||||
let current = node; |
|
||||
|
|
||||
while (node) { |
|
||||
const { |
|
||||
type |
|
||||
} = current; |
|
||||
|
|
||||
if (type === "OptionalCallExpression") { |
|
||||
if (current.optional) return; |
|
||||
current = current.callee; |
|
||||
continue; |
|
||||
} |
|
||||
|
|
||||
if (type === "OptionalMemberExpression") { |
|
||||
if (current.optional) return; |
|
||||
current = current.object; |
|
||||
continue; |
|
||||
} |
|
||||
|
|
||||
break; |
|
||||
} |
|
||||
|
|
||||
throw new TypeError(`Non-optional ${node.type} must chain from an optional OptionalMemberExpression or OptionalCallExpression. Found chain from ${(_current = current) == null ? void 0 : _current.type}`); |
|
||||
} |
|
||||
|
|
||||
return validate; |
|
||||
} |
|
||||
|
|
||||
function chain(...fns) { |
|
||||
function validate(...args) { |
|
||||
for (const fn of fns) { |
|
||||
fn(...args); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
validate.chainOf = fns; |
|
||||
return validate; |
|
||||
} |
|
||||
|
|
||||
const validTypeOpts = ["aliases", "builder", "deprecatedAlias", "fields", "inherits", "visitor", "validate"]; |
|
||||
const validFieldKeys = ["default", "optional", "validate"]; |
|
||||
|
|
||||
function defineType(type, opts = {}) { |
|
||||
const inherits = opts.inherits && store[opts.inherits] || {}; |
|
||||
let fields = opts.fields; |
|
||||
|
|
||||
if (!fields) { |
|
||||
fields = {}; |
|
||||
|
|
||||
if (inherits.fields) { |
|
||||
const keys = Object.getOwnPropertyNames(inherits.fields); |
|
||||
|
|
||||
for (const key of keys) { |
|
||||
const field = inherits.fields[key]; |
|
||||
fields[key] = { |
|
||||
default: field.default, |
|
||||
optional: field.optional, |
|
||||
validate: field.validate |
|
||||
}; |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
const visitor = opts.visitor || inherits.visitor || []; |
|
||||
const aliases = opts.aliases || inherits.aliases || []; |
|
||||
const builder = opts.builder || inherits.builder || opts.visitor || []; |
|
||||
|
|
||||
for (const k of Object.keys(opts)) { |
|
||||
if (validTypeOpts.indexOf(k) === -1) { |
|
||||
throw new Error(`Unknown type option "${k}" on ${type}`); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
if (opts.deprecatedAlias) { |
|
||||
DEPRECATED_KEYS[opts.deprecatedAlias] = type; |
|
||||
} |
|
||||
|
|
||||
for (const key of visitor.concat(builder)) { |
|
||||
fields[key] = fields[key] || {}; |
|
||||
} |
|
||||
|
|
||||
for (const key of Object.keys(fields)) { |
|
||||
const field = fields[key]; |
|
||||
|
|
||||
if (field.default !== undefined && builder.indexOf(key) === -1) { |
|
||||
field.optional = true; |
|
||||
} |
|
||||
|
|
||||
if (field.default === undefined) { |
|
||||
field.default = null; |
|
||||
} else if (!field.validate && field.default != null) { |
|
||||
field.validate = assertValueType(getType(field.default)); |
|
||||
} |
|
||||
|
|
||||
for (const k of Object.keys(field)) { |
|
||||
if (validFieldKeys.indexOf(k) === -1) { |
|
||||
throw new Error(`Unknown field key "${k}" on ${type}.${key}`); |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
VISITOR_KEYS[type] = opts.visitor = visitor; |
|
||||
BUILDER_KEYS[type] = opts.builder = builder; |
|
||||
NODE_FIELDS[type] = opts.fields = fields; |
|
||||
ALIAS_KEYS[type] = opts.aliases = aliases; |
|
||||
aliases.forEach(alias => { |
|
||||
FLIPPED_ALIAS_KEYS[alias] = FLIPPED_ALIAS_KEYS[alias] || []; |
|
||||
FLIPPED_ALIAS_KEYS[alias].push(type); |
|
||||
}); |
|
||||
|
|
||||
if (opts.validate) { |
|
||||
NODE_PARENT_VALIDATIONS[type] = opts.validate; |
|
||||
} |
|
||||
|
|
||||
store[type] = opts; |
|
||||
} |
|
||||
|
|
||||
const store = {}; |
|
||||
File diff suppressed because one or more lines are too long
@ -1,588 +0,0 @@ |
|||||
"use strict"; |
|
||||
|
|
||||
Object.defineProperty(exports, "__esModule", { |
|
||||
value: true |
|
||||
}); |
|
||||
var _exportNames = { |
|
||||
react: true, |
|
||||
assertNode: true, |
|
||||
createTypeAnnotationBasedOnTypeof: true, |
|
||||
createUnionTypeAnnotation: true, |
|
||||
cloneNode: true, |
|
||||
clone: true, |
|
||||
cloneDeep: true, |
|
||||
cloneDeepWithoutLoc: true, |
|
||||
cloneWithoutLoc: true, |
|
||||
addComment: true, |
|
||||
addComments: true, |
|
||||
inheritInnerComments: true, |
|
||||
inheritLeadingComments: true, |
|
||||
inheritsComments: true, |
|
||||
inheritTrailingComments: true, |
|
||||
removeComments: true, |
|
||||
ensureBlock: true, |
|
||||
toBindingIdentifierName: true, |
|
||||
toBlock: true, |
|
||||
toComputedKey: true, |
|
||||
toExpression: true, |
|
||||
toIdentifier: true, |
|
||||
toKeyAlias: true, |
|
||||
toSequenceExpression: true, |
|
||||
toStatement: true, |
|
||||
valueToNode: true, |
|
||||
appendToMemberExpression: true, |
|
||||
inherits: true, |
|
||||
prependToMemberExpression: true, |
|
||||
removeProperties: true, |
|
||||
removePropertiesDeep: true, |
|
||||
removeTypeDuplicates: true, |
|
||||
getBindingIdentifiers: true, |
|
||||
getOuterBindingIdentifiers: true, |
|
||||
traverse: true, |
|
||||
traverseFast: true, |
|
||||
shallowEqual: true, |
|
||||
is: true, |
|
||||
isBinding: true, |
|
||||
isBlockScoped: true, |
|
||||
isImmutable: true, |
|
||||
isLet: true, |
|
||||
isNode: true, |
|
||||
isNodesEquivalent: true, |
|
||||
isPlaceholderType: true, |
|
||||
isReferenced: true, |
|
||||
isScope: true, |
|
||||
isSpecifierDefault: true, |
|
||||
isType: true, |
|
||||
isValidES3Identifier: true, |
|
||||
isValidIdentifier: true, |
|
||||
isVar: true, |
|
||||
matchesPattern: true, |
|
||||
validate: true, |
|
||||
buildMatchMemberExpression: true |
|
||||
}; |
|
||||
Object.defineProperty(exports, "assertNode", { |
|
||||
enumerable: true, |
|
||||
get: function () { |
|
||||
return _assertNode.default; |
|
||||
} |
|
||||
}); |
|
||||
Object.defineProperty(exports, "createTypeAnnotationBasedOnTypeof", { |
|
||||
enumerable: true, |
|
||||
get: function () { |
|
||||
return _createTypeAnnotationBasedOnTypeof.default; |
|
||||
} |
|
||||
}); |
|
||||
Object.defineProperty(exports, "createUnionTypeAnnotation", { |
|
||||
enumerable: true, |
|
||||
get: function () { |
|
||||
return _createUnionTypeAnnotation.default; |
|
||||
} |
|
||||
}); |
|
||||
Object.defineProperty(exports, "cloneNode", { |
|
||||
enumerable: true, |
|
||||
get: function () { |
|
||||
return _cloneNode.default; |
|
||||
} |
|
||||
}); |
|
||||
Object.defineProperty(exports, "clone", { |
|
||||
enumerable: true, |
|
||||
get: function () { |
|
||||
return _clone.default; |
|
||||
} |
|
||||
}); |
|
||||
Object.defineProperty(exports, "cloneDeep", { |
|
||||
enumerable: true, |
|
||||
get: function () { |
|
||||
return _cloneDeep.default; |
|
||||
} |
|
||||
}); |
|
||||
Object.defineProperty(exports, "cloneDeepWithoutLoc", { |
|
||||
enumerable: true, |
|
||||
get: function () { |
|
||||
return _cloneDeepWithoutLoc.default; |
|
||||
} |
|
||||
}); |
|
||||
Object.defineProperty(exports, "cloneWithoutLoc", { |
|
||||
enumerable: true, |
|
||||
get: function () { |
|
||||
return _cloneWithoutLoc.default; |
|
||||
} |
|
||||
}); |
|
||||
Object.defineProperty(exports, "addComment", { |
|
||||
enumerable: true, |
|
||||
get: function () { |
|
||||
return _addComment.default; |
|
||||
} |
|
||||
}); |
|
||||
Object.defineProperty(exports, "addComments", { |
|
||||
enumerable: true, |
|
||||
get: function () { |
|
||||
return _addComments.default; |
|
||||
} |
|
||||
}); |
|
||||
Object.defineProperty(exports, "inheritInnerComments", { |
|
||||
enumerable: true, |
|
||||
get: function () { |
|
||||
return _inheritInnerComments.default; |
|
||||
} |
|
||||
}); |
|
||||
Object.defineProperty(exports, "inheritLeadingComments", { |
|
||||
enumerable: true, |
|
||||
get: function () { |
|
||||
return _inheritLeadingComments.default; |
|
||||
} |
|
||||
}); |
|
||||
Object.defineProperty(exports, "inheritsComments", { |
|
||||
enumerable: true, |
|
||||
get: function () { |
|
||||
return _inheritsComments.default; |
|
||||
} |
|
||||
}); |
|
||||
Object.defineProperty(exports, "inheritTrailingComments", { |
|
||||
enumerable: true, |
|
||||
get: function () { |
|
||||
return _inheritTrailingComments.default; |
|
||||
} |
|
||||
}); |
|
||||
Object.defineProperty(exports, "removeComments", { |
|
||||
enumerable: true, |
|
||||
get: function () { |
|
||||
return _removeComments.default; |
|
||||
} |
|
||||
}); |
|
||||
Object.defineProperty(exports, "ensureBlock", { |
|
||||
enumerable: true, |
|
||||
get: function () { |
|
||||
return _ensureBlock.default; |
|
||||
} |
|
||||
}); |
|
||||
Object.defineProperty(exports, "toBindingIdentifierName", { |
|
||||
enumerable: true, |
|
||||
get: function () { |
|
||||
return _toBindingIdentifierName.default; |
|
||||
} |
|
||||
}); |
|
||||
Object.defineProperty(exports, "toBlock", { |
|
||||
enumerable: true, |
|
||||
get: function () { |
|
||||
return _toBlock.default; |
|
||||
} |
|
||||
}); |
|
||||
Object.defineProperty(exports, "toComputedKey", { |
|
||||
enumerable: true, |
|
||||
get: function () { |
|
||||
return _toComputedKey.default; |
|
||||
} |
|
||||
}); |
|
||||
Object.defineProperty(exports, "toExpression", { |
|
||||
enumerable: true, |
|
||||
get: function () { |
|
||||
return _toExpression.default; |
|
||||
} |
|
||||
}); |
|
||||
Object.defineProperty(exports, "toIdentifier", { |
|
||||
enumerable: true, |
|
||||
get: function () { |
|
||||
return _toIdentifier.default; |
|
||||
} |
|
||||
}); |
|
||||
Object.defineProperty(exports, "toKeyAlias", { |
|
||||
enumerable: true, |
|
||||
get: function () { |
|
||||
return _toKeyAlias.default; |
|
||||
} |
|
||||
}); |
|
||||
Object.defineProperty(exports, "toSequenceExpression", { |
|
||||
enumerable: true, |
|
||||
get: function () { |
|
||||
return _toSequenceExpression.default; |
|
||||
} |
|
||||
}); |
|
||||
Object.defineProperty(exports, "toStatement", { |
|
||||
enumerable: true, |
|
||||
get: function () { |
|
||||
return _toStatement.default; |
|
||||
} |
|
||||
}); |
|
||||
Object.defineProperty(exports, "valueToNode", { |
|
||||
enumerable: true, |
|
||||
get: function () { |
|
||||
return _valueToNode.default; |
|
||||
} |
|
||||
}); |
|
||||
Object.defineProperty(exports, "appendToMemberExpression", { |
|
||||
enumerable: true, |
|
||||
get: function () { |
|
||||
return _appendToMemberExpression.default; |
|
||||
} |
|
||||
}); |
|
||||
Object.defineProperty(exports, "inherits", { |
|
||||
enumerable: true, |
|
||||
get: function () { |
|
||||
return _inherits.default; |
|
||||
} |
|
||||
}); |
|
||||
Object.defineProperty(exports, "prependToMemberExpression", { |
|
||||
enumerable: true, |
|
||||
get: function () { |
|
||||
return _prependToMemberExpression.default; |
|
||||
} |
|
||||
}); |
|
||||
Object.defineProperty(exports, "removeProperties", { |
|
||||
enumerable: true, |
|
||||
get: function () { |
|
||||
return _removeProperties.default; |
|
||||
} |
|
||||
}); |
|
||||
Object.defineProperty(exports, "removePropertiesDeep", { |
|
||||
enumerable: true, |
|
||||
get: function () { |
|
||||
return _removePropertiesDeep.default; |
|
||||
} |
|
||||
}); |
|
||||
Object.defineProperty(exports, "removeTypeDuplicates", { |
|
||||
enumerable: true, |
|
||||
get: function () { |
|
||||
return _removeTypeDuplicates.default; |
|
||||
} |
|
||||
}); |
|
||||
Object.defineProperty(exports, "getBindingIdentifiers", { |
|
||||
enumerable: true, |
|
||||
get: function () { |
|
||||
return _getBindingIdentifiers.default; |
|
||||
} |
|
||||
}); |
|
||||
Object.defineProperty(exports, "getOuterBindingIdentifiers", { |
|
||||
enumerable: true, |
|
||||
get: function () { |
|
||||
return _getOuterBindingIdentifiers.default; |
|
||||
} |
|
||||
}); |
|
||||
Object.defineProperty(exports, "traverse", { |
|
||||
enumerable: true, |
|
||||
get: function () { |
|
||||
return _traverse.default; |
|
||||
} |
|
||||
}); |
|
||||
Object.defineProperty(exports, "traverseFast", { |
|
||||
enumerable: true, |
|
||||
get: function () { |
|
||||
return _traverseFast.default; |
|
||||
} |
|
||||
}); |
|
||||
Object.defineProperty(exports, "shallowEqual", { |
|
||||
enumerable: true, |
|
||||
get: function () { |
|
||||
return _shallowEqual.default; |
|
||||
} |
|
||||
}); |
|
||||
Object.defineProperty(exports, "is", { |
|
||||
enumerable: true, |
|
||||
get: function () { |
|
||||
return _is.default; |
|
||||
} |
|
||||
}); |
|
||||
Object.defineProperty(exports, "isBinding", { |
|
||||
enumerable: true, |
|
||||
get: function () { |
|
||||
return _isBinding.default; |
|
||||
} |
|
||||
}); |
|
||||
Object.defineProperty(exports, "isBlockScoped", { |
|
||||
enumerable: true, |
|
||||
get: function () { |
|
||||
return _isBlockScoped.default; |
|
||||
} |
|
||||
}); |
|
||||
Object.defineProperty(exports, "isImmutable", { |
|
||||
enumerable: true, |
|
||||
get: function () { |
|
||||
return _isImmutable.default; |
|
||||
} |
|
||||
}); |
|
||||
Object.defineProperty(exports, "isLet", { |
|
||||
enumerable: true, |
|
||||
get: function () { |
|
||||
return _isLet.default; |
|
||||
} |
|
||||
}); |
|
||||
Object.defineProperty(exports, "isNode", { |
|
||||
enumerable: true, |
|
||||
get: function () { |
|
||||
return _isNode.default; |
|
||||
} |
|
||||
}); |
|
||||
Object.defineProperty(exports, "isNodesEquivalent", { |
|
||||
enumerable: true, |
|
||||
get: function () { |
|
||||
return _isNodesEquivalent.default; |
|
||||
} |
|
||||
}); |
|
||||
Object.defineProperty(exports, "isPlaceholderType", { |
|
||||
enumerable: true, |
|
||||
get: function () { |
|
||||
return _isPlaceholderType.default; |
|
||||
} |
|
||||
}); |
|
||||
Object.defineProperty(exports, "isReferenced", { |
|
||||
enumerable: true, |
|
||||
get: function () { |
|
||||
return _isReferenced.default; |
|
||||
} |
|
||||
}); |
|
||||
Object.defineProperty(exports, "isScope", { |
|
||||
enumerable: true, |
|
||||
get: function () { |
|
||||
return _isScope.default; |
|
||||
} |
|
||||
}); |
|
||||
Object.defineProperty(exports, "isSpecifierDefault", { |
|
||||
enumerable: true, |
|
||||
get: function () { |
|
||||
return _isSpecifierDefault.default; |
|
||||
} |
|
||||
}); |
|
||||
Object.defineProperty(exports, "isType", { |
|
||||
enumerable: true, |
|
||||
get: function () { |
|
||||
return _isType.default; |
|
||||
} |
|
||||
}); |
|
||||
Object.defineProperty(exports, "isValidES3Identifier", { |
|
||||
enumerable: true, |
|
||||
get: function () { |
|
||||
return _isValidES3Identifier.default; |
|
||||
} |
|
||||
}); |
|
||||
Object.defineProperty(exports, "isValidIdentifier", { |
|
||||
enumerable: true, |
|
||||
get: function () { |
|
||||
return _isValidIdentifier.default; |
|
||||
} |
|
||||
}); |
|
||||
Object.defineProperty(exports, "isVar", { |
|
||||
enumerable: true, |
|
||||
get: function () { |
|
||||
return _isVar.default; |
|
||||
} |
|
||||
}); |
|
||||
Object.defineProperty(exports, "matchesPattern", { |
|
||||
enumerable: true, |
|
||||
get: function () { |
|
||||
return _matchesPattern.default; |
|
||||
} |
|
||||
}); |
|
||||
Object.defineProperty(exports, "validate", { |
|
||||
enumerable: true, |
|
||||
get: function () { |
|
||||
return _validate.default; |
|
||||
} |
|
||||
}); |
|
||||
Object.defineProperty(exports, "buildMatchMemberExpression", { |
|
||||
enumerable: true, |
|
||||
get: function () { |
|
||||
return _buildMatchMemberExpression.default; |
|
||||
} |
|
||||
}); |
|
||||
exports.react = void 0; |
|
||||
|
|
||||
var _isReactComponent = _interopRequireDefault(require("./validators/react/isReactComponent")); |
|
||||
|
|
||||
var _isCompatTag = _interopRequireDefault(require("./validators/react/isCompatTag")); |
|
||||
|
|
||||
var _buildChildren = _interopRequireDefault(require("./builders/react/buildChildren")); |
|
||||
|
|
||||
var _assertNode = _interopRequireDefault(require("./asserts/assertNode")); |
|
||||
|
|
||||
var _generated = require("./asserts/generated"); |
|
||||
|
|
||||
Object.keys(_generated).forEach(function (key) { |
|
||||
if (key === "default" || key === "__esModule") return; |
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; |
|
||||
Object.defineProperty(exports, key, { |
|
||||
enumerable: true, |
|
||||
get: function () { |
|
||||
return _generated[key]; |
|
||||
} |
|
||||
}); |
|
||||
}); |
|
||||
|
|
||||
var _createTypeAnnotationBasedOnTypeof = _interopRequireDefault(require("./builders/flow/createTypeAnnotationBasedOnTypeof")); |
|
||||
|
|
||||
var _createUnionTypeAnnotation = _interopRequireDefault(require("./builders/flow/createUnionTypeAnnotation")); |
|
||||
|
|
||||
var _generated2 = require("./builders/generated"); |
|
||||
|
|
||||
Object.keys(_generated2).forEach(function (key) { |
|
||||
if (key === "default" || key === "__esModule") return; |
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; |
|
||||
Object.defineProperty(exports, key, { |
|
||||
enumerable: true, |
|
||||
get: function () { |
|
||||
return _generated2[key]; |
|
||||
} |
|
||||
}); |
|
||||
}); |
|
||||
|
|
||||
var _cloneNode = _interopRequireDefault(require("./clone/cloneNode")); |
|
||||
|
|
||||
var _clone = _interopRequireDefault(require("./clone/clone")); |
|
||||
|
|
||||
var _cloneDeep = _interopRequireDefault(require("./clone/cloneDeep")); |
|
||||
|
|
||||
var _cloneDeepWithoutLoc = _interopRequireDefault(require("./clone/cloneDeepWithoutLoc")); |
|
||||
|
|
||||
var _cloneWithoutLoc = _interopRequireDefault(require("./clone/cloneWithoutLoc")); |
|
||||
|
|
||||
var _addComment = _interopRequireDefault(require("./comments/addComment")); |
|
||||
|
|
||||
var _addComments = _interopRequireDefault(require("./comments/addComments")); |
|
||||
|
|
||||
var _inheritInnerComments = _interopRequireDefault(require("./comments/inheritInnerComments")); |
|
||||
|
|
||||
var _inheritLeadingComments = _interopRequireDefault(require("./comments/inheritLeadingComments")); |
|
||||
|
|
||||
var _inheritsComments = _interopRequireDefault(require("./comments/inheritsComments")); |
|
||||
|
|
||||
var _inheritTrailingComments = _interopRequireDefault(require("./comments/inheritTrailingComments")); |
|
||||
|
|
||||
var _removeComments = _interopRequireDefault(require("./comments/removeComments")); |
|
||||
|
|
||||
var _generated3 = require("./constants/generated"); |
|
||||
|
|
||||
Object.keys(_generated3).forEach(function (key) { |
|
||||
if (key === "default" || key === "__esModule") return; |
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; |
|
||||
Object.defineProperty(exports, key, { |
|
||||
enumerable: true, |
|
||||
get: function () { |
|
||||
return _generated3[key]; |
|
||||
} |
|
||||
}); |
|
||||
}); |
|
||||
|
|
||||
var _constants = require("./constants"); |
|
||||
|
|
||||
Object.keys(_constants).forEach(function (key) { |
|
||||
if (key === "default" || key === "__esModule") return; |
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; |
|
||||
Object.defineProperty(exports, key, { |
|
||||
enumerable: true, |
|
||||
get: function () { |
|
||||
return _constants[key]; |
|
||||
} |
|
||||
}); |
|
||||
}); |
|
||||
|
|
||||
var _ensureBlock = _interopRequireDefault(require("./converters/ensureBlock")); |
|
||||
|
|
||||
var _toBindingIdentifierName = _interopRequireDefault(require("./converters/toBindingIdentifierName")); |
|
||||
|
|
||||
var _toBlock = _interopRequireDefault(require("./converters/toBlock")); |
|
||||
|
|
||||
var _toComputedKey = _interopRequireDefault(require("./converters/toComputedKey")); |
|
||||
|
|
||||
var _toExpression = _interopRequireDefault(require("./converters/toExpression")); |
|
||||
|
|
||||
var _toIdentifier = _interopRequireDefault(require("./converters/toIdentifier")); |
|
||||
|
|
||||
var _toKeyAlias = _interopRequireDefault(require("./converters/toKeyAlias")); |
|
||||
|
|
||||
var _toSequenceExpression = _interopRequireDefault(require("./converters/toSequenceExpression")); |
|
||||
|
|
||||
var _toStatement = _interopRequireDefault(require("./converters/toStatement")); |
|
||||
|
|
||||
var _valueToNode = _interopRequireDefault(require("./converters/valueToNode")); |
|
||||
|
|
||||
var _definitions = require("./definitions"); |
|
||||
|
|
||||
Object.keys(_definitions).forEach(function (key) { |
|
||||
if (key === "default" || key === "__esModule") return; |
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; |
|
||||
Object.defineProperty(exports, key, { |
|
||||
enumerable: true, |
|
||||
get: function () { |
|
||||
return _definitions[key]; |
|
||||
} |
|
||||
}); |
|
||||
}); |
|
||||
|
|
||||
var _appendToMemberExpression = _interopRequireDefault(require("./modifications/appendToMemberExpression")); |
|
||||
|
|
||||
var _inherits = _interopRequireDefault(require("./modifications/inherits")); |
|
||||
|
|
||||
var _prependToMemberExpression = _interopRequireDefault(require("./modifications/prependToMemberExpression")); |
|
||||
|
|
||||
var _removeProperties = _interopRequireDefault(require("./modifications/removeProperties")); |
|
||||
|
|
||||
var _removePropertiesDeep = _interopRequireDefault(require("./modifications/removePropertiesDeep")); |
|
||||
|
|
||||
var _removeTypeDuplicates = _interopRequireDefault(require("./modifications/flow/removeTypeDuplicates")); |
|
||||
|
|
||||
var _getBindingIdentifiers = _interopRequireDefault(require("./retrievers/getBindingIdentifiers")); |
|
||||
|
|
||||
var _getOuterBindingIdentifiers = _interopRequireDefault(require("./retrievers/getOuterBindingIdentifiers")); |
|
||||
|
|
||||
var _traverse = _interopRequireDefault(require("./traverse/traverse")); |
|
||||
|
|
||||
var _traverseFast = _interopRequireDefault(require("./traverse/traverseFast")); |
|
||||
|
|
||||
var _shallowEqual = _interopRequireDefault(require("./utils/shallowEqual")); |
|
||||
|
|
||||
var _is = _interopRequireDefault(require("./validators/is")); |
|
||||
|
|
||||
var _isBinding = _interopRequireDefault(require("./validators/isBinding")); |
|
||||
|
|
||||
var _isBlockScoped = _interopRequireDefault(require("./validators/isBlockScoped")); |
|
||||
|
|
||||
var _isImmutable = _interopRequireDefault(require("./validators/isImmutable")); |
|
||||
|
|
||||
var _isLet = _interopRequireDefault(require("./validators/isLet")); |
|
||||
|
|
||||
var _isNode = _interopRequireDefault(require("./validators/isNode")); |
|
||||
|
|
||||
var _isNodesEquivalent = _interopRequireDefault(require("./validators/isNodesEquivalent")); |
|
||||
|
|
||||
var _isPlaceholderType = _interopRequireDefault(require("./validators/isPlaceholderType")); |
|
||||
|
|
||||
var _isReferenced = _interopRequireDefault(require("./validators/isReferenced")); |
|
||||
|
|
||||
var _isScope = _interopRequireDefault(require("./validators/isScope")); |
|
||||
|
|
||||
var _isSpecifierDefault = _interopRequireDefault(require("./validators/isSpecifierDefault")); |
|
||||
|
|
||||
var _isType = _interopRequireDefault(require("./validators/isType")); |
|
||||
|
|
||||
var _isValidES3Identifier = _interopRequireDefault(require("./validators/isValidES3Identifier")); |
|
||||
|
|
||||
var _isValidIdentifier = _interopRequireDefault(require("./validators/isValidIdentifier")); |
|
||||
|
|
||||
var _isVar = _interopRequireDefault(require("./validators/isVar")); |
|
||||
|
|
||||
var _matchesPattern = _interopRequireDefault(require("./validators/matchesPattern")); |
|
||||
|
|
||||
var _validate = _interopRequireDefault(require("./validators/validate")); |
|
||||
|
|
||||
var _buildMatchMemberExpression = _interopRequireDefault(require("./validators/buildMatchMemberExpression")); |
|
||||
|
|
||||
var _generated4 = require("./validators/generated"); |
|
||||
|
|
||||
Object.keys(_generated4).forEach(function (key) { |
|
||||
if (key === "default" || key === "__esModule") return; |
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; |
|
||||
Object.defineProperty(exports, key, { |
|
||||
enumerable: true, |
|
||||
get: function () { |
|
||||
return _generated4[key]; |
|
||||
} |
|
||||
}); |
|
||||
}); |
|
||||
|
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
|
||||
|
|
||||
const react = { |
|
||||
isReactComponent: _isReactComponent.default, |
|
||||
isCompatTag: _isCompatTag.default, |
|
||||
buildChildren: _buildChildren.default |
|
||||
}; |
|
||||
exports.react = react; |
|
||||
File diff suppressed because it is too large
@ -1,15 +0,0 @@ |
|||||
"use strict"; |
|
||||
|
|
||||
Object.defineProperty(exports, "__esModule", { |
|
||||
value: true |
|
||||
}); |
|
||||
exports.default = appendToMemberExpression; |
|
||||
|
|
||||
var _generated = require("../builders/generated"); |
|
||||
|
|
||||
function appendToMemberExpression(member, append, computed = false) { |
|
||||
member.object = (0, _generated.memberExpression)(member.object, member.property, member.computed); |
|
||||
member.property = append; |
|
||||
member.computed = !!computed; |
|
||||
return member; |
|
||||
} |
|
||||
@ -1,74 +0,0 @@ |
|||||
"use strict"; |
|
||||
|
|
||||
Object.defineProperty(exports, "__esModule", { |
|
||||
value: true |
|
||||
}); |
|
||||
exports.default = removeTypeDuplicates; |
|
||||
|
|
||||
var _generated = require("../../validators/generated"); |
|
||||
|
|
||||
function removeTypeDuplicates(nodes) { |
|
||||
const generics = {}; |
|
||||
const bases = {}; |
|
||||
const typeGroups = []; |
|
||||
const types = []; |
|
||||
|
|
||||
for (let i = 0; i < nodes.length; i++) { |
|
||||
const node = nodes[i]; |
|
||||
if (!node) continue; |
|
||||
|
|
||||
if (types.indexOf(node) >= 0) { |
|
||||
continue; |
|
||||
} |
|
||||
|
|
||||
if ((0, _generated.isAnyTypeAnnotation)(node)) { |
|
||||
return [node]; |
|
||||
} |
|
||||
|
|
||||
if ((0, _generated.isFlowBaseAnnotation)(node)) { |
|
||||
bases[node.type] = node; |
|
||||
continue; |
|
||||
} |
|
||||
|
|
||||
if ((0, _generated.isUnionTypeAnnotation)(node)) { |
|
||||
if (typeGroups.indexOf(node.types) < 0) { |
|
||||
nodes = nodes.concat(node.types); |
|
||||
typeGroups.push(node.types); |
|
||||
} |
|
||||
|
|
||||
continue; |
|
||||
} |
|
||||
|
|
||||
if ((0, _generated.isGenericTypeAnnotation)(node)) { |
|
||||
const name = node.id.name; |
|
||||
|
|
||||
if (generics[name]) { |
|
||||
let existing = generics[name]; |
|
||||
|
|
||||
if (existing.typeParameters) { |
|
||||
if (node.typeParameters) { |
|
||||
existing.typeParameters.params = removeTypeDuplicates(existing.typeParameters.params.concat(node.typeParameters.params)); |
|
||||
} |
|
||||
} else { |
|
||||
existing = node.typeParameters; |
|
||||
} |
|
||||
} else { |
|
||||
generics[name] = node; |
|
||||
} |
|
||||
|
|
||||
continue; |
|
||||
} |
|
||||
|
|
||||
types.push(node); |
|
||||
} |
|
||||
|
|
||||
for (const type of Object.keys(bases)) { |
|
||||
types.push(bases[type]); |
|
||||
} |
|
||||
|
|
||||
for (const name of Object.keys(generics)) { |
|
||||
types.push(generics[name]); |
|
||||
} |
|
||||
|
|
||||
return types; |
|
||||
} |
|
||||
@ -1,33 +0,0 @@ |
|||||
"use strict"; |
|
||||
|
|
||||
Object.defineProperty(exports, "__esModule", { |
|
||||
value: true |
|
||||
}); |
|
||||
exports.default = inherits; |
|
||||
|
|
||||
var _constants = require("../constants"); |
|
||||
|
|
||||
var _inheritsComments = _interopRequireDefault(require("../comments/inheritsComments")); |
|
||||
|
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
|
||||
|
|
||||
function inherits(child, parent) { |
|
||||
if (!child || !parent) return child; |
|
||||
|
|
||||
for (const key of _constants.INHERIT_KEYS.optional) { |
|
||||
if (child[key] == null) { |
|
||||
child[key] = parent[key]; |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
for (const key of Object.keys(parent)) { |
|
||||
if (key[0] === "_" && key !== "__clone") child[key] = parent[key]; |
|
||||
} |
|
||||
|
|
||||
for (const key of _constants.INHERIT_KEYS.force) { |
|
||||
child[key] = parent[key]; |
|
||||
} |
|
||||
|
|
||||
(0, _inheritsComments.default)(child, parent); |
|
||||
return child; |
|
||||
} |
|
||||
@ -1,13 +0,0 @@ |
|||||
"use strict"; |
|
||||
|
|
||||
Object.defineProperty(exports, "__esModule", { |
|
||||
value: true |
|
||||
}); |
|
||||
exports.default = prependToMemberExpression; |
|
||||
|
|
||||
var _generated = require("../builders/generated"); |
|
||||
|
|
||||
function prependToMemberExpression(member, prepend) { |
|
||||
member.object = (0, _generated.memberExpression)(prepend, member.object); |
|
||||
return member; |
|
||||
} |
|
||||
@ -1,30 +0,0 @@ |
|||||
"use strict"; |
|
||||
|
|
||||
Object.defineProperty(exports, "__esModule", { |
|
||||
value: true |
|
||||
}); |
|
||||
exports.default = removeProperties; |
|
||||
|
|
||||
var _constants = require("../constants"); |
|
||||
|
|
||||
const CLEAR_KEYS = ["tokens", "start", "end", "loc", "raw", "rawValue"]; |
|
||||
|
|
||||
const CLEAR_KEYS_PLUS_COMMENTS = _constants.COMMENT_KEYS.concat(["comments"]).concat(CLEAR_KEYS); |
|
||||
|
|
||||
function removeProperties(node, opts = {}) { |
|
||||
const map = opts.preserveComments ? CLEAR_KEYS : CLEAR_KEYS_PLUS_COMMENTS; |
|
||||
|
|
||||
for (const key of map) { |
|
||||
if (node[key] != null) node[key] = undefined; |
|
||||
} |
|
||||
|
|
||||
for (const key of Object.keys(node)) { |
|
||||
if (key[0] === "_" && node[key] != null) node[key] = undefined; |
|
||||
} |
|
||||
|
|
||||
const symbols = Object.getOwnPropertySymbols(node); |
|
||||
|
|
||||
for (const sym of symbols) { |
|
||||
node[sym] = null; |
|
||||
} |
|
||||
} |
|
||||
@ -1,17 +0,0 @@ |
|||||
"use strict"; |
|
||||
|
|
||||
Object.defineProperty(exports, "__esModule", { |
|
||||
value: true |
|
||||
}); |
|
||||
exports.default = removePropertiesDeep; |
|
||||
|
|
||||
var _traverseFast = _interopRequireDefault(require("../traverse/traverseFast")); |
|
||||
|
|
||||
var _removeProperties = _interopRequireDefault(require("./removeProperties")); |
|
||||
|
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
|
||||
|
|
||||
function removePropertiesDeep(tree, opts) { |
|
||||
(0, _traverseFast.default)(tree, _removeProperties.default, opts); |
|
||||
return tree; |
|
||||
} |
|
||||
@ -1,103 +0,0 @@ |
|||||
"use strict"; |
|
||||
|
|
||||
Object.defineProperty(exports, "__esModule", { |
|
||||
value: true |
|
||||
}); |
|
||||
exports.default = getBindingIdentifiers; |
|
||||
|
|
||||
var _generated = require("../validators/generated"); |
|
||||
|
|
||||
function getBindingIdentifiers(node, duplicates, outerOnly) { |
|
||||
let search = [].concat(node); |
|
||||
const ids = Object.create(null); |
|
||||
|
|
||||
while (search.length) { |
|
||||
const id = search.shift(); |
|
||||
if (!id) continue; |
|
||||
const keys = getBindingIdentifiers.keys[id.type]; |
|
||||
|
|
||||
if ((0, _generated.isIdentifier)(id)) { |
|
||||
if (duplicates) { |
|
||||
const _ids = ids[id.name] = ids[id.name] || []; |
|
||||
|
|
||||
_ids.push(id); |
|
||||
} else { |
|
||||
ids[id.name] = id; |
|
||||
} |
|
||||
|
|
||||
continue; |
|
||||
} |
|
||||
|
|
||||
if ((0, _generated.isExportDeclaration)(id)) { |
|
||||
if ((0, _generated.isDeclaration)(id.declaration)) { |
|
||||
search.push(id.declaration); |
|
||||
} |
|
||||
|
|
||||
continue; |
|
||||
} |
|
||||
|
|
||||
if (outerOnly) { |
|
||||
if ((0, _generated.isFunctionDeclaration)(id)) { |
|
||||
search.push(id.id); |
|
||||
continue; |
|
||||
} |
|
||||
|
|
||||
if ((0, _generated.isFunctionExpression)(id)) { |
|
||||
continue; |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
if (keys) { |
|
||||
for (let i = 0; i < keys.length; i++) { |
|
||||
const key = keys[i]; |
|
||||
|
|
||||
if (id[key]) { |
|
||||
search = search.concat(id[key]); |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
return ids; |
|
||||
} |
|
||||
|
|
||||
getBindingIdentifiers.keys = { |
|
||||
DeclareClass: ["id"], |
|
||||
DeclareFunction: ["id"], |
|
||||
DeclareModule: ["id"], |
|
||||
DeclareVariable: ["id"], |
|
||||
DeclareInterface: ["id"], |
|
||||
DeclareTypeAlias: ["id"], |
|
||||
DeclareOpaqueType: ["id"], |
|
||||
InterfaceDeclaration: ["id"], |
|
||||
TypeAlias: ["id"], |
|
||||
OpaqueType: ["id"], |
|
||||
CatchClause: ["param"], |
|
||||
LabeledStatement: ["label"], |
|
||||
UnaryExpression: ["argument"], |
|
||||
AssignmentExpression: ["left"], |
|
||||
ImportSpecifier: ["local"], |
|
||||
ImportNamespaceSpecifier: ["local"], |
|
||||
ImportDefaultSpecifier: ["local"], |
|
||||
ImportDeclaration: ["specifiers"], |
|
||||
ExportSpecifier: ["exported"], |
|
||||
ExportNamespaceSpecifier: ["exported"], |
|
||||
ExportDefaultSpecifier: ["exported"], |
|
||||
FunctionDeclaration: ["id", "params"], |
|
||||
FunctionExpression: ["id", "params"], |
|
||||
ArrowFunctionExpression: ["params"], |
|
||||
ObjectMethod: ["params"], |
|
||||
ClassMethod: ["params"], |
|
||||
ForInStatement: ["left"], |
|
||||
ForOfStatement: ["left"], |
|
||||
ClassDeclaration: ["id"], |
|
||||
ClassExpression: ["id"], |
|
||||
RestElement: ["argument"], |
|
||||
UpdateExpression: ["argument"], |
|
||||
ObjectProperty: ["value"], |
|
||||
AssignmentPattern: ["left"], |
|
||||
ArrayPattern: ["elements"], |
|
||||
ObjectPattern: ["properties"], |
|
||||
VariableDeclaration: ["declarations"], |
|
||||
VariableDeclarator: ["id"] |
|
||||
}; |
|
||||
@ -1,14 +0,0 @@ |
|||||
"use strict"; |
|
||||
|
|
||||
Object.defineProperty(exports, "__esModule", { |
|
||||
value: true |
|
||||
}); |
|
||||
exports.default = getOuterBindingIdentifiers; |
|
||||
|
|
||||
var _getBindingIdentifiers = _interopRequireDefault(require("./getBindingIdentifiers")); |
|
||||
|
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
|
||||
|
|
||||
function getOuterBindingIdentifiers(node, duplicates) { |
|
||||
return (0, _getBindingIdentifiers.default)(node, duplicates, true); |
|
||||
} |
|
||||
@ -1,55 +0,0 @@ |
|||||
"use strict"; |
|
||||
|
|
||||
Object.defineProperty(exports, "__esModule", { |
|
||||
value: true |
|
||||
}); |
|
||||
exports.default = traverse; |
|
||||
|
|
||||
var _definitions = require("../definitions"); |
|
||||
|
|
||||
function traverse(node, handlers, state) { |
|
||||
if (typeof handlers === "function") { |
|
||||
handlers = { |
|
||||
enter: handlers |
|
||||
}; |
|
||||
} |
|
||||
|
|
||||
const { |
|
||||
enter, |
|
||||
exit |
|
||||
} = handlers; |
|
||||
traverseSimpleImpl(node, enter, exit, state, []); |
|
||||
} |
|
||||
|
|
||||
function traverseSimpleImpl(node, enter, exit, state, ancestors) { |
|
||||
const keys = _definitions.VISITOR_KEYS[node.type]; |
|
||||
if (!keys) return; |
|
||||
if (enter) enter(node, ancestors, state); |
|
||||
|
|
||||
for (const key of keys) { |
|
||||
const subNode = node[key]; |
|
||||
|
|
||||
if (Array.isArray(subNode)) { |
|
||||
for (let i = 0; i < subNode.length; i++) { |
|
||||
const child = subNode[i]; |
|
||||
if (!child) continue; |
|
||||
ancestors.push({ |
|
||||
node, |
|
||||
key, |
|
||||
index: i |
|
||||
}); |
|
||||
traverseSimpleImpl(child, enter, exit, state, ancestors); |
|
||||
ancestors.pop(); |
|
||||
} |
|
||||
} else if (subNode) { |
|
||||
ancestors.push({ |
|
||||
node, |
|
||||
key |
|
||||
}); |
|
||||
traverseSimpleImpl(subNode, enter, exit, state, ancestors); |
|
||||
ancestors.pop(); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
if (exit) exit(node, ancestors, state); |
|
||||
} |
|
||||
@ -1,28 +0,0 @@ |
|||||
"use strict"; |
|
||||
|
|
||||
Object.defineProperty(exports, "__esModule", { |
|
||||
value: true |
|
||||
}); |
|
||||
exports.default = traverseFast; |
|
||||
|
|
||||
var _definitions = require("../definitions"); |
|
||||
|
|
||||
function traverseFast(node, enter, opts) { |
|
||||
if (!node) return; |
|
||||
const keys = _definitions.VISITOR_KEYS[node.type]; |
|
||||
if (!keys) return; |
|
||||
opts = opts || {}; |
|
||||
enter(node, opts); |
|
||||
|
|
||||
for (const key of keys) { |
|
||||
const subNode = node[key]; |
|
||||
|
|
||||
if (Array.isArray(subNode)) { |
|
||||
for (const node of subNode) { |
|
||||
traverseFast(node, enter, opts); |
|
||||
} |
|
||||
} else { |
|
||||
traverseFast(subNode, enter, opts); |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,16 +0,0 @@ |
|||||
"use strict"; |
|
||||
|
|
||||
Object.defineProperty(exports, "__esModule", { |
|
||||
value: true |
|
||||
}); |
|
||||
exports.default = inherit; |
|
||||
|
|
||||
var _uniq = _interopRequireDefault(require("lodash/uniq")); |
|
||||
|
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
|
||||
|
|
||||
function inherit(key, child, parent) { |
|
||||
if (child && parent) { |
|
||||
child[key] = (0, _uniq.default)([].concat(child[key], parent[key]).filter(Boolean)); |
|
||||
} |
|
||||
} |
|
||||
@ -1,47 +0,0 @@ |
|||||
"use strict"; |
|
||||
|
|
||||
Object.defineProperty(exports, "__esModule", { |
|
||||
value: true |
|
||||
}); |
|
||||
exports.default = cleanJSXElementLiteralChild; |
|
||||
|
|
||||
var _generated = require("../../builders/generated"); |
|
||||
|
|
||||
function cleanJSXElementLiteralChild(child, args) { |
|
||||
const lines = child.value.split(/\r\n|\n|\r/); |
|
||||
let lastNonEmptyLine = 0; |
|
||||
|
|
||||
for (let i = 0; i < lines.length; i++) { |
|
||||
if (lines[i].match(/[^ \t]/)) { |
|
||||
lastNonEmptyLine = i; |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
let str = ""; |
|
||||
|
|
||||
for (let i = 0; i < lines.length; i++) { |
|
||||
const line = lines[i]; |
|
||||
const isFirstLine = i === 0; |
|
||||
const isLastLine = i === lines.length - 1; |
|
||||
const isLastNonEmptyLine = i === lastNonEmptyLine; |
|
||||
let trimmedLine = line.replace(/\t/g, " "); |
|
||||
|
|
||||
if (!isFirstLine) { |
|
||||
trimmedLine = trimmedLine.replace(/^[ ]+/, ""); |
|
||||
} |
|
||||
|
|
||||
if (!isLastLine) { |
|
||||
trimmedLine = trimmedLine.replace(/[ ]+$/, ""); |
|
||||
} |
|
||||
|
|
||||
if (trimmedLine) { |
|
||||
if (!isLastNonEmptyLine) { |
|
||||
trimmedLine += " "; |
|
||||
} |
|
||||
|
|
||||
str += trimmedLine; |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
if (str) args.push((0, _generated.stringLiteral)(str)); |
|
||||
} |
|
||||
@ -1,18 +0,0 @@ |
|||||
"use strict"; |
|
||||
|
|
||||
Object.defineProperty(exports, "__esModule", { |
|
||||
value: true |
|
||||
}); |
|
||||
exports.default = shallowEqual; |
|
||||
|
|
||||
function shallowEqual(actual, expected) { |
|
||||
const keys = Object.keys(expected); |
|
||||
|
|
||||
for (const key of keys) { |
|
||||
if (actual[key] !== expected[key]) { |
|
||||
return false; |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
return true; |
|
||||
} |
|
||||
@ -1,15 +0,0 @@ |
|||||
"use strict"; |
|
||||
|
|
||||
Object.defineProperty(exports, "__esModule", { |
|
||||
value: true |
|
||||
}); |
|
||||
exports.default = buildMatchMemberExpression; |
|
||||
|
|
||||
var _matchesPattern = _interopRequireDefault(require("./matchesPattern")); |
|
||||
|
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
|
||||
|
|
||||
function buildMatchMemberExpression(match, allowPartial) { |
|
||||
const parts = match.split("."); |
|
||||
return member => (0, _matchesPattern.default)(member, parts, allowPartial); |
|
||||
} |
|
||||
File diff suppressed because it is too large
@ -1,35 +0,0 @@ |
|||||
"use strict"; |
|
||||
|
|
||||
Object.defineProperty(exports, "__esModule", { |
|
||||
value: true |
|
||||
}); |
|
||||
exports.default = is; |
|
||||
|
|
||||
var _shallowEqual = _interopRequireDefault(require("../utils/shallowEqual")); |
|
||||
|
|
||||
var _isType = _interopRequireDefault(require("./isType")); |
|
||||
|
|
||||
var _isPlaceholderType = _interopRequireDefault(require("./isPlaceholderType")); |
|
||||
|
|
||||
var _definitions = require("../definitions"); |
|
||||
|
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
|
||||
|
|
||||
function is(type, node, opts) { |
|
||||
if (!node) return false; |
|
||||
const matches = (0, _isType.default)(node.type, type); |
|
||||
|
|
||||
if (!matches) { |
|
||||
if (!opts && node.type === "Placeholder" && type in _definitions.FLIPPED_ALIAS_KEYS) { |
|
||||
return (0, _isPlaceholderType.default)(node.expectedNode, type); |
|
||||
} |
|
||||
|
|
||||
return false; |
|
||||
} |
|
||||
|
|
||||
if (typeof opts === "undefined") { |
|
||||
return true; |
|
||||
} else { |
|
||||
return (0, _shallowEqual.default)(node, opts); |
|
||||
} |
|
||||
} |
|
||||
@ -1,33 +0,0 @@ |
|||||
"use strict"; |
|
||||
|
|
||||
Object.defineProperty(exports, "__esModule", { |
|
||||
value: true |
|
||||
}); |
|
||||
exports.default = isBinding; |
|
||||
|
|
||||
var _getBindingIdentifiers = _interopRequireDefault(require("../retrievers/getBindingIdentifiers")); |
|
||||
|
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
|
||||
|
|
||||
function isBinding(node, parent, grandparent) { |
|
||||
if (grandparent && node.type === "Identifier" && parent.type === "ObjectProperty" && grandparent.type === "ObjectExpression") { |
|
||||
return false; |
|
||||
} |
|
||||
|
|
||||
const keys = _getBindingIdentifiers.default.keys[parent.type]; |
|
||||
|
|
||||
if (keys) { |
|
||||
for (let i = 0; i < keys.length; i++) { |
|
||||
const key = keys[i]; |
|
||||
const val = parent[key]; |
|
||||
|
|
||||
if (Array.isArray(val)) { |
|
||||
if (val.indexOf(node) >= 0) return true; |
|
||||
} else { |
|
||||
if (val === node) return true; |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
return false; |
|
||||
} |
|
||||
@ -1,16 +0,0 @@ |
|||||
"use strict"; |
|
||||
|
|
||||
Object.defineProperty(exports, "__esModule", { |
|
||||
value: true |
|
||||
}); |
|
||||
exports.default = isBlockScoped; |
|
||||
|
|
||||
var _generated = require("./generated"); |
|
||||
|
|
||||
var _isLet = _interopRequireDefault(require("./isLet")); |
|
||||
|
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
|
||||
|
|
||||
function isBlockScoped(node) { |
|
||||
return (0, _generated.isFunctionDeclaration)(node) || (0, _generated.isClassDeclaration)(node) || (0, _isLet.default)(node); |
|
||||
} |
|
||||
@ -1,26 +0,0 @@ |
|||||
"use strict"; |
|
||||
|
|
||||
Object.defineProperty(exports, "__esModule", { |
|
||||
value: true |
|
||||
}); |
|
||||
exports.default = isImmutable; |
|
||||
|
|
||||
var _isType = _interopRequireDefault(require("./isType")); |
|
||||
|
|
||||
var _generated = require("./generated"); |
|
||||
|
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
|
||||
|
|
||||
function isImmutable(node) { |
|
||||
if ((0, _isType.default)(node.type, "Immutable")) return true; |
|
||||
|
|
||||
if ((0, _generated.isIdentifier)(node)) { |
|
||||
if (node.name === "undefined") { |
|
||||
return true; |
|
||||
} else { |
|
||||
return false; |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
return false; |
|
||||
} |
|
||||
@ -1,14 +0,0 @@ |
|||||
"use strict"; |
|
||||
|
|
||||
Object.defineProperty(exports, "__esModule", { |
|
||||
value: true |
|
||||
}); |
|
||||
exports.default = isLet; |
|
||||
|
|
||||
var _generated = require("./generated"); |
|
||||
|
|
||||
var _constants = require("../constants"); |
|
||||
|
|
||||
function isLet(node) { |
|
||||
return (0, _generated.isVariableDeclaration)(node) && (node.kind !== "var" || node[_constants.BLOCK_SCOPED_SYMBOL]); |
|
||||
} |
|
||||
@ -1,12 +0,0 @@ |
|||||
"use strict"; |
|
||||
|
|
||||
Object.defineProperty(exports, "__esModule", { |
|
||||
value: true |
|
||||
}); |
|
||||
exports.default = isNode; |
|
||||
|
|
||||
var _definitions = require("../definitions"); |
|
||||
|
|
||||
function isNode(node) { |
|
||||
return !!(node && _definitions.VISITOR_KEYS[node.type]); |
|
||||
} |
|
||||
@ -1,67 +0,0 @@ |
|||||
"use strict"; |
|
||||
|
|
||||
Object.defineProperty(exports, "__esModule", { |
|
||||
value: true |
|
||||
}); |
|
||||
exports.default = isNodesEquivalent; |
|
||||
|
|
||||
var _definitions = require("../definitions"); |
|
||||
|
|
||||
function isNodesEquivalent(a, b) { |
|
||||
if (typeof a !== "object" || typeof b !== "object" || a == null || b == null) { |
|
||||
return a === b; |
|
||||
} |
|
||||
|
|
||||
if (a.type !== b.type) { |
|
||||
return false; |
|
||||
} |
|
||||
|
|
||||
const fields = Object.keys(_definitions.NODE_FIELDS[a.type] || a.type); |
|
||||
const visitorKeys = _definitions.VISITOR_KEYS[a.type]; |
|
||||
|
|
||||
for (const field of fields) { |
|
||||
if (typeof a[field] !== typeof b[field]) { |
|
||||
return false; |
|
||||
} |
|
||||
|
|
||||
if (a[field] == null && b[field] == null) { |
|
||||
continue; |
|
||||
} else if (a[field] == null || b[field] == null) { |
|
||||
return false; |
|
||||
} |
|
||||
|
|
||||
if (Array.isArray(a[field])) { |
|
||||
if (!Array.isArray(b[field])) { |
|
||||
return false; |
|
||||
} |
|
||||
|
|
||||
if (a[field].length !== b[field].length) { |
|
||||
return false; |
|
||||
} |
|
||||
|
|
||||
for (let i = 0; i < a[field].length; i++) { |
|
||||
if (!isNodesEquivalent(a[field][i], b[field][i])) { |
|
||||
return false; |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
continue; |
|
||||
} |
|
||||
|
|
||||
if (typeof a[field] === "object" && (!visitorKeys || !visitorKeys.includes(field))) { |
|
||||
for (const key of Object.keys(a[field])) { |
|
||||
if (a[field][key] !== b[field][key]) { |
|
||||
return false; |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
continue; |
|
||||
} |
|
||||
|
|
||||
if (!isNodesEquivalent(a[field], b[field])) { |
|
||||
return false; |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
return true; |
|
||||
} |
|
||||
@ -1,21 +0,0 @@ |
|||||
"use strict"; |
|
||||
|
|
||||
Object.defineProperty(exports, "__esModule", { |
|
||||
value: true |
|
||||
}); |
|
||||
exports.default = isPlaceholderType; |
|
||||
|
|
||||
var _definitions = require("../definitions"); |
|
||||
|
|
||||
function isPlaceholderType(placeholderType, targetType) { |
|
||||
if (placeholderType === targetType) return true; |
|
||||
const aliases = _definitions.PLACEHOLDERS_ALIAS[placeholderType]; |
|
||||
|
|
||||
if (aliases) { |
|
||||
for (const alias of aliases) { |
|
||||
if (targetType === alias) return true; |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
return false; |
|
||||
} |
|
||||
@ -1,116 +0,0 @@ |
|||||
"use strict"; |
|
||||
|
|
||||
Object.defineProperty(exports, "__esModule", { |
|
||||
value: true |
|
||||
}); |
|
||||
exports.default = isReferenced; |
|
||||
|
|
||||
function isReferenced(node, parent, grandparent) { |
|
||||
switch (parent.type) { |
|
||||
case "MemberExpression": |
|
||||
case "JSXMemberExpression": |
|
||||
case "OptionalMemberExpression": |
|
||||
if (parent.property === node) { |
|
||||
return !!parent.computed; |
|
||||
} |
|
||||
|
|
||||
return parent.object === node; |
|
||||
|
|
||||
case "VariableDeclarator": |
|
||||
return parent.init === node; |
|
||||
|
|
||||
case "ArrowFunctionExpression": |
|
||||
return parent.body === node; |
|
||||
|
|
||||
case "ExportSpecifier": |
|
||||
if (parent.source) { |
|
||||
return false; |
|
||||
} |
|
||||
|
|
||||
return parent.local === node; |
|
||||
|
|
||||
case "PrivateName": |
|
||||
return false; |
|
||||
|
|
||||
case "ClassMethod": |
|
||||
case "ClassPrivateMethod": |
|
||||
case "ObjectMethod": |
|
||||
if (parent.params.includes(node)) { |
|
||||
return false; |
|
||||
} |
|
||||
|
|
||||
case "ObjectProperty": |
|
||||
case "ClassProperty": |
|
||||
case "ClassPrivateProperty": |
|
||||
if (parent.key === node) { |
|
||||
return !!parent.computed; |
|
||||
} |
|
||||
|
|
||||
if (parent.value === node) { |
|
||||
return !grandparent || grandparent.type !== "ObjectPattern"; |
|
||||
} |
|
||||
|
|
||||
return true; |
|
||||
|
|
||||
case "ClassDeclaration": |
|
||||
case "ClassExpression": |
|
||||
return parent.superClass === node; |
|
||||
|
|
||||
case "AssignmentExpression": |
|
||||
return parent.right === node; |
|
||||
|
|
||||
case "AssignmentPattern": |
|
||||
return parent.right === node; |
|
||||
|
|
||||
case "LabeledStatement": |
|
||||
return false; |
|
||||
|
|
||||
case "CatchClause": |
|
||||
return false; |
|
||||
|
|
||||
case "RestElement": |
|
||||
return false; |
|
||||
|
|
||||
case "BreakStatement": |
|
||||
case "ContinueStatement": |
|
||||
return false; |
|
||||
|
|
||||
case "FunctionDeclaration": |
|
||||
case "FunctionExpression": |
|
||||
return false; |
|
||||
|
|
||||
case "ExportNamespaceSpecifier": |
|
||||
case "ExportDefaultSpecifier": |
|
||||
return false; |
|
||||
|
|
||||
case "ImportDefaultSpecifier": |
|
||||
case "ImportNamespaceSpecifier": |
|
||||
case "ImportSpecifier": |
|
||||
return false; |
|
||||
|
|
||||
case "JSXAttribute": |
|
||||
return false; |
|
||||
|
|
||||
case "ObjectPattern": |
|
||||
case "ArrayPattern": |
|
||||
return false; |
|
||||
|
|
||||
case "MetaProperty": |
|
||||
return false; |
|
||||
|
|
||||
case "ObjectTypeProperty": |
|
||||
return parent.key !== node; |
|
||||
|
|
||||
case "TSEnumMember": |
|
||||
return parent.id !== node; |
|
||||
|
|
||||
case "TSPropertySignature": |
|
||||
if (parent.key === node) { |
|
||||
return !!parent.computed; |
|
||||
} |
|
||||
|
|
||||
return true; |
|
||||
} |
|
||||
|
|
||||
return true; |
|
||||
} |
|
||||
@ -1,28 +0,0 @@ |
|||||
"use strict"; |
|
||||
|
|
||||
Object.defineProperty(exports, "__esModule", { |
|
||||
value: true |
|
||||
}); |
|
||||
exports.default = isScope; |
|
||||
|
|
||||
var _generated = require("./generated"); |
|
||||
|
|
||||
function isScope(node, parent) { |
|
||||
if ((0, _generated.isBlockStatement)(node) && (0, _generated.isFunction)(parent, { |
|
||||
body: node |
|
||||
})) { |
|
||||
return false; |
|
||||
} |
|
||||
|
|
||||
if ((0, _generated.isBlockStatement)(node) && (0, _generated.isCatchClause)(parent, { |
|
||||
body: node |
|
||||
})) { |
|
||||
return false; |
|
||||
} |
|
||||
|
|
||||
if ((0, _generated.isPattern)(node) && (0, _generated.isFunction)(parent)) { |
|
||||
return true; |
|
||||
} |
|
||||
|
|
||||
return (0, _generated.isScopable)(node); |
|
||||
} |
|
||||
@ -1,14 +0,0 @@ |
|||||
"use strict"; |
|
||||
|
|
||||
Object.defineProperty(exports, "__esModule", { |
|
||||
value: true |
|
||||
}); |
|
||||
exports.default = isSpecifierDefault; |
|
||||
|
|
||||
var _generated = require("./generated"); |
|
||||
|
|
||||
function isSpecifierDefault(specifier) { |
|
||||
return (0, _generated.isImportDefaultSpecifier)(specifier) || (0, _generated.isIdentifier)(specifier.imported || specifier.exported, { |
|
||||
name: "default" |
|
||||
}); |
|
||||
} |
|
||||
@ -1,24 +0,0 @@ |
|||||
"use strict"; |
|
||||
|
|
||||
Object.defineProperty(exports, "__esModule", { |
|
||||
value: true |
|
||||
}); |
|
||||
exports.default = isType; |
|
||||
|
|
||||
var _definitions = require("../definitions"); |
|
||||
|
|
||||
function isType(nodeType, targetType) { |
|
||||
if (nodeType === targetType) return true; |
|
||||
if (_definitions.ALIAS_KEYS[targetType]) return false; |
|
||||
const aliases = _definitions.FLIPPED_ALIAS_KEYS[targetType]; |
|
||||
|
|
||||
if (aliases) { |
|
||||
if (aliases[0] === nodeType) return true; |
|
||||
|
|
||||
for (const alias of aliases) { |
|
||||
if (nodeType === alias) return true; |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
return false; |
|
||||
} |
|
||||
@ -1,16 +0,0 @@ |
|||||
"use strict"; |
|
||||
|
|
||||
Object.defineProperty(exports, "__esModule", { |
|
||||
value: true |
|
||||
}); |
|
||||
exports.default = isValidES3Identifier; |
|
||||
|
|
||||
var _isValidIdentifier = _interopRequireDefault(require("./isValidIdentifier")); |
|
||||
|
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
|
||||
|
|
||||
const RESERVED_WORDS_ES3_ONLY = new Set(["abstract", "boolean", "byte", "char", "double", "enum", "final", "float", "goto", "implements", "int", "interface", "long", "native", "package", "private", "protected", "public", "short", "static", "synchronized", "throws", "transient", "volatile"]); |
|
||||
|
|
||||
function isValidES3Identifier(name) { |
|
||||
return (0, _isValidIdentifier.default)(name) && !RESERVED_WORDS_ES3_ONLY.has(name); |
|
||||
} |
|
||||
@ -1,22 +0,0 @@ |
|||||
"use strict"; |
|
||||
|
|
||||
Object.defineProperty(exports, "__esModule", { |
|
||||
value: true |
|
||||
}); |
|
||||
exports.default = isValidIdentifier; |
|
||||
|
|
||||
var _helperValidatorIdentifier = require("@babel/helper-validator-identifier"); |
|
||||
|
|
||||
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") { |
|
||||
return false; |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
return (0, _helperValidatorIdentifier.isIdentifierName)(name); |
|
||||
} |
|
||||
@ -1,16 +0,0 @@ |
|||||
"use strict"; |
|
||||
|
|
||||
Object.defineProperty(exports, "__esModule", { |
|
||||
value: true |
|
||||
}); |
|
||||
exports.default = isVar; |
|
||||
|
|
||||
var _generated = require("./generated"); |
|
||||
|
|
||||
var _constants = require("../constants"); |
|
||||
|
|
||||
function isVar(node) { |
|
||||
return (0, _generated.isVariableDeclaration)(node, { |
|
||||
kind: "var" |
|
||||
}) && !node[_constants.BLOCK_SCOPED_SYMBOL]; |
|
||||
} |
|
||||
@ -1,40 +0,0 @@ |
|||||
"use strict"; |
|
||||
|
|
||||
Object.defineProperty(exports, "__esModule", { |
|
||||
value: true |
|
||||
}); |
|
||||
exports.default = matchesPattern; |
|
||||
|
|
||||
var _generated = require("./generated"); |
|
||||
|
|
||||
function matchesPattern(member, match, allowPartial) { |
|
||||
if (!(0, _generated.isMemberExpression)(member)) return false; |
|
||||
const parts = Array.isArray(match) ? match : match.split("."); |
|
||||
const nodes = []; |
|
||||
let node; |
|
||||
|
|
||||
for (node = member; (0, _generated.isMemberExpression)(node); node = node.object) { |
|
||||
nodes.push(node.property); |
|
||||
} |
|
||||
|
|
||||
nodes.push(node); |
|
||||
if (nodes.length < parts.length) return false; |
|
||||
if (!allowPartial && nodes.length > parts.length) return false; |
|
||||
|
|
||||
for (let i = 0, j = nodes.length - 1; i < parts.length; i++, j--) { |
|
||||
const node = nodes[j]; |
|
||||
let value; |
|
||||
|
|
||||
if ((0, _generated.isIdentifier)(node)) { |
|
||||
value = node.name; |
|
||||
} else if ((0, _generated.isStringLiteral)(node)) { |
|
||||
value = node.value; |
|
||||
} else { |
|
||||
return false; |
|
||||
} |
|
||||
|
|
||||
if (parts[i] !== value) return false; |
|
||||
} |
|
||||
|
|
||||
return true; |
|
||||
} |
|
||||
@ -1,10 +0,0 @@ |
|||||
"use strict"; |
|
||||
|
|
||||
Object.defineProperty(exports, "__esModule", { |
|
||||
value: true |
|
||||
}); |
|
||||
exports.default = isCompatTag; |
|
||||
|
|
||||
function isCompatTag(tagName) { |
|
||||
return !!tagName && /^[a-z]/.test(tagName); |
|
||||
} |
|
||||
@ -1,14 +0,0 @@ |
|||||
"use strict"; |
|
||||
|
|
||||
Object.defineProperty(exports, "__esModule", { |
|
||||
value: true |
|
||||
}); |
|
||||
exports.default = void 0; |
|
||||
|
|
||||
var _buildMatchMemberExpression = _interopRequireDefault(require("../buildMatchMemberExpression")); |
|
||||
|
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
|
||||
|
|
||||
const isReactComponent = (0, _buildMatchMemberExpression.default)("React.Component"); |
|
||||
var _default = isReactComponent; |
|
||||
exports.default = _default; |
|
||||
@ -1,32 +0,0 @@ |
|||||
"use strict"; |
|
||||
|
|
||||
Object.defineProperty(exports, "__esModule", { |
|
||||
value: true |
|
||||
}); |
|
||||
exports.default = validate; |
|
||||
exports.validateField = validateField; |
|
||||
exports.validateChild = validateChild; |
|
||||
|
|
||||
var _definitions = require("../definitions"); |
|
||||
|
|
||||
function validate(node, key, val) { |
|
||||
if (!node) return; |
|
||||
const fields = _definitions.NODE_FIELDS[node.type]; |
|
||||
if (!fields) return; |
|
||||
const field = fields[key]; |
|
||||
validateField(node, key, val, field); |
|
||||
validateChild(node, key, val); |
|
||||
} |
|
||||
|
|
||||
function validateField(node, key, val, field) { |
|
||||
if (!field || !field.validate) return; |
|
||||
if (field.optional && val == null) return; |
|
||||
field.validate(node, key, val); |
|
||||
} |
|
||||
|
|
||||
function validateChild(node, key, val) { |
|
||||
if (val == null) return; |
|
||||
const validate = _definitions.NODE_PARENT_VALIDATIONS[val.type]; |
|
||||
if (!validate) return; |
|
||||
validate(node, key, val); |
|
||||
} |
|
||||
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue