├── rustfmt.toml ├── .gitignore ├── src ├── expressions │ ├── transform_function_call.rs │ ├── transform_string.rs │ ├── transform_var.rs │ ├── transform_prefix_suffixes.rs │ ├── transform_index.rs │ ├── transform_function_args.rs │ ├── transform_if_expression.rs │ ├── transform_expression.rs │ ├── transform_unary.rs │ ├── transform_number.rs │ ├── transform_binary.rs │ ├── mod.rs │ ├── transform_call.rs │ ├── transform_function_params.rs │ ├── transform_value.rs │ └── transform_table_constructor.rs ├── types │ ├── transform_type_specifier.rs │ ├── transform_type_info.rs │ ├── mod.rs │ ├── transform_type_declaration.rs │ ├── transform_type_generic.rs │ ├── transform_table_type.rs │ └── transform_type.rs ├── statements │ ├── transform_block.rs │ ├── transform_block_statements.rs │ ├── transform_if_statement.rs │ ├── transform_local_function.rs │ ├── transform_compound_assignment.rs │ ├── mod.rs │ ├── transform_assignment.rs │ ├── transform_module_block.rs │ ├── transform_last_statement.rs │ ├── transform_statement.rs │ ├── transform_function_declaration.rs │ ├── transform_local_assignment.rs │ ├── transform_generic_for.rs │ └── transform_numeric_for.rs ├── prelude.rs ├── util │ └── mod.rs ├── roblox │ └── mod.rs └── main.rs ├── Cargo.toml ├── README.md ├── .github └── workflows │ └── ci.yml ├── LICENSE └── Cargo.lock /rustfmt.toml: -------------------------------------------------------------------------------- 1 | hard_tabs = true 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | 3 | test.rbxm 4 | test.rbxmx 5 | test.lua 6 | test.luau 7 | test.ts 8 | -------------------------------------------------------------------------------- /src/expressions/transform_function_call.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | 3 | pub fn transform_function_call(call: &lua_ast::FunctionCall) -> Box { 4 | transform_prefix_suffixes(call.prefix(), call.suffixes()) 5 | } 6 | -------------------------------------------------------------------------------- /src/types/transform_type_specifier.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | 3 | pub fn transform_type_specifier(type_specifier: &lua_ast::types::TypeSpecifier) -> Box { 4 | transform_type_info(type_specifier.type_info()) 5 | } 6 | -------------------------------------------------------------------------------- /src/statements/transform_block.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | 3 | pub fn transform_block(block: &lua_ast::Block) -> Stmt { 4 | Stmt::Block(BlockStmt { 5 | span: Default::default(), 6 | stmts: transform_block_statements(block), 7 | }) 8 | } 9 | -------------------------------------------------------------------------------- /src/types/transform_type_info.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | 3 | pub fn transform_type_info(type_info: &lua_ast::types::TypeInfo) -> Box { 4 | boxed(TsTypeAnn { 5 | span: Default::default(), 6 | type_ann: transform_type(type_info), 7 | }) 8 | } 9 | -------------------------------------------------------------------------------- /src/prelude.rs: -------------------------------------------------------------------------------- 1 | pub use full_moon::{ast as lua_ast, node, tokenizer}; 2 | 3 | pub use swc_atoms::{js_word, JsWord}; 4 | pub use swc_ecma_ast::*; 5 | 6 | pub use crate::expressions::*; 7 | pub use crate::statements::*; 8 | pub use crate::types::*; 9 | pub use crate::util::*; 10 | -------------------------------------------------------------------------------- /src/statements/transform_block_statements.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | 3 | pub fn transform_block_statements(block: &lua_ast::Block) -> Vec { 4 | let mut out: Vec = block.stmts().map(transform_statement).collect(); 5 | if let Some(stmt) = block.last_stmt() { 6 | out.push(transform_last_statement(stmt)); 7 | }; 8 | out 9 | } 10 | -------------------------------------------------------------------------------- /src/expressions/transform_string.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | 3 | pub fn transform_string(token: &tokenizer::TokenReference) -> Box { 4 | match token.token().token_type() { 5 | tokenizer::TokenType::StringLiteral { 6 | literal, 7 | multi_line: _, 8 | quote_type: _, 9 | } => boxed(Expr::Lit(Lit::Str(make_string(literal)))), 10 | _ => skip( 11 | "transform_string token was not TokenType::StringLiteral", 12 | token, 13 | ), 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/expressions/transform_var.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | 3 | pub fn transform_var(var: &lua_ast::Var) -> Box { 4 | match var { 5 | lua_ast::Var::Expression(expr) => transform_prefix_suffixes(expr.prefix(), expr.suffixes()), 6 | lua_ast::Var::Name(name) => boxed(Expr::Ident(Ident { 7 | optional: false, 8 | span: Default::default(), 9 | sym: JsWord::from(name.token().to_string()), 10 | })), 11 | _ => skip("Unknown variable variant", var), 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/types/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod transform_table_type; 2 | pub use transform_table_type::transform_table_type; 3 | pub mod transform_type_declaration; 4 | pub use transform_type_declaration::transform_type_declaration; 5 | pub mod transform_type_generic; 6 | pub use transform_type_generic::transform_type_generic; 7 | pub mod transform_type_info; 8 | pub use transform_type_info::transform_type_info; 9 | pub mod transform_type_specifier; 10 | pub use transform_type_specifier::transform_type_specifier; 11 | pub mod transform_type; 12 | pub use transform_type::transform_type; 13 | -------------------------------------------------------------------------------- /src/types/transform_type_declaration.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | 3 | pub fn transform_type_declaration(type_declaration: &lua_ast::types::TypeDeclaration) -> Stmt { 4 | Stmt::Decl(Decl::TsTypeAlias(boxed(TsTypeAliasDecl { 5 | span: Default::default(), 6 | declare: false, 7 | id: Ident { 8 | span: Default::default(), 9 | optional: false, 10 | sym: JsWord::from(type_declaration.type_name().token().to_string()), 11 | }, 12 | type_params: transform_type_generic(type_declaration.generics()), 13 | type_ann: transform_type(type_declaration.type_definition()), 14 | }))) 15 | } 16 | -------------------------------------------------------------------------------- /src/statements/transform_if_statement.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | 3 | pub fn transform_if_statement(statement: &lua_ast::If) -> Stmt { 4 | Stmt::If(IfStmt { 5 | span: Default::default(), 6 | test: transform_expression(statement.condition()), 7 | cons: boxed(transform_block(statement.block())), 8 | alt: match statement.else_if() { 9 | None => statement.else_block().map(transform_block).map(boxed), 10 | Some(else_ifs) => else_ifs.iter().rev().fold( 11 | statement.else_block().map(transform_block).map(boxed), 12 | |acc, else_if| { 13 | Some(boxed(Stmt::If(IfStmt { 14 | span: Default::default(), 15 | test: transform_expression(else_if.condition()), 16 | cons: boxed(transform_block(else_if.block())), 17 | alt: acc, 18 | }))) 19 | }, 20 | ), 21 | }, 22 | }) 23 | } 24 | -------------------------------------------------------------------------------- /src/expressions/transform_prefix_suffixes.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | 3 | pub fn transform_prefix_suffixes<'a>( 4 | prefix: &lua_ast::Prefix, 5 | suffixes: impl Iterator, 6 | ) -> Box { 7 | suffixes.fold( 8 | match prefix { 9 | lua_ast::Prefix::Name(token) => boxed(Expr::Ident(Ident { 10 | optional: false, 11 | span: Default::default(), 12 | sym: JsWord::from(token.token().to_string()), 13 | })), 14 | lua_ast::Prefix::Expression(expr) => transform_expression(expr), 15 | _ => skip("Unknown prefix variant", prefix), 16 | }, 17 | |base, suffix| match suffix { 18 | lua_ast::Suffix::Call(call) => transform_call(call, base), 19 | lua_ast::Suffix::Index(index) => transform_index(index, base), 20 | _ => skip("Unknown suffix variant", suffix), 21 | }, 22 | ) 23 | } 24 | -------------------------------------------------------------------------------- /src/expressions/transform_index.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | 3 | pub fn transform_index(index: &lua_ast::Index, base: Box) -> Box { 4 | boxed(Expr::Member(MemberExpr { 5 | span: Default::default(), 6 | obj: base, 7 | prop: match index { 8 | lua_ast::Index::Brackets { 9 | expression, 10 | brackets: _, 11 | } => MemberProp::Computed(ComputedPropName { 12 | span: Default::default(), 13 | expr: transform_expression(expression), 14 | }), 15 | lua_ast::Index::Dot { name, dot: _ } => MemberProp::Ident(Ident { 16 | span: Default::default(), 17 | optional: false, 18 | sym: JsWord::from(name.token().to_string()), 19 | }), 20 | _ => MemberProp::Computed(ComputedPropName { 21 | span: Default::default(), 22 | expr: skip("Unknown index variant", index), 23 | }), 24 | }, 25 | })) 26 | } 27 | -------------------------------------------------------------------------------- /src/expressions/transform_function_args.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | 3 | pub fn transform_function_args(args: &lua_ast::FunctionArgs) -> Vec { 4 | match args { 5 | lua_ast::FunctionArgs::Parentheses { 6 | arguments, 7 | parentheses: _, 8 | } => arguments 9 | .iter() 10 | .map(|arg| ExprOrSpread { 11 | spread: None, 12 | expr: transform_expression(arg), 13 | }) 14 | .collect(), 15 | lua_ast::FunctionArgs::String(string) => { 16 | vec![ExprOrSpread { 17 | spread: None, 18 | expr: transform_string(string), 19 | }] 20 | } 21 | lua_ast::FunctionArgs::TableConstructor(table) => vec![ExprOrSpread { 22 | spread: None, 23 | expr: transform_table_constructor(table), 24 | }], 25 | _ => vec![ExprOrSpread { 26 | spread: None, 27 | expr: skip("Unknown function args type", args), 28 | }], 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/expressions/transform_if_expression.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | 3 | pub fn transform_if_expression(expression: &lua_ast::types::IfExpression) -> Box { 4 | boxed(Expr::Cond(CondExpr { 5 | span: Default::default(), 6 | test: transform_expression(expression.condition()), 7 | cons: transform_expression(expression.if_expression()), 8 | alt: match expression.else_if_expressions() { 9 | None => parens(transform_expression(expression.else_expression())), 10 | Some(else_ifs) => else_ifs.iter().rev().fold( 11 | transform_expression(expression.else_expression()), 12 | |acc, else_if| { 13 | boxed(Expr::Cond(CondExpr { 14 | span: Default::default(), 15 | test: parens(transform_expression(else_if.condition())), 16 | cons: parens(transform_expression(else_if.expression())), 17 | alt: acc, 18 | })) 19 | }, 20 | ), 21 | }, 22 | })) 23 | } 24 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2018" 3 | name = "lua-to-ts" 4 | version = "0.1.0" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | 8 | [features] 9 | progressbar = ["console", "indicatif"] 10 | 11 | [dependencies] 12 | clap = { version = "3.2.17", features = ["derive"] } 13 | console = { version = "0.15.0", optional = true } 14 | exitcode = "1.1.2" 15 | full_moon = { version = "0.15.0", features = ["roblox"] } 16 | indicatif = { version = "0.16.2", optional = true } 17 | itertools = "0.10.3" 18 | lazy_static = "1.4.0" 19 | rbx_binary = "0.6.6" 20 | rbx_dom_weak = "2.4.0" 21 | rbx_types = "1.4.2" 22 | rbx_xml = "0.12.4" 23 | swc_atoms = "0.4.24" 24 | swc_common = "0.29.13" 25 | swc_ecma_ast = "0.94.17" 26 | swc_ecma_codegen = "0.127.29" 27 | 28 | [profile.dev.package.full_moon] 29 | # Fixes stack overflow from non-optimised recursion while parsing 30 | opt-level = 2 31 | -------------------------------------------------------------------------------- /src/statements/transform_local_function.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | 3 | pub fn transform_local_function(declaration: &lua_ast::LocalFunction) -> Stmt { 4 | Stmt::Decl(Decl::Fn(FnDecl { 5 | declare: false, 6 | ident: Ident { 7 | span: Default::default(), 8 | sym: JsWord::from(declaration.name().token().to_string()), 9 | optional: false, 10 | }, 11 | function: boxed(Function { 12 | span: Default::default(), 13 | is_async: false, 14 | is_generator: false, 15 | return_type: None, 16 | type_params: None, 17 | decorators: vec![], 18 | params: transform_function_params( 19 | declaration.body().parameters().iter(), 20 | declaration.body().type_specifiers(), 21 | ) 22 | .into_iter() 23 | .map(|param| Param { 24 | span: Default::default(), 25 | decorators: vec![], 26 | pat: param, 27 | }) 28 | .collect(), 29 | body: Some(BlockStmt { 30 | span: Default::default(), 31 | stmts: transform_block_statements(declaration.body().block()), 32 | }), 33 | }), 34 | })) 35 | } 36 | -------------------------------------------------------------------------------- /src/expressions/transform_expression.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | 3 | pub fn transform_expression(expr: &lua_ast::Expression) -> Box { 4 | match expr { 5 | lua_ast::Expression::BinaryOperator { lhs, binop, rhs } => { 6 | transform_binary_expression(binop, lhs, rhs) 7 | } 8 | lua_ast::Expression::Parentheses { 9 | contained: _, 10 | expression, 11 | } => boxed(Expr::Paren(ParenExpr { 12 | span: Default::default(), 13 | expr: transform_expression(expression), 14 | })), 15 | lua_ast::Expression::UnaryOperator { unop, expression } => { 16 | transform_unary_expression(unop, expression) 17 | } 18 | lua_ast::Expression::Value { 19 | value, 20 | type_assertion, 21 | } => { 22 | let expr = transform_value(value); 23 | if let Some(type_assertion) = type_assertion { 24 | boxed(Expr::TsAs(TsAsExpr { 25 | span: Default::default(), 26 | expr, 27 | type_ann: transform_type(type_assertion.cast_to()), 28 | })) 29 | } else { 30 | expr 31 | } 32 | } 33 | _ => skip("Unknown expression variant", expr), 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/expressions/transform_unary.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | 3 | pub fn transform_unary_expression( 4 | op: &lua_ast::UnOp, 5 | expression: &lua_ast::Expression, 6 | ) -> Box { 7 | match op { 8 | lua_ast::UnOp::Hash(_) => boxed(Expr::Call(CallExpr { 9 | span: Default::default(), 10 | args: vec![], 11 | type_args: None, 12 | callee: Callee::Expr(boxed(Expr::Member(MemberExpr { 13 | span: Default::default(), 14 | obj: transform_expression(expression), 15 | prop: MemberProp::Ident(Ident { 16 | span: Default::default(), 17 | sym: JsWord::from("size"), 18 | optional: false, 19 | }), 20 | }))), 21 | })), 22 | lua_ast::UnOp::Minus(_) => boxed(Expr::Unary(UnaryExpr { 23 | span: Default::default(), 24 | op: UnaryOp::Minus, 25 | arg: parens(transform_expression(expression)), 26 | })), 27 | lua_ast::UnOp::Not(_) => boxed(Expr::Unary(UnaryExpr { 28 | span: Default::default(), 29 | op: UnaryOp::Bang, 30 | arg: parens(transform_expression(expression)), 31 | })), 32 | _ => skip("Unknown unary operator", op), 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/expressions/transform_number.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | 3 | // Taken and adapted from StyLua under the MPL-2.0 license 4 | // https://github.com/JohnnyMorganz/StyLua/blob/7efc7cbd91a4b8235ea4e8c6b07b7028fc1534b7/src/verify_ast.rs#L129-L147 5 | pub fn transform_number(token: &tokenizer::TokenReference) -> Box { 6 | let text = match token.token_type() { 7 | tokenizer::TokenType::Number { text } => text, 8 | _ => return skip("transform_number token was not TokenType::Number", token), 9 | }; 10 | let text = text.replace('_', ""); 11 | let number = match text.as_str().parse::() { 12 | Ok(num) => num, 13 | // Try parsing as Hex (0x) 14 | Err(_) => match u64::from_str_radix(&text[2..], 16) { 15 | Ok(num) => num as f64, 16 | // Try parsing as binary (0b) 17 | Err(_) => match u64::from_str_radix(&text.as_str()[2..], 2) { 18 | Ok(num) => num as f64, 19 | // Will have been full_moon tokenizer error 20 | Err(_) => return skip("Invalid number literal", token), 21 | }, 22 | }, 23 | }; 24 | boxed(Expr::Lit(Lit::Num(Number { 25 | span: Default::default(), 26 | value: number, 27 | raw: None, 28 | }))) 29 | } 30 | -------------------------------------------------------------------------------- /src/statements/transform_compound_assignment.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | 3 | pub fn transform_compound_assignment(assignment: &lua_ast::types::CompoundAssignment) -> Stmt { 4 | Stmt::Expr(ExprStmt { 5 | span: Default::default(), 6 | expr: boxed(Expr::Assign({ 7 | AssignExpr { 8 | span: Default::default(), 9 | op: match assignment.compound_operator() { 10 | lua_ast::types::CompoundOp::PlusEqual(_) => AssignOp::AddAssign, 11 | lua_ast::types::CompoundOp::MinusEqual(_) => AssignOp::SubAssign, 12 | lua_ast::types::CompoundOp::StarEqual(_) => AssignOp::MulAssign, 13 | lua_ast::types::CompoundOp::SlashEqual(_) => AssignOp::DivAssign, 14 | lua_ast::types::CompoundOp::PercentEqual(_) => AssignOp::ModAssign, 15 | lua_ast::types::CompoundOp::CaretEqual(_) => AssignOp::ExpAssign, 16 | lua_ast::types::CompoundOp::TwoDotsEqual(_) => AssignOp::AddAssign, 17 | _ => { 18 | return skip_stmt( 19 | "Unknown compound assignment operator", 20 | assignment.compound_operator(), 21 | ) 22 | } 23 | }, 24 | left: PatOrExpr::Expr(transform_var(assignment.lhs())), 25 | right: transform_expression(assignment.rhs()), 26 | } 27 | })), 28 | }) 29 | } 30 | -------------------------------------------------------------------------------- /src/expressions/transform_binary.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | 3 | pub fn transform_binary_expression( 4 | op: &lua_ast::BinOp, 5 | lhs: &lua_ast::Expression, 6 | rhs: &lua_ast::Expression, 7 | ) -> Box { 8 | boxed(Expr::Bin(BinExpr { 9 | span: Default::default(), 10 | op: match op { 11 | lua_ast::BinOp::And(_) => BinaryOp::LogicalAnd, 12 | lua_ast::BinOp::Caret(_) => BinaryOp::Exp, 13 | lua_ast::BinOp::GreaterThan(_) => BinaryOp::Gt, 14 | lua_ast::BinOp::GreaterThanEqual(_) => BinaryOp::GtEq, 15 | lua_ast::BinOp::LessThan(_) => BinaryOp::Lt, 16 | lua_ast::BinOp::LessThanEqual(_) => BinaryOp::LtEq, 17 | lua_ast::BinOp::Minus(_) => BinaryOp::Sub, 18 | lua_ast::BinOp::Or(_) => BinaryOp::LogicalOr, 19 | lua_ast::BinOp::Percent(_) => BinaryOp::Mod, 20 | lua_ast::BinOp::Plus(_) => BinaryOp::Add, 21 | lua_ast::BinOp::Slash(_) => BinaryOp::Div, 22 | lua_ast::BinOp::Star(_) => BinaryOp::Mul, 23 | lua_ast::BinOp::TildeEqual(_) => BinaryOp::NotEqEq, 24 | lua_ast::BinOp::TwoDots(_) => BinaryOp::Add, 25 | lua_ast::BinOp::TwoEqual(_) => BinaryOp::EqEqEq, 26 | _ => return skip("Unknown binary operator", op), 27 | }, 28 | left: parens(transform_expression(lhs)), 29 | right: parens(transform_expression(rhs)), 30 | })) 31 | } 32 | -------------------------------------------------------------------------------- /src/statements/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod transform_assignment; 2 | pub use transform_assignment::transform_assignment; 3 | pub mod transform_block; 4 | pub use transform_block::transform_block; 5 | pub mod transform_block_statements; 6 | pub use transform_block_statements::transform_block_statements; 7 | pub mod transform_compound_assignment; 8 | pub use transform_compound_assignment::transform_compound_assignment; 9 | pub mod transform_function_declaration; 10 | pub use transform_function_declaration::transform_function_declaration; 11 | pub mod transform_generic_for; 12 | pub use transform_generic_for::transform_generic_for; 13 | pub mod transform_if_statement; 14 | pub use transform_if_statement::transform_if_statement; 15 | pub mod transform_last_statement; 16 | pub use transform_last_statement::transform_last_statement; 17 | pub mod transform_local_assignment; 18 | pub use transform_local_assignment::transform_local_assignment; 19 | pub mod transform_local_function; 20 | pub use transform_local_function::transform_local_function; 21 | pub mod transform_module_block; 22 | pub use transform_module_block::transform_module_block; 23 | pub mod transform_numeric_for; 24 | pub use transform_numeric_for::transform_numeric_for; 25 | pub mod transform_statement; 26 | pub use transform_statement::transform_statement; 27 | -------------------------------------------------------------------------------- /src/expressions/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod transform_binary; 2 | pub use transform_binary::transform_binary_expression; 3 | pub mod transform_call; 4 | pub use transform_call::transform_call; 5 | pub mod transform_expression; 6 | pub use transform_expression::transform_expression; 7 | pub mod transform_function_args; 8 | pub use transform_function_args::transform_function_args; 9 | pub mod transform_function_call; 10 | pub use transform_function_call::transform_function_call; 11 | pub mod transform_function_params; 12 | pub use transform_function_params::transform_function_params; 13 | pub mod transform_if_expression; 14 | pub use transform_if_expression::transform_if_expression; 15 | pub mod transform_index; 16 | pub use transform_index::transform_index; 17 | pub mod transform_number; 18 | pub use transform_number::transform_number; 19 | pub mod transform_prefix_suffixes; 20 | pub use transform_prefix_suffixes::transform_prefix_suffixes; 21 | pub mod transform_string; 22 | pub use transform_string::transform_string; 23 | pub mod transform_table_constructor; 24 | pub use transform_table_constructor::transform_table_constructor; 25 | pub mod transform_unary; 26 | pub use transform_unary::transform_unary_expression; 27 | pub mod transform_value; 28 | pub use transform_value::transform_value; 29 | pub mod transform_var; 30 | pub use transform_var::transform_var; 31 | -------------------------------------------------------------------------------- /src/statements/transform_assignment.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | 3 | pub fn transform_assignment(assignment: &lua_ast::Assignment) -> Stmt { 4 | Stmt::Expr(ExprStmt { 5 | span: Default::default(), 6 | expr: boxed(Expr::Assign({ 7 | let names = assignment.variables(); 8 | let expressions = assignment.expressions(); 9 | AssignExpr { 10 | span: Default::default(), 11 | op: AssignOp::Assign, 12 | left: if names.len() == 1 { 13 | PatOrExpr::Expr(transform_var(names.iter().next().unwrap())) 14 | } else { 15 | PatOrExpr::Pat(boxed(Pat::Array(ArrayPat { 16 | span: Default::default(), 17 | optional: false, 18 | type_ann: None, 19 | elems: names 20 | .iter() 21 | .map(|name| Some(Pat::Expr(transform_var(name)))) 22 | .collect(), 23 | }))) 24 | }, 25 | right: { 26 | if expressions.len() != 1 { 27 | boxed(Expr::Array(ArrayLit { 28 | span: Default::default(), 29 | elems: expressions 30 | .iter() 31 | .map(|exp| { 32 | Some(ExprOrSpread { 33 | spread: None, 34 | expr: transform_expression(exp), 35 | }) 36 | }) 37 | .collect(), 38 | })) 39 | } else { 40 | transform_expression(expressions.iter().next().unwrap()) 41 | } 42 | }, 43 | } 44 | })), 45 | }) 46 | } 47 | -------------------------------------------------------------------------------- /src/expressions/transform_call.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | 3 | pub fn transform_call(call: &lua_ast::Call, base: Box) -> Box { 4 | let (result, args) = match call { 5 | lua_ast::Call::MethodCall(method_call) => ( 6 | boxed(Expr::Member(MemberExpr { 7 | span: Default::default(), 8 | obj: base, 9 | prop: MemberProp::Ident(Ident { 10 | span: Default::default(), 11 | optional: false, 12 | sym: JsWord::from(method_call.name().token().to_string()), 13 | }), 14 | })), 15 | transform_function_args(method_call.args()), 16 | ), 17 | lua_ast::Call::AnonymousCall(args) => { 18 | if let Expr::Member(MemberExpr { 19 | prop: MemberProp::Ident(Ident { 20 | sym: js_word!("new"), 21 | .. 22 | }), 23 | obj, 24 | span: _, 25 | }) = *base 26 | { 27 | return boxed(Expr::New(NewExpr { 28 | span: Default::default(), 29 | callee: obj, 30 | args: Some(transform_function_args(args)), 31 | type_args: None, 32 | })); 33 | } 34 | (base, transform_function_args(args)) 35 | } 36 | _ => ( 37 | base, 38 | vec![ExprOrSpread { 39 | spread: None, 40 | expr: skip("Unknown call type", call), 41 | }], 42 | ), 43 | }; 44 | boxed(Expr::Call(CallExpr { 45 | span: Default::default(), 46 | type_args: None, 47 | callee: Callee::Expr(result), 48 | args, 49 | })) 50 | } 51 | -------------------------------------------------------------------------------- /src/statements/transform_module_block.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | 3 | pub fn transform_module_block(block: &lua_ast::Block) -> Vec { 4 | let mut out: Vec = block 5 | .stmts() 6 | .flat_map(|stmt| { 7 | if let lua_ast::Stmt::ExportedTypeDeclaration(declaration) = stmt { 8 | vec![ 9 | ModuleItem::Stmt(transform_type_declaration(declaration.type_declaration())), 10 | ModuleItem::ModuleDecl(ModuleDecl::ExportNamed(NamedExport { 11 | asserts: None, 12 | src: None, 13 | type_only: true, 14 | span: Default::default(), 15 | specifiers: vec![ExportSpecifier::Named(ExportNamedSpecifier { 16 | span: Default::default(), 17 | is_type_only: true, 18 | exported: None, 19 | orig: ModuleExportName::Ident(Ident { 20 | span: Default::default(), 21 | optional: false, 22 | sym: JsWord::from( 23 | declaration.type_declaration().type_name().to_string(), 24 | ), 25 | }), 26 | })], 27 | })), 28 | ] 29 | } else { 30 | vec![ModuleItem::Stmt(transform_statement(stmt))] 31 | } 32 | }) 33 | .collect(); 34 | if let Some(lua_ast::LastStmt::Return(return_statement)) = block.last_stmt() { 35 | out.push(ModuleItem::ModuleDecl(ModuleDecl::ExportDefaultExpr( 36 | ExportDefaultExpr { 37 | span: Default::default(), 38 | expr: transform_expression(return_statement.returns().iter().next().unwrap()), 39 | }, 40 | ))); 41 | }; 42 | out 43 | } 44 | -------------------------------------------------------------------------------- /src/types/transform_type_generic.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | 3 | fn skipped_type_name() -> Ident { 4 | Ident { 5 | span: Default::default(), 6 | optional: false, 7 | sym: JsWord::from("FailedToTransformType"), 8 | } 9 | } 10 | 11 | fn transform_type_generic_name( 12 | generic: &lua_ast::types::GenericParameterInfo, 13 | ) -> (Ident, Option>) { 14 | match generic { 15 | lua_ast::types::GenericParameterInfo::Name(token) => ( 16 | Ident { 17 | span: Default::default(), 18 | optional: false, 19 | sym: JsWord::from(token.token().to_string()), 20 | }, 21 | None, 22 | ), 23 | lua_ast::types::GenericParameterInfo::Variadic { .. } => ( 24 | skipped_type_name(), 25 | Some(skip_type("variadic type generic not supported", generic)), 26 | ), 27 | _ => ( 28 | skipped_type_name(), 29 | Some(skip_type("unknown type generic kind", generic)), 30 | ), 31 | } 32 | } 33 | 34 | pub fn transform_type_generic( 35 | generic: Option<&lua_ast::types::GenericDeclaration>, 36 | ) -> Option> { 37 | generic.map(|generic| { 38 | boxed(TsTypeParamDecl { 39 | span: Default::default(), 40 | params: generic 41 | .generics() 42 | .iter() 43 | .map(|generic| { 44 | let (name, constraint) = transform_type_generic_name(generic.parameter()); 45 | TsTypeParam { 46 | span: Default::default(), 47 | is_in: false, 48 | is_out: false, 49 | name, 50 | constraint, 51 | default: generic.default_type().map(transform_type), 52 | } 53 | }) 54 | .collect(), 55 | }) 56 | }) 57 | } 58 | -------------------------------------------------------------------------------- /src/types/transform_table_type.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | 3 | pub fn transform_table_type( 4 | fields: &lua_ast::punctuated::Punctuated, 5 | ) -> Box { 6 | boxed(TsType::TsTypeLit(TsTypeLit { 7 | span: Default::default(), 8 | members: fields 9 | .iter() 10 | .map(|field| match field.key() { 11 | lua_ast::types::TypeFieldKey::Name(token) => { 12 | TsTypeElement::TsPropertySignature(TsPropertySignature { 13 | span: Default::default(), 14 | readonly: false, 15 | key: boxed(Expr::Ident(Ident { 16 | span: Default::default(), 17 | optional: false, 18 | sym: JsWord::from(token.token().to_string()), 19 | })), 20 | computed: false, 21 | optional: matches!( 22 | field.value(), 23 | lua_ast::types::TypeInfo::Optional { .. } 24 | ), 25 | init: None, 26 | params: vec![], 27 | type_ann: Some(transform_type_info(field.value())), 28 | type_params: None, 29 | }) 30 | } 31 | lua_ast::types::TypeFieldKey::IndexSignature { inner, brackets: _ } => { 32 | TsTypeElement::TsIndexSignature(TsIndexSignature { 33 | span: Default::default(), 34 | readonly: false, 35 | is_static: false, 36 | params: vec![TsFnParam::Ident(BindingIdent { 37 | id: Ident { 38 | span: Default::default(), 39 | optional: false, 40 | sym: JsWord::from("_"), 41 | }, 42 | type_ann: Some(transform_type_info(inner)), 43 | })], 44 | type_ann: Some(transform_type_info(field.value())), 45 | }) 46 | } 47 | _ => unimplemented!("Unknown TypeFieldKey kind"), 48 | }) 49 | .collect(), 50 | })) 51 | } 52 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # lua-to-ts 2 | 3 | This tool converts Lua code to TS automatically, including the conversion of common standards to their TS equivalents. 4 | Code that fails to be converted will be transformed into a call to `error` with some information regarding the reason it failed. 5 | 6 | ### Known issues and pitfalls 7 | - swc_ecma_codegen, the tool used for outputting TypeScript, does not format much. The output may look ugly. Just run prettier. 8 | - Lua truthiness is not converted! You should run roblox-ts with the `--logTruthyChanges` option and fix anything it points out. 9 | - Arrow functions (generated from anonymous functions in Lua) do not render their return types. This seems to be a bug with swc's emitter, see swc-project/swc#4305. 10 | - The text inside "failed to convert" error calls may currently be wrong due to a [full_moon bug](https://github.com/Kampfkarren/full-moon/issues/161) 11 | - All variable declarations are `let`, regardless of redeclarations. Use eslint's `prefer-const` rule. 12 | - Type annotations from `for a: number in b do` are preserved, but disallowed by TS. They do parse correctly, but throw an error. Generally, these are unnecessary and can just be removed, but they are transformed for the sake of completeness. 13 | - Indexing a constructor but not calling it, like `Vector3.new`, will not work after transformation. TS has no compatible concept for this. You can remove the alias, or replace it with a function that calls `new X()` with the correct arguments. 14 | - Lua multiple assignments, like `a, b = 1, 2`, will transform to `[a, b] = [1, 2]`. This might look ugly, but is necessary to retain the correct execution order. 15 | 16 | ### Unsupported features 17 | - For loops with multiple expressions (`for _ in a, b do`) 18 | - Numeric for loops with a non-literal step argument (`for i = 1, 10, a do`) 19 | -------------------------------------------------------------------------------- /src/statements/transform_last_statement.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | 3 | pub fn transform_last_statement(stmt: &lua_ast::LastStmt) -> Stmt { 4 | match stmt { 5 | lua_ast::LastStmt::Break(_) => Stmt::Break(BreakStmt { 6 | span: Default::default(), 7 | label: None, 8 | }), 9 | lua_ast::LastStmt::Continue(_) => Stmt::Continue(ContinueStmt { 10 | span: Default::default(), 11 | label: None, 12 | }), 13 | lua_ast::LastStmt::Return(return_statement) => Stmt::Return(ReturnStmt { 14 | span: Default::default(), 15 | arg: { 16 | let returns = return_statement.returns(); 17 | match returns.len() { 18 | 0 => None, 19 | 1 => Some(transform_expression(returns.iter().next().unwrap())), 20 | _ => Some(boxed(Expr::TsAs(TsAsExpr { 21 | span: Default::default(), 22 | expr: boxed(Expr::Array(ArrayLit { 23 | span: Default::default(), 24 | elems: returns 25 | .iter() 26 | .map(transform_expression) 27 | .map(|expr| ExprOrSpread { spread: None, expr }) 28 | .map(Some) 29 | .collect(), 30 | })), 31 | type_ann: boxed(TsType::TsTypeRef(TsTypeRef { 32 | span: Default::default(), 33 | type_name: TsEntityName::Ident(Ident { 34 | span: Default::default(), 35 | optional: false, 36 | sym: JsWord::from("LuaTuple"), 37 | }), 38 | type_params: Some(boxed(TsTypeParamInstantiation { 39 | span: Default::default(), 40 | params: vec![boxed(TsType::TsTupleType(TsTupleType { 41 | span: Default::default(), 42 | elem_types: vec![TsTupleElement { 43 | span: Default::default(), 44 | label: None, 45 | ty: skip_type("Can't infer return types", return_statement), 46 | }], 47 | }))], 48 | })), 49 | })), 50 | }))), 51 | } 52 | }, 53 | }), 54 | _ => skip_stmt("Unknown last statement type", stmt), 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/util/mod.rs: -------------------------------------------------------------------------------- 1 | pub use crate::prelude::*; 2 | 3 | pub fn boxed(arg: T) -> Box { 4 | Box::new(arg) 5 | } 6 | 7 | pub fn make_string(content: &str) -> Str { 8 | Str { 9 | span: Default::default(), 10 | value: JsWord::from(content), 11 | raw: None, 12 | } 13 | } 14 | 15 | pub fn ident(name: String) -> Ident { 16 | Ident { 17 | span: Default::default(), 18 | optional: false, 19 | sym: JsWord::from(name), 20 | } 21 | } 22 | 23 | pub fn parens(expr: Box) -> Box { 24 | boxed(Expr::Paren(ParenExpr { 25 | span: Default::default(), 26 | expr, 27 | })) 28 | } 29 | 30 | fn get_fail_string(reason: &str, node: &(impl node::Node + std::fmt::Debug + ToString)) -> Str { 31 | #[cfg(debug)] 32 | eprintln!("{}: {:#?}", reason, node); 33 | make_string(&format!( 34 | "[lua-to-ts] Failed to transform: `{}` because: {}", 35 | node.to_string().trim(), 36 | reason 37 | )) 38 | } 39 | 40 | pub fn skip(reason: &str, node: &(impl node::Node + std::fmt::Debug + ToString)) -> Box { 41 | boxed(Expr::Call(CallExpr { 42 | span: Default::default(), 43 | type_args: Default::default(), 44 | args: vec![ExprOrSpread { 45 | spread: None, 46 | expr: boxed(Expr::Lit(Lit::Str(get_fail_string(reason, node)))), 47 | }], 48 | callee: Callee::Expr(boxed(Expr::Ident(Ident { 49 | span: Default::default(), 50 | sym: JsWord::from("error"), 51 | optional: false, 52 | }))), 53 | })) 54 | } 55 | 56 | pub fn skip_stmt(reason: &str, node: &(impl node::Node + std::fmt::Debug + ToString)) -> Stmt { 57 | Stmt::Expr(ExprStmt { 58 | span: Default::default(), 59 | expr: skip(reason, node), 60 | }) 61 | } 62 | 63 | pub fn skip_type( 64 | reason: &str, 65 | node: &(impl node::Node + std::fmt::Debug + ToString), 66 | ) -> Box { 67 | boxed(TsType::TsLitType(TsLitType { 68 | span: Default::default(), 69 | lit: TsLit::Str(get_fail_string(reason, node)), 70 | })) 71 | } 72 | 73 | pub const REST_ARGS_NAME: &str = "_args"; 74 | -------------------------------------------------------------------------------- /src/statements/transform_statement.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | 3 | pub fn transform_statement(stmt: &lua_ast::Stmt) -> Stmt { 4 | match stmt { 5 | lua_ast::Stmt::Assignment(assignment) => transform_assignment(assignment), 6 | lua_ast::Stmt::Do(do_stmt) => transform_block(do_stmt.block()), 7 | lua_ast::Stmt::FunctionCall(function_call) => Stmt::Expr(ExprStmt { 8 | span: Default::default(), 9 | expr: transform_function_call(function_call), 10 | }), 11 | lua_ast::Stmt::FunctionDeclaration(declaration) => { 12 | transform_function_declaration(declaration) 13 | } 14 | lua_ast::Stmt::GenericFor(generic_for) => transform_generic_for(generic_for), 15 | lua_ast::Stmt::If(if_stmt) => transform_if_statement(if_stmt), 16 | lua_ast::Stmt::LocalAssignment(local_assignment) => { 17 | transform_local_assignment(local_assignment) 18 | } 19 | lua_ast::Stmt::LocalFunction(declaration) => transform_local_function(declaration), 20 | lua_ast::Stmt::NumericFor(numeric_for) => transform_numeric_for(numeric_for), 21 | lua_ast::Stmt::Repeat(repeat) => Stmt::DoWhile(DoWhileStmt { 22 | span: Default::default(), 23 | body: boxed(transform_block(repeat.block())), 24 | test: boxed(Expr::Unary(UnaryExpr { 25 | span: Default::default(), 26 | op: UnaryOp::Bang, 27 | arg: transform_expression(repeat.until()), 28 | })), 29 | }), 30 | lua_ast::Stmt::While(while_stmt) => Stmt::While(WhileStmt { 31 | span: Default::default(), 32 | test: transform_expression(while_stmt.condition()), 33 | body: boxed(transform_block(while_stmt.block())), 34 | }), 35 | lua_ast::Stmt::CompoundAssignment(compound_assignment) => { 36 | transform_compound_assignment(compound_assignment) 37 | } 38 | lua_ast::Stmt::ExportedTypeDeclaration(declaration) => skip_stmt( 39 | "Exported type declaration only allowed as top-level", 40 | declaration, 41 | ), 42 | lua_ast::Stmt::TypeDeclaration(declaration) => transform_type_declaration(declaration), 43 | _ => skip_stmt("Unknown statement type", stmt), 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | on: 2 | pull_request: 3 | push: 4 | branches: [master] 5 | 6 | name: Continuous integration 7 | 8 | jobs: 9 | check: 10 | name: Check 11 | runs-on: ubuntu-latest 12 | steps: 13 | - uses: actions/checkout@v2 14 | - uses: actions-rs/toolchain@v1 15 | with: 16 | profile: minimal 17 | toolchain: stable 18 | override: true 19 | - uses: actions-rs/cargo@v1 20 | with: 21 | command: check 22 | 23 | build: 24 | needs: check 25 | name: Build 26 | runs-on: ubuntu-latest 27 | steps: 28 | - uses: actions/checkout@v2 29 | - uses: actions-rs/toolchain@v1 30 | with: 31 | profile: minimal 32 | toolchain: stable 33 | override: true 34 | - uses: actions-rs/cargo@v1 35 | with: 36 | command: build 37 | args: --locked 38 | 39 | test: 40 | needs: build 41 | name: Test Suite 42 | runs-on: ubuntu-latest 43 | steps: 44 | - uses: actions/checkout@v2 45 | - uses: actions-rs/toolchain@v1 46 | with: 47 | profile: minimal 48 | toolchain: stable 49 | override: true 50 | - uses: actions-rs/cargo@v1 51 | with: 52 | command: test 53 | 54 | fmt: 55 | name: Rustfmt 56 | runs-on: ubuntu-latest 57 | steps: 58 | - uses: actions/checkout@v2 59 | - uses: actions-rs/toolchain@v1 60 | with: 61 | profile: minimal 62 | toolchain: stable 63 | override: true 64 | - run: rustup component add rustfmt 65 | - uses: actions-rs/cargo@v1 66 | with: 67 | command: fmt 68 | args: --all -- --check 69 | 70 | clippy: 71 | needs: check 72 | name: Clippy 73 | runs-on: ubuntu-latest 74 | steps: 75 | - uses: actions/checkout@v2 76 | - uses: actions-rs/toolchain@v1 77 | with: 78 | profile: minimal 79 | toolchain: stable 80 | override: true 81 | - run: rustup component add clippy 82 | - uses: actions-rs/cargo@v1 83 | with: 84 | command: clippy 85 | args: -- -D warnings 86 | -------------------------------------------------------------------------------- /src/expressions/transform_function_params.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | 3 | fn skip_double_rest(param: &lua_ast::Parameter) -> Pat { 4 | Pat::Expr(skip( 5 | &format!( 6 | "Double use of `{}` or ... in function parameters", 7 | REST_ARGS_NAME 8 | ), 9 | param, 10 | )) 11 | } 12 | 13 | pub fn transform_function_params<'a>( 14 | params: impl Iterator, 15 | mut type_specifiers: impl Iterator>, 16 | ) -> Vec { 17 | let mut has_args_or_ellipse = false; 18 | params 19 | .map(|param| { 20 | let type_specifier = type_specifiers.next().flatten(); 21 | match param { 22 | lua_ast::Parameter::Name(name) => Pat::Ident(BindingIdent { 23 | id: Ident { 24 | span: Default::default(), 25 | sym: JsWord::from({ 26 | let name = name.token().to_string(); 27 | if name == REST_ARGS_NAME { 28 | if has_args_or_ellipse { 29 | return skip_double_rest(param); 30 | } else { 31 | has_args_or_ellipse = true; 32 | }; 33 | } 34 | name 35 | }), 36 | optional: false, 37 | }, 38 | type_ann: type_specifier.map(transform_type_specifier), 39 | }), 40 | lua_ast::Parameter::Ellipse(_) => { 41 | if has_args_or_ellipse { 42 | return skip_double_rest(param); 43 | } else { 44 | has_args_or_ellipse = true; 45 | }; 46 | Pat::Rest(RestPat { 47 | span: Default::default(), 48 | dot3_token: Default::default(), 49 | type_ann: type_specifier.map(|t| { 50 | boxed(TsTypeAnn { 51 | span: Default::default(), 52 | // Luau rest param is the individual type 53 | // TS requires array of individual type 54 | type_ann: boxed(TsType::TsArrayType(TsArrayType { 55 | span: Default::default(), 56 | elem_type: transform_type(t.type_info()), 57 | })), 58 | }) 59 | }), 60 | arg: boxed(Pat::Ident(BindingIdent { 61 | // type_ann already done above 62 | type_ann: None, 63 | id: Ident { 64 | span: Default::default(), 65 | sym: JsWord::from(REST_ARGS_NAME), 66 | optional: false, 67 | }, 68 | })), 69 | }) 70 | } 71 | _ => Pat::Expr(skip("Unknown parameter type", param)), 72 | } 73 | }) 74 | .collect() 75 | } 76 | -------------------------------------------------------------------------------- /src/statements/transform_function_declaration.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | 3 | fn transform_function_name(name: &lua_ast::FunctionName) -> Expr { 4 | let mut iter = name.names().iter(); 5 | let mut result = Expr::Ident(Ident { 6 | span: Default::default(), 7 | sym: JsWord::from(iter.next().unwrap().token().to_string()), 8 | optional: false, 9 | }); 10 | for token in iter { 11 | result = Expr::Member(MemberExpr { 12 | span: Default::default(), 13 | obj: boxed(result), 14 | prop: MemberProp::Ident(Ident { 15 | span: Default::default(), 16 | sym: JsWord::from(token.token().to_string()), 17 | optional: false, 18 | }), 19 | }); 20 | } 21 | if let Some(token) = name.method_name() { 22 | result = Expr::Member(MemberExpr { 23 | span: Default::default(), 24 | obj: boxed(result), 25 | prop: MemberProp::Ident(Ident { 26 | span: Default::default(), 27 | sym: JsWord::from(token.token().to_string()), 28 | optional: false, 29 | }), 30 | }); 31 | } 32 | result 33 | } 34 | 35 | pub fn transform_function_declaration(declaration: &lua_ast::FunctionDeclaration) -> Stmt { 36 | let function = boxed(Function { 37 | span: Default::default(), 38 | is_async: false, 39 | is_generator: false, 40 | return_type: declaration 41 | .body() 42 | .return_type() 43 | .map(transform_type_specifier), 44 | type_params: transform_type_generic(declaration.body().generics()), 45 | decorators: vec![], 46 | params: transform_function_params( 47 | declaration.body().parameters().iter(), 48 | declaration.body().type_specifiers(), 49 | ) 50 | .into_iter() 51 | .map(|param| Param { 52 | span: Default::default(), 53 | decorators: vec![], 54 | pat: param, 55 | }) 56 | .collect(), 57 | body: Some(BlockStmt { 58 | span: Default::default(), 59 | stmts: transform_block_statements(declaration.body().block()), 60 | }), 61 | }); 62 | 63 | let name = transform_function_name(declaration.name()); 64 | if let Expr::Ident(ident) = name { 65 | Stmt::Decl(Decl::Fn(FnDecl { 66 | declare: false, 67 | function, 68 | ident, 69 | })) 70 | } else { 71 | Stmt::Expr(ExprStmt { 72 | span: Default::default(), 73 | expr: boxed(Expr::Assign(AssignExpr { 74 | span: Default::default(), 75 | left: PatOrExpr::Expr(boxed(name)), 76 | op: AssignOp::Assign, 77 | right: boxed(Expr::Fn(FnExpr { 78 | ident: None, 79 | function, 80 | })), 81 | })), 82 | }) 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /src/statements/transform_local_assignment.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | 3 | pub fn transform_local_assignment(local_assignment: &lua_ast::LocalAssignment) -> Stmt { 4 | Stmt::Decl(Decl::Var(boxed(VarDecl { 5 | span: Default::default(), 6 | declare: false, 7 | kind: VarDeclKind::Let, 8 | decls: { 9 | let names = local_assignment.names(); 10 | let expressions = local_assignment.expressions(); 11 | let mut type_specifiers = local_assignment.type_specifiers(); 12 | if local_assignment.equal_token().is_some() { 13 | vec![VarDeclarator { 14 | span: Default::default(), 15 | definite: false, 16 | name: if names.len() == 1 { 17 | Pat::Ident(BindingIdent { 18 | type_ann: type_specifiers 19 | .next() 20 | .flatten() 21 | .map(transform_type_specifier), 22 | id: Ident::new( 23 | JsWord::from(names.iter().next().unwrap().token().to_string()), 24 | Default::default(), 25 | ), 26 | }) 27 | } else { 28 | Pat::Array(ArrayPat { 29 | span: Default::default(), 30 | optional: false, 31 | type_ann: None, 32 | elems: names 33 | .iter() 34 | .map(|name| { 35 | Some(Pat::Ident(BindingIdent { 36 | type_ann: type_specifiers 37 | .next() 38 | .flatten() 39 | .map(transform_type_specifier), 40 | id: Ident::new( 41 | JsWord::from(name.token().to_string()), 42 | Default::default(), 43 | ), 44 | })) 45 | }) 46 | .collect(), 47 | }) 48 | }, 49 | init: { 50 | if expressions.len() != 1 { 51 | Some(boxed(Expr::Array(ArrayLit { 52 | span: Default::default(), 53 | elems: expressions 54 | .iter() 55 | .map(|exp| { 56 | Some(ExprOrSpread { 57 | spread: None, 58 | expr: transform_expression(exp), 59 | }) 60 | }) 61 | .collect(), 62 | }))) 63 | } else { 64 | expressions.iter().next().map(transform_expression) 65 | } 66 | }, 67 | }] 68 | } else { 69 | names 70 | .iter() 71 | .map(|name| VarDeclarator { 72 | span: Default::default(), 73 | init: None, 74 | definite: false, 75 | name: Pat::Ident(BindingIdent { 76 | type_ann: local_assignment 77 | .type_specifiers() 78 | .next() 79 | .flatten() 80 | .map(transform_type_specifier), 81 | id: Ident::new( 82 | JsWord::from(name.token().to_string()), 83 | Default::default(), 84 | ), 85 | }), 86 | }) 87 | .collect() 88 | } 89 | }, 90 | }))) 91 | } 92 | -------------------------------------------------------------------------------- /src/statements/transform_generic_for.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | 3 | pub fn transform_generic_for(generic_for: &lua_ast::GenericFor) -> Stmt { 4 | let expression = generic_for.expressions(); 5 | if expression.len() != 1 { 6 | return skip_stmt( 7 | "For-in loops with multiple expressions not supported", 8 | generic_for, 9 | ); 10 | } 11 | Stmt::ForOf(ForOfStmt { 12 | span: Default::default(), 13 | await_token: None, 14 | left: VarDeclOrPat::VarDecl(boxed(VarDecl { 15 | span: Default::default(), 16 | kind: VarDeclKind::Let, 17 | declare: false, 18 | decls: vec![VarDeclarator { 19 | span: Default::default(), 20 | init: None, 21 | definite: false, 22 | name: Pat::Array(ArrayPat { 23 | span: Default::default(), 24 | optional: false, 25 | type_ann: { 26 | if generic_for 27 | .type_specifiers() 28 | .any(|type_specifier| type_specifier.is_some()) 29 | { 30 | Some(boxed(TsTypeAnn { 31 | span: Default::default(), 32 | type_ann: boxed(TsType::TsTupleType(TsTupleType { 33 | span: Default::default(), 34 | elem_types: generic_for 35 | .type_specifiers() 36 | .enumerate() 37 | .map(|(i, type_specifier)| TsTupleElement { 38 | span: Default::default(), 39 | label: generic_for 40 | .names() 41 | .iter() 42 | .nth(i) 43 | .map(|name| Ident { 44 | span: Default::default(), 45 | optional: false, 46 | sym: JsWord::from(name.token().to_string()), 47 | }) 48 | .map(BindingIdent::from) 49 | .map(Pat::Ident), 50 | ty: type_specifier 51 | .map(|type_specifier| { 52 | transform_type(type_specifier.type_info()) 53 | }) 54 | .unwrap_or_else(|| { 55 | boxed(TsType::TsKeywordType(TsKeywordType { 56 | span: Default::default(), 57 | kind: TsKeywordTypeKind::TsAnyKeyword, 58 | })) 59 | }), 60 | }) 61 | .collect(), 62 | })), 63 | })) 64 | } else { 65 | None 66 | } 67 | }, 68 | elems: generic_for 69 | .names() 70 | .iter() 71 | .map(|name| Ident { 72 | span: Default::default(), 73 | optional: false, 74 | sym: JsWord::from(name.token().to_string()), 75 | }) 76 | .map(BindingIdent::from) 77 | .map(Pat::Ident) 78 | .map(Some) 79 | .collect(), 80 | }), 81 | }], 82 | })), 83 | right: transform_expression(expression.iter().next().unwrap()), 84 | body: boxed(transform_block(generic_for.block())), 85 | }) 86 | } 87 | -------------------------------------------------------------------------------- /src/statements/transform_numeric_for.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | 3 | pub fn transform_numeric_for(numeric_for: &lua_ast::NumericFor) -> Stmt { 4 | let op = if let Some(expr) = numeric_for.step() { 5 | if let lua_ast::Expression::Value { 6 | value, 7 | type_assertion: _, 8 | } = expr 9 | { 10 | if let lua_ast::Value::Number(_) = **value { 11 | Some(BinaryOp::LtEq) 12 | } else { 13 | None 14 | } 15 | } else if let lua_ast::Expression::UnaryOperator { 16 | unop: lua_ast::UnOp::Minus(_), 17 | expression, 18 | } = expr 19 | { 20 | if let lua_ast::Expression::Value { 21 | ref value, 22 | type_assertion: _, 23 | } = **expression 24 | { 25 | if let lua_ast::Value::Number(_) = **value { 26 | Some(BinaryOp::GtEq) 27 | } else { 28 | None 29 | } 30 | } else { 31 | None 32 | } 33 | } else { 34 | None 35 | } 36 | } else { 37 | Some(BinaryOp::LtEq) 38 | }; 39 | if op.is_none() { 40 | return skip_stmt( 41 | "Numeric for loops with non-literal step are not supported", 42 | numeric_for, 43 | ); 44 | }; 45 | Stmt::For(ForStmt { 46 | span: Default::default(), 47 | init: Some(VarDeclOrExpr::VarDecl(boxed(VarDecl { 48 | span: Default::default(), 49 | kind: VarDeclKind::Let, 50 | declare: false, 51 | decls: vec![VarDeclarator { 52 | span: Default::default(), 53 | init: Some(transform_expression(numeric_for.start())), 54 | definite: false, 55 | name: Pat::Ident(BindingIdent { 56 | type_ann: numeric_for.type_specifier().map(transform_type_specifier), 57 | id: Ident { 58 | span: Default::default(), 59 | optional: false, 60 | sym: JsWord::from(numeric_for.index_variable().token().to_string()), 61 | }, 62 | }), 63 | }], 64 | }))), 65 | test: Some(boxed(Expr::Bin(BinExpr { 66 | span: Default::default(), 67 | left: boxed(Expr::Ident(Ident { 68 | span: Default::default(), 69 | optional: false, 70 | sym: JsWord::from(numeric_for.index_variable().token().to_string()), 71 | })), 72 | op: op.unwrap(), 73 | right: transform_expression(numeric_for.end()), 74 | }))), 75 | update: Some(boxed(Expr::Assign(AssignExpr { 76 | span: Default::default(), 77 | left: PatOrExpr::Expr(boxed(Expr::Ident(Ident { 78 | span: Default::default(), 79 | optional: false, 80 | sym: JsWord::from(numeric_for.index_variable().token().to_string()), 81 | }))), 82 | op: AssignOp::AddAssign, 83 | right: numeric_for 84 | .step() 85 | .map(transform_expression) 86 | .unwrap_or_else(|| { 87 | boxed(Expr::Lit(Lit::Num(Number { 88 | span: Default::default(), 89 | value: 1.0, 90 | raw: None, 91 | }))) 92 | }), 93 | }))), 94 | body: boxed(transform_block(numeric_for.block())), 95 | }) 96 | } 97 | -------------------------------------------------------------------------------- /src/expressions/transform_value.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | 3 | pub fn transform_value(value: &lua_ast::Value) -> Box { 4 | match value { 5 | lua_ast::Value::Function((_, body)) => boxed(Expr::Arrow(ArrowExpr { 6 | span: Default::default(), 7 | is_async: false, 8 | is_generator: false, 9 | return_type: body.return_type().map(transform_type_specifier), 10 | type_params: transform_type_generic(body.generics()), 11 | params: transform_function_params(body.parameters().iter(), body.type_specifiers()), 12 | body: BlockStmtOrExpr::BlockStmt(BlockStmt { 13 | span: Default::default(), 14 | stmts: transform_block_statements(body.block()), 15 | }), 16 | })), 17 | lua_ast::Value::FunctionCall(call) => transform_function_call(call), 18 | lua_ast::Value::IfExpression(if_expression) => transform_if_expression(if_expression), 19 | lua_ast::Value::TableConstructor(table_constructor) => { 20 | transform_table_constructor(table_constructor) 21 | } 22 | lua_ast::Value::Number(number) => transform_number(number), 23 | // `expr` will also be wrapped in Expression::Parentheses 24 | lua_ast::Value::ParenthesesExpression(expr) => transform_expression(expr), 25 | lua_ast::Value::String(number) => transform_string(number), 26 | lua_ast::Value::Symbol(token) 27 | if matches!( 28 | token.token().token_type(), 29 | tokenizer::TokenType::Symbol { 30 | symbol: tokenizer::Symbol::Nil 31 | } 32 | ) => 33 | { 34 | boxed(Expr::Ident(Ident { 35 | span: Default::default(), 36 | sym: JsWord::from("undefined"), 37 | optional: false, 38 | })) 39 | } 40 | lua_ast::Value::Symbol(token) 41 | if matches!( 42 | token.token().token_type(), 43 | tokenizer::TokenType::Symbol { 44 | symbol: tokenizer::Symbol::True 45 | } 46 | ) => 47 | { 48 | boxed(Expr::Lit(Lit::Bool(Bool { 49 | span: Default::default(), 50 | value: true, 51 | }))) 52 | } 53 | lua_ast::Value::Symbol(token) 54 | if matches!( 55 | token.token().token_type(), 56 | tokenizer::TokenType::Symbol { 57 | symbol: tokenizer::Symbol::False 58 | } 59 | ) => 60 | { 61 | boxed(Expr::Lit(Lit::Bool(Bool { 62 | span: Default::default(), 63 | value: false, 64 | }))) 65 | } 66 | lua_ast::Value::Symbol(token) 67 | if matches!( 68 | token.token().token_type(), 69 | tokenizer::TokenType::Symbol { 70 | symbol: tokenizer::Symbol::Ellipse 71 | } 72 | ) => 73 | { 74 | // Use ident hack because can't use ExprOrSpread 75 | boxed(Expr::Ident(Ident { 76 | span: Default::default(), 77 | optional: false, 78 | sym: JsWord::from(format!("...{}", REST_ARGS_NAME)), 79 | })) 80 | } 81 | lua_ast::Value::Var(var) => transform_var(var), 82 | _ => skip("Unknown value variant", value), 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /src/roblox/mod.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | use itertools::Itertools; 3 | use rbx_dom_weak::*; 4 | use rbx_types::Ref; 5 | 6 | fn refs_to_sorted_instances<'a>( 7 | dom: &WeakDom, 8 | iter: impl Iterator, 9 | ) -> impl Iterator { 10 | iter.map(|&r| dom.get_by_ref(r).unwrap()) 11 | .unique_by(|c| &c.name) 12 | .sorted_by(|a, b| Ord::cmp(&a.name, &b.name)) 13 | } 14 | 15 | fn transform_children(dom: &WeakDom, children: &[Ref]) -> Vec { 16 | refs_to_sorted_instances(dom, children.iter()) 17 | .map(|child| transform_instance(dom, child)) 18 | .collect() 19 | } 20 | 21 | fn transform_instance(dom: &WeakDom, instance: &Instance) -> TsTypeElement { 22 | TsTypeElement::TsPropertySignature(TsPropertySignature { 23 | span: Default::default(), 24 | readonly: false, 25 | key: boxed(Expr::Ident(ident(instance.name.clone()))), 26 | computed: false, 27 | optional: false, 28 | type_params: None, 29 | type_ann: Some(boxed(TsTypeAnn { 30 | span: Default::default(), 31 | type_ann: boxed({ 32 | let class_type = TsType::TsTypeRef(TsTypeRef { 33 | span: Default::default(), 34 | type_name: TsEntityName::Ident(ident(instance.class.clone())), 35 | type_params: None, 36 | }); 37 | let children = instance.children(); 38 | if !children.is_empty() { 39 | TsType::TsUnionOrIntersectionType( 40 | TsUnionOrIntersectionType::TsIntersectionType(TsIntersectionType { 41 | span: Default::default(), 42 | types: vec![ 43 | boxed(class_type), 44 | boxed(TsType::TsTypeLit(TsTypeLit { 45 | span: Default::default(), 46 | members: transform_children(dom, instance.children()), 47 | })), 48 | ], 49 | }), 50 | ) 51 | } else { 52 | class_type 53 | } 54 | }), 55 | })), 56 | init: None, 57 | params: vec![], 58 | }) 59 | } 60 | 61 | pub fn transform_dom(dom: WeakDom) -> Vec { 62 | refs_to_sorted_instances(&dom, dom.root().children().iter()) 63 | .map(|instance| { 64 | ModuleItem::ModuleDecl(ModuleDecl::ExportDecl(ExportDecl { 65 | span: Default::default(), 66 | decl: Decl::TsInterface(boxed(TsInterfaceDecl { 67 | span: Default::default(), 68 | id: Ident { 69 | span: Default::default(), 70 | optional: false, 71 | sym: JsWord::from(instance.name.clone()), 72 | }, 73 | declare: false, 74 | type_params: None, 75 | extends: vec![TsExprWithTypeArgs { 76 | span: Default::default(), 77 | expr: boxed(Expr::Ident(ident(instance.class.clone()))), 78 | type_args: None, 79 | }], 80 | body: TsInterfaceBody { 81 | span: Default::default(), 82 | body: transform_children(&dom, instance.children()), 83 | }, 84 | })), 85 | })) 86 | }) 87 | .collect() 88 | } 89 | -------------------------------------------------------------------------------- /src/expressions/transform_table_constructor.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | 3 | fn get_unpack_data(original_expression: &lua_ast::Expression) -> (Option<()>, Box) { 4 | let default = || (None, transform_expression(original_expression)); 5 | let value = match original_expression { 6 | lua_ast::Expression::Value { 7 | value, 8 | type_assertion: _, 9 | } => value, 10 | _ => return default(), 11 | }; 12 | let function_call = match **value { 13 | lua_ast::Value::FunctionCall(ref function_call) => function_call, 14 | _ => return default(), 15 | }; 16 | let token = match function_call.prefix() { 17 | lua_ast::Prefix::Name(token) => token, 18 | _ => return default(), 19 | }; 20 | let call = if token.token().to_string() == "unpack" { 21 | function_call.suffixes().next().unwrap() 22 | } else { 23 | return default(); 24 | }; 25 | let function_args = match call { 26 | lua_ast::Suffix::Call(lua_ast::Call::AnonymousCall(function_args)) => function_args, 27 | _ => unreachable!(), 28 | }; 29 | // unpack only ever has one argument 30 | let arg = transform_function_args(function_args).remove(0); 31 | (Some(()), arg.expr) 32 | } 33 | 34 | pub fn transform_table_constructor(args: &lua_ast::TableConstructor) -> Box { 35 | let is_array = args 36 | .fields() 37 | .iter() 38 | .all(|field| matches!(field, lua_ast::Field::NoKey(_))); 39 | boxed(if is_array { 40 | Expr::Array(ArrayLit { 41 | span: Default::default(), 42 | elems: args 43 | .fields() 44 | .iter() 45 | .map(|field| { 46 | if let lua_ast::Field::NoKey(original_expression) = field { 47 | // Detect usage of `unpack` in table constructor 48 | // This needs to convert to the `...` spread operator in TS 49 | let (spread, expr) = get_unpack_data(original_expression); 50 | Some(ExprOrSpread { 51 | spread: spread.map(|()| Default::default()), 52 | expr, 53 | }) 54 | } else { 55 | unreachable!() 56 | } 57 | }) 58 | .collect(), 59 | }) 60 | } else { 61 | Expr::Object(ObjectLit { 62 | span: Default::default(), 63 | props: args 64 | .fields() 65 | .iter() 66 | .map(|field| { 67 | PropOrSpread::Prop(boxed(Prop::KeyValue(match field { 68 | lua_ast::Field::NameKey { 69 | key, 70 | value, 71 | equal: _, 72 | } => KeyValueProp { 73 | // Not PropName::Ident because Luau has different ident validity rules 74 | key: PropName::Str(make_string(&key.token().to_string())), 75 | value: transform_expression(value), 76 | }, 77 | lua_ast::Field::ExpressionKey { 78 | key, 79 | value, 80 | equal: _, 81 | brackets: _, 82 | } => KeyValueProp { 83 | key: PropName::Computed(ComputedPropName { 84 | span: Default::default(), 85 | expr: transform_expression(key), 86 | }), 87 | value: transform_expression(value), 88 | }, 89 | lua_ast::Field::NoKey(value) => KeyValueProp { 90 | key: PropName::Num(Number::from( 91 | args.fields() 92 | .iter() 93 | .filter(|f| matches!(f, lua_ast::Field::NoKey(_))) 94 | .position(|f| f == field) 95 | // unwrap: field will always be NoKey and thus found in iterator 96 | // +1: Luau tables start indexing at 1 97 | .unwrap() + 1, 98 | )), 99 | value: transform_expression(value), 100 | }, 101 | _ => KeyValueProp { 102 | key: PropName::Ident(Ident { 103 | optional: false, 104 | span: Default::default(), 105 | sym: JsWord::from("UnknownTableField"), 106 | }), 107 | value: skip("Unknown Field kind", field), 108 | }, 109 | }))) 110 | }) 111 | .collect(), 112 | }) 113 | }) 114 | } 115 | -------------------------------------------------------------------------------- /src/main.rs: -------------------------------------------------------------------------------- 1 | mod expressions; 2 | mod statements; 3 | mod types; 4 | mod util; 5 | 6 | mod roblox; 7 | use roblox::transform_dom; 8 | 9 | mod prelude; 10 | use crate::prelude::*; 11 | 12 | #[cfg(feature = "progressbar")] 13 | use console::style; 14 | #[cfg(feature = "progressbar")] 15 | use indicatif::{ProgressBar, ProgressStyle}; 16 | #[cfg(feature = "progressbar")] 17 | use lazy_static::lazy_static; 18 | #[cfg(feature = "progressbar")] 19 | use std::convert::TryInto; 20 | 21 | use std::{ 22 | fs::{read_to_string, File, OpenOptions}, 23 | io::{BufReader, Write}, 24 | path::Path, 25 | process, 26 | }; 27 | use swc_common::{sync::Lrc, SourceMap}; 28 | use swc_ecma_codegen::{text_writer::JsWriter, Emitter}; 29 | 30 | #[cfg(feature = "progressbar")] 31 | lazy_static! { 32 | static ref PROGRESS_BAR_STYLE: ProgressStyle = ProgressStyle::default_bar() 33 | .template( 34 | "{spinner:.cyan} [{elapsed:.dim}] {msg}... [{bar:40.cyan/blue}] ({pos}/{len}, ETA {eta})\n{prefix}", 35 | ) 36 | .tick_strings(&["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"]) 37 | .progress_chars("=>-"); 38 | 39 | static ref SPINNER_STYLE_RUNNING: ProgressStyle = ProgressStyle::default_spinner() 40 | .tick_strings(&["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"]) 41 | .template("{spinner:.cyan} [{elapsed:.dim}] {msg}..."); 42 | 43 | static ref SPINNER_STYLE_WAITING: ProgressStyle = ProgressStyle::default_spinner() 44 | .tick_strings(&[". ", ".. ", "...", " "]) 45 | .template("{spinner:.cyan} {msg}"); 46 | 47 | static ref SPINNER_STYLE_FINISHED: ProgressStyle = ProgressStyle::default_spinner() 48 | .template(format!("{} {{msg:.dim}}", style("✔").green()).as_str()); 49 | 50 | static ref SPINNER_STYLE_FAILED: ProgressStyle = ProgressStyle::default_spinner() 51 | .template(format!("{} {{msg:.dim}}", style("❌").red()).as_str()); 52 | } 53 | 54 | use clap::Parser; 55 | 56 | #[derive(Parser)] 57 | struct Cli { 58 | #[clap(required = true)] 59 | files: Vec, 60 | #[clap(long)] 61 | overwrite: bool, 62 | } 63 | 64 | #[allow(clippy::large_enum_variant)] 65 | enum TransformFile { 66 | Lua(lua_ast::Ast), 67 | Model(rbx_dom_weak::WeakDom), 68 | } 69 | 70 | impl TransformFile { 71 | fn from(filename: &str) -> Result { 72 | match Path::new(filename) 73 | .extension() 74 | .and_then(std::ffi::OsStr::to_str) 75 | { 76 | Some("lua" | "luau") => match full_moon::parse( 77 | &read_to_string(filename) 78 | .map_err(|err| format!("Error while opening `{}`: {}", filename, err))?, 79 | ) { 80 | Err(err) => Err(format!("Error while parsing `{}`: {}", filename, err))?, 81 | Ok(ast) => Ok(TransformFile::Lua(ast)), 82 | }, 83 | Some("rbxm") => match rbx_binary::from_reader(BufReader::new( 84 | File::open(filename) 85 | .map_err(|err| format!("Error while opening `{}`: {}", filename, err))?, 86 | )) { 87 | Err(err) => Err(format!("Error while parsing `{}`: {}", filename, err))?, 88 | Ok(ast) => Ok(TransformFile::Model(ast)), 89 | }, 90 | Some("rbxmx") => { 91 | match rbx_xml::from_reader_default(BufReader::new( 92 | File::open(filename) 93 | .map_err(|err| format!("Error while opening `{}`: {}", filename, err))?, 94 | )) { 95 | Err(err) => Err(format!("Error while parsing `{}`: {}", filename, err))?, 96 | Ok(ast) => Ok(TransformFile::Model(ast)), 97 | } 98 | } 99 | _ => Err(format!("Could not detect file kind of `{}`", filename)), 100 | } 101 | } 102 | fn transform(self) -> Vec { 103 | match self { 104 | TransformFile::Lua(ast) => transform_module_block(ast.nodes()), 105 | TransformFile::Model(dom) => transform_dom(dom), 106 | } 107 | } 108 | } 109 | 110 | fn process_files(args: Cli) -> i32 { 111 | let mut failure_messages = vec![]; 112 | let mut exit_code = exitcode::OK; 113 | 114 | #[cfg(feature = "progressbar")] 115 | let pb = ProgressBar::new(args.files.len().try_into().unwrap()); 116 | #[cfg(feature = "progressbar")] 117 | pb.set_style(PROGRESS_BAR_STYLE.clone()); 118 | #[cfg(feature = "progressbar")] 119 | let mut i = 0; 120 | 121 | for filename in args.files { 122 | #[cfg(feature = "progressbar")] 123 | { 124 | i += 1; 125 | pb.set_position(i); 126 | } 127 | 128 | #[cfg(feature = "progressbar")] 129 | pb.set_message(format!("Parsing {}", filename)); 130 | let ast = match TransformFile::from(&filename) { 131 | Err(err) => { 132 | exit_code = exitcode::DATAERR; 133 | failure_messages.push(err); 134 | continue; 135 | } 136 | Ok(ast) => ast, 137 | }; 138 | 139 | #[cfg(feature = "progressbar")] 140 | pb.set_message(format!("Transforming {}", filename)); 141 | let body = ast.transform(); 142 | 143 | #[cfg(feature = "progressbar")] 144 | pb.set_message(format!("Emitting {}", filename)); 145 | let cm = Lrc::new(SourceMap::default()); 146 | let code = { 147 | let mut buf = vec![]; 148 | 149 | { 150 | let mut emitter = Emitter { 151 | cfg: swc_ecma_codegen::Config { 152 | ..Default::default() 153 | }, 154 | cm: cm.clone(), 155 | comments: None, 156 | wr: JsWriter::new(cm.clone(), "\n", &mut buf, None), 157 | }; 158 | 159 | emitter 160 | .emit_module(&Module { 161 | body, 162 | span: Default::default(), 163 | shebang: None, 164 | }) 165 | .unwrap(); 166 | } 167 | 168 | String::from_utf8_lossy(&buf).to_string() 169 | }; 170 | 171 | #[cfg(feature = "progressbar")] 172 | pb.set_message(format!("Writing {}", filename)); 173 | let target = Path::new(&filename).with_extension("ts"); 174 | let file = OpenOptions::new() 175 | .write(true) 176 | .truncate(true) 177 | .create_new(!args.overwrite) 178 | .open(&target); 179 | 180 | // Handle common error cases gracefully 181 | let mut file = match file { 182 | Err(err) if err.kind() == std::io::ErrorKind::AlreadyExists => { 183 | exit_code = exitcode::CANTCREAT; 184 | failure_messages.push(format!( 185 | "Refusing to overwrite `{}`", 186 | target.to_string_lossy() 187 | )); 188 | continue; 189 | } 190 | Err(err) => { 191 | exit_code = exitcode::CANTCREAT; 192 | failure_messages.push(format!( 193 | "Error while opening file handle for `{}`: {:?}", 194 | target.to_string_lossy(), 195 | err 196 | )); 197 | continue; 198 | } 199 | Ok(file) => file, 200 | }; 201 | 202 | if let Err(err) = file.write_all(code.as_bytes()) { 203 | exit_code = exitcode::IOERR; 204 | failure_messages.push(format!( 205 | "Error while writing `{}`: {:?}", 206 | target.to_string_lossy(), 207 | err 208 | )); 209 | continue; 210 | }; 211 | } 212 | #[cfg(feature = "progressbar")] 213 | { 214 | pb.set_style(SPINNER_STYLE_FINISHED.clone()); 215 | pb.finish_with_message("Processed files"); 216 | } 217 | 218 | if !failure_messages.is_empty() { 219 | println!("{}", failure_messages.join("\n")); 220 | } 221 | 222 | exit_code 223 | } 224 | 225 | fn main() { 226 | process::exit(process_files(Cli::parse())); 227 | } 228 | -------------------------------------------------------------------------------- /src/types/transform_type.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | 3 | pub fn transform_type(type_info: &lua_ast::types::TypeInfo) -> Box { 4 | match type_info { 5 | lua_ast::types::TypeInfo::Array { 6 | type_info, 7 | braces: _, 8 | } => boxed(TsType::TsArrayType(TsArrayType { 9 | span: Default::default(), 10 | elem_type: transform_type(type_info), 11 | })), 12 | lua_ast::types::TypeInfo::Basic(token) => boxed(TsType::TsTypeRef(TsTypeRef { 13 | span: Default::default(), 14 | type_params: None, 15 | type_name: TsEntityName::Ident(Ident { 16 | span: Default::default(), 17 | optional: false, 18 | sym: JsWord::from(token.token().to_string()), 19 | }), 20 | })), 21 | lua_ast::types::TypeInfo::String(token) => boxed(TsType::TsLitType(TsLitType { 22 | span: Default::default(), 23 | lit: TsLit::Str(make_string(&token.token().to_string())), 24 | })), 25 | lua_ast::types::TypeInfo::Boolean(token) => boxed(TsType::TsLitType(TsLitType { 26 | span: Default::default(), 27 | lit: TsLit::Bool(Bool { 28 | span: Default::default(), 29 | value: token.token().to_string() == "true", 30 | }), 31 | })), 32 | lua_ast::types::TypeInfo::Callback { 33 | generics, 34 | arguments, 35 | return_type, 36 | parentheses: _, 37 | arrow: _, 38 | } => boxed(TsType::TsFnOrConstructorType( 39 | TsFnOrConstructorType::TsFnType(TsFnType { 40 | span: Default::default(), 41 | type_params: transform_type_generic(generics.as_ref()), 42 | params: arguments 43 | .iter() 44 | .map(|argument| { 45 | TsFnParam::Ident(BindingIdent { 46 | id: Ident { 47 | span: Default::default(), 48 | optional: false, 49 | sym: JsWord::from( 50 | argument 51 | .name() 52 | .map(|name| name.0.token().to_string()) 53 | .as_deref() 54 | .unwrap_or("_"), 55 | ), 56 | }, 57 | type_ann: Some(transform_type_info(argument.type_info())), 58 | }) 59 | }) 60 | .collect(), 61 | type_ann: boxed(TsTypeAnn { 62 | span: Default::default(), 63 | type_ann: transform_type(return_type), 64 | }), 65 | }), 66 | )), 67 | lua_ast::types::TypeInfo::Generic { 68 | base, 69 | generics, 70 | arrows: _, 71 | } => boxed(TsType::TsTypeRef(TsTypeRef { 72 | span: Default::default(), 73 | type_params: Some(boxed(TsTypeParamInstantiation { 74 | span: Default::default(), 75 | params: generics.iter().map(transform_type).collect(), 76 | })), 77 | type_name: TsEntityName::Ident(Ident { 78 | span: Default::default(), 79 | optional: false, 80 | sym: JsWord::from(base.token().to_string()), 81 | }), 82 | })), 83 | lua_ast::types::TypeInfo::GenericPack { 84 | name: _, 85 | ellipse: _, 86 | } => skip_type("TS does not allow variadic type arguments", type_info), 87 | lua_ast::types::TypeInfo::Intersection { 88 | left, 89 | right, 90 | ampersand: _, 91 | } => boxed(TsType::TsUnionOrIntersectionType( 92 | TsUnionOrIntersectionType::TsIntersectionType(TsIntersectionType { 93 | span: Default::default(), 94 | types: vec![transform_type(left), transform_type(right)], 95 | }), 96 | )), 97 | lua_ast::types::TypeInfo::Module { 98 | module, 99 | type_info, 100 | punctuation: _, 101 | } => boxed(TsType::TsTypeRef(TsTypeRef { 102 | span: Default::default(), 103 | type_name: TsEntityName::TsQualifiedName(boxed(TsQualifiedName { 104 | left: TsEntityName::Ident(Ident { 105 | span: Default::default(), 106 | optional: false, 107 | sym: JsWord::from(module.token().to_string()), 108 | }), 109 | right: Ident { 110 | span: Default::default(), 111 | optional: false, 112 | sym: JsWord::from(match **type_info { 113 | lua_ast::types::IndexedTypeInfo::Basic(ref token) => { 114 | token.token().to_string() 115 | } 116 | lua_ast::types::IndexedTypeInfo::Generic { 117 | ref base, 118 | arrows: _, 119 | generics: _, 120 | } => base.token().to_string(), 121 | _ => unimplemented!("Unknown IndexedTypeInfo kind"), 122 | }), 123 | }, 124 | })), 125 | type_params: match **type_info { 126 | lua_ast::types::IndexedTypeInfo::Basic(_) => None, 127 | lua_ast::types::IndexedTypeInfo::Generic { 128 | base: _, 129 | arrows: _, 130 | ref generics, 131 | } => Some(boxed(TsTypeParamInstantiation { 132 | span: Default::default(), 133 | params: generics.iter().map(transform_type).collect(), 134 | })), 135 | _ => unreachable!("Already panicked for unknown IndexedTypeInfo above"), 136 | }, 137 | })), 138 | lua_ast::types::TypeInfo::Optional { 139 | base, 140 | question_mark: _, 141 | } => boxed(TsType::TsUnionOrIntersectionType( 142 | TsUnionOrIntersectionType::TsUnionType(TsUnionType { 143 | span: Default::default(), 144 | types: vec![ 145 | transform_type(base), 146 | boxed(TsType::TsKeywordType(TsKeywordType { 147 | span: Default::default(), 148 | kind: TsKeywordTypeKind::TsUndefinedKeyword, 149 | })), 150 | ], 151 | }), 152 | )), 153 | lua_ast::types::TypeInfo::Table { fields, braces: _ } => transform_table_type(fields), 154 | lua_ast::types::TypeInfo::Typeof { 155 | inner: _, 156 | typeof_token: _, 157 | parentheses: _, 158 | } => skip_type("TS has no functional equivalent of Luau typeof", type_info), 159 | lua_ast::types::TypeInfo::Tuple { 160 | types, 161 | parentheses: _, 162 | } => { 163 | if types.len() == 1 { 164 | boxed(TsType::TsParenthesizedType(TsParenthesizedType { 165 | span: Default::default(), 166 | type_ann: transform_type(types.iter().next().unwrap()), 167 | })) 168 | } else { 169 | boxed(TsType::TsTypeRef(TsTypeRef { 170 | span: Default::default(), 171 | type_name: TsEntityName::Ident(Ident { 172 | span: Default::default(), 173 | optional: false, 174 | sym: JsWord::from("LuaTuple"), 175 | }), 176 | type_params: Some(boxed(TsTypeParamInstantiation { 177 | span: Default::default(), 178 | params: vec![boxed(TsType::TsTupleType(TsTupleType { 179 | span: Default::default(), 180 | elem_types: types 181 | .iter() 182 | .map(|type_info| TsTupleElement { 183 | span: Default::default(), 184 | label: None, 185 | ty: match type_info { 186 | lua_ast::types::TypeInfo::Variadic { 187 | type_info, 188 | ellipse: _, 189 | } => boxed(TsType::TsRestType(TsRestType { 190 | span: Default::default(), 191 | type_ann: boxed(TsType::TsArrayType(TsArrayType { 192 | span: Default::default(), 193 | elem_type: transform_type(type_info), 194 | })), 195 | })), 196 | _ => transform_type(type_info), 197 | }, 198 | }) 199 | .collect(), 200 | }))], 201 | })), 202 | })) 203 | } 204 | } 205 | lua_ast::types::TypeInfo::Union { 206 | left, 207 | right, 208 | pipe: _, 209 | } => boxed(TsType::TsUnionOrIntersectionType( 210 | TsUnionOrIntersectionType::TsUnionType(TsUnionType { 211 | span: Default::default(), 212 | types: vec![transform_type(left), transform_type(right)], 213 | }), 214 | )), 215 | lua_ast::types::TypeInfo::Variadic { 216 | type_info, 217 | ellipse: _, 218 | } => boxed(TsType::TsTypeRef(TsTypeRef { 219 | span: Default::default(), 220 | type_name: TsEntityName::Ident(Ident { 221 | span: Default::default(), 222 | optional: false, 223 | sym: JsWord::from("LuaTuple"), 224 | }), 225 | type_params: Some(boxed(TsTypeParamInstantiation { 226 | span: Default::default(), 227 | params: vec![boxed(TsType::TsArrayType(TsArrayType { 228 | span: Default::default(), 229 | elem_type: transform_type(type_info), 230 | }))], 231 | })), 232 | })), 233 | lua_ast::types::TypeInfo::VariadicPack { 234 | name: _, 235 | ellipse: _, 236 | } => skip_type("TS does not allow variadic type arguments", type_info), 237 | _ => skip_type("Unknown TypeInfo kind", type_info), 238 | } 239 | } 240 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Mozilla Public License Version 2.0 2 | ================================== 3 | 4 | 1. Definitions 5 | -------------- 6 | 7 | 1.1. "Contributor" 8 | means each individual or legal entity that creates, contributes to 9 | the creation of, or owns Covered Software. 10 | 11 | 1.2. "Contributor Version" 12 | means the combination of the Contributions of others (if any) used 13 | by a Contributor and that particular Contributor's Contribution. 14 | 15 | 1.3. "Contribution" 16 | means Covered Software of a particular Contributor. 17 | 18 | 1.4. "Covered Software" 19 | means Source Code Form to which the initial Contributor has attached 20 | the notice in Exhibit A, the Executable Form of such Source Code 21 | Form, and Modifications of such Source Code Form, in each case 22 | including portions thereof. 23 | 24 | 1.5. "Incompatible With Secondary Licenses" 25 | means 26 | 27 | (a) that the initial Contributor has attached the notice described 28 | in Exhibit B to the Covered Software; or 29 | 30 | (b) that the Covered Software was made available under the terms of 31 | version 1.1 or earlier of the License, but not also under the 32 | terms of a Secondary License. 33 | 34 | 1.6. "Executable Form" 35 | means any form of the work other than Source Code Form. 36 | 37 | 1.7. "Larger Work" 38 | means a work that combines Covered Software with other material, in 39 | a separate file or files, that is not Covered Software. 40 | 41 | 1.8. "License" 42 | means this document. 43 | 44 | 1.9. "Licensable" 45 | means having the right to grant, to the maximum extent possible, 46 | whether at the time of the initial grant or subsequently, any and 47 | all of the rights conveyed by this License. 48 | 49 | 1.10. "Modifications" 50 | means any of the following: 51 | 52 | (a) any file in Source Code Form that results from an addition to, 53 | deletion from, or modification of the contents of Covered 54 | Software; or 55 | 56 | (b) any new file in Source Code Form that contains any Covered 57 | Software. 58 | 59 | 1.11. "Patent Claims" of a Contributor 60 | means any patent claim(s), including without limitation, method, 61 | process, and apparatus claims, in any patent Licensable by such 62 | Contributor that would be infringed, but for the grant of the 63 | License, by the making, using, selling, offering for sale, having 64 | made, import, or transfer of either its Contributions or its 65 | Contributor Version. 66 | 67 | 1.12. "Secondary License" 68 | means either the GNU General Public License, Version 2.0, the GNU 69 | Lesser General Public License, Version 2.1, the GNU Affero General 70 | Public License, Version 3.0, or any later versions of those 71 | licenses. 72 | 73 | 1.13. "Source Code Form" 74 | means the form of the work preferred for making modifications. 75 | 76 | 1.14. "You" (or "Your") 77 | means an individual or a legal entity exercising rights under this 78 | License. For legal entities, "You" includes any entity that 79 | controls, is controlled by, or is under common control with You. For 80 | purposes of this definition, "control" means (a) the power, direct 81 | or indirect, to cause the direction or management of such entity, 82 | whether by contract or otherwise, or (b) ownership of more than 83 | fifty percent (50%) of the outstanding shares or beneficial 84 | ownership of such entity. 85 | 86 | 2. License Grants and Conditions 87 | -------------------------------- 88 | 89 | 2.1. Grants 90 | 91 | Each Contributor hereby grants You a world-wide, royalty-free, 92 | non-exclusive license: 93 | 94 | (a) under intellectual property rights (other than patent or trademark) 95 | Licensable by such Contributor to use, reproduce, make available, 96 | modify, display, perform, distribute, and otherwise exploit its 97 | Contributions, either on an unmodified basis, with Modifications, or 98 | as part of a Larger Work; and 99 | 100 | (b) under Patent Claims of such Contributor to make, use, sell, offer 101 | for sale, have made, import, and otherwise transfer either its 102 | Contributions or its Contributor Version. 103 | 104 | 2.2. Effective Date 105 | 106 | The licenses granted in Section 2.1 with respect to any Contribution 107 | become effective for each Contribution on the date the Contributor first 108 | distributes such Contribution. 109 | 110 | 2.3. Limitations on Grant Scope 111 | 112 | The licenses granted in this Section 2 are the only rights granted under 113 | this License. No additional rights or licenses will be implied from the 114 | distribution or licensing of Covered Software under this License. 115 | Notwithstanding Section 2.1(b) above, no patent license is granted by a 116 | Contributor: 117 | 118 | (a) for any code that a Contributor has removed from Covered Software; 119 | or 120 | 121 | (b) for infringements caused by: (i) Your and any other third party's 122 | modifications of Covered Software, or (ii) the combination of its 123 | Contributions with other software (except as part of its Contributor 124 | Version); or 125 | 126 | (c) under Patent Claims infringed by Covered Software in the absence of 127 | its Contributions. 128 | 129 | This License does not grant any rights in the trademarks, service marks, 130 | or logos of any Contributor (except as may be necessary to comply with 131 | the notice requirements in Section 3.4). 132 | 133 | 2.4. Subsequent Licenses 134 | 135 | No Contributor makes additional grants as a result of Your choice to 136 | distribute the Covered Software under a subsequent version of this 137 | License (see Section 10.2) or under the terms of a Secondary License (if 138 | permitted under the terms of Section 3.3). 139 | 140 | 2.5. Representation 141 | 142 | Each Contributor represents that the Contributor believes its 143 | Contributions are its original creation(s) or it has sufficient rights 144 | to grant the rights to its Contributions conveyed by this License. 145 | 146 | 2.6. Fair Use 147 | 148 | This License is not intended to limit any rights You have under 149 | applicable copyright doctrines of fair use, fair dealing, or other 150 | equivalents. 151 | 152 | 2.7. Conditions 153 | 154 | Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted 155 | in Section 2.1. 156 | 157 | 3. Responsibilities 158 | ------------------- 159 | 160 | 3.1. Distribution of Source Form 161 | 162 | All distribution of Covered Software in Source Code Form, including any 163 | Modifications that You create or to which You contribute, must be under 164 | the terms of this License. You must inform recipients that the Source 165 | Code Form of the Covered Software is governed by the terms of this 166 | License, and how they can obtain a copy of this License. You may not 167 | attempt to alter or restrict the recipients' rights in the Source Code 168 | Form. 169 | 170 | 3.2. Distribution of Executable Form 171 | 172 | If You distribute Covered Software in Executable Form then: 173 | 174 | (a) such Covered Software must also be made available in Source Code 175 | Form, as described in Section 3.1, and You must inform recipients of 176 | the Executable Form how they can obtain a copy of such Source Code 177 | Form by reasonable means in a timely manner, at a charge no more 178 | than the cost of distribution to the recipient; and 179 | 180 | (b) You may distribute such Executable Form under the terms of this 181 | License, or sublicense it under different terms, provided that the 182 | license for the Executable Form does not attempt to limit or alter 183 | the recipients' rights in the Source Code Form under this License. 184 | 185 | 3.3. Distribution of a Larger Work 186 | 187 | You may create and distribute a Larger Work under terms of Your choice, 188 | provided that You also comply with the requirements of this License for 189 | the Covered Software. If the Larger Work is a combination of Covered 190 | Software with a work governed by one or more Secondary Licenses, and the 191 | Covered Software is not Incompatible With Secondary Licenses, this 192 | License permits You to additionally distribute such Covered Software 193 | under the terms of such Secondary License(s), so that the recipient of 194 | the Larger Work may, at their option, further distribute the Covered 195 | Software under the terms of either this License or such Secondary 196 | License(s). 197 | 198 | 3.4. Notices 199 | 200 | You may not remove or alter the substance of any license notices 201 | (including copyright notices, patent notices, disclaimers of warranty, 202 | or limitations of liability) contained within the Source Code Form of 203 | the Covered Software, except that You may alter any license notices to 204 | the extent required to remedy known factual inaccuracies. 205 | 206 | 3.5. Application of Additional Terms 207 | 208 | You may choose to offer, and to charge a fee for, warranty, support, 209 | indemnity or liability obligations to one or more recipients of Covered 210 | Software. However, You may do so only on Your own behalf, and not on 211 | behalf of any Contributor. You must make it absolutely clear that any 212 | such warranty, support, indemnity, or liability obligation is offered by 213 | You alone, and You hereby agree to indemnify every Contributor for any 214 | liability incurred by such Contributor as a result of warranty, support, 215 | indemnity or liability terms You offer. You may include additional 216 | disclaimers of warranty and limitations of liability specific to any 217 | jurisdiction. 218 | 219 | 4. Inability to Comply Due to Statute or Regulation 220 | --------------------------------------------------- 221 | 222 | If it is impossible for You to comply with any of the terms of this 223 | License with respect to some or all of the Covered Software due to 224 | statute, judicial order, or regulation then You must: (a) comply with 225 | the terms of this License to the maximum extent possible; and (b) 226 | describe the limitations and the code they affect. Such description must 227 | be placed in a text file included with all distributions of the Covered 228 | Software under this License. Except to the extent prohibited by statute 229 | or regulation, such description must be sufficiently detailed for a 230 | recipient of ordinary skill to be able to understand it. 231 | 232 | 5. Termination 233 | -------------- 234 | 235 | 5.1. The rights granted under this License will terminate automatically 236 | if You fail to comply with any of its terms. However, if You become 237 | compliant, then the rights granted under this License from a particular 238 | Contributor are reinstated (a) provisionally, unless and until such 239 | Contributor explicitly and finally terminates Your grants, and (b) on an 240 | ongoing basis, if such Contributor fails to notify You of the 241 | non-compliance by some reasonable means prior to 60 days after You have 242 | come back into compliance. Moreover, Your grants from a particular 243 | Contributor are reinstated on an ongoing basis if such Contributor 244 | notifies You of the non-compliance by some reasonable means, this is the 245 | first time You have received notice of non-compliance with this License 246 | from such Contributor, and You become compliant prior to 30 days after 247 | Your receipt of the notice. 248 | 249 | 5.2. If You initiate litigation against any entity by asserting a patent 250 | infringement claim (excluding declaratory judgment actions, 251 | counter-claims, and cross-claims) alleging that a Contributor Version 252 | directly or indirectly infringes any patent, then the rights granted to 253 | You by any and all Contributors for the Covered Software under Section 254 | 2.1 of this License shall terminate. 255 | 256 | 5.3. In the event of termination under Sections 5.1 or 5.2 above, all 257 | end user license agreements (excluding distributors and resellers) which 258 | have been validly granted by You or Your distributors under this License 259 | prior to termination shall survive termination. 260 | 261 | ************************************************************************ 262 | * * 263 | * 6. Disclaimer of Warranty * 264 | * ------------------------- * 265 | * * 266 | * Covered Software is provided under this License on an "as is" * 267 | * basis, without warranty of any kind, either expressed, implied, or * 268 | * statutory, including, without limitation, warranties that the * 269 | * Covered Software is free of defects, merchantable, fit for a * 270 | * particular purpose or non-infringing. The entire risk as to the * 271 | * quality and performance of the Covered Software is with You. * 272 | * Should any Covered Software prove defective in any respect, You * 273 | * (not any Contributor) assume the cost of any necessary servicing, * 274 | * repair, or correction. This disclaimer of warranty constitutes an * 275 | * essential part of this License. No use of any Covered Software is * 276 | * authorized under this License except under this disclaimer. * 277 | * * 278 | ************************************************************************ 279 | 280 | ************************************************************************ 281 | * * 282 | * 7. Limitation of Liability * 283 | * -------------------------- * 284 | * * 285 | * Under no circumstances and under no legal theory, whether tort * 286 | * (including negligence), contract, or otherwise, shall any * 287 | * Contributor, or anyone who distributes Covered Software as * 288 | * permitted above, be liable to You for any direct, indirect, * 289 | * special, incidental, or consequential damages of any character * 290 | * including, without limitation, damages for lost profits, loss of * 291 | * goodwill, work stoppage, computer failure or malfunction, or any * 292 | * and all other commercial damages or losses, even if such party * 293 | * shall have been informed of the possibility of such damages. This * 294 | * limitation of liability shall not apply to liability for death or * 295 | * personal injury resulting from such party's negligence to the * 296 | * extent applicable law prohibits such limitation. Some * 297 | * jurisdictions do not allow the exclusion or limitation of * 298 | * incidental or consequential damages, so this exclusion and * 299 | * limitation may not apply to You. * 300 | * * 301 | ************************************************************************ 302 | 303 | 8. Litigation 304 | ------------- 305 | 306 | Any litigation relating to this License may be brought only in the 307 | courts of a jurisdiction where the defendant maintains its principal 308 | place of business and such litigation shall be governed by laws of that 309 | jurisdiction, without reference to its conflict-of-law provisions. 310 | Nothing in this Section shall prevent a party's ability to bring 311 | cross-claims or counter-claims. 312 | 313 | 9. Miscellaneous 314 | ---------------- 315 | 316 | This License represents the complete agreement concerning the subject 317 | matter hereof. If any provision of this License is held to be 318 | unenforceable, such provision shall be reformed only to the extent 319 | necessary to make it enforceable. Any law or regulation which provides 320 | that the language of a contract shall be construed against the drafter 321 | shall not be used to construe this License against a Contributor. 322 | 323 | 10. Versions of the License 324 | --------------------------- 325 | 326 | 10.1. New Versions 327 | 328 | Mozilla Foundation is the license steward. Except as provided in Section 329 | 10.3, no one other than the license steward has the right to modify or 330 | publish new versions of this License. Each version will be given a 331 | distinguishing version number. 332 | 333 | 10.2. Effect of New Versions 334 | 335 | You may distribute the Covered Software under the terms of the version 336 | of the License under which You originally received the Covered Software, 337 | or under the terms of any subsequent version published by the license 338 | steward. 339 | 340 | 10.3. Modified Versions 341 | 342 | If you create software not governed by this License, and you want to 343 | create a new license for such software, you may create and use a 344 | modified version of this License if you rename the license and remove 345 | any references to the name of the license steward (except to note that 346 | such modified license differs from this License). 347 | 348 | 10.4. Distributing Source Code Form that is Incompatible With Secondary 349 | Licenses 350 | 351 | If You choose to distribute Source Code Form that is Incompatible With 352 | Secondary Licenses under the terms of this version of the License, the 353 | notice described in Exhibit B of this License must be attached. 354 | 355 | Exhibit A - Source Code Form License Notice 356 | ------------------------------------------- 357 | 358 | This Source Code Form is subject to the terms of the Mozilla Public 359 | License, v. 2.0. If a copy of the MPL was not distributed with this 360 | file, You can obtain one at http://mozilla.org/MPL/2.0/. 361 | 362 | If it is not possible or desirable to put the notice in a particular 363 | file, then You may include the notice in a location (such as a LICENSE 364 | file in a relevant directory) where a recipient would be likely to look 365 | for such a notice. 366 | 367 | You may add additional accurate notices of copyright ownership. 368 | 369 | Exhibit B - "Incompatible With Secondary Licenses" Notice 370 | --------------------------------------------------------- 371 | 372 | This Source Code Form is "Incompatible With Secondary Licenses", as 373 | defined by the Mozilla Public License, v. 2.0. 374 | -------------------------------------------------------------------------------- /Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 3 4 | 5 | [[package]] 6 | name = "Inflector" 7 | version = "0.11.4" 8 | source = "registry+https://github.com/rust-lang/crates.io-index" 9 | checksum = "fe438c63458706e03479442743baae6c88256498e6431708f6dfc520a26515d3" 10 | dependencies = [ 11 | "lazy_static", 12 | "regex", 13 | ] 14 | 15 | [[package]] 16 | name = "ahash" 17 | version = "0.7.6" 18 | source = "registry+https://github.com/rust-lang/crates.io-index" 19 | checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" 20 | dependencies = [ 21 | "getrandom", 22 | "once_cell", 23 | "version_check", 24 | ] 25 | 26 | [[package]] 27 | name = "aho-corasick" 28 | version = "0.7.19" 29 | source = "registry+https://github.com/rust-lang/crates.io-index" 30 | checksum = "b4f55bd91a0978cbfd91c457a164bab8b4001c833b7f323132c0a4e1922dd44e" 31 | dependencies = [ 32 | "memchr", 33 | ] 34 | 35 | [[package]] 36 | name = "arrayref" 37 | version = "0.3.6" 38 | source = "registry+https://github.com/rust-lang/crates.io-index" 39 | checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" 40 | 41 | [[package]] 42 | name = "arrayvec" 43 | version = "0.7.2" 44 | source = "registry+https://github.com/rust-lang/crates.io-index" 45 | checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6" 46 | 47 | [[package]] 48 | name = "ast_node" 49 | version = "0.8.6" 50 | source = "registry+https://github.com/rust-lang/crates.io-index" 51 | checksum = "cf94863c5fdfee166d0907c44e5fee970123b2b7307046d35d1e671aa93afbba" 52 | dependencies = [ 53 | "darling", 54 | "pmutil", 55 | "proc-macro2", 56 | "quote", 57 | "swc_macros_common", 58 | "syn", 59 | ] 60 | 61 | [[package]] 62 | name = "atty" 63 | version = "0.2.14" 64 | source = "registry+https://github.com/rust-lang/crates.io-index" 65 | checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" 66 | dependencies = [ 67 | "hermit-abi", 68 | "libc", 69 | "winapi", 70 | ] 71 | 72 | [[package]] 73 | name = "autocfg" 74 | version = "1.1.0" 75 | source = "registry+https://github.com/rust-lang/crates.io-index" 76 | checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" 77 | 78 | [[package]] 79 | name = "base64" 80 | version = "0.13.0" 81 | source = "registry+https://github.com/rust-lang/crates.io-index" 82 | checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" 83 | 84 | [[package]] 85 | name = "better_scoped_tls" 86 | version = "0.1.0" 87 | source = "registry+https://github.com/rust-lang/crates.io-index" 88 | checksum = "b73e8ecdec39e98aa3b19e8cd0b8ed8f77ccb86a6b0b2dc7cd86d105438a2123" 89 | dependencies = [ 90 | "scoped-tls", 91 | ] 92 | 93 | [[package]] 94 | name = "bitflags" 95 | version = "1.3.2" 96 | source = "registry+https://github.com/rust-lang/crates.io-index" 97 | checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" 98 | 99 | [[package]] 100 | name = "blake3" 101 | version = "1.3.1" 102 | source = "registry+https://github.com/rust-lang/crates.io-index" 103 | checksum = "a08e53fc5a564bb15bfe6fae56bd71522205f1f91893f9c0116edad6496c183f" 104 | dependencies = [ 105 | "arrayref", 106 | "arrayvec", 107 | "cc", 108 | "cfg-if", 109 | "constant_time_eq", 110 | "digest", 111 | ] 112 | 113 | [[package]] 114 | name = "block-buffer" 115 | version = "0.10.2" 116 | source = "registry+https://github.com/rust-lang/crates.io-index" 117 | checksum = "0bf7fe51849ea569fd452f37822f606a5cabb684dc918707a0193fd4664ff324" 118 | dependencies = [ 119 | "generic-array", 120 | ] 121 | 122 | [[package]] 123 | name = "bytecount" 124 | version = "0.5.1" 125 | source = "registry+https://github.com/rust-lang/crates.io-index" 126 | checksum = "be0fdd54b507df8f22012890aadd099979befdba27713c767993f8380112ca7c" 127 | 128 | [[package]] 129 | name = "byteorder" 130 | version = "1.4.3" 131 | source = "registry+https://github.com/rust-lang/crates.io-index" 132 | checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" 133 | 134 | [[package]] 135 | name = "cc" 136 | version = "1.0.73" 137 | source = "registry+https://github.com/rust-lang/crates.io-index" 138 | checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" 139 | 140 | [[package]] 141 | name = "cfg-if" 142 | version = "1.0.0" 143 | source = "registry+https://github.com/rust-lang/crates.io-index" 144 | checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" 145 | 146 | [[package]] 147 | name = "clap" 148 | version = "3.2.17" 149 | source = "registry+https://github.com/rust-lang/crates.io-index" 150 | checksum = "29e724a68d9319343bb3328c9cc2dfde263f4b3142ee1059a9980580171c954b" 151 | dependencies = [ 152 | "atty", 153 | "bitflags", 154 | "clap_derive", 155 | "clap_lex", 156 | "indexmap", 157 | "once_cell", 158 | "strsim", 159 | "termcolor", 160 | "textwrap", 161 | ] 162 | 163 | [[package]] 164 | name = "clap_derive" 165 | version = "3.2.17" 166 | source = "registry+https://github.com/rust-lang/crates.io-index" 167 | checksum = "13547f7012c01ab4a0e8f8967730ada8f9fdf419e8b6c792788f39cf4e46eefa" 168 | dependencies = [ 169 | "heck", 170 | "proc-macro-error", 171 | "proc-macro2", 172 | "quote", 173 | "syn", 174 | ] 175 | 176 | [[package]] 177 | name = "clap_lex" 178 | version = "0.2.4" 179 | source = "registry+https://github.com/rust-lang/crates.io-index" 180 | checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5" 181 | dependencies = [ 182 | "os_str_bytes", 183 | ] 184 | 185 | [[package]] 186 | name = "console" 187 | version = "0.15.0" 188 | source = "registry+https://github.com/rust-lang/crates.io-index" 189 | checksum = "a28b32d32ca44b70c3e4acd7db1babf555fa026e385fb95f18028f88848b3c31" 190 | dependencies = [ 191 | "encode_unicode", 192 | "libc", 193 | "once_cell", 194 | "regex", 195 | "terminal_size", 196 | "unicode-width", 197 | "winapi", 198 | ] 199 | 200 | [[package]] 201 | name = "constant_time_eq" 202 | version = "0.1.5" 203 | source = "registry+https://github.com/rust-lang/crates.io-index" 204 | checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" 205 | 206 | [[package]] 207 | name = "convert_case" 208 | version = "0.4.0" 209 | source = "registry+https://github.com/rust-lang/crates.io-index" 210 | checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" 211 | 212 | [[package]] 213 | name = "crypto-common" 214 | version = "0.1.6" 215 | source = "registry+https://github.com/rust-lang/crates.io-index" 216 | checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" 217 | dependencies = [ 218 | "generic-array", 219 | "typenum", 220 | ] 221 | 222 | [[package]] 223 | name = "darling" 224 | version = "0.13.4" 225 | source = "registry+https://github.com/rust-lang/crates.io-index" 226 | checksum = "a01d95850c592940db9b8194bc39f4bc0e89dee5c4265e4b1807c34a9aba453c" 227 | dependencies = [ 228 | "darling_core", 229 | "darling_macro", 230 | ] 231 | 232 | [[package]] 233 | name = "darling_core" 234 | version = "0.13.4" 235 | source = "registry+https://github.com/rust-lang/crates.io-index" 236 | checksum = "859d65a907b6852c9361e3185c862aae7fafd2887876799fa55f5f99dc40d610" 237 | dependencies = [ 238 | "fnv", 239 | "ident_case", 240 | "proc-macro2", 241 | "quote", 242 | "strsim", 243 | "syn", 244 | ] 245 | 246 | [[package]] 247 | name = "darling_macro" 248 | version = "0.13.4" 249 | source = "registry+https://github.com/rust-lang/crates.io-index" 250 | checksum = "9c972679f83bdf9c42bd905396b6c3588a843a17f0f16dfcfa3e2c5d57441835" 251 | dependencies = [ 252 | "darling_core", 253 | "quote", 254 | "syn", 255 | ] 256 | 257 | [[package]] 258 | name = "derive_more" 259 | version = "0.99.17" 260 | source = "registry+https://github.com/rust-lang/crates.io-index" 261 | checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" 262 | dependencies = [ 263 | "convert_case", 264 | "proc-macro2", 265 | "quote", 266 | "rustc_version 0.4.0", 267 | "syn", 268 | ] 269 | 270 | [[package]] 271 | name = "digest" 272 | version = "0.10.3" 273 | source = "registry+https://github.com/rust-lang/crates.io-index" 274 | checksum = "f2fb860ca6fafa5552fb6d0e816a69c8e49f0908bf524e30a90d97c85892d506" 275 | dependencies = [ 276 | "block-buffer", 277 | "crypto-common", 278 | "subtle", 279 | ] 280 | 281 | [[package]] 282 | name = "either" 283 | version = "1.6.1" 284 | source = "registry+https://github.com/rust-lang/crates.io-index" 285 | checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" 286 | 287 | [[package]] 288 | name = "encode_unicode" 289 | version = "0.3.6" 290 | source = "registry+https://github.com/rust-lang/crates.io-index" 291 | checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" 292 | 293 | [[package]] 294 | name = "exitcode" 295 | version = "1.1.2" 296 | source = "registry+https://github.com/rust-lang/crates.io-index" 297 | checksum = "de853764b47027c2e862a995c34978ffa63c1501f2e15f987ba11bd4f9bba193" 298 | 299 | [[package]] 300 | name = "fnv" 301 | version = "1.0.7" 302 | source = "registry+https://github.com/rust-lang/crates.io-index" 303 | checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" 304 | 305 | [[package]] 306 | name = "form_urlencoded" 307 | version = "1.1.0" 308 | source = "registry+https://github.com/rust-lang/crates.io-index" 309 | checksum = "a9c384f161156f5260c24a097c56119f9be8c798586aecc13afbcbe7b7e26bf8" 310 | dependencies = [ 311 | "percent-encoding", 312 | ] 313 | 314 | [[package]] 315 | name = "from_variant" 316 | version = "0.1.4" 317 | source = "registry+https://github.com/rust-lang/crates.io-index" 318 | checksum = "f0981e470d2ab9f643df3921d54f1952ea100c39fdb6a3fdc820e20d2291df6c" 319 | dependencies = [ 320 | "pmutil", 321 | "proc-macro2", 322 | "swc_macros_common", 323 | "syn", 324 | ] 325 | 326 | [[package]] 327 | name = "full_moon" 328 | version = "0.15.1" 329 | source = "registry+https://github.com/rust-lang/crates.io-index" 330 | checksum = "1bf176fa61b7bfd03d311cf17618bb8cb16115e9077ab591a847c3437c8a6001" 331 | dependencies = [ 332 | "bytecount", 333 | "cfg-if", 334 | "derive_more", 335 | "full_moon_derive", 336 | "paste 0.1.18", 337 | "peg", 338 | "serde", 339 | "smol_str", 340 | ] 341 | 342 | [[package]] 343 | name = "full_moon_derive" 344 | version = "0.10.0" 345 | source = "registry+https://github.com/rust-lang/crates.io-index" 346 | checksum = "87826a47a649663aa287e57ea9f31450a56fabcd553a2fe17b2f669f1b5e855b" 347 | dependencies = [ 348 | "indexmap", 349 | "proc-macro2", 350 | "quote", 351 | "syn", 352 | ] 353 | 354 | [[package]] 355 | name = "generic-array" 356 | version = "0.14.6" 357 | source = "registry+https://github.com/rust-lang/crates.io-index" 358 | checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" 359 | dependencies = [ 360 | "typenum", 361 | "version_check", 362 | ] 363 | 364 | [[package]] 365 | name = "getrandom" 366 | version = "0.2.7" 367 | source = "registry+https://github.com/rust-lang/crates.io-index" 368 | checksum = "4eb1a864a501629691edf6c15a593b7a51eebaa1e8468e9ddc623de7c9b58ec6" 369 | dependencies = [ 370 | "cfg-if", 371 | "libc", 372 | "wasi", 373 | ] 374 | 375 | [[package]] 376 | name = "hashbrown" 377 | version = "0.12.1" 378 | source = "registry+https://github.com/rust-lang/crates.io-index" 379 | checksum = "db0d4cf898abf0081f964436dc980e96670a0f36863e4b83aaacdb65c9d7ccc3" 380 | 381 | [[package]] 382 | name = "heck" 383 | version = "0.4.0" 384 | source = "registry+https://github.com/rust-lang/crates.io-index" 385 | checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9" 386 | 387 | [[package]] 388 | name = "hermit-abi" 389 | version = "0.1.19" 390 | source = "registry+https://github.com/rust-lang/crates.io-index" 391 | checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" 392 | dependencies = [ 393 | "libc", 394 | ] 395 | 396 | [[package]] 397 | name = "ident_case" 398 | version = "1.0.1" 399 | source = "registry+https://github.com/rust-lang/crates.io-index" 400 | checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" 401 | 402 | [[package]] 403 | name = "idna" 404 | version = "0.3.0" 405 | source = "registry+https://github.com/rust-lang/crates.io-index" 406 | checksum = "e14ddfc70884202db2244c223200c204c2bda1bc6e0998d11b5e024d657209e6" 407 | dependencies = [ 408 | "unicode-bidi", 409 | "unicode-normalization", 410 | ] 411 | 412 | [[package]] 413 | name = "if_chain" 414 | version = "1.0.2" 415 | source = "registry+https://github.com/rust-lang/crates.io-index" 416 | checksum = "cb56e1aa765b4b4f3aadfab769793b7087bb03a4ea4920644a6d238e2df5b9ed" 417 | 418 | [[package]] 419 | name = "indexmap" 420 | version = "1.9.1" 421 | source = "registry+https://github.com/rust-lang/crates.io-index" 422 | checksum = "10a35a97730320ffe8e2d410b5d3b69279b98d2c14bdb8b70ea89ecf7888d41e" 423 | dependencies = [ 424 | "autocfg", 425 | "hashbrown", 426 | ] 427 | 428 | [[package]] 429 | name = "indicatif" 430 | version = "0.16.2" 431 | source = "registry+https://github.com/rust-lang/crates.io-index" 432 | checksum = "2d207dc617c7a380ab07ff572a6e52fa202a2a8f355860ac9c38e23f8196be1b" 433 | dependencies = [ 434 | "console", 435 | "lazy_static", 436 | "number_prefix", 437 | "regex", 438 | ] 439 | 440 | [[package]] 441 | name = "is-macro" 442 | version = "0.2.1" 443 | source = "registry+https://github.com/rust-lang/crates.io-index" 444 | checksum = "1c068d4c6b922cd6284c609cfa6dec0e41615c9c5a1a4ba729a970d8daba05fb" 445 | dependencies = [ 446 | "Inflector", 447 | "pmutil", 448 | "proc-macro2", 449 | "quote", 450 | "syn", 451 | ] 452 | 453 | [[package]] 454 | name = "itertools" 455 | version = "0.10.3" 456 | source = "registry+https://github.com/rust-lang/crates.io-index" 457 | checksum = "a9a9d19fa1e79b6215ff29b9d6880b706147f16e9b1dbb1e4e5947b5b02bc5e3" 458 | dependencies = [ 459 | "either", 460 | ] 461 | 462 | [[package]] 463 | name = "itoa" 464 | version = "1.0.4" 465 | source = "registry+https://github.com/rust-lang/crates.io-index" 466 | checksum = "4217ad341ebadf8d8e724e264f13e593e0648f5b3e94b3896a5df283be015ecc" 467 | 468 | [[package]] 469 | name = "lazy_static" 470 | version = "1.4.0" 471 | source = "registry+https://github.com/rust-lang/crates.io-index" 472 | checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" 473 | 474 | [[package]] 475 | name = "libc" 476 | version = "0.2.126" 477 | source = "registry+https://github.com/rust-lang/crates.io-index" 478 | checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836" 479 | 480 | [[package]] 481 | name = "lock_api" 482 | version = "0.4.7" 483 | source = "registry+https://github.com/rust-lang/crates.io-index" 484 | checksum = "327fa5b6a6940e4699ec49a9beae1ea4845c6bab9314e4f84ac68742139d8c53" 485 | dependencies = [ 486 | "autocfg", 487 | "scopeguard", 488 | ] 489 | 490 | [[package]] 491 | name = "log" 492 | version = "0.4.17" 493 | source = "registry+https://github.com/rust-lang/crates.io-index" 494 | checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" 495 | dependencies = [ 496 | "cfg-if", 497 | ] 498 | 499 | [[package]] 500 | name = "lua-to-ts" 501 | version = "0.1.0" 502 | dependencies = [ 503 | "clap", 504 | "console", 505 | "exitcode", 506 | "full_moon", 507 | "indicatif", 508 | "itertools", 509 | "lazy_static", 510 | "rbx_binary", 511 | "rbx_dom_weak", 512 | "rbx_types", 513 | "rbx_xml", 514 | "swc_atoms", 515 | "swc_common", 516 | "swc_ecma_ast", 517 | "swc_ecma_codegen", 518 | ] 519 | 520 | [[package]] 521 | name = "lz4" 522 | version = "1.23.3" 523 | source = "registry+https://github.com/rust-lang/crates.io-index" 524 | checksum = "4edcb94251b1c375c459e5abe9fb0168c1c826c3370172684844f8f3f8d1a885" 525 | dependencies = [ 526 | "libc", 527 | "lz4-sys", 528 | ] 529 | 530 | [[package]] 531 | name = "lz4-sys" 532 | version = "1.9.3" 533 | source = "registry+https://github.com/rust-lang/crates.io-index" 534 | checksum = "d7be8908e2ed6f31c02db8a9fa962f03e36c53fbfde437363eae3306b85d7e17" 535 | dependencies = [ 536 | "cc", 537 | "libc", 538 | ] 539 | 540 | [[package]] 541 | name = "memchr" 542 | version = "2.5.0" 543 | source = "registry+https://github.com/rust-lang/crates.io-index" 544 | checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" 545 | 546 | [[package]] 547 | name = "new_debug_unreachable" 548 | version = "1.0.4" 549 | source = "registry+https://github.com/rust-lang/crates.io-index" 550 | checksum = "e4a24736216ec316047a1fc4252e27dabb04218aa4a3f37c6e7ddbf1f9782b54" 551 | 552 | [[package]] 553 | name = "num-bigint" 554 | version = "0.4.3" 555 | source = "registry+https://github.com/rust-lang/crates.io-index" 556 | checksum = "f93ab6289c7b344a8a9f60f88d80aa20032336fe78da341afc91c8a2341fc75f" 557 | dependencies = [ 558 | "autocfg", 559 | "num-integer", 560 | "num-traits", 561 | "serde", 562 | ] 563 | 564 | [[package]] 565 | name = "num-integer" 566 | version = "0.1.45" 567 | source = "registry+https://github.com/rust-lang/crates.io-index" 568 | checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" 569 | dependencies = [ 570 | "autocfg", 571 | "num-traits", 572 | ] 573 | 574 | [[package]] 575 | name = "num-traits" 576 | version = "0.2.15" 577 | source = "registry+https://github.com/rust-lang/crates.io-index" 578 | checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" 579 | dependencies = [ 580 | "autocfg", 581 | ] 582 | 583 | [[package]] 584 | name = "number_prefix" 585 | version = "0.4.0" 586 | source = "registry+https://github.com/rust-lang/crates.io-index" 587 | checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3" 588 | 589 | [[package]] 590 | name = "once_cell" 591 | version = "1.16.0" 592 | source = "registry+https://github.com/rust-lang/crates.io-index" 593 | checksum = "86f0b0d4bf799edbc74508c1e8bf170ff5f41238e5f8225603ca7caaae2b7860" 594 | 595 | [[package]] 596 | name = "os_str_bytes" 597 | version = "6.3.0" 598 | source = "registry+https://github.com/rust-lang/crates.io-index" 599 | checksum = "9ff7415e9ae3fff1225851df9e0d9e4e5479f947619774677a63572e55e80eff" 600 | 601 | [[package]] 602 | name = "parking_lot" 603 | version = "0.12.1" 604 | source = "registry+https://github.com/rust-lang/crates.io-index" 605 | checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" 606 | dependencies = [ 607 | "lock_api", 608 | "parking_lot_core", 609 | ] 610 | 611 | [[package]] 612 | name = "parking_lot_core" 613 | version = "0.9.3" 614 | source = "registry+https://github.com/rust-lang/crates.io-index" 615 | checksum = "09a279cbf25cb0757810394fbc1e359949b59e348145c643a939a525692e6929" 616 | dependencies = [ 617 | "cfg-if", 618 | "libc", 619 | "redox_syscall", 620 | "smallvec", 621 | "windows-sys", 622 | ] 623 | 624 | [[package]] 625 | name = "paste" 626 | version = "0.1.18" 627 | source = "registry+https://github.com/rust-lang/crates.io-index" 628 | checksum = "45ca20c77d80be666aef2b45486da86238fabe33e38306bd3118fe4af33fa880" 629 | dependencies = [ 630 | "paste-impl", 631 | "proc-macro-hack", 632 | ] 633 | 634 | [[package]] 635 | name = "paste" 636 | version = "1.0.8" 637 | source = "registry+https://github.com/rust-lang/crates.io-index" 638 | checksum = "9423e2b32f7a043629287a536f21951e8c6a82482d0acb1eeebfc90bc2225b22" 639 | 640 | [[package]] 641 | name = "paste-impl" 642 | version = "0.1.18" 643 | source = "registry+https://github.com/rust-lang/crates.io-index" 644 | checksum = "d95a7db200b97ef370c8e6de0088252f7e0dfff7d047a28528e47456c0fc98b6" 645 | dependencies = [ 646 | "proc-macro-hack", 647 | ] 648 | 649 | [[package]] 650 | name = "peg" 651 | version = "0.7.0" 652 | source = "registry+https://github.com/rust-lang/crates.io-index" 653 | checksum = "07c0b841ea54f523f7aa556956fbd293bcbe06f2e67d2eb732b7278aaf1d166a" 654 | dependencies = [ 655 | "peg-macros", 656 | "peg-runtime", 657 | ] 658 | 659 | [[package]] 660 | name = "peg-macros" 661 | version = "0.7.0" 662 | source = "registry+https://github.com/rust-lang/crates.io-index" 663 | checksum = "b5aa52829b8decbef693af90202711348ab001456803ba2a98eb4ec8fb70844c" 664 | dependencies = [ 665 | "peg-runtime", 666 | "proc-macro2", 667 | "quote", 668 | ] 669 | 670 | [[package]] 671 | name = "peg-runtime" 672 | version = "0.7.0" 673 | source = "registry+https://github.com/rust-lang/crates.io-index" 674 | checksum = "c719dcf55f09a3a7e764c6649ab594c18a177e3599c467983cdf644bfc0a4088" 675 | 676 | [[package]] 677 | name = "percent-encoding" 678 | version = "2.2.0" 679 | source = "registry+https://github.com/rust-lang/crates.io-index" 680 | checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" 681 | 682 | [[package]] 683 | name = "phf_generator" 684 | version = "0.10.0" 685 | source = "registry+https://github.com/rust-lang/crates.io-index" 686 | checksum = "5d5285893bb5eb82e6aaf5d59ee909a06a16737a8970984dd7746ba9283498d6" 687 | dependencies = [ 688 | "phf_shared", 689 | "rand", 690 | ] 691 | 692 | [[package]] 693 | name = "phf_shared" 694 | version = "0.10.0" 695 | source = "registry+https://github.com/rust-lang/crates.io-index" 696 | checksum = "b6796ad771acdc0123d2a88dc428b5e38ef24456743ddb1744ed628f9815c096" 697 | dependencies = [ 698 | "siphasher", 699 | ] 700 | 701 | [[package]] 702 | name = "pin-project-lite" 703 | version = "0.2.9" 704 | source = "registry+https://github.com/rust-lang/crates.io-index" 705 | checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" 706 | 707 | [[package]] 708 | name = "pmutil" 709 | version = "0.5.3" 710 | source = "registry+https://github.com/rust-lang/crates.io-index" 711 | checksum = "3894e5d549cccbe44afecf72922f277f603cd4bb0219c8342631ef18fffbe004" 712 | dependencies = [ 713 | "proc-macro2", 714 | "quote", 715 | "syn", 716 | ] 717 | 718 | [[package]] 719 | name = "ppv-lite86" 720 | version = "0.2.16" 721 | source = "registry+https://github.com/rust-lang/crates.io-index" 722 | checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872" 723 | 724 | [[package]] 725 | name = "precomputed-hash" 726 | version = "0.1.1" 727 | source = "registry+https://github.com/rust-lang/crates.io-index" 728 | checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" 729 | 730 | [[package]] 731 | name = "proc-macro-error" 732 | version = "1.0.4" 733 | source = "registry+https://github.com/rust-lang/crates.io-index" 734 | checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" 735 | dependencies = [ 736 | "proc-macro-error-attr", 737 | "proc-macro2", 738 | "quote", 739 | "syn", 740 | "version_check", 741 | ] 742 | 743 | [[package]] 744 | name = "proc-macro-error-attr" 745 | version = "1.0.4" 746 | source = "registry+https://github.com/rust-lang/crates.io-index" 747 | checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" 748 | dependencies = [ 749 | "proc-macro2", 750 | "quote", 751 | "version_check", 752 | ] 753 | 754 | [[package]] 755 | name = "proc-macro-hack" 756 | version = "0.5.19" 757 | source = "registry+https://github.com/rust-lang/crates.io-index" 758 | checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" 759 | 760 | [[package]] 761 | name = "proc-macro2" 762 | version = "1.0.40" 763 | source = "registry+https://github.com/rust-lang/crates.io-index" 764 | checksum = "dd96a1e8ed2596c337f8eae5f24924ec83f5ad5ab21ea8e455d3566c69fbcaf7" 765 | dependencies = [ 766 | "unicode-ident", 767 | ] 768 | 769 | [[package]] 770 | name = "profiling" 771 | version = "1.0.6" 772 | source = "registry+https://github.com/rust-lang/crates.io-index" 773 | checksum = "2f61dcf0b917cd75d4521d7343d1ffff3d1583054133c9b5cbea3375c703c40d" 774 | dependencies = [ 775 | "profiling-procmacros", 776 | ] 777 | 778 | [[package]] 779 | name = "profiling-procmacros" 780 | version = "1.0.6" 781 | source = "registry+https://github.com/rust-lang/crates.io-index" 782 | checksum = "98eee3c112f2a6f784b6713fe1d7fb7d6506e066121c0a49371fdb976f72bae5" 783 | dependencies = [ 784 | "quote", 785 | "syn", 786 | ] 787 | 788 | [[package]] 789 | name = "quote" 790 | version = "1.0.20" 791 | source = "registry+https://github.com/rust-lang/crates.io-index" 792 | checksum = "3bcdf212e9776fbcb2d23ab029360416bb1706b1aea2d1a5ba002727cbcab804" 793 | dependencies = [ 794 | "proc-macro2", 795 | ] 796 | 797 | [[package]] 798 | name = "rand" 799 | version = "0.8.5" 800 | source = "registry+https://github.com/rust-lang/crates.io-index" 801 | checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" 802 | dependencies = [ 803 | "libc", 804 | "rand_chacha", 805 | "rand_core", 806 | ] 807 | 808 | [[package]] 809 | name = "rand_chacha" 810 | version = "0.3.1" 811 | source = "registry+https://github.com/rust-lang/crates.io-index" 812 | checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" 813 | dependencies = [ 814 | "ppv-lite86", 815 | "rand_core", 816 | ] 817 | 818 | [[package]] 819 | name = "rand_core" 820 | version = "0.6.3" 821 | source = "registry+https://github.com/rust-lang/crates.io-index" 822 | checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7" 823 | dependencies = [ 824 | "getrandom", 825 | ] 826 | 827 | [[package]] 828 | name = "rbx_binary" 829 | version = "0.6.6" 830 | source = "registry+https://github.com/rust-lang/crates.io-index" 831 | checksum = "842a9253d37ca9df932108806a0f6c97195f2411bf05671e88744be622548807" 832 | dependencies = [ 833 | "log", 834 | "lz4", 835 | "profiling", 836 | "rbx_dom_weak", 837 | "rbx_reflection", 838 | "rbx_reflection_database", 839 | "thiserror", 840 | ] 841 | 842 | [[package]] 843 | name = "rbx_dom_weak" 844 | version = "2.4.0" 845 | source = "registry+https://github.com/rust-lang/crates.io-index" 846 | checksum = "b7cc2238fd858d706f4f5c6a0f9af3cd4a10f3f8dc8b6534e683f8543af26f33" 847 | dependencies = [ 848 | "rbx_types", 849 | "serde", 850 | ] 851 | 852 | [[package]] 853 | name = "rbx_reflection" 854 | version = "4.2.0" 855 | source = "registry+https://github.com/rust-lang/crates.io-index" 856 | checksum = "a8915748c8a3b2a92540e4e35e99ebd548df2d62b0a6cf38ae5d0081f0e611d5" 857 | dependencies = [ 858 | "rbx_types", 859 | "serde", 860 | ] 861 | 862 | [[package]] 863 | name = "rbx_reflection_database" 864 | version = "0.2.5+roblox-530" 865 | source = "registry+https://github.com/rust-lang/crates.io-index" 866 | checksum = "3e790ac1c92dee33669e7e12414caf75eb5cfce6fb5c54998eb9001d204fbab1" 867 | dependencies = [ 868 | "lazy_static", 869 | "rbx_reflection", 870 | "rmp-serde", 871 | "serde", 872 | ] 873 | 874 | [[package]] 875 | name = "rbx_types" 876 | version = "1.4.2" 877 | source = "registry+https://github.com/rust-lang/crates.io-index" 878 | checksum = "a773e53402f2ae7537bbec77badb7e3ff3e6ddac5ee9c2df7edf0a60edf5c9d8" 879 | dependencies = [ 880 | "base64", 881 | "bitflags", 882 | "blake3", 883 | "lazy_static", 884 | "rand", 885 | "serde", 886 | "thiserror", 887 | ] 888 | 889 | [[package]] 890 | name = "rbx_xml" 891 | version = "0.12.4" 892 | source = "registry+https://github.com/rust-lang/crates.io-index" 893 | checksum = "2559683f2f9205d442bd9083d7557be58b6cdcd0e5cc22600a6546a08e6d54f0" 894 | dependencies = [ 895 | "base64", 896 | "log", 897 | "rbx_dom_weak", 898 | "rbx_reflection", 899 | "rbx_reflection_database", 900 | "xml-rs", 901 | ] 902 | 903 | [[package]] 904 | name = "redox_syscall" 905 | version = "0.2.13" 906 | source = "registry+https://github.com/rust-lang/crates.io-index" 907 | checksum = "62f25bc4c7e55e0b0b7a1d43fb893f4fa1361d0abe38b9ce4f323c2adfe6ef42" 908 | dependencies = [ 909 | "bitflags", 910 | ] 911 | 912 | [[package]] 913 | name = "regex" 914 | version = "1.5.6" 915 | source = "registry+https://github.com/rust-lang/crates.io-index" 916 | checksum = "d83f127d94bdbcda4c8cc2e50f6f84f4b611f69c902699ca385a39c3a75f9ff1" 917 | dependencies = [ 918 | "aho-corasick", 919 | "memchr", 920 | "regex-syntax", 921 | ] 922 | 923 | [[package]] 924 | name = "regex-syntax" 925 | version = "0.6.26" 926 | source = "registry+https://github.com/rust-lang/crates.io-index" 927 | checksum = "49b3de9ec5dc0a3417da371aab17d729997c15010e7fd24ff707773a33bddb64" 928 | 929 | [[package]] 930 | name = "rmp" 931 | version = "0.8.11" 932 | source = "registry+https://github.com/rust-lang/crates.io-index" 933 | checksum = "44519172358fd6d58656c86ab8e7fbc9e1490c3e8f14d35ed78ca0dd07403c9f" 934 | dependencies = [ 935 | "byteorder", 936 | "num-traits", 937 | "paste 1.0.8", 938 | ] 939 | 940 | [[package]] 941 | name = "rmp-serde" 942 | version = "0.14.4" 943 | source = "registry+https://github.com/rust-lang/crates.io-index" 944 | checksum = "4ce7d70c926fe472aed493b902010bccc17fa9f7284145cb8772fd22fdb052d8" 945 | dependencies = [ 946 | "byteorder", 947 | "rmp", 948 | "serde", 949 | ] 950 | 951 | [[package]] 952 | name = "rustc-hash" 953 | version = "1.1.0" 954 | source = "registry+https://github.com/rust-lang/crates.io-index" 955 | checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" 956 | 957 | [[package]] 958 | name = "rustc_version" 959 | version = "0.2.3" 960 | source = "registry+https://github.com/rust-lang/crates.io-index" 961 | checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" 962 | dependencies = [ 963 | "semver 0.9.0", 964 | ] 965 | 966 | [[package]] 967 | name = "rustc_version" 968 | version = "0.4.0" 969 | source = "registry+https://github.com/rust-lang/crates.io-index" 970 | checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" 971 | dependencies = [ 972 | "semver 1.0.10", 973 | ] 974 | 975 | [[package]] 976 | name = "ryu" 977 | version = "1.0.11" 978 | source = "registry+https://github.com/rust-lang/crates.io-index" 979 | checksum = "4501abdff3ae82a1c1b477a17252eb69cee9e66eb915c1abaa4f44d873df9f09" 980 | 981 | [[package]] 982 | name = "scoped-tls" 983 | version = "1.0.1" 984 | source = "registry+https://github.com/rust-lang/crates.io-index" 985 | checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294" 986 | 987 | [[package]] 988 | name = "scopeguard" 989 | version = "1.1.0" 990 | source = "registry+https://github.com/rust-lang/crates.io-index" 991 | checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" 992 | 993 | [[package]] 994 | name = "semver" 995 | version = "0.9.0" 996 | source = "registry+https://github.com/rust-lang/crates.io-index" 997 | checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" 998 | dependencies = [ 999 | "semver-parser", 1000 | ] 1001 | 1002 | [[package]] 1003 | name = "semver" 1004 | version = "1.0.10" 1005 | source = "registry+https://github.com/rust-lang/crates.io-index" 1006 | checksum = "a41d061efea015927ac527063765e73601444cdc344ba855bc7bd44578b25e1c" 1007 | 1008 | [[package]] 1009 | name = "semver-parser" 1010 | version = "0.7.0" 1011 | source = "registry+https://github.com/rust-lang/crates.io-index" 1012 | checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" 1013 | 1014 | [[package]] 1015 | name = "serde" 1016 | version = "1.0.137" 1017 | source = "registry+https://github.com/rust-lang/crates.io-index" 1018 | checksum = "61ea8d54c77f8315140a05f4c7237403bf38b72704d031543aa1d16abbf517d1" 1019 | dependencies = [ 1020 | "serde_derive", 1021 | ] 1022 | 1023 | [[package]] 1024 | name = "serde_derive" 1025 | version = "1.0.137" 1026 | source = "registry+https://github.com/rust-lang/crates.io-index" 1027 | checksum = "1f26faba0c3959972377d3b2d306ee9f71faee9714294e41bb777f83f88578be" 1028 | dependencies = [ 1029 | "proc-macro2", 1030 | "quote", 1031 | "syn", 1032 | ] 1033 | 1034 | [[package]] 1035 | name = "serde_json" 1036 | version = "1.0.87" 1037 | source = "registry+https://github.com/rust-lang/crates.io-index" 1038 | checksum = "6ce777b7b150d76b9cf60d28b55f5847135a003f7d7350c6be7a773508ce7d45" 1039 | dependencies = [ 1040 | "itoa", 1041 | "ryu", 1042 | "serde", 1043 | ] 1044 | 1045 | [[package]] 1046 | name = "siphasher" 1047 | version = "0.3.10" 1048 | source = "registry+https://github.com/rust-lang/crates.io-index" 1049 | checksum = "7bd3e3206899af3f8b12af284fafc038cc1dc2b41d1b89dd17297221c5d225de" 1050 | 1051 | [[package]] 1052 | name = "smallvec" 1053 | version = "1.8.0" 1054 | source = "registry+https://github.com/rust-lang/crates.io-index" 1055 | checksum = "f2dd574626839106c320a323308629dcb1acfc96e32a8cba364ddc61ac23ee83" 1056 | 1057 | [[package]] 1058 | name = "smol_str" 1059 | version = "0.1.23" 1060 | source = "registry+https://github.com/rust-lang/crates.io-index" 1061 | checksum = "7475118a28b7e3a2e157ce0131ba8c5526ea96e90ee601d9f6bb2e286a35ab44" 1062 | dependencies = [ 1063 | "serde", 1064 | ] 1065 | 1066 | [[package]] 1067 | name = "sourcemap" 1068 | version = "6.2.0" 1069 | source = "registry+https://github.com/rust-lang/crates.io-index" 1070 | checksum = "c46fdc1838ff49cf692226f5c2b0f5b7538f556863d0eca602984714667ac6e7" 1071 | dependencies = [ 1072 | "base64", 1073 | "if_chain", 1074 | "lazy_static", 1075 | "regex", 1076 | "rustc_version 0.2.3", 1077 | "serde", 1078 | "serde_json", 1079 | "url", 1080 | ] 1081 | 1082 | [[package]] 1083 | name = "stable_deref_trait" 1084 | version = "1.2.0" 1085 | source = "registry+https://github.com/rust-lang/crates.io-index" 1086 | checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" 1087 | 1088 | [[package]] 1089 | name = "string_cache" 1090 | version = "0.8.4" 1091 | source = "registry+https://github.com/rust-lang/crates.io-index" 1092 | checksum = "213494b7a2b503146286049378ce02b482200519accc31872ee8be91fa820a08" 1093 | dependencies = [ 1094 | "new_debug_unreachable", 1095 | "once_cell", 1096 | "parking_lot", 1097 | "phf_shared", 1098 | "precomputed-hash", 1099 | "serde", 1100 | ] 1101 | 1102 | [[package]] 1103 | name = "string_cache_codegen" 1104 | version = "0.5.2" 1105 | source = "registry+https://github.com/rust-lang/crates.io-index" 1106 | checksum = "6bb30289b722be4ff74a408c3cc27edeaad656e06cb1fe8fa9231fa59c728988" 1107 | dependencies = [ 1108 | "phf_generator", 1109 | "phf_shared", 1110 | "proc-macro2", 1111 | "quote", 1112 | ] 1113 | 1114 | [[package]] 1115 | name = "string_enum" 1116 | version = "0.3.2" 1117 | source = "registry+https://github.com/rust-lang/crates.io-index" 1118 | checksum = "994453cd270ad0265796eb24abf5540091ed03e681c5f3c12bc33e4db33253e1" 1119 | dependencies = [ 1120 | "pmutil", 1121 | "proc-macro2", 1122 | "quote", 1123 | "swc_macros_common", 1124 | "syn", 1125 | ] 1126 | 1127 | [[package]] 1128 | name = "strsim" 1129 | version = "0.10.0" 1130 | source = "registry+https://github.com/rust-lang/crates.io-index" 1131 | checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" 1132 | 1133 | [[package]] 1134 | name = "subtle" 1135 | version = "2.4.1" 1136 | source = "registry+https://github.com/rust-lang/crates.io-index" 1137 | checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" 1138 | 1139 | [[package]] 1140 | name = "swc_atoms" 1141 | version = "0.4.24" 1142 | source = "registry+https://github.com/rust-lang/crates.io-index" 1143 | checksum = "79642938ff437f2217718abf30a3450b014f600847c8f4bd60fa44f88a5210ea" 1144 | dependencies = [ 1145 | "once_cell", 1146 | "rustc-hash", 1147 | "serde", 1148 | "string_cache", 1149 | "string_cache_codegen", 1150 | "triomphe", 1151 | ] 1152 | 1153 | [[package]] 1154 | name = "swc_common" 1155 | version = "0.29.13" 1156 | source = "registry+https://github.com/rust-lang/crates.io-index" 1157 | checksum = "953e1f014688eadbbd3e9131a525e8922c552540bb02b0bb6d9fdcb1375bccc4" 1158 | dependencies = [ 1159 | "ahash", 1160 | "ast_node", 1161 | "better_scoped_tls", 1162 | "cfg-if", 1163 | "either", 1164 | "from_variant", 1165 | "new_debug_unreachable", 1166 | "num-bigint", 1167 | "once_cell", 1168 | "rustc-hash", 1169 | "serde", 1170 | "siphasher", 1171 | "string_cache", 1172 | "swc_atoms", 1173 | "swc_eq_ignore_macros", 1174 | "swc_visit", 1175 | "tracing", 1176 | "unicode-width", 1177 | "url", 1178 | ] 1179 | 1180 | [[package]] 1181 | name = "swc_ecma_ast" 1182 | version = "0.94.17" 1183 | source = "registry+https://github.com/rust-lang/crates.io-index" 1184 | checksum = "bc39246540303a9058283e6ef691a276c34afd8331e6873fb3e6fb7803eb77eb" 1185 | dependencies = [ 1186 | "bitflags", 1187 | "is-macro", 1188 | "num-bigint", 1189 | "scoped-tls", 1190 | "serde", 1191 | "string_enum", 1192 | "swc_atoms", 1193 | "swc_common", 1194 | "unicode-id", 1195 | ] 1196 | 1197 | [[package]] 1198 | name = "swc_ecma_codegen" 1199 | version = "0.127.29" 1200 | source = "registry+https://github.com/rust-lang/crates.io-index" 1201 | checksum = "4f7dc7fbe2ad55c407766edd5b735e9cc693b20e37d3b5681d1660d6d5087348" 1202 | dependencies = [ 1203 | "memchr", 1204 | "num-bigint", 1205 | "once_cell", 1206 | "rustc-hash", 1207 | "serde", 1208 | "sourcemap", 1209 | "swc_atoms", 1210 | "swc_common", 1211 | "swc_ecma_ast", 1212 | "swc_ecma_codegen_macros", 1213 | "tracing", 1214 | ] 1215 | 1216 | [[package]] 1217 | name = "swc_ecma_codegen_macros" 1218 | version = "0.7.1" 1219 | source = "registry+https://github.com/rust-lang/crates.io-index" 1220 | checksum = "0159c99f81f52e48fe692ef7af1b0990b45d3006b14c6629be0b1ffee1b23aea" 1221 | dependencies = [ 1222 | "pmutil", 1223 | "proc-macro2", 1224 | "quote", 1225 | "swc_macros_common", 1226 | "syn", 1227 | ] 1228 | 1229 | [[package]] 1230 | name = "swc_eq_ignore_macros" 1231 | version = "0.1.1" 1232 | source = "registry+https://github.com/rust-lang/crates.io-index" 1233 | checksum = "0c20468634668c2bbab581947bb8c75c97158d5a6959f4ba33df20983b20b4f6" 1234 | dependencies = [ 1235 | "pmutil", 1236 | "proc-macro2", 1237 | "quote", 1238 | "syn", 1239 | ] 1240 | 1241 | [[package]] 1242 | name = "swc_macros_common" 1243 | version = "0.3.6" 1244 | source = "registry+https://github.com/rust-lang/crates.io-index" 1245 | checksum = "a4be988307882648d9bc7c71a6a73322b7520ef0211e920489a98f8391d8caa2" 1246 | dependencies = [ 1247 | "pmutil", 1248 | "proc-macro2", 1249 | "quote", 1250 | "syn", 1251 | ] 1252 | 1253 | [[package]] 1254 | name = "swc_visit" 1255 | version = "0.5.3" 1256 | source = "registry+https://github.com/rust-lang/crates.io-index" 1257 | checksum = "82f2bcb7223e185c4c7cbf5e0c1207dec6d2bfd5e72e3fb7b3e8d179747e9130" 1258 | dependencies = [ 1259 | "either", 1260 | "swc_visit_macros", 1261 | ] 1262 | 1263 | [[package]] 1264 | name = "swc_visit_macros" 1265 | version = "0.5.4" 1266 | source = "registry+https://github.com/rust-lang/crates.io-index" 1267 | checksum = "8fb1f3561674d84947694d41fb6d5737d19539222779baeac1b3a071a2b29428" 1268 | dependencies = [ 1269 | "Inflector", 1270 | "pmutil", 1271 | "proc-macro2", 1272 | "quote", 1273 | "swc_macros_common", 1274 | "syn", 1275 | ] 1276 | 1277 | [[package]] 1278 | name = "syn" 1279 | version = "1.0.98" 1280 | source = "registry+https://github.com/rust-lang/crates.io-index" 1281 | checksum = "c50aef8a904de4c23c788f104b7dddc7d6f79c647c7c8ce4cc8f73eb0ca773dd" 1282 | dependencies = [ 1283 | "proc-macro2", 1284 | "quote", 1285 | "unicode-ident", 1286 | ] 1287 | 1288 | [[package]] 1289 | name = "termcolor" 1290 | version = "1.1.3" 1291 | source = "registry+https://github.com/rust-lang/crates.io-index" 1292 | checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755" 1293 | dependencies = [ 1294 | "winapi-util", 1295 | ] 1296 | 1297 | [[package]] 1298 | name = "terminal_size" 1299 | version = "0.1.17" 1300 | source = "registry+https://github.com/rust-lang/crates.io-index" 1301 | checksum = "633c1a546cee861a1a6d0dc69ebeca693bf4296661ba7852b9d21d159e0506df" 1302 | dependencies = [ 1303 | "libc", 1304 | "winapi", 1305 | ] 1306 | 1307 | [[package]] 1308 | name = "textwrap" 1309 | version = "0.15.0" 1310 | source = "registry+https://github.com/rust-lang/crates.io-index" 1311 | checksum = "b1141d4d61095b28419e22cb0bbf02755f5e54e0526f97f1e3d1d160e60885fb" 1312 | 1313 | [[package]] 1314 | name = "thiserror" 1315 | version = "1.0.32" 1316 | source = "registry+https://github.com/rust-lang/crates.io-index" 1317 | checksum = "f5f6586b7f764adc0231f4c79be7b920e766bb2f3e51b3661cdb263828f19994" 1318 | dependencies = [ 1319 | "thiserror-impl", 1320 | ] 1321 | 1322 | [[package]] 1323 | name = "thiserror-impl" 1324 | version = "1.0.32" 1325 | source = "registry+https://github.com/rust-lang/crates.io-index" 1326 | checksum = "12bafc5b54507e0149cdf1b145a5d80ab80a90bcd9275df43d4fff68460f6c21" 1327 | dependencies = [ 1328 | "proc-macro2", 1329 | "quote", 1330 | "syn", 1331 | ] 1332 | 1333 | [[package]] 1334 | name = "tinyvec" 1335 | version = "1.6.0" 1336 | source = "registry+https://github.com/rust-lang/crates.io-index" 1337 | checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" 1338 | dependencies = [ 1339 | "tinyvec_macros", 1340 | ] 1341 | 1342 | [[package]] 1343 | name = "tinyvec_macros" 1344 | version = "0.1.0" 1345 | source = "registry+https://github.com/rust-lang/crates.io-index" 1346 | checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" 1347 | 1348 | [[package]] 1349 | name = "tracing" 1350 | version = "0.1.37" 1351 | source = "registry+https://github.com/rust-lang/crates.io-index" 1352 | checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" 1353 | dependencies = [ 1354 | "cfg-if", 1355 | "pin-project-lite", 1356 | "tracing-attributes", 1357 | "tracing-core", 1358 | ] 1359 | 1360 | [[package]] 1361 | name = "tracing-attributes" 1362 | version = "0.1.23" 1363 | source = "registry+https://github.com/rust-lang/crates.io-index" 1364 | checksum = "4017f8f45139870ca7e672686113917c71c7a6e02d4924eda67186083c03081a" 1365 | dependencies = [ 1366 | "proc-macro2", 1367 | "quote", 1368 | "syn", 1369 | ] 1370 | 1371 | [[package]] 1372 | name = "tracing-core" 1373 | version = "0.1.30" 1374 | source = "registry+https://github.com/rust-lang/crates.io-index" 1375 | checksum = "24eb03ba0eab1fd845050058ce5e616558e8f8d8fca633e6b163fe25c797213a" 1376 | dependencies = [ 1377 | "once_cell", 1378 | ] 1379 | 1380 | [[package]] 1381 | name = "triomphe" 1382 | version = "0.1.8" 1383 | source = "registry+https://github.com/rust-lang/crates.io-index" 1384 | checksum = "f1ee9bd9239c339d714d657fac840c6d2a4f9c45f4f9ec7b0975113458be78db" 1385 | dependencies = [ 1386 | "serde", 1387 | "stable_deref_trait", 1388 | ] 1389 | 1390 | [[package]] 1391 | name = "typenum" 1392 | version = "1.15.0" 1393 | source = "registry+https://github.com/rust-lang/crates.io-index" 1394 | checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" 1395 | 1396 | [[package]] 1397 | name = "unicode-bidi" 1398 | version = "0.3.8" 1399 | source = "registry+https://github.com/rust-lang/crates.io-index" 1400 | checksum = "099b7128301d285f79ddd55b9a83d5e6b9e97c92e0ea0daebee7263e932de992" 1401 | 1402 | [[package]] 1403 | name = "unicode-id" 1404 | version = "0.3.3" 1405 | source = "registry+https://github.com/rust-lang/crates.io-index" 1406 | checksum = "d70b6494226b36008c8366c288d77190b3fad2eb4c10533139c1c1f461127f1a" 1407 | 1408 | [[package]] 1409 | name = "unicode-ident" 1410 | version = "1.0.1" 1411 | source = "registry+https://github.com/rust-lang/crates.io-index" 1412 | checksum = "5bd2fe26506023ed7b5e1e315add59d6f584c621d037f9368fea9cfb988f368c" 1413 | 1414 | [[package]] 1415 | name = "unicode-normalization" 1416 | version = "0.1.22" 1417 | source = "registry+https://github.com/rust-lang/crates.io-index" 1418 | checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" 1419 | dependencies = [ 1420 | "tinyvec", 1421 | ] 1422 | 1423 | [[package]] 1424 | name = "unicode-width" 1425 | version = "0.1.9" 1426 | source = "registry+https://github.com/rust-lang/crates.io-index" 1427 | checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973" 1428 | 1429 | [[package]] 1430 | name = "url" 1431 | version = "2.3.1" 1432 | source = "registry+https://github.com/rust-lang/crates.io-index" 1433 | checksum = "0d68c799ae75762b8c3fe375feb6600ef5602c883c5d21eb51c09f22b83c4643" 1434 | dependencies = [ 1435 | "form_urlencoded", 1436 | "idna", 1437 | "percent-encoding", 1438 | ] 1439 | 1440 | [[package]] 1441 | name = "version_check" 1442 | version = "0.9.4" 1443 | source = "registry+https://github.com/rust-lang/crates.io-index" 1444 | checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" 1445 | 1446 | [[package]] 1447 | name = "wasi" 1448 | version = "0.11.0+wasi-snapshot-preview1" 1449 | source = "registry+https://github.com/rust-lang/crates.io-index" 1450 | checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" 1451 | 1452 | [[package]] 1453 | name = "winapi" 1454 | version = "0.3.9" 1455 | source = "registry+https://github.com/rust-lang/crates.io-index" 1456 | checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" 1457 | dependencies = [ 1458 | "winapi-i686-pc-windows-gnu", 1459 | "winapi-x86_64-pc-windows-gnu", 1460 | ] 1461 | 1462 | [[package]] 1463 | name = "winapi-i686-pc-windows-gnu" 1464 | version = "0.4.0" 1465 | source = "registry+https://github.com/rust-lang/crates.io-index" 1466 | checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" 1467 | 1468 | [[package]] 1469 | name = "winapi-util" 1470 | version = "0.1.5" 1471 | source = "registry+https://github.com/rust-lang/crates.io-index" 1472 | checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" 1473 | dependencies = [ 1474 | "winapi", 1475 | ] 1476 | 1477 | [[package]] 1478 | name = "winapi-x86_64-pc-windows-gnu" 1479 | version = "0.4.0" 1480 | source = "registry+https://github.com/rust-lang/crates.io-index" 1481 | checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" 1482 | 1483 | [[package]] 1484 | name = "windows-sys" 1485 | version = "0.36.1" 1486 | source = "registry+https://github.com/rust-lang/crates.io-index" 1487 | checksum = "ea04155a16a59f9eab786fe12a4a450e75cdb175f9e0d80da1e17db09f55b8d2" 1488 | dependencies = [ 1489 | "windows_aarch64_msvc", 1490 | "windows_i686_gnu", 1491 | "windows_i686_msvc", 1492 | "windows_x86_64_gnu", 1493 | "windows_x86_64_msvc", 1494 | ] 1495 | 1496 | [[package]] 1497 | name = "windows_aarch64_msvc" 1498 | version = "0.36.1" 1499 | source = "registry+https://github.com/rust-lang/crates.io-index" 1500 | checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47" 1501 | 1502 | [[package]] 1503 | name = "windows_i686_gnu" 1504 | version = "0.36.1" 1505 | source = "registry+https://github.com/rust-lang/crates.io-index" 1506 | checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6" 1507 | 1508 | [[package]] 1509 | name = "windows_i686_msvc" 1510 | version = "0.36.1" 1511 | source = "registry+https://github.com/rust-lang/crates.io-index" 1512 | checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024" 1513 | 1514 | [[package]] 1515 | name = "windows_x86_64_gnu" 1516 | version = "0.36.1" 1517 | source = "registry+https://github.com/rust-lang/crates.io-index" 1518 | checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1" 1519 | 1520 | [[package]] 1521 | name = "windows_x86_64_msvc" 1522 | version = "0.36.1" 1523 | source = "registry+https://github.com/rust-lang/crates.io-index" 1524 | checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680" 1525 | 1526 | [[package]] 1527 | name = "xml-rs" 1528 | version = "0.8.4" 1529 | source = "registry+https://github.com/rust-lang/crates.io-index" 1530 | checksum = "d2d7d3948613f75c98fd9328cfdcc45acc4d360655289d0a7d4ec931392200a3" 1531 | --------------------------------------------------------------------------------