siphon-cli
Version:
Simple bundler for web applications. 📦🔧🧡
948 lines (947 loc) • 36 kB
JavaScript
;
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ArrayExpression = exports.AssignmentExpression = exports.UnaryExpression = exports.ClassExpression = exports.ImportExpression = exports.ThisExpression = exports.NewExpression = exports.BlockStatement = exports.CatchClause = exports.TryStatement = exports.ThrowStatement = exports.ReturnStatement = exports.ContinueStatement = exports.BreakStatement = exports.ForOfStatement = exports.ForInStatement = exports.ForStatement = exports.SwitchCase = exports.SwitchStatement = exports.DoWhileStatement = exports.Comma = exports.WhileStatement = exports.IfStatement = exports.EmptyStatement = exports.LabeledStatement = exports.ExpressionStatement = exports.ExportAllDeclaration = exports.ExportDefaultDeclaration = exports.ExportSpecifier = exports.ExportNamedDeclaration = exports.ImportNamespaceSpecifier = exports.ImportDefaultSpecifier = exports.ImportSpecifier = exports.ImportDeclaration = exports.Super = exports.PropertyDefinition = exports.MethodDefinition = exports.ClassBody = exports.ClassDeclaration = exports.FunctionDeclaration = exports.VariableDeclarator = exports.VariableDeclaration = exports.PrivateIdentifier = exports.Identifier = exports.TemplateElement = exports.TemplateLiteral = exports.Literal = exports.EmptyNode = exports.Program = exports.JSNode = void 0;
exports.isValidPropertyKeyStart = exports.isValidForParam = exports.isValidForInParam = exports.isValidParameter = exports.isChainExpression = exports.isOptional = exports.isValidReference = exports.isIdentifier = exports.isValidExpression = exports.JSXClosingFragment = exports.JSXOpeningFragment = exports.JSXFragment = exports.JSXNamespacedName = exports.JSXMemberExpression = exports.JSXText = exports.JSXExpressionContainer = exports.JSXAttribute = exports.JSXIdentifier = exports.JSXClosingElement = exports.JSXOpeningElement = exports.JSXElement = exports.RestElement = exports.SpreadElement = exports.ObjectPattern = exports.ArrayPattern = exports.AssignmentPattern = exports.ArrowFunctionExpression = exports.SequenceExpression = exports.LogicalExpression = exports.BinaryExpression = exports.YieldExpression = exports.FunctionExpression = exports.CallExpression = exports.ConditionalExpression = exports.ChainExpression = exports.MemberExpression = exports.AwaitExpression = exports.UpdateExpression = exports.Property = exports.ObjectExpression = void 0;
var utils_1 = require("../utils");
var JSNode = (function () {
function JSNode(start) {
this.type = "Node";
this.loc = { start: start };
}
return JSNode;
}());
exports.JSNode = JSNode;
var Program = (function (_super) {
__extends(Program, _super);
function Program() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = "Program";
_this.body = [];
return _this;
}
Program.prototype.push = function (node) {
if (node)
this.body.push(node);
};
Program.prototype.pop = function () {
return this.body.pop();
};
return Program;
}(JSNode));
exports.Program = Program;
var EmptyNode = (function (_super) {
__extends(EmptyNode, _super);
function EmptyNode() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = "EmptyNode";
return _this;
}
return EmptyNode;
}(JSNode));
exports.EmptyNode = EmptyNode;
var Literal = (function (_super) {
__extends(Literal, _super);
function Literal() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = "Literal";
_this.raw = "";
return _this;
}
return Literal;
}(JSNode));
exports.Literal = Literal;
var TemplateLiteral = (function (_super) {
__extends(TemplateLiteral, _super);
function TemplateLiteral() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = "TemplateLiteral";
return _this;
}
return TemplateLiteral;
}(JSNode));
exports.TemplateLiteral = TemplateLiteral;
var TemplateElement = (function (_super) {
__extends(TemplateElement, _super);
function TemplateElement() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = "TemplateElement";
return _this;
}
return TemplateElement;
}(JSNode));
exports.TemplateElement = TemplateElement;
var Identifier = (function (_super) {
__extends(Identifier, _super);
function Identifier() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = "Identifier";
_this.name = "";
return _this;
}
return Identifier;
}(JSNode));
exports.Identifier = Identifier;
var PrivateIdentifier = (function (_super) {
__extends(PrivateIdentifier, _super);
function PrivateIdentifier() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = "PrivateIdentifier";
_this.name = "";
return _this;
}
return PrivateIdentifier;
}(JSNode));
exports.PrivateIdentifier = PrivateIdentifier;
var VariableDeclaration = (function (_super) {
__extends(VariableDeclaration, _super);
function VariableDeclaration() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = "VariableDeclaration";
_this.kind = "";
_this.declarations = [];
return _this;
}
return VariableDeclaration;
}(JSNode));
exports.VariableDeclaration = VariableDeclaration;
var VariableDeclarator = (function (_super) {
__extends(VariableDeclarator, _super);
function VariableDeclarator() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = "VariableDeclarator";
return _this;
}
return VariableDeclarator;
}(JSNode));
exports.VariableDeclarator = VariableDeclarator;
var FunctionDeclaration = (function (_super) {
__extends(FunctionDeclaration, _super);
function FunctionDeclaration() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = "FunctionDeclaration";
_this.params = [];
return _this;
}
return FunctionDeclaration;
}(JSNode));
exports.FunctionDeclaration = FunctionDeclaration;
var ClassDeclaration = (function (_super) {
__extends(ClassDeclaration, _super);
function ClassDeclaration() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = "ClassDeclaration";
_this.superClass = null;
return _this;
}
return ClassDeclaration;
}(JSNode));
exports.ClassDeclaration = ClassDeclaration;
var ClassBody = (function (_super) {
__extends(ClassBody, _super);
function ClassBody() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = "ClassBody";
_this.body = [];
return _this;
}
return ClassBody;
}(JSNode));
exports.ClassBody = ClassBody;
var MethodDefinition = (function (_super) {
__extends(MethodDefinition, _super);
function MethodDefinition() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = "MethodDefinition";
return _this;
}
return MethodDefinition;
}(JSNode));
exports.MethodDefinition = MethodDefinition;
var PropertyDefinition = (function (_super) {
__extends(PropertyDefinition, _super);
function PropertyDefinition() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = "PropertyDefinition";
return _this;
}
return PropertyDefinition;
}(JSNode));
exports.PropertyDefinition = PropertyDefinition;
var Super = (function (_super) {
__extends(Super, _super);
function Super() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = "Super";
return _this;
}
return Super;
}(JSNode));
exports.Super = Super;
var ImportDeclaration = (function (_super) {
__extends(ImportDeclaration, _super);
function ImportDeclaration() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = "ImportDeclaration";
_this.specifiers = [];
return _this;
}
return ImportDeclaration;
}(JSNode));
exports.ImportDeclaration = ImportDeclaration;
var ImportSpecifier = (function (_super) {
__extends(ImportSpecifier, _super);
function ImportSpecifier() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = "ImportSpecifier";
return _this;
}
return ImportSpecifier;
}(JSNode));
exports.ImportSpecifier = ImportSpecifier;
var ImportDefaultSpecifier = (function (_super) {
__extends(ImportDefaultSpecifier, _super);
function ImportDefaultSpecifier() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = "ImportDefaultSpecifier";
return _this;
}
return ImportDefaultSpecifier;
}(JSNode));
exports.ImportDefaultSpecifier = ImportDefaultSpecifier;
var ImportNamespaceSpecifier = (function (_super) {
__extends(ImportNamespaceSpecifier, _super);
function ImportNamespaceSpecifier() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = "ImportNamespaceSpecifier";
return _this;
}
return ImportNamespaceSpecifier;
}(JSNode));
exports.ImportNamespaceSpecifier = ImportNamespaceSpecifier;
var ExportNamedDeclaration = (function (_super) {
__extends(ExportNamedDeclaration, _super);
function ExportNamedDeclaration() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = "ExportNamedDeclaration";
_this.declaration = null;
_this.specifiers = [];
return _this;
}
return ExportNamedDeclaration;
}(JSNode));
exports.ExportNamedDeclaration = ExportNamedDeclaration;
var ExportSpecifier = (function (_super) {
__extends(ExportSpecifier, _super);
function ExportSpecifier() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = "ExportSpecifier";
return _this;
}
return ExportSpecifier;
}(JSNode));
exports.ExportSpecifier = ExportSpecifier;
var ExportDefaultDeclaration = (function (_super) {
__extends(ExportDefaultDeclaration, _super);
function ExportDefaultDeclaration() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = "ExportDefaultDeclaration";
return _this;
}
return ExportDefaultDeclaration;
}(JSNode));
exports.ExportDefaultDeclaration = ExportDefaultDeclaration;
var ExportAllDeclaration = (function (_super) {
__extends(ExportAllDeclaration, _super);
function ExportAllDeclaration() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = "ExportAllDeclaration";
return _this;
}
return ExportAllDeclaration;
}(JSNode));
exports.ExportAllDeclaration = ExportAllDeclaration;
var ExpressionStatement = (function (_super) {
__extends(ExpressionStatement, _super);
function ExpressionStatement() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = "ExpressionStatement";
return _this;
}
return ExpressionStatement;
}(JSNode));
exports.ExpressionStatement = ExpressionStatement;
var LabeledStatement = (function (_super) {
__extends(LabeledStatement, _super);
function LabeledStatement() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = "LabeledStatement";
return _this;
}
return LabeledStatement;
}(JSNode));
exports.LabeledStatement = LabeledStatement;
var EmptyStatement = (function (_super) {
__extends(EmptyStatement, _super);
function EmptyStatement() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = "EmptyStatement";
return _this;
}
return EmptyStatement;
}(JSNode));
exports.EmptyStatement = EmptyStatement;
var IfStatement = (function (_super) {
__extends(IfStatement, _super);
function IfStatement() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = "IfStatement";
return _this;
}
return IfStatement;
}(JSNode));
exports.IfStatement = IfStatement;
var WhileStatement = (function (_super) {
__extends(WhileStatement, _super);
function WhileStatement() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = "WhileStatement";
return _this;
}
return WhileStatement;
}(JSNode));
exports.WhileStatement = WhileStatement;
var Comma = (function (_super) {
__extends(Comma, _super);
function Comma() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = "Comma";
_this.validNode = false;
return _this;
}
return Comma;
}(JSNode));
exports.Comma = Comma;
var DoWhileStatement = (function (_super) {
__extends(DoWhileStatement, _super);
function DoWhileStatement() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = "DoWhileStatement";
return _this;
}
return DoWhileStatement;
}(JSNode));
exports.DoWhileStatement = DoWhileStatement;
var SwitchStatement = (function (_super) {
__extends(SwitchStatement, _super);
function SwitchStatement() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = "SwitchStatement";
return _this;
}
return SwitchStatement;
}(JSNode));
exports.SwitchStatement = SwitchStatement;
var SwitchCase = (function (_super) {
__extends(SwitchCase, _super);
function SwitchCase() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = "SwitchCase";
_this.test = null;
_this.consequent = [];
return _this;
}
return SwitchCase;
}(JSNode));
exports.SwitchCase = SwitchCase;
var ForStatement = (function (_super) {
__extends(ForStatement, _super);
function ForStatement() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = "ForStatement";
return _this;
}
return ForStatement;
}(JSNode));
exports.ForStatement = ForStatement;
var ForInStatement = (function (_super) {
__extends(ForInStatement, _super);
function ForInStatement() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = "ForInStatement";
return _this;
}
return ForInStatement;
}(JSNode));
exports.ForInStatement = ForInStatement;
var ForOfStatement = (function (_super) {
__extends(ForOfStatement, _super);
function ForOfStatement() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = "ForOfStatement";
_this.await = false;
return _this;
}
return ForOfStatement;
}(JSNode));
exports.ForOfStatement = ForOfStatement;
var BreakStatement = (function (_super) {
__extends(BreakStatement, _super);
function BreakStatement() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = "BreakStatement";
return _this;
}
return BreakStatement;
}(JSNode));
exports.BreakStatement = BreakStatement;
var ContinueStatement = (function (_super) {
__extends(ContinueStatement, _super);
function ContinueStatement() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = "ContinueStatement";
return _this;
}
return ContinueStatement;
}(JSNode));
exports.ContinueStatement = ContinueStatement;
var ReturnStatement = (function (_super) {
__extends(ReturnStatement, _super);
function ReturnStatement() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = "ReturnStatement";
return _this;
}
return ReturnStatement;
}(JSNode));
exports.ReturnStatement = ReturnStatement;
var ThrowStatement = (function (_super) {
__extends(ThrowStatement, _super);
function ThrowStatement() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = "ThrowStatement";
return _this;
}
return ThrowStatement;
}(JSNode));
exports.ThrowStatement = ThrowStatement;
var TryStatement = (function (_super) {
__extends(TryStatement, _super);
function TryStatement() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = "TryStatement";
return _this;
}
return TryStatement;
}(JSNode));
exports.TryStatement = TryStatement;
var CatchClause = (function (_super) {
__extends(CatchClause, _super);
function CatchClause() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = "CatchClause";
return _this;
}
return CatchClause;
}(JSNode));
exports.CatchClause = CatchClause;
var BlockStatement = (function (_super) {
__extends(BlockStatement, _super);
function BlockStatement() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = "BlockStatement";
_this.body = [];
return _this;
}
return BlockStatement;
}(JSNode));
exports.BlockStatement = BlockStatement;
var NewExpression = (function (_super) {
__extends(NewExpression, _super);
function NewExpression() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = "NewExpression";
return _this;
}
return NewExpression;
}(JSNode));
exports.NewExpression = NewExpression;
var ThisExpression = (function (_super) {
__extends(ThisExpression, _super);
function ThisExpression() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = "ThisExpression";
return _this;
}
return ThisExpression;
}(JSNode));
exports.ThisExpression = ThisExpression;
var ImportExpression = (function (_super) {
__extends(ImportExpression, _super);
function ImportExpression() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = "ImportExpression";
return _this;
}
return ImportExpression;
}(JSNode));
exports.ImportExpression = ImportExpression;
var ClassExpression = (function (_super) {
__extends(ClassExpression, _super);
function ClassExpression() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = "ClassExpression";
_this.id = null;
_this.superClass = null;
return _this;
}
return ClassExpression;
}(JSNode));
exports.ClassExpression = ClassExpression;
var UnaryExpression = (function (_super) {
__extends(UnaryExpression, _super);
function UnaryExpression() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = "UnaryExpression";
_this.prefix = true;
return _this;
}
return UnaryExpression;
}(JSNode));
exports.UnaryExpression = UnaryExpression;
var AssignmentExpression = (function (_super) {
__extends(AssignmentExpression, _super);
function AssignmentExpression() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = "AssignmentExpression";
_this.operator = "";
return _this;
}
return AssignmentExpression;
}(JSNode));
exports.AssignmentExpression = AssignmentExpression;
var ArrayExpression = (function (_super) {
__extends(ArrayExpression, _super);
function ArrayExpression() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = "ArrayExpression";
return _this;
}
return ArrayExpression;
}(JSNode));
exports.ArrayExpression = ArrayExpression;
var ObjectExpression = (function (_super) {
__extends(ObjectExpression, _super);
function ObjectExpression() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = "ObjectExpression";
return _this;
}
return ObjectExpression;
}(JSNode));
exports.ObjectExpression = ObjectExpression;
var Property = (function (_super) {
__extends(Property, _super);
function Property() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = "Property";
_this.kind = "init";
_this.method = false;
_this.shorthand = false;
_this.computed = false;
return _this;
}
return Property;
}(JSNode));
exports.Property = Property;
var UpdateExpression = (function (_super) {
__extends(UpdateExpression, _super);
function UpdateExpression() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = "UpdateExpression";
return _this;
}
return UpdateExpression;
}(JSNode));
exports.UpdateExpression = UpdateExpression;
var AwaitExpression = (function (_super) {
__extends(AwaitExpression, _super);
function AwaitExpression() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = "AwaitExpression";
return _this;
}
return AwaitExpression;
}(JSNode));
exports.AwaitExpression = AwaitExpression;
var MemberExpression = (function (_super) {
__extends(MemberExpression, _super);
function MemberExpression() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = "MemberExpression";
_this.optional = false;
_this.computed = false;
return _this;
}
return MemberExpression;
}(JSNode));
exports.MemberExpression = MemberExpression;
var ChainExpression = (function (_super) {
__extends(ChainExpression, _super);
function ChainExpression() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = "ChainExpression";
return _this;
}
return ChainExpression;
}(JSNode));
exports.ChainExpression = ChainExpression;
var ConditionalExpression = (function (_super) {
__extends(ConditionalExpression, _super);
function ConditionalExpression() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = "ConditionalExpression";
return _this;
}
return ConditionalExpression;
}(JSNode));
exports.ConditionalExpression = ConditionalExpression;
var CallExpression = (function (_super) {
__extends(CallExpression, _super);
function CallExpression() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = "CallExpression";
return _this;
}
return CallExpression;
}(JSNode));
exports.CallExpression = CallExpression;
var FunctionExpression = (function (_super) {
__extends(FunctionExpression, _super);
function FunctionExpression() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = "FunctionExpression";
return _this;
}
return FunctionExpression;
}(JSNode));
exports.FunctionExpression = FunctionExpression;
var YieldExpression = (function (_super) {
__extends(YieldExpression, _super);
function YieldExpression() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = "YieldExpression";
return _this;
}
return YieldExpression;
}(JSNode));
exports.YieldExpression = YieldExpression;
var BinaryExpression = (function (_super) {
__extends(BinaryExpression, _super);
function BinaryExpression() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = "BinaryExpression";
_this.operator = "";
return _this;
}
return BinaryExpression;
}(JSNode));
exports.BinaryExpression = BinaryExpression;
var LogicalExpression = (function (_super) {
__extends(LogicalExpression, _super);
function LogicalExpression() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = "LogicalExpression";
_this.operator = "";
return _this;
}
return LogicalExpression;
}(JSNode));
exports.LogicalExpression = LogicalExpression;
var SequenceExpression = (function (_super) {
__extends(SequenceExpression, _super);
function SequenceExpression() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = "SequenceExpression";
_this.expressions = [];
return _this;
}
return SequenceExpression;
}(JSNode));
exports.SequenceExpression = SequenceExpression;
var ArrowFunctionExpression = (function (_super) {
__extends(ArrowFunctionExpression, _super);
function ArrowFunctionExpression() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = "ArrowFunctionExpression";
_this.id = null;
_this.expression = false;
_this.params = [];
_this.generator = false;
_this.async = false;
return _this;
}
return ArrowFunctionExpression;
}(JSNode));
exports.ArrowFunctionExpression = ArrowFunctionExpression;
var AssignmentPattern = (function (_super) {
__extends(AssignmentPattern, _super);
function AssignmentPattern() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = "AssignmentPattern";
return _this;
}
return AssignmentPattern;
}(JSNode));
exports.AssignmentPattern = AssignmentPattern;
var ArrayPattern = (function (_super) {
__extends(ArrayPattern, _super);
function ArrayPattern() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = "ArrayPattern";
_this.elements = [];
return _this;
}
return ArrayPattern;
}(JSNode));
exports.ArrayPattern = ArrayPattern;
var ObjectPattern = (function (_super) {
__extends(ObjectPattern, _super);
function ObjectPattern() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = "ObjectPattern";
_this.properties = [];
return _this;
}
return ObjectPattern;
}(JSNode));
exports.ObjectPattern = ObjectPattern;
var SpreadElement = (function (_super) {
__extends(SpreadElement, _super);
function SpreadElement() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = "SpreadElement";
return _this;
}
return SpreadElement;
}(JSNode));
exports.SpreadElement = SpreadElement;
var RestElement = (function (_super) {
__extends(RestElement, _super);
function RestElement() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = "RestElement";
return _this;
}
return RestElement;
}(JSNode));
exports.RestElement = RestElement;
var JSXElement = (function (_super) {
__extends(JSXElement, _super);
function JSXElement() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = "JSXElement";
return _this;
}
return JSXElement;
}(JSNode));
exports.JSXElement = JSXElement;
var JSXOpeningElement = (function (_super) {
__extends(JSXOpeningElement, _super);
function JSXOpeningElement() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = "JSXOpeningElement";
return _this;
}
return JSXOpeningElement;
}(JSNode));
exports.JSXOpeningElement = JSXOpeningElement;
var JSXClosingElement = (function (_super) {
__extends(JSXClosingElement, _super);
function JSXClosingElement() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = "JSXClosingElement";
return _this;
}
return JSXClosingElement;
}(JSNode));
exports.JSXClosingElement = JSXClosingElement;
var JSXIdentifier = (function (_super) {
__extends(JSXIdentifier, _super);
function JSXIdentifier() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = "JSXIdentifier";
return _this;
}
return JSXIdentifier;
}(JSNode));
exports.JSXIdentifier = JSXIdentifier;
var JSXAttribute = (function (_super) {
__extends(JSXAttribute, _super);
function JSXAttribute() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = "JSXAttribute";
return _this;
}
return JSXAttribute;
}(JSNode));
exports.JSXAttribute = JSXAttribute;
var JSXExpressionContainer = (function (_super) {
__extends(JSXExpressionContainer, _super);
function JSXExpressionContainer() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = "JSXExpressionContainer";
return _this;
}
return JSXExpressionContainer;
}(JSNode));
exports.JSXExpressionContainer = JSXExpressionContainer;
var JSXText = (function (_super) {
__extends(JSXText, _super);
function JSXText() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = "JSXText";
return _this;
}
return JSXText;
}(JSNode));
exports.JSXText = JSXText;
var JSXMemberExpression = (function (_super) {
__extends(JSXMemberExpression, _super);
function JSXMemberExpression() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = "JSXMemberExpression";
return _this;
}
return JSXMemberExpression;
}(JSNode));
exports.JSXMemberExpression = JSXMemberExpression;
var JSXNamespacedName = (function (_super) {
__extends(JSXNamespacedName, _super);
function JSXNamespacedName() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = "JSXNamespacedName";
return _this;
}
return JSXNamespacedName;
}(JSNode));
exports.JSXNamespacedName = JSXNamespacedName;
var JSXFragment = (function (_super) {
__extends(JSXFragment, _super);
function JSXFragment() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = "JSXFragment";
return _this;
}
return JSXFragment;
}(JSNode));
exports.JSXFragment = JSXFragment;
var JSXOpeningFragment = (function (_super) {
__extends(JSXOpeningFragment, _super);
function JSXOpeningFragment() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = "JSXOpeningFragment";
return _this;
}
return JSXOpeningFragment;
}(JSNode));
exports.JSXOpeningFragment = JSXOpeningFragment;
var JSXClosingFragment = (function (_super) {
__extends(JSXClosingFragment, _super);
function JSXClosingFragment() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = "JSXClosingFragment";
return _this;
}
return JSXClosingFragment;
}(JSNode));
exports.JSXClosingFragment = JSXClosingFragment;
function isValidExpression(node) {
return node
? node.type.endsWith("Expression") ||
node.type.endsWith("Literal") ||
node.type.endsWith("Identifier")
: false;
}
exports.isValidExpression = isValidExpression;
function isIdentifier(node) {
return node ? node instanceof Identifier : false;
}
exports.isIdentifier = isIdentifier;
function isValidReference(node) {
return node
? node instanceof Identifier ||
(node instanceof MemberExpression && !isOptional(node))
: false;
}
exports.isValidReference = isValidReference;
function isOptional(node) {
if (node === undefined)
return false;
if (node.optional)
return true;
else if (node.object instanceof MemberExpression) {
var obj = node;
while (obj instanceof MemberExpression) {
obj = obj.object;
if (obj.optional)
return true;
}
return false;
}
else
return false;
}
exports.isOptional = isOptional;
function isChainExpression(node) {
return node instanceof MemberExpression && isOptional(node);
}
exports.isChainExpression = isChainExpression;
function isValidParameter(node) {
return node
? node instanceof AssignmentExpression || node instanceof Identifier
: false;
}
exports.isValidParameter = isValidParameter;
function isValidForInParam(paramBody) {
return paramBody
? (paramBody.length === 1 &&
paramBody[0] instanceof ExpressionStatement &&
paramBody[0].expression instanceof BinaryExpression &&
paramBody[0].expression.operator === "in") ||
(paramBody[0] instanceof VariableDeclaration &&
paramBody[0].declarations.length === 1 &&
paramBody[0].declarations[0].in)
: false;
}
exports.isValidForInParam = isValidForInParam;
function isValidForParam(paramBody) {
var _a, _b;
return paramBody
? (paramBody.length === 3 || paramBody.length === 2) &&
paramBody.find(function (param) {
return !/ExpressionStatement|VariableDeclaration|EmptyStatement/.test(param.type);
}) === undefined &&
/ExpressionStatement|EmptyStatement/.test(paramBody[1].type) &&
/ExpressionStatement|EmptyStatement/.test((_b = (_a = paramBody[2]) === null || _a === void 0 ? void 0 : _a.type) !== null && _b !== void 0 ? _b : "EmptyStatement")
: false;
}
exports.isValidForParam = isValidForParam;
function isValidPropertyKeyStart(char) {
return ((0, utils_1.isDigit)(char) || (0, utils_1.isValidIdentifierCharacter)(char) || /"|'|\[/.test(char));
}
exports.isValidPropertyKeyStart = isValidPropertyKeyStart;