Commit a2e8cafb authored by patri's avatar patri
Browse files

Test New PC

parent e65a993d
...@@ -10,25 +10,22 @@ exports.ObjectPattern = exports.ObjectExpression = ObjectExpression; ...@@ -10,25 +10,22 @@ exports.ObjectPattern = exports.ObjectExpression = ObjectExpression;
exports.ObjectMethod = ObjectMethod; exports.ObjectMethod = ObjectMethod;
exports.ObjectProperty = ObjectProperty; exports.ObjectProperty = ObjectProperty;
exports.ArrayPattern = exports.ArrayExpression = ArrayExpression; exports.ArrayPattern = exports.ArrayExpression = ArrayExpression;
exports.RecordExpression = RecordExpression;
exports.TupleExpression = TupleExpression;
exports.RegExpLiteral = RegExpLiteral; exports.RegExpLiteral = RegExpLiteral;
exports.BooleanLiteral = BooleanLiteral; exports.BooleanLiteral = BooleanLiteral;
exports.NullLiteral = NullLiteral; exports.NullLiteral = NullLiteral;
exports.NumericLiteral = NumericLiteral; exports.NumericLiteral = NumericLiteral;
exports.StringLiteral = StringLiteral; exports.StringLiteral = StringLiteral;
exports.BigIntLiteral = BigIntLiteral; exports.BigIntLiteral = BigIntLiteral;
exports.DecimalLiteral = DecimalLiteral;
exports.PipelineTopicExpression = PipelineTopicExpression; exports.PipelineTopicExpression = PipelineTopicExpression;
exports.PipelineBareFunction = PipelineBareFunction; exports.PipelineBareFunction = PipelineBareFunction;
exports.PipelinePrimaryTopicReference = PipelinePrimaryTopicReference; exports.PipelinePrimaryTopicReference = PipelinePrimaryTopicReference;
var t = _interopRequireWildcard(require("@babel/types")); var t = require("@babel/types");
var _jsesc = _interopRequireDefault(require("jsesc")); var _jsesc = require("jsesc");
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; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { 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 Identifier(node) { function Identifier(node) {
this.exactSource(node.loc, () => { this.exactSource(node.loc, () => {
...@@ -117,6 +114,68 @@ function ArrayExpression(node) { ...@@ -117,6 +114,68 @@ function ArrayExpression(node) {
this.token("]"); this.token("]");
} }
function RecordExpression(node) {
const props = node.properties;
let startToken;
let endToken;
if (this.format.recordAndTupleSyntaxType === "bar") {
startToken = "{|";
endToken = "|}";
} else if (this.format.recordAndTupleSyntaxType === "hash") {
startToken = "#{";
endToken = "}";
} else {
throw new Error(`The "recordAndTupleSyntaxType" generator option must be "bar" or "hash" (${JSON.stringify(this.format.recordAndTupleSyntaxType)} received).`);
}
this.token(startToken);
this.printInnerComments(node);
if (props.length) {
this.space();
this.printList(props, node, {
indent: true,
statement: true
});
this.space();
}
this.token(endToken);
}
function TupleExpression(node) {
const elems = node.elements;
const len = elems.length;
let startToken;
let endToken;
if (this.format.recordAndTupleSyntaxType === "bar") {
startToken = "[|";
endToken = "|]";
} else if (this.format.recordAndTupleSyntaxType === "hash") {
startToken = "#[";
endToken = "]";
} else {
throw new Error(`${this.format.recordAndTupleSyntaxType} is not a valid recordAndTuple syntax type`);
}
this.token(startToken);
this.printInnerComments(node);
for (let i = 0; i < elems.length; i++) {
const elem = elems[i];
if (elem) {
if (i > 0) this.space();
this.print(elem, node);
if (i < len - 1) this.token(",");
}
}
this.token(endToken);
}
function RegExpLiteral(node) { function RegExpLiteral(node) {
this.word(`/${node.pattern}/${node.flags}`); this.word(`/${node.pattern}/${node.flags}`);
} }
...@@ -131,9 +190,12 @@ function NullLiteral() { ...@@ -131,9 +190,12 @@ function NullLiteral() {
function NumericLiteral(node) { function NumericLiteral(node) {
const raw = this.getPossibleRaw(node); const raw = this.getPossibleRaw(node);
const opts = this.format.jsescOption;
const value = node.value + ""; const value = node.value + "";
if (raw == null) { if (opts.numbers) {
this.number(_jsesc(node.value, opts));
} else if (raw == null) {
this.number(value); this.number(value);
} else if (this.format.minified) { } else if (this.format.minified) {
this.number(raw.length < value.length ? raw : value); this.number(raw.length < value.length ? raw : value);
...@@ -150,13 +212,10 @@ function StringLiteral(node) { ...@@ -150,13 +212,10 @@ function StringLiteral(node) {
return; return;
} }
const opts = this.format.jsescOption; const val = _jsesc(node.value, Object.assign(this.format.jsescOption, this.format.jsonCompatibleStrings && {
json: true
if (this.format.jsonCompatibleStrings) { }));
opts.json = true;
}
const val = (0, _jsesc.default)(node.value, opts);
return this.token(val); return this.token(val);
} }
...@@ -164,11 +223,22 @@ function BigIntLiteral(node) { ...@@ -164,11 +223,22 @@ function BigIntLiteral(node) {
const raw = this.getPossibleRaw(node); const raw = this.getPossibleRaw(node);
if (!this.format.minified && raw != null) { if (!this.format.minified && raw != null) {
this.token(raw); this.word(raw);
return;
}
this.word(node.value + "n");
}
function DecimalLiteral(node) {
const raw = this.getPossibleRaw(node);
if (!this.format.minified && raw != null) {
this.word(raw);
return; return;
} }
this.token(node.value); this.word(node.value + "m");
} }
function PipelineTopicExpression(node) { function PipelineTopicExpression(node) {
......
...@@ -28,6 +28,7 @@ exports.TSVoidKeyword = TSVoidKeyword; ...@@ -28,6 +28,7 @@ exports.TSVoidKeyword = TSVoidKeyword;
exports.TSUndefinedKeyword = TSUndefinedKeyword; exports.TSUndefinedKeyword = TSUndefinedKeyword;
exports.TSNullKeyword = TSNullKeyword; exports.TSNullKeyword = TSNullKeyword;
exports.TSNeverKeyword = TSNeverKeyword; exports.TSNeverKeyword = TSNeverKeyword;
exports.TSIntrinsicKeyword = TSIntrinsicKeyword;
exports.TSThisType = TSThisType; exports.TSThisType = TSThisType;
exports.TSFunctionType = TSFunctionType; exports.TSFunctionType = TSFunctionType;
exports.TSConstructorType = TSConstructorType; exports.TSConstructorType = TSConstructorType;
...@@ -42,6 +43,7 @@ exports.TSArrayType = TSArrayType; ...@@ -42,6 +43,7 @@ exports.TSArrayType = TSArrayType;
exports.TSTupleType = TSTupleType; exports.TSTupleType = TSTupleType;
exports.TSOptionalType = TSOptionalType; exports.TSOptionalType = TSOptionalType;
exports.TSRestType = TSRestType; exports.TSRestType = TSRestType;
exports.TSNamedTupleMember = TSNamedTupleMember;
exports.TSUnionType = TSUnionType; exports.TSUnionType = TSUnionType;
exports.TSIntersectionType = TSIntersectionType; exports.TSIntersectionType = TSIntersectionType;
exports.tsPrintUnionOrIntersectionType = tsPrintUnionOrIntersectionType; exports.tsPrintUnionOrIntersectionType = tsPrintUnionOrIntersectionType;
...@@ -71,6 +73,8 @@ exports.TSNamespaceExportDeclaration = TSNamespaceExportDeclaration; ...@@ -71,6 +73,8 @@ exports.TSNamespaceExportDeclaration = TSNamespaceExportDeclaration;
exports.tsPrintSignatureDeclarationBase = tsPrintSignatureDeclarationBase; exports.tsPrintSignatureDeclarationBase = tsPrintSignatureDeclarationBase;
exports.tsPrintClassMemberModifiers = tsPrintClassMemberModifiers; exports.tsPrintClassMemberModifiers = tsPrintClassMemberModifiers;
var t = require("@babel/types");
function TSTypeAnnotation(node) { function TSTypeAnnotation(node) {
this.token(":"); this.token(":");
this.space(); this.space();
...@@ -192,6 +196,15 @@ function tsPrintPropertyOrMethodName(node) { ...@@ -192,6 +196,15 @@ function tsPrintPropertyOrMethodName(node) {
} }
function TSMethodSignature(node) { function TSMethodSignature(node) {
const {
kind
} = node;
if (kind === "set" || kind === "get") {
this.word(kind);
this.space();
}
this.tsPrintPropertyOrMethodName(node); this.tsPrintPropertyOrMethodName(node);
this.tsPrintSignatureDeclarationBase(node); this.tsPrintSignatureDeclarationBase(node);
this.token(";"); this.token(";");
...@@ -199,9 +212,15 @@ function TSMethodSignature(node) { ...@@ -199,9 +212,15 @@ function TSMethodSignature(node) {
function TSIndexSignature(node) { function TSIndexSignature(node) {
const { const {
readonly readonly,
static: isStatic
} = node; } = node;
if (isStatic) {
this.word("static");
this.space();
}
if (readonly) { if (readonly) {
this.word("readonly"); this.word("readonly");
this.space(); this.space();
...@@ -264,6 +283,10 @@ function TSNeverKeyword() { ...@@ -264,6 +283,10 @@ function TSNeverKeyword() {
this.word("never"); this.word("never");
} }
function TSIntrinsicKeyword() {
this.word("intrinsic");
}
function TSThisType() { function TSThisType() {
this.word("this"); this.word("this");
} }
...@@ -273,6 +296,11 @@ function TSFunctionType(node) { ...@@ -273,6 +296,11 @@ function TSFunctionType(node) {
} }
function TSConstructorType(node) { function TSConstructorType(node) {
if (node.abstract) {
this.word("abstract");
this.space();
}
this.word("new"); this.word("new");
this.space(); this.space();
this.tsPrintFunctionOrConstructorType(node); this.tsPrintFunctionOrConstructorType(node);
...@@ -370,6 +398,14 @@ function TSRestType(node) { ...@@ -370,6 +398,14 @@ function TSRestType(node) {
this.print(node.typeAnnotation, node); this.print(node.typeAnnotation, node);
} }
function TSNamedTupleMember(node) {
this.print(node.label, node);
if (node.optional) this.token("?");
this.token(":");
this.space();
this.print(node.elementType, node);
}
function TSUnionType(node) { function TSUnionType(node) {
this.tsPrintUnionOrIntersectionType(node, "|"); this.tsPrintUnionOrIntersectionType(node, "|");
} }
...@@ -418,7 +454,7 @@ function TSParenthesizedType(node) { ...@@ -418,7 +454,7 @@ function TSParenthesizedType(node) {
} }
function TSTypeOperator(node) { function TSTypeOperator(node) {
this.token(node.operator); this.word(node.operator);
this.space(); this.space();
this.print(node.typeAnnotation, node); this.print(node.typeAnnotation, node);
} }
...@@ -432,9 +468,10 @@ function TSIndexedAccessType(node) { ...@@ -432,9 +468,10 @@ function TSIndexedAccessType(node) {
function TSMappedType(node) { function TSMappedType(node) {
const { const {
nameType,
optional,
readonly, readonly,
typeParameter, typeParameter
optional
} = node; } = node;
this.token("{"); this.token("{");
this.space(); this.space();
...@@ -451,6 +488,14 @@ function TSMappedType(node) { ...@@ -451,6 +488,14 @@ function TSMappedType(node) {
this.word("in"); this.word("in");
this.space(); this.space();
this.print(typeParameter.constraint, typeParameter); this.print(typeParameter.constraint, typeParameter);
if (nameType) {
this.space();
this.word("as");
this.space();
this.print(nameType, node);
}
this.token("]"); this.token("]");
if (optional) { if (optional) {
...@@ -499,7 +544,7 @@ function TSInterfaceDeclaration(node) { ...@@ -499,7 +544,7 @@ function TSInterfaceDeclaration(node) {
this.print(id, node); this.print(id, node);
this.print(typeParameters, node); this.print(typeParameters, node);
if (extendz) { if (extendz != null && extendz.length) {
this.space(); this.space();
this.word("extends"); this.word("extends");
this.space(); this.space();
...@@ -746,6 +791,11 @@ function tsPrintClassMemberModifiers(node, isField) { ...@@ -746,6 +791,11 @@ function tsPrintClassMemberModifiers(node, isField) {
this.space(); this.space();
} }
if (node.override) {
this.word("override");
this.space();
}
if (node.abstract) { if (node.abstract) {
this.word("abstract"); this.word("abstract");
this.space(); this.space();
......
...@@ -3,20 +3,19 @@ ...@@ -3,20 +3,19 @@
Object.defineProperty(exports, "__esModule", { Object.defineProperty(exports, "__esModule", {
value: true value: true
}); });
exports.default = _default; exports.default = generate;
exports.CodeGenerator = void 0; exports.CodeGenerator = void 0;
var _sourceMap = _interopRequireDefault(require("./source-map")); var _sourceMap = require("./source-map");
var _printer = _interopRequireDefault(require("./printer")); var _printer = require("./printer");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
class Generator extends _printer.default { class Generator extends _printer.default {
constructor(ast, opts = {}, code) { constructor(ast, opts = {}, code) {
const format = normalizeOptions(code, opts); const format = normalizeOptions(code, opts);
const map = opts.sourceMaps ? new _sourceMap.default(opts, code) : null; const map = opts.sourceMaps ? new _sourceMap.default(opts, code) : null;
super(format, map); super(format, map);
this.ast = void 0;
this.ast = ast; this.ast = ast;
} }
...@@ -37,7 +36,6 @@ function normalizeOptions(code, opts) { ...@@ -37,7 +36,6 @@ function normalizeOptions(code, opts) {
compact: opts.compact, compact: opts.compact,
minified: opts.minified, minified: opts.minified,
concise: opts.concise, concise: opts.concise,
jsonCompatibleStrings: opts.jsonCompatibleStrings,
indent: { indent: {
adjustMultilineComment: true, adjustMultilineComment: true,
style: " ", style: " ",
...@@ -46,9 +44,14 @@ function normalizeOptions(code, opts) { ...@@ -46,9 +44,14 @@ function normalizeOptions(code, opts) {
decoratorsBeforeExport: !!opts.decoratorsBeforeExport, decoratorsBeforeExport: !!opts.decoratorsBeforeExport,
jsescOption: Object.assign({ jsescOption: Object.assign({
quotes: "double", quotes: "double",
wrap: true wrap: true,
}, opts.jsescOption) minimal: false
}, opts.jsescOption),
recordAndTupleSyntaxType: opts.recordAndTupleSyntaxType
}; };
{
format.jsonCompatibleStrings = opts.jsonCompatibleStrings;
}
if (format.minified) { if (format.minified) {
format.compact = true; format.compact = true;
...@@ -75,6 +78,7 @@ function normalizeOptions(code, opts) { ...@@ -75,6 +78,7 @@ function normalizeOptions(code, opts) {
class CodeGenerator { class CodeGenerator {
constructor(ast, opts, code) { constructor(ast, opts, code) {
this._generator = void 0;
this._generator = new Generator(ast, opts, code); this._generator = new Generator(ast, opts, code);
} }
...@@ -86,7 +90,7 @@ class CodeGenerator { ...@@ -86,7 +90,7 @@ class CodeGenerator {
exports.CodeGenerator = CodeGenerator; exports.CodeGenerator = CodeGenerator;
function _default(ast, opts, code) { function generate(ast, opts, code) {
const gen = new Generator(ast, opts, code); const gen = new Generator(ast, opts, code);
return gen.generate(); return gen.generate();
} }
\ No newline at end of file
...@@ -8,15 +8,11 @@ exports.needsWhitespaceBefore = needsWhitespaceBefore; ...@@ -8,15 +8,11 @@ exports.needsWhitespaceBefore = needsWhitespaceBefore;
exports.needsWhitespaceAfter = needsWhitespaceAfter; exports.needsWhitespaceAfter = needsWhitespaceAfter;
exports.needsParens = needsParens; exports.needsParens = needsParens;
var whitespace = _interopRequireWildcard(require("./whitespace")); var whitespace = require("./whitespace");
var parens = _interopRequireWildcard(require("./parentheses")); var parens = require("./parentheses");
var t = _interopRequireWildcard(require("@babel/types")); var t = 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; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { 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 expandAliases(obj) { function expandAliases(obj) {
const newObj = {}; const newObj = {};
...@@ -58,11 +54,7 @@ function isOrHasCallExpression(node) { ...@@ -58,11 +54,7 @@ function isOrHasCallExpression(node) {
return true; return true;
} }
if (t.isMemberExpression(node)) { return t.isMemberExpression(node) && isOrHasCallExpression(node.object);
return isOrHasCallExpression(node.object) || !node.computed && isOrHasCallExpression(node.property);
} else {
return false;
}
} }
function needsWhitespace(node, parent, type) { function needsWhitespace(node, parent, type) {
...@@ -107,6 +99,5 @@ function needsParens(node, parent, printStack) { ...@@ -107,6 +99,5 @@ function needsParens(node, parent, printStack) {
if (isOrHasCallExpression(node)) return true; if (isOrHasCallExpression(node)) return true;
} }
if (t.isLogicalExpression(node) && parent.operator === "??") return true;
return find(expandedParens, node, parent, printStack); return find(expandedParens, node, parent, printStack);
} }
\ No newline at end of file
...@@ -10,9 +10,11 @@ exports.ObjectExpression = ObjectExpression; ...@@ -10,9 +10,11 @@ exports.ObjectExpression = ObjectExpression;
exports.DoExpression = DoExpression; exports.DoExpression = DoExpression;
exports.Binary = Binary; exports.Binary = Binary;
exports.IntersectionTypeAnnotation = exports.UnionTypeAnnotation = UnionTypeAnnotation; exports.IntersectionTypeAnnotation = exports.UnionTypeAnnotation = UnionTypeAnnotation;
exports.OptionalIndexedAccessType = OptionalIndexedAccessType;
exports.TSAsExpression = TSAsExpression; exports.TSAsExpression = TSAsExpression;
exports.TSTypeAssertion = TSTypeAssertion; exports.TSTypeAssertion = TSTypeAssertion;
exports.TSIntersectionType = exports.TSUnionType = TSUnionType; exports.TSIntersectionType = exports.TSUnionType = TSUnionType;
exports.TSInferType = TSInferType;
exports.BinaryExpression = BinaryExpression; exports.BinaryExpression = BinaryExpression;
exports.SequenceExpression = SequenceExpression; exports.SequenceExpression = SequenceExpression;
exports.AwaitExpression = exports.YieldExpression = YieldExpression; exports.AwaitExpression = exports.YieldExpression = YieldExpression;
...@@ -21,18 +23,16 @@ exports.UnaryLike = UnaryLike; ...@@ -21,18 +23,16 @@ exports.UnaryLike = UnaryLike;
exports.FunctionExpression = FunctionExpression; exports.FunctionExpression = FunctionExpression;
exports.ArrowFunctionExpression = ArrowFunctionExpression; exports.ArrowFunctionExpression = ArrowFunctionExpression;
exports.ConditionalExpression = ConditionalExpression; exports.ConditionalExpression = ConditionalExpression;
exports.OptionalMemberExpression = OptionalMemberExpression; exports.OptionalCallExpression = exports.OptionalMemberExpression = OptionalMemberExpression;
exports.AssignmentExpression = AssignmentExpression; exports.AssignmentExpression = AssignmentExpression;
exports.NewExpression = NewExpression; exports.LogicalExpression = LogicalExpression;
exports.Identifier = Identifier;
var t = _interopRequireWildcard(require("@babel/types")); var t = 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; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { 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 PRECEDENCE = { const PRECEDENCE = {
"||": 0, "||": 0,
"??": 0,
"&&": 1, "&&": 1,
"|": 2, "|": 2,
"^": 3, "^": 3,
...@@ -60,6 +60,8 @@ const PRECEDENCE = { ...@@ -60,6 +60,8 @@ const PRECEDENCE = {
const isClassExtendsClause = (node, parent) => (t.isClassDeclaration(parent) || t.isClassExpression(parent)) && parent.superClass === node; const isClassExtendsClause = (node, parent) => (t.isClassDeclaration(parent) || t.isClassExpression(parent)) && parent.superClass === node;
const hasPostfixPart = (node, parent) => (t.isMemberExpression(parent) || t.isOptionalMemberExpression(parent)) && parent.object === node || (t.isCallExpression(parent) || t.isOptionalCallExpression(parent) || t.isNewExpression(parent)) && parent.callee === node || t.isTaggedTemplateExpression(parent) && parent.tag === node || t.isTSNonNullExpression(parent);
function NullableTypeAnnotation(node, parent) { function NullableTypeAnnotation(node, parent) {
return t.isArrayTypeAnnotation(parent); return t.isArrayTypeAnnotation(parent);
} }
...@@ -69,23 +71,20 @@ function FunctionTypeAnnotation(node, parent, printStack) { ...@@ -69,23 +71,20 @@ function FunctionTypeAnnotation(node, parent, printStack) {
} }
function UpdateExpression(node, parent) { function UpdateExpression(node, parent) {
return t.isMemberExpression(parent, { return hasPostfixPart(node, parent) || isClassExtendsClause(node, parent);
object: node
}) || t.isCallExpression(parent, {
callee: node
}) || t.isNewExpression(parent, {
callee: node
}) || isClassExtendsClause(node, parent);
} }
function ObjectExpression(node, parent, printStack) { function ObjectExpression(node, parent, printStack) {
return isFirstInStatement(printStack, { return isFirstInContext(printStack, {
considerArrow: true expressionStatement: true,
arrowBody: true
}); });
} }
function DoExpression(node, parent, printStack) { function DoExpression(node, parent, printStack) {
return isFirstInStatement(printStack); return !node.async && isFirstInContext(printStack, {
expressionStatement: true
});
} }
function Binary(node, parent) { function Binary(node, parent) {
...@@ -99,7 +98,7 @@ function Binary(node, parent) { ...@@ -99,7 +98,7 @@ function Binary(node, parent) {
return true; return true;
} }
if ((t.isCallExpression(parent) || t.isNewExpression(parent)) && parent.callee === node || t.isUnaryLike(parent) || t.isMemberExpression(parent) && parent.object === node || t.isAwaitExpression(parent)) { if (hasPostfixPart(node, parent) || t.isUnaryLike(parent) || t.isAwaitExpression(parent)) {
return true; return true;
} }
...@@ -113,14 +112,18 @@ function Binary(node, parent) { ...@@ -113,14 +112,18 @@ function Binary(node, parent) {
return true; return true;
} }
} }
return false;
} }
function UnionTypeAnnotation(node, parent) { function UnionTypeAnnotation(node, parent) {
return t.isArrayTypeAnnotation(parent) || t.isNullableTypeAnnotation(parent) || t.isIntersectionTypeAnnotation(parent) || t.isUnionTypeAnnotation(parent); return t.isArrayTypeAnnotation(parent) || t.isNullableTypeAnnotation(parent) || t.isIntersectionTypeAnnotation(parent) || t.isUnionTypeAnnotation(parent);
} }
function OptionalIndexedAccessType(node, parent) {
return t.isIndexedAccessType(parent, {
objectType: node
});
}
function TSAsExpression() { function TSAsExpression() {
return true; return true;
} }
...@@ -133,6 +136,10 @@ function TSUnionType(node, parent) { ...@@ -133,6 +136,10 @@ function TSUnionType(node, parent) {
return t.isTSArrayType(parent) || t.isTSOptionalType(parent) || t.isTSIntersectionType(parent) || t.isTSUnionType(parent) || t.isTSRestType(parent); return t.isTSArrayType(parent) || t.isTSOptionalType(parent) || t.isTSIntersectionType(parent) || t.isTSUnionType(parent) || t.isTSRestType(parent);
} }
function TSInferType(node, parent) {
return t.isTSArrayType(parent) || t.isTSOptionalType(parent);
}
function BinaryExpression(node, parent) { function BinaryExpression(node, parent) {
return node.operator === "in" && (t.isVariableDeclarator(parent) || t.isFor(parent)); return node.operator === "in" && (t.isVariableDeclarator(parent) || t.isFor(parent));
} }
...@@ -146,31 +153,27 @@ function SequenceExpression(node, parent) { ...@@ -146,31 +153,27 @@ function SequenceExpression(node, parent) {
} }
function YieldExpression(node, parent) { function YieldExpression(node, parent) {
return t.isBinary(parent) || t.isUnaryLike(parent) || t.isCallExpression(parent) || t.isMemberExpression(parent) || t.isNewExpression(parent) || t.isAwaitExpression(parent) && t.isYieldExpression(node) || t.isConditionalExpression(parent) && node === parent.test || isClassExtendsClause(node, parent); return t.isBinary(parent) || t.isUnaryLike(parent) || hasPostfixPart(node, parent) || t.isAwaitExpression(parent) && t.isYieldExpression(node) || t.isConditionalExpression(parent) && node === parent.test || isClassExtendsClause(node, parent);
} }
function ClassExpression(node, parent, printStack) { function ClassExpression(node, parent, printStack) {
return isFirstInStatement(printStack, { return isFirstInContext(printStack, {
considerDefaultExports: true expressionStatement: true,
exportDefault: true
}); });
} }
function UnaryLike(node, parent) { function UnaryLike(node, parent) {
return t.isMemberExpression(parent, { return hasPostfixPart(node, parent) || t.isBinaryExpression(parent, {
object: node
}) || t.isCallExpression(parent, {
callee: node
}) || t.isNewExpression(parent, {
callee: node
}) || t.isBinaryExpression(parent, {
operator: "**", operator: "**",
left: node left: node
}) || isClassExtendsClause(node, parent); }) || isClassExtendsClause(node, parent);
} }
function FunctionExpression(node, parent, printStack) { function FunctionExpression(node, parent, printStack) {
return isFirstInStatement(printStack, { return isFirstInContext(printStack, {
considerDefaultExports: true expressionStatement: true,
exportDefault: true
}); });
} }
...@@ -181,7 +184,7 @@ function ArrowFunctionExpression(node, parent) { ...@@ -181,7 +184,7 @@ function ArrowFunctionExpression(node, parent) {
function ConditionalExpression(node, parent) { function ConditionalExpression(node, parent) {
if (t.isUnaryLike(parent) || t.isBinary(parent) || t.isConditionalExpression(parent, { if (t.isUnaryLike(parent) || t.isBinary(parent) || t.isConditionalExpression(parent, {
test: node test: node
}) || t.isAwaitExpression(parent) || t.isOptionalMemberExpression(parent) || t.isTaggedTemplateExpression(parent) || t.isTSTypeAssertion(parent) || t.isTSAsExpression(parent)) { }) || t.isAwaitExpression(parent) || t.isTSTypeAssertion(parent) || t.isTSAsExpression(parent)) {
return true; return true;
} }
...@@ -189,46 +192,89 @@ function ConditionalExpression(node, parent) { ...@@ -189,46 +192,89 @@ function ConditionalExpression(node, parent) {
} }
function OptionalMemberExpression(node, parent) { function OptionalMemberExpression(node, parent) {
return t.isCallExpression(parent) || t.isMemberExpression(parent); return t.isCallExpression(parent, {
callee: node
}) || t.isMemberExpression(parent, {
object: node
});
} }
function AssignmentExpression(node) { function AssignmentExpression(node, parent) {
if (t.isObjectPattern(node.left)) { if (t.isObjectPattern(node.left)) {
return true; return true;
} else { } else {
return ConditionalExpression(...arguments); return ConditionalExpression(node, parent);
} }
} }
function NewExpression(node, parent) { function LogicalExpression(node, parent) {
return isClassExtendsClause(node, parent); switch (node.operator) {
case "||":
if (!t.isLogicalExpression(parent)) return false;
return parent.operator === "??" || parent.operator === "&&";
case "&&":
return t.isLogicalExpression(parent, {
operator: "??"
});
case "??":
return t.isLogicalExpression(parent) && parent.operator !== "??";
}
} }
function isFirstInStatement(printStack, { function Identifier(node, parent, printStack) {
considerArrow = false, if (node.name === "let") {
considerDefaultExports = false const isFollowedByBracket = t.isMemberExpression(parent, {
} = {}) { object: node,
computed: true
}) || t.isOptionalMemberExpression(parent, {
object: node,
computed: true,
optional: false
});
return isFirstInContext(printStack, {
expressionStatement: isFollowedByBracket,
forHead: isFollowedByBracket,
forInHead: isFollowedByBracket,
forOfHead: true
});
}
return node.name === "async" && t.isForOfStatement(parent) && node === parent.left;
}
function isFirstInContext(printStack, {
expressionStatement = false,
arrowBody = false,
exportDefault = false,
forHead = false,
forInHead = false,
forOfHead = false
}) {
let i = printStack.length - 1; let i = printStack.length - 1;
let node = printStack[i]; let node = printStack[i];
i--; i--;
let parent = printStack[i]; let parent = printStack[i];
while (i > 0) { while (i >= 0) {
if (t.isExpressionStatement(parent, { if (expressionStatement && t.isExpressionStatement(parent, {
expression: node expression: node
}) || t.isTaggedTemplateExpression(parent) || considerDefaultExports && t.isExportDefaultDeclaration(parent, { }) || exportDefault && t.isExportDefaultDeclaration(parent, {
declaration: node declaration: node
}) || considerArrow && t.isArrowFunctionExpression(parent, { }) || arrowBody && t.isArrowFunctionExpression(parent, {
body: node body: node
}) || forHead && t.isForStatement(parent, {
init: node
}) || forInHead && t.isForInStatement(parent, {
left: node
}) || forOfHead && t.isForOfStatement(parent, {
left: node
})) { })) {
return true; return true;
} }
if (t.isCallExpression(parent, { if (hasPostfixPart(node, parent) && !t.isNewExpression(parent) || t.isSequenceExpression(parent) && parent.expressions[0] === node || t.isConditional(parent, {
callee: node
}) || t.isSequenceExpression(parent) && parent.expressions[0] === node || t.isMemberExpression(parent, {
object: node
}) || t.isConditional(parent, {
test: node test: node
}) || t.isBinary(parent, { }) || t.isBinary(parent, {
left: node left: node
......
...@@ -5,20 +5,16 @@ Object.defineProperty(exports, "__esModule", { ...@@ -5,20 +5,16 @@ Object.defineProperty(exports, "__esModule", {
}); });
exports.list = exports.nodes = void 0; exports.list = exports.nodes = void 0;
var t = _interopRequireWildcard(require("@babel/types")); var t = 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; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { 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 crawl(node, state = {}) { function crawl(node, state = {}) {
if (t.isMemberExpression(node)) { if (t.isMemberExpression(node) || t.isOptionalMemberExpression(node)) {
crawl(node.object, state); crawl(node.object, state);
if (node.computed) crawl(node.property, state); if (node.computed) crawl(node.property, state);
} else if (t.isBinary(node) || t.isAssignmentExpression(node)) { } else if (t.isBinary(node) || t.isAssignmentExpression(node)) {
crawl(node.left, state); crawl(node.left, state);
crawl(node.right, state); crawl(node.right, state);
} else if (t.isCallExpression(node)) { } else if (t.isCallExpression(node) || t.isOptionalCallExpression(node)) {
state.hasCall = true; state.hasCall = true;
crawl(node.callee, state); crawl(node.callee, state);
} else if (t.isFunction(node)) { } else if (t.isFunction(node)) {
...@@ -62,7 +58,7 @@ const nodes = { ...@@ -62,7 +58,7 @@ const nodes = {
SwitchCase(node, parent) { SwitchCase(node, parent) {
return { return {
before: node.consequent.length || parent.cases[0] === node, before: !!node.consequent.length || parent.cases[0] === node,
after: !node.consequent.length && parent.cases[parent.cases.length - 1] === node after: !node.consequent.length && parent.cases[parent.cases.length - 1] === node
}; };
}, },
...@@ -76,7 +72,7 @@ const nodes = { ...@@ -76,7 +72,7 @@ const nodes = {
}, },
Literal(node) { Literal(node) {
if (node.value === "use strict") { if (t.isStringLiteral(node) && node.value === "use strict") {
return { return {
after: true after: true
}; };
...@@ -92,6 +88,15 @@ const nodes = { ...@@ -92,6 +88,15 @@ const nodes = {
} }
}, },
OptionalCallExpression(node) {
if (t.isFunction(node.callee)) {
return {
before: true,
after: true
};
}
},
VariableDeclaration(node) { VariableDeclaration(node) {
for (let i = 0; i < node.declarations.length; i++) { for (let i = 0; i < node.declarations.length; i++) {
const declar = node.declarations[i]; const declar = node.declarations[i];
...@@ -132,7 +137,9 @@ nodes.ObjectProperty = nodes.ObjectTypeProperty = nodes.ObjectMethod = function ...@@ -132,7 +137,9 @@ nodes.ObjectProperty = nodes.ObjectTypeProperty = nodes.ObjectMethod = function
}; };
nodes.ObjectTypeCallProperty = function (node, parent) { nodes.ObjectTypeCallProperty = function (node, parent) {
if (parent.callProperties[0] === node && (!parent.properties || !parent.properties.length)) { var _parent$properties;
if (parent.callProperties[0] === node && !((_parent$properties = parent.properties) != null && _parent$properties.length)) {
return { return {
before: true before: true
}; };
...@@ -140,7 +147,9 @@ nodes.ObjectTypeCallProperty = function (node, parent) { ...@@ -140,7 +147,9 @@ nodes.ObjectTypeCallProperty = function (node, parent) {
}; };
nodes.ObjectTypeIndexer = function (node, parent) { nodes.ObjectTypeIndexer = function (node, parent) {
if (parent.indexers[0] === node && (!parent.properties || !parent.properties.length) && (!parent.callProperties || !parent.callProperties.length)) { var _parent$properties2, _parent$callPropertie;
if (parent.indexers[0] === node && !((_parent$properties2 = parent.properties) != null && _parent$properties2.length) && !((_parent$callPropertie = parent.callProperties) != null && _parent$callPropertie.length)) {
return { return {
before: true before: true
}; };
...@@ -148,7 +157,9 @@ nodes.ObjectTypeIndexer = function (node, parent) { ...@@ -148,7 +157,9 @@ nodes.ObjectTypeIndexer = function (node, parent) {
}; };
nodes.ObjectTypeInternalSlot = function (node, parent) { nodes.ObjectTypeInternalSlot = function (node, parent) {
if (parent.internalSlots[0] === node && (!parent.properties || !parent.properties.length) && (!parent.callProperties || !parent.callProperties.length) && (!parent.indexers || !parent.indexers.length)) { var _parent$properties3, _parent$callPropertie2, _parent$indexers;
if (parent.internalSlots[0] === node && !((_parent$properties3 = parent.properties) != null && _parent$properties3.length) && !((_parent$callPropertie2 = parent.callProperties) != null && _parent$callPropertie2.length) && !((_parent$indexers = parent.indexers) != null && _parent$indexers.length)) {
return { return {
before: true before: true
}; };
......
...@@ -5,27 +5,18 @@ Object.defineProperty(exports, "__esModule", { ...@@ -5,27 +5,18 @@ Object.defineProperty(exports, "__esModule", {
}); });
exports.default = void 0; exports.default = void 0;
var _isInteger = _interopRequireDefault(require("lodash/isInteger")); var _buffer = require("./buffer");
var _repeat = _interopRequireDefault(require("lodash/repeat")); var n = require("./node");
var _buffer = _interopRequireDefault(require("./buffer")); var t = require("@babel/types");
var n = _interopRequireWildcard(require("./node")); var generatorFunctions = require("./generators");
var t = _interopRequireWildcard(require("@babel/types"));
var generatorFunctions = _interopRequireWildcard(require("./generators"));
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; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const SCIENTIFIC_NOTATION = /e/i; const SCIENTIFIC_NOTATION = /e/i;
const ZERO_DECIMAL_INTEGER = /\.0+$/; const ZERO_DECIMAL_INTEGER = /\.0+$/;
const NON_DECIMAL_LITERAL = /^0[box]/; const NON_DECIMAL_LITERAL = /^0[box]/;
const PURE_ANNOTATION_RE = /^\s*[@#]__PURE__\s*$/;
class Printer { class Printer {
constructor(format, map) { constructor(format, map) {
...@@ -33,14 +24,13 @@ class Printer { ...@@ -33,14 +24,13 @@ class Printer {
this._printStack = []; this._printStack = [];
this._indent = 0; this._indent = 0;
this._insideAux = false; this._insideAux = false;
this._printedCommentStarts = {};
this._parenPushNewlineState = null; this._parenPushNewlineState = null;
this._noLineTerminator = false; this._noLineTerminator = false;
this._printAuxAfterOnNextUserNode = false; this._printAuxAfterOnNextUserNode = false;
this._printedComments = new WeakSet(); this._printedComments = new WeakSet();
this._endsWithInteger = false; this._endsWithInteger = false;
this._endsWithWord = false; this._endsWithWord = false;
this.format = format || {}; this.format = format;
this._buf = new _buffer.default(map); this._buf = new _buffer.default(map);
} }
...@@ -98,7 +88,7 @@ class Printer { ...@@ -98,7 +88,7 @@ class Printer {
number(str) { number(str) {
this.word(str); this.word(str);
this._endsWithInteger = (0, _isInteger.default)(+str) && !NON_DECIMAL_LITERAL.test(str) && !SCIENTIFIC_NOTATION.test(str) && !ZERO_DECIMAL_INTEGER.test(str) && str[str.length - 1] !== "."; this._endsWithInteger = Number.isInteger(+str) && !NON_DECIMAL_LITERAL.test(str) && !SCIENTIFIC_NOTATION.test(str) && !ZERO_DECIMAL_INTEGER.test(str) && str[str.length - 1] !== ".";
} }
token(str) { token(str) {
...@@ -183,19 +173,32 @@ class Printer { ...@@ -183,19 +173,32 @@ class Printer {
_maybeAddParen(str) { _maybeAddParen(str) {
const parenPushNewlineState = this._parenPushNewlineState; const parenPushNewlineState = this._parenPushNewlineState;
if (!parenPushNewlineState) return; if (!parenPushNewlineState) return;
this._parenPushNewlineState = null;
let i; let i;
for (i = 0; i < str.length && str[i] === " "; i++) continue; for (i = 0; i < str.length && str[i] === " "; i++) continue;
if (i === str.length) return; if (i === str.length) {
return;
}
const cha = str[i]; const cha = str[i];
if (cha !== "\n") { if (cha !== "\n") {
if (cha !== "/") return; if (cha !== "/" || i + 1 === str.length) {
if (i + 1 === str.length) return; this._parenPushNewlineState = null;
return;
}
const chaPost = str[i + 1]; const chaPost = str[i + 1];
if (chaPost !== "/" && chaPost !== "*") return;
if (chaPost === "*") {
if (PURE_ANNOTATION_RE.test(str.slice(i + 2, str.length - 2))) {
return;
}
} else if (chaPost !== "/") {
this._parenPushNewlineState = null;
return;
}
} }
this.token("("); this.token("(");
...@@ -207,7 +210,7 @@ class Printer { ...@@ -207,7 +210,7 @@ class Printer {
if (!this.format.retainLines) return; if (!this.format.retainLines) return;
const pos = loc ? loc[prop] : null; const pos = loc ? loc[prop] : null;
if (pos && pos.line !== null) { if ((pos == null ? void 0 : pos.line) != null) {
const count = pos.line - this._buf.getCurrentLine(); const count = pos.line - this._buf.getCurrentLine();
for (let i = 0; i < count; i++) { for (let i = 0; i < count; i++) {
...@@ -217,7 +220,7 @@ class Printer { ...@@ -217,7 +220,7 @@ class Printer {
} }
_getIndent() { _getIndent() {
return (0, _repeat.default)(this.format.indent.style, this._indent); return this.format.indent.style.repeat(this._indent);
} }
startTerminatorless(isLabel = false) { startTerminatorless(isLabel = false) {
...@@ -234,7 +237,7 @@ class Printer { ...@@ -234,7 +237,7 @@ class Printer {
endTerminatorless(state) { endTerminatorless(state) {
this._noLineTerminator = false; this._noLineTerminator = false;
if (state && state.printed) { if (state != null && state.printed) {
this.dedent(); this.dedent();
this.newline(); this.newline();
this.token(")"); this.token(")");
...@@ -252,7 +255,7 @@ class Printer { ...@@ -252,7 +255,7 @@ class Printer {
const printMethod = this[node.type]; const printMethod = this[node.type];
if (!printMethod) { if (!printMethod) {
throw new ReferenceError(`unknown node of type ${JSON.stringify(node.type)} with constructor ${JSON.stringify(node && node.constructor.name)}`); throw new ReferenceError(`unknown node of type ${JSON.stringify(node.type)} with constructor ${JSON.stringify(node == null ? void 0 : node.constructor.name)}`);
} }
this._printStack.push(node); this._printStack.push(node);
...@@ -327,7 +330,7 @@ class Printer { ...@@ -327,7 +330,7 @@ class Printer {
} }
printJoin(nodes, parent, opts = {}) { printJoin(nodes, parent, opts = {}) {
if (!nodes || !nodes.length) return; if (!(nodes != null && nodes.length)) return;
if (opts.indent) this.indent(); if (opts.indent) this.indent();
const newlineOpts = { const newlineOpts = {
addNewlines: opts.addNewlines addNewlines: opts.addNewlines
...@@ -375,11 +378,13 @@ class Printer { ...@@ -375,11 +378,13 @@ class Printer {
} }
_printLeadingComments(node) { _printLeadingComments(node) {
this._printComments(this._getComments(true, node)); this._printComments(this._getComments(true, node), true);
} }
printInnerComments(node, indent = true) { printInnerComments(node, indent = true) {
if (!node.innerComments || !node.innerComments.length) return; var _node$innerComments;
if (!((_node$innerComments = node.innerComments) != null && _node$innerComments.length)) return;
if (indent) this.indent(); if (indent) this.indent();
this._printComments(node.innerComments); this._printComments(node.innerComments);
...@@ -424,54 +429,75 @@ class Printer { ...@@ -424,54 +429,75 @@ class Printer {
return node && (leading ? node.leadingComments : node.trailingComments) || []; return node && (leading ? node.leadingComments : node.trailingComments) || [];
} }
_printComment(comment) { _printComment(comment, skipNewLines) {
if (!this.format.shouldPrintComment(comment.value)) return; if (!this.format.shouldPrintComment(comment.value)) return;
if (comment.ignore) return; if (comment.ignore) return;
if (this._printedComments.has(comment)) return; if (this._printedComments.has(comment)) return;
this._printedComments.add(comment); this._printedComments.add(comment);
if (comment.start != null) {
if (this._printedCommentStarts[comment.start]) return;
this._printedCommentStarts[comment.start] = true;
}
const isBlockComment = comment.type === "CommentBlock"; const isBlockComment = comment.type === "CommentBlock";
this.newline(this._buf.hasContent() && !this._noLineTerminator && isBlockComment ? 1 : 0); const printNewLines = isBlockComment && !skipNewLines && !this._noLineTerminator;
if (printNewLines && this._buf.hasContent()) this.newline(1);
if (!this.endsWith("[") && !this.endsWith("{")) this.space(); if (!this.endsWith("[") && !this.endsWith("{")) this.space();
let val = !isBlockComment && !this._noLineTerminator ? `//${comment.value}\n` : `/*${comment.value}*/`; let val = !isBlockComment && !this._noLineTerminator ? `//${comment.value}\n` : `/*${comment.value}*/`;
if (isBlockComment && this.format.indent.adjustMultilineComment) { if (isBlockComment && this.format.indent.adjustMultilineComment) {
const offset = comment.loc && comment.loc.start.column; var _comment$loc;
const offset = (_comment$loc = comment.loc) == null ? void 0 : _comment$loc.start.column;
if (offset) { if (offset) {
const newlineRegex = new RegExp("\\n\\s{1," + offset + "}", "g"); const newlineRegex = new RegExp("\\n\\s{1," + offset + "}", "g");
val = val.replace(newlineRegex, "\n"); val = val.replace(newlineRegex, "\n");
} }
const indentSize = Math.max(this._getIndent().length, this._buf.getCurrentColumn()); const indentSize = Math.max(this._getIndent().length, this.format.retainLines ? 0 : this._buf.getCurrentColumn());
val = val.replace(/\n(?!$)/g, `\n${(0, _repeat.default)(" ", indentSize)}`); val = val.replace(/\n(?!$)/g, `\n${" ".repeat(indentSize)}`);
} }
if (this.endsWith("/")) this._space(); if (this.endsWith("/")) this._space();
this.withSource("start", comment.loc, () => { this.withSource("start", comment.loc, () => {
this._append(val); this._append(val);
}); });
this.newline(isBlockComment && !this._noLineTerminator ? 1 : 0); if (printNewLines) this.newline(1);
}
_printComments(comments, inlinePureAnnotation) {
if (!(comments != null && comments.length)) return;
if (inlinePureAnnotation && comments.length === 1 && PURE_ANNOTATION_RE.test(comments[0].value)) {
this._printComment(comments[0], this._buf.hasContent() && !this.endsWith("\n"));
} else {
for (const comment of comments) {
this._printComment(comment);
}
}
} }
_printComments(comments) { printAssertions(node) {
if (!comments || !comments.length) return; var _node$assertions;
for (const comment of comments) { if ((_node$assertions = node.assertions) != null && _node$assertions.length) {
this._printComment(comment); this.space();
this.word("assert");
this.space();
this.token("{");
this.space();
this.printList(node.assertions, node);
this.space();
this.token("}");
} }
} }
} }
exports.default = Printer;
Object.assign(Printer.prototype, generatorFunctions); Object.assign(Printer.prototype, generatorFunctions);
{
Printer.prototype.Noop = function Noop() {};
}
var _default = Printer;
exports.default = _default;
function commaSeparator() { function commaSeparator() {
this.token(","); this.token(",");
......
...@@ -5,12 +5,17 @@ Object.defineProperty(exports, "__esModule", { ...@@ -5,12 +5,17 @@ Object.defineProperty(exports, "__esModule", {
}); });
exports.default = void 0; exports.default = void 0;
var _sourceMap = _interopRequireDefault(require("source-map")); var _sourceMap = require("source-map");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
class SourceMap { class SourceMap {
constructor(opts, code) { constructor(opts, code) {
this._cachedMap = void 0;
this._code = void 0;
this._opts = void 0;
this._rawMappings = void 0;
this._lastGenLine = void 0;
this._lastSourceLine = void 0;
this._lastSourceColumn = void 0;
this._cachedMap = null; this._cachedMap = null;
this._code = code; this._code = code;
this._opts = opts; this._opts = opts;
...@@ -19,7 +24,7 @@ class SourceMap { ...@@ -19,7 +24,7 @@ class SourceMap {
get() { get() {
if (!this._cachedMap) { if (!this._cachedMap) {
const map = this._cachedMap = new _sourceMap.default.SourceMapGenerator({ const map = this._cachedMap = new _sourceMap.SourceMapGenerator({
sourceRoot: this._opts.sourceRoot sourceRoot: this._opts.sourceRoot
}); });
const code = this._code; const code = this._code;
......
{ {
"_from": "@babel/generator@^7.7.2", "name": "@babel/generator",
"_id": "@babel/generator@7.7.2", "version": "7.14.5",
"_inBundle": false,
"_integrity": "sha512-WthSArvAjYLz4TcbKOi88me+KmDJdKSlfwwN8CnUYn9jBkzhq0ZEPuBfkAWIvjJ3AdEV1Cf/+eSQTnp3IDJKlQ==",
"_location": "/@babel/generator",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "@babel/generator@^7.7.2",
"name": "@babel/generator",
"escapedName": "@babel%2fgenerator",
"scope": "@babel",
"rawSpec": "^7.7.2",
"saveSpec": null,
"fetchSpec": "^7.7.2"
},
"_requiredBy": [
"/@babel/core",
"/@babel/traverse"
],
"_resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.7.2.tgz",
"_shasum": "2f4852d04131a5e17ea4f6645488b5da66ebf3af",
"_spec": "@babel/generator@^7.7.2",
"_where": "C:\\Work\\OneDrive - bwstaff\\M4_Lab\\TV3\\NewVersion01\\LAFJLBmf939XYm5gj\\dev\\node_modules\\@babel\\core",
"author": {
"name": "Sebastian McKenzie",
"email": "sebmck@gmail.com"
},
"bundleDependencies": false,
"dependencies": {
"@babel/types": "^7.7.2",
"jsesc": "^2.5.1",
"lodash": "^4.17.13",
"source-map": "^0.5.0"
},
"deprecated": false,
"description": "Turns an AST into code.", "description": "Turns an AST into code.",
"devDependencies": { "author": "The Babel Team (https://babel.dev/team)",
"@babel/helper-fixtures": "^7.6.3",
"@babel/parser": "^7.7.2"
},
"files": [
"lib"
],
"gitHead": "35f4d1276310bac6fede4a6f86a5c76f951e179e",
"homepage": "https://babeljs.io/",
"license": "MIT", "license": "MIT",
"main": "lib/index.js",
"name": "@babel/generator",
"publishConfig": { "publishConfig": {
"access": "public" "access": "public"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://github.com/babel/babel/tree/master/packages/babel-generator" "url": "https://github.com/babel/babel.git",
"directory": "packages/babel-generator"
},
"homepage": "https://babel.dev/docs/en/next/babel-generator",
"bugs": "https://github.com/babel/babel/issues?utf8=%E2%9C%93&q=is%3Aissue+label%3A%22pkg%3A%20generator%22+is%3Aopen",
"main": "./lib/index.js",
"files": [
"lib"
],
"dependencies": {
"@babel/types": "^7.14.5",
"jsesc": "^2.5.1",
"source-map": "^0.5.0"
},
"devDependencies": {
"@babel/helper-fixtures": "7.14.5",
"@babel/parser": "7.14.5",
"@types/jsesc": "^2.5.0",
"@types/source-map": "^0.5.0"
}, },
"version": "7.7.2" "engines": {
} "node": ">=6.9.0"
}
}
\ No newline at end of file
{ {
"_from": "@babel/helper-annotate-as-pure@^7.7.0", "name": "@babel/helper-annotate-as-pure",
"_id": "@babel/helper-annotate-as-pure@7.7.0", "version": "7.7.0",
"_inBundle": false,
"_integrity": "sha512-k50CQxMlYTYo+GGyUGFwpxKVtxVJi9yh61sXZji3zYHccK9RYliZGSTOgci85T+r+0VFN2nWbGM04PIqwfrpMg==",
"_location": "/@babel/helper-annotate-as-pure",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "@babel/helper-annotate-as-pure@^7.7.0",
"name": "@babel/helper-annotate-as-pure",
"escapedName": "@babel%2fhelper-annotate-as-pure",
"scope": "@babel",
"rawSpec": "^7.7.0",
"saveSpec": null,
"fetchSpec": "^7.7.0"
},
"_requiredBy": [
"/@babel/helper-remap-async-to-generator",
"/@babel/plugin-transform-classes",
"/@babel/plugin-transform-template-literals"
],
"_resolved": "https://registry.npmjs.org/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.7.0.tgz",
"_shasum": "efc54032d43891fe267679e63f6860aa7dbf4a5e",
"_spec": "@babel/helper-annotate-as-pure@^7.7.0",
"_where": "C:\\Work\\OneDrive - bwstaff\\M4_Lab\\TV3\\NewVersion01\\LAFJLBmf939XYm5gj\\dev\\node_modules\\@babel\\helper-remap-async-to-generator",
"bundleDependencies": false,
"dependencies": {
"@babel/types": "^7.7.0"
},
"deprecated": false,
"description": "Helper function to annotate paths and nodes with #__PURE__ comment", "description": "Helper function to annotate paths and nodes with #__PURE__ comment",
"gitHead": "97faa83953cb87e332554fa559a4956d202343ea", "repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-annotate-as-pure",
"license": "MIT", "license": "MIT",
"main": "lib/index.js",
"name": "@babel/helper-annotate-as-pure",
"publishConfig": { "publishConfig": {
"access": "public" "access": "public"
}, },
"repository": { "main": "lib/index.js",
"type": "git", "dependencies": {
"url": "https://github.com/babel/babel/tree/master/packages/babel-helper-annotate-as-pure" "@babel/types": "^7.7.0"
}, },
"version": "7.7.0" "gitHead": "97faa83953cb87e332554fa559a4956d202343ea"
} }
{ {
"_from": "@babel/helper-builder-binary-assignment-operator-visitor@^7.1.0", "name": "@babel/helper-builder-binary-assignment-operator-visitor",
"_id": "@babel/helper-builder-binary-assignment-operator-visitor@7.7.0", "version": "7.7.0",
"_inBundle": false,
"_integrity": "sha512-Cd8r8zs4RKDwMG/92lpZcnn5WPQ3LAMQbCw42oqUh4s7vsSN5ANUZjMel0OOnxDLq57hoDDbai+ryygYfCTOsw==",
"_location": "/@babel/helper-builder-binary-assignment-operator-visitor",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "@babel/helper-builder-binary-assignment-operator-visitor@^7.1.0",
"name": "@babel/helper-builder-binary-assignment-operator-visitor",
"escapedName": "@babel%2fhelper-builder-binary-assignment-operator-visitor",
"scope": "@babel",
"rawSpec": "^7.1.0",
"saveSpec": null,
"fetchSpec": "^7.1.0"
},
"_requiredBy": [
"/@babel/plugin-transform-exponentiation-operator"
],
"_resolved": "https://registry.npmjs.org/@babel/helper-builder-binary-assignment-operator-visitor/-/helper-builder-binary-assignment-operator-visitor-7.7.0.tgz",
"_shasum": "32dd9551d6ed3a5fc2edc50d6912852aa18274d9",
"_spec": "@babel/helper-builder-binary-assignment-operator-visitor@^7.1.0",
"_where": "C:\\Work\\OneDrive - bwstaff\\M4_Lab\\TV3\\NewVersion01\\LAFJLBmf939XYm5gj\\dev\\node_modules\\@babel\\plugin-transform-exponentiation-operator",
"bundleDependencies": false,
"dependencies": {
"@babel/helper-explode-assignable-expression": "^7.7.0",
"@babel/types": "^7.7.0"
},
"deprecated": false,
"description": "Helper function to build binary assignment operator visitors", "description": "Helper function to build binary assignment operator visitors",
"gitHead": "97faa83953cb87e332554fa559a4956d202343ea", "repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-builder-binary-assignment-operator-visitor",
"license": "MIT", "license": "MIT",
"main": "lib/index.js",
"name": "@babel/helper-builder-binary-assignment-operator-visitor",
"publishConfig": { "publishConfig": {
"access": "public" "access": "public"
}, },
"repository": { "main": "lib/index.js",
"type": "git", "dependencies": {
"url": "https://github.com/babel/babel/tree/master/packages/babel-helper-builder-binary-assignment-operator-visitor" "@babel/helper-explode-assignable-expression": "^7.7.0",
"@babel/types": "^7.7.0"
}, },
"version": "7.7.0" "gitHead": "97faa83953cb87e332554fa559a4956d202343ea"
} }
{ {
"_from": "@babel/helper-call-delegate@^7.4.4", "name": "@babel/helper-call-delegate",
"_id": "@babel/helper-call-delegate@7.7.0", "version": "7.7.0",
"_inBundle": false,
"_integrity": "sha512-Su0Mdq7uSSWGZayGMMQ+z6lnL00mMCnGAbO/R0ZO9odIdB/WNU/VfQKqMQU0fdIsxQYbRjDM4BixIa93SQIpvw==",
"_location": "/@babel/helper-call-delegate",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "@babel/helper-call-delegate@^7.4.4",
"name": "@babel/helper-call-delegate",
"escapedName": "@babel%2fhelper-call-delegate",
"scope": "@babel",
"rawSpec": "^7.4.4",
"saveSpec": null,
"fetchSpec": "^7.4.4"
},
"_requiredBy": [
"/@babel/plugin-transform-parameters"
],
"_resolved": "https://registry.npmjs.org/@babel/helper-call-delegate/-/helper-call-delegate-7.7.0.tgz",
"_shasum": "df8942452c2c1a217335ca7e393b9afc67f668dc",
"_spec": "@babel/helper-call-delegate@^7.4.4",
"_where": "C:\\Work\\OneDrive - bwstaff\\M4_Lab\\TV3\\NewVersion01\\LAFJLBmf939XYm5gj\\dev\\node_modules\\@babel\\plugin-transform-parameters",
"bundleDependencies": false,
"dependencies": {
"@babel/helper-hoist-variables": "^7.7.0",
"@babel/traverse": "^7.7.0",
"@babel/types": "^7.7.0"
},
"deprecated": false,
"description": "Helper function to call delegate", "description": "Helper function to call delegate",
"gitHead": "97faa83953cb87e332554fa559a4956d202343ea", "repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-call-delegate",
"license": "MIT", "license": "MIT",
"main": "lib/index.js",
"name": "@babel/helper-call-delegate",
"publishConfig": { "publishConfig": {
"access": "public" "access": "public"
}, },
"repository": { "main": "lib/index.js",
"type": "git", "dependencies": {
"url": "https://github.com/babel/babel/tree/master/packages/babel-helper-call-delegate" "@babel/helper-hoist-variables": "^7.7.0",
"@babel/traverse": "^7.7.0",
"@babel/types": "^7.7.0"
}, },
"version": "7.7.0" "gitHead": "97faa83953cb87e332554fa559a4956d202343ea"
} }
{ {
"_from": "@babel/helper-create-class-features-plugin@^7.7.0", "name": "@babel/helper-create-class-features-plugin",
"_id": "@babel/helper-create-class-features-plugin@7.7.0", "version": "7.7.0",
"_inBundle": false, "author": "The Babel Team (https://babeljs.io/team)",
"_integrity": "sha512-MZiB5qvTWoyiFOgootmRSDV1udjIqJW/8lmxgzKq6oDqxdmHUjeP2ZUOmgHdYjmUVNABqRrHjYAYRvj8Eox/UA==", "license": "MIT",
"_location": "/@babel/helper-create-class-features-plugin", "description": "Compile class public and private fields, private methods and decorators to ES6",
"_phantomChildren": {}, "repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-create-class-features-plugin",
"_requested": { "main": "lib/index.js",
"type": "range", "publishConfig": {
"registry": true, "access": "public"
"raw": "@babel/helper-create-class-features-plugin@^7.7.0",
"name": "@babel/helper-create-class-features-plugin",
"escapedName": "@babel%2fhelper-create-class-features-plugin",
"scope": "@babel",
"rawSpec": "^7.7.0",
"saveSpec": null,
"fetchSpec": "^7.7.0"
}, },
"_requiredBy": [ "keywords": [
"/@babel/plugin-proposal-class-properties", "babel",
"/@babel/plugin-proposal-decorators" "babel-plugin"
], ],
"_resolved": "https://registry.npmjs.org/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.7.0.tgz",
"_shasum": "bcdc223abbfdd386f94196ae2544987f8df775e8",
"_spec": "@babel/helper-create-class-features-plugin@^7.7.0",
"_where": "C:\\Work\\OneDrive - bwstaff\\M4_Lab\\TV3\\NewVersion01\\LAFJLBmf939XYm5gj\\dev\\node_modules\\@babel\\plugin-proposal-class-properties",
"author": {
"name": "The Babel Team",
"url": "https://babeljs.io/team"
},
"bundleDependencies": false,
"dependencies": { "dependencies": {
"@babel/helper-function-name": "^7.7.0", "@babel/helper-function-name": "^7.7.0",
"@babel/helper-member-expression-to-functions": "^7.7.0", "@babel/helper-member-expression-to-functions": "^7.7.0",
...@@ -37,29 +21,12 @@ ...@@ -37,29 +21,12 @@
"@babel/helper-replace-supers": "^7.7.0", "@babel/helper-replace-supers": "^7.7.0",
"@babel/helper-split-export-declaration": "^7.7.0" "@babel/helper-split-export-declaration": "^7.7.0"
}, },
"deprecated": false,
"description": "Compile class public and private fields, private methods and decorators to ES6",
"devDependencies": {
"@babel/core": "^7.7.0",
"@babel/helper-plugin-test-runner": "^7.0.0"
},
"gitHead": "97faa83953cb87e332554fa559a4956d202343ea",
"keywords": [
"babel",
"babel-plugin"
],
"license": "MIT",
"main": "lib/index.js",
"name": "@babel/helper-create-class-features-plugin",
"peerDependencies": { "peerDependencies": {
"@babel/core": "^7.0.0" "@babel/core": "^7.0.0"
}, },
"publishConfig": { "devDependencies": {
"access": "public" "@babel/core": "^7.7.0",
}, "@babel/helper-plugin-test-runner": "^7.0.0"
"repository": {
"type": "git",
"url": "https://github.com/babel/babel/tree/master/packages/babel-helper-create-class-features-plugin"
}, },
"version": "7.7.0" "gitHead": "97faa83953cb87e332554fa559a4956d202343ea"
} }
{ {
"_from": "@babel/helper-create-regexp-features-plugin@^7.7.0", "name": "@babel/helper-create-regexp-features-plugin",
"_id": "@babel/helper-create-regexp-features-plugin@7.7.2", "version": "7.7.2",
"_inBundle": false, "author": "The Babel Team (https://babeljs.io/team)",
"_integrity": "sha512-pAil/ZixjTlrzNpjx+l/C/wJk002Wo7XbbZ8oujH/AoJ3Juv0iN/UTcPUHXKMFLqsfS0Hy6Aow8M31brUYBlQQ==", "license": "MIT",
"_location": "/@babel/helper-create-regexp-features-plugin",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "@babel/helper-create-regexp-features-plugin@^7.7.0",
"name": "@babel/helper-create-regexp-features-plugin",
"escapedName": "@babel%2fhelper-create-regexp-features-plugin",
"scope": "@babel",
"rawSpec": "^7.7.0",
"saveSpec": null,
"fetchSpec": "^7.7.0"
},
"_requiredBy": [
"/@babel/plugin-proposal-unicode-property-regex",
"/@babel/plugin-transform-dotall-regex",
"/@babel/plugin-transform-named-capturing-groups-regex",
"/@babel/plugin-transform-unicode-regex"
],
"_resolved": "https://registry.npmjs.org/@babel/helper-create-regexp-features-plugin/-/helper-create-regexp-features-plugin-7.7.2.tgz",
"_shasum": "6f20443778c8fce2af2ff4206284afc0ced65db6",
"_spec": "@babel/helper-create-regexp-features-plugin@^7.7.0",
"_where": "C:\\Work\\OneDrive - bwstaff\\M4_Lab\\TV3\\NewVersion01\\LAFJLBmf939XYm5gj\\dev\\node_modules\\@babel\\plugin-proposal-unicode-property-regex",
"author": {
"name": "The Babel Team",
"url": "https://babeljs.io/team"
},
"bugs": {
"url": "https://github.com/babel/babel/issues"
},
"bundleDependencies": false,
"dependencies": {
"@babel/helper-regex": "^7.4.4",
"regexpu-core": "^4.6.0"
},
"deprecated": false,
"description": "Compile ESNext Regular Expressions to ES5", "description": "Compile ESNext Regular Expressions to ES5",
"devDependencies": { "repository": {
"@babel/core": "^7.7.2", "type": "git",
"@babel/helper-plugin-test-runner": "^7.0.0" "url": "https://github.com/babel/babel",
"directory": "packages/babel-helper-create-regexp-features-plugin"
},
"main": "lib/index.js",
"publishConfig": {
"access": "public"
}, },
"gitHead": "35f4d1276310bac6fede4a6f86a5c76f951e179e",
"homepage": "https://github.com/babel/babel#readme",
"keywords": [ "keywords": [
"babel", "babel",
"babel-plugin" "babel-plugin"
], ],
"license": "MIT", "dependencies": {
"main": "lib/index.js", "@babel/helper-regex": "^7.4.4",
"name": "@babel/helper-create-regexp-features-plugin", "regexpu-core": "^4.6.0"
},
"peerDependencies": { "peerDependencies": {
"@babel/core": "^7.0.0" "@babel/core": "^7.0.0"
}, },
"publishConfig": { "devDependencies": {
"access": "public" "@babel/core": "^7.7.2",
}, "@babel/helper-plugin-test-runner": "^7.0.0"
"repository": {
"type": "git",
"url": "git+https://github.com/babel/babel.git",
"directory": "packages/babel-helper-create-regexp-features-plugin"
}, },
"version": "7.7.2" "gitHead": "35f4d1276310bac6fede4a6f86a5c76f951e179e"
} }
{ {
"_from": "@babel/helper-define-map@^7.7.0", "name": "@babel/helper-define-map",
"_id": "@babel/helper-define-map@7.7.0", "version": "7.7.0",
"_inBundle": false,
"_integrity": "sha512-kPKWPb0dMpZi+ov1hJiwse9dWweZsz3V9rP4KdytnX1E7z3cTNmFGglwklzFPuqIcHLIY3bgKSs4vkwXXdflQA==",
"_location": "/@babel/helper-define-map",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "@babel/helper-define-map@^7.7.0",
"name": "@babel/helper-define-map",
"escapedName": "@babel%2fhelper-define-map",
"scope": "@babel",
"rawSpec": "^7.7.0",
"saveSpec": null,
"fetchSpec": "^7.7.0"
},
"_requiredBy": [
"/@babel/plugin-transform-classes"
],
"_resolved": "https://registry.npmjs.org/@babel/helper-define-map/-/helper-define-map-7.7.0.tgz",
"_shasum": "60b0e9fd60def9de5054c38afde8c8ee409c7529",
"_spec": "@babel/helper-define-map@^7.7.0",
"_where": "C:\\Work\\OneDrive - bwstaff\\M4_Lab\\TV3\\NewVersion01\\LAFJLBmf939XYm5gj\\dev\\node_modules\\@babel\\plugin-transform-classes",
"bundleDependencies": false,
"dependencies": {
"@babel/helper-function-name": "^7.7.0",
"@babel/types": "^7.7.0",
"lodash": "^4.17.13"
},
"deprecated": false,
"description": "Helper function to define a map", "description": "Helper function to define a map",
"gitHead": "97faa83953cb87e332554fa559a4956d202343ea", "repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-define-map",
"license": "MIT", "license": "MIT",
"main": "lib/index.js",
"name": "@babel/helper-define-map",
"publishConfig": { "publishConfig": {
"access": "public" "access": "public"
}, },
"repository": { "main": "lib/index.js",
"type": "git", "dependencies": {
"url": "https://github.com/babel/babel/tree/master/packages/babel-helper-define-map" "@babel/helper-function-name": "^7.7.0",
"@babel/types": "^7.7.0",
"lodash": "^4.17.13"
}, },
"version": "7.7.0" "gitHead": "97faa83953cb87e332554fa559a4956d202343ea"
} }
{ {
"_from": "@babel/helper-explode-assignable-expression@^7.7.0", "name": "@babel/helper-explode-assignable-expression",
"_id": "@babel/helper-explode-assignable-expression@7.7.0", "version": "7.7.0",
"_inBundle": false,
"_integrity": "sha512-CDs26w2shdD1urNUAji2RJXyBFCaR+iBEGnFz3l7maizMkQe3saVw9WtjG1tz8CwbjvlFnaSLVhgnu1SWaherg==",
"_location": "/@babel/helper-explode-assignable-expression",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "@babel/helper-explode-assignable-expression@^7.7.0",
"name": "@babel/helper-explode-assignable-expression",
"escapedName": "@babel%2fhelper-explode-assignable-expression",
"scope": "@babel",
"rawSpec": "^7.7.0",
"saveSpec": null,
"fetchSpec": "^7.7.0"
},
"_requiredBy": [
"/@babel/helper-builder-binary-assignment-operator-visitor"
],
"_resolved": "https://registry.npmjs.org/@babel/helper-explode-assignable-expression/-/helper-explode-assignable-expression-7.7.0.tgz",
"_shasum": "db2a6705555ae1f9f33b4b8212a546bc7f9dc3ef",
"_spec": "@babel/helper-explode-assignable-expression@^7.7.0",
"_where": "C:\\Work\\OneDrive - bwstaff\\M4_Lab\\TV3\\NewVersion01\\LAFJLBmf939XYm5gj\\dev\\node_modules\\@babel\\helper-builder-binary-assignment-operator-visitor",
"bundleDependencies": false,
"dependencies": {
"@babel/traverse": "^7.7.0",
"@babel/types": "^7.7.0"
},
"deprecated": false,
"description": "Helper function to explode an assignable expression", "description": "Helper function to explode an assignable expression",
"gitHead": "97faa83953cb87e332554fa559a4956d202343ea", "repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-explode-assignable-expression",
"license": "MIT", "license": "MIT",
"main": "lib/index.js",
"name": "@babel/helper-explode-assignable-expression",
"publishConfig": { "publishConfig": {
"access": "public" "access": "public"
}, },
"repository": { "main": "lib/index.js",
"type": "git", "dependencies": {
"url": "https://github.com/babel/babel/tree/master/packages/babel-helper-explode-assignable-expression" "@babel/traverse": "^7.7.0",
"@babel/types": "^7.7.0"
}, },
"version": "7.7.0" "gitHead": "97faa83953cb87e332554fa559a4956d202343ea"
} }
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
> Helper function to change the property 'name' of every function > Helper function to change the property 'name' of every function
See our website [@babel/helper-function-name](https://babeljs.io/docs/en/next/babel-helper-function-name.html) for more information. See our website [@babel/helper-function-name](https://babeljs.io/docs/en/babel-helper-function-name) for more information.
## Install ## Install
......
...@@ -5,17 +5,11 @@ Object.defineProperty(exports, "__esModule", { ...@@ -5,17 +5,11 @@ Object.defineProperty(exports, "__esModule", {
}); });
exports.default = _default; exports.default = _default;
var _helperGetFunctionArity = _interopRequireDefault(require("@babel/helper-get-function-arity")); var _helperGetFunctionArity = require("@babel/helper-get-function-arity");
var _template = _interopRequireDefault(require("@babel/template")); var _template = require("@babel/template");
var t = _interopRequireWildcard(require("@babel/types")); var t = 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; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const buildPropertyMethodAssignmentWrapper = (0, _template.default)(` const buildPropertyMethodAssignmentWrapper = (0, _template.default)(`
(function (FUNCTION_KEY) { (function (FUNCTION_KEY) {
...@@ -150,7 +144,9 @@ function _default({ ...@@ -150,7 +144,9 @@ function _default({
return; return;
} }
} }
} else if (t.isAssignmentExpression(parent)) { } else if (t.isAssignmentExpression(parent, {
operator: "="
})) {
id = parent.left; id = parent.left;
} else if (!id) { } else if (!id) {
return; return;
......
{ {
"_from": "@babel/helper-function-name@^7.7.0", "name": "@babel/helper-function-name",
"_id": "@babel/helper-function-name@7.7.0", "version": "7.14.5",
"_inBundle": false,
"_integrity": "sha512-tDsJgMUAP00Ugv8O2aGEua5I2apkaQO7lBGUq1ocwN3G23JE5Dcq0uh3GvFTChPa4b40AWiAsLvCZOA2rdnQ7Q==",
"_location": "/@babel/helper-function-name",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "@babel/helper-function-name@^7.7.0",
"name": "@babel/helper-function-name",
"escapedName": "@babel%2fhelper-function-name",
"scope": "@babel",
"rawSpec": "^7.7.0",
"saveSpec": null,
"fetchSpec": "^7.7.0"
},
"_requiredBy": [
"/@babel/helper-create-class-features-plugin",
"/@babel/helper-define-map",
"/@babel/helper-wrap-function",
"/@babel/plugin-transform-classes",
"/@babel/plugin-transform-function-name",
"/@babel/traverse"
],
"_resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.7.0.tgz",
"_shasum": "44a5ad151cfff8ed2599c91682dda2ec2c8430a3",
"_spec": "@babel/helper-function-name@^7.7.0",
"_where": "C:\\Work\\OneDrive - bwstaff\\M4_Lab\\TV3\\NewVersion01\\LAFJLBmf939XYm5gj\\dev\\node_modules\\@babel\\traverse",
"bundleDependencies": false,
"dependencies": {
"@babel/helper-get-function-arity": "^7.7.0",
"@babel/template": "^7.7.0",
"@babel/types": "^7.7.0"
},
"deprecated": false,
"description": "Helper function to change the property 'name' of every function", "description": "Helper function to change the property 'name' of every function",
"gitHead": "97faa83953cb87e332554fa559a4956d202343ea", "repository": {
"type": "git",
"url": "https://github.com/babel/babel.git",
"directory": "packages/babel-helper-function-name"
},
"homepage": "https://babel.dev/docs/en/next/babel-helper-function-name",
"license": "MIT", "license": "MIT",
"main": "lib/index.js",
"name": "@babel/helper-function-name",
"publishConfig": { "publishConfig": {
"access": "public" "access": "public"
}, },
"repository": { "main": "./lib/index.js",
"type": "git", "dependencies": {
"url": "https://github.com/babel/babel/tree/master/packages/babel-helper-function-name" "@babel/helper-get-function-arity": "^7.14.5",
"@babel/template": "^7.14.5",
"@babel/types": "^7.14.5"
},
"engines": {
"node": ">=6.9.0"
}, },
"version": "7.7.0" "author": "The Babel Team (https://babel.dev/team)"
} }
\ No newline at end of file
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
> Helper function to get function arity > Helper function to get function arity
See our website [@babel/helper-get-function-arity](https://babeljs.io/docs/en/next/babel-helper-get-function-arity.html) for more information. See our website [@babel/helper-get-function-arity](https://babeljs.io/docs/en/babel-helper-get-function-arity) for more information.
## Install ## Install
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment