oxc 0.1.0-aarch64-linux-gnu

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.txt +21 -0
  3. data/README.md +437 -0
  4. data/ext/oxc/extconf.rb +123 -0
  5. data/ext/oxc/include/oxc.h +40 -0
  6. data/ext/oxc/oxc.c +136 -0
  7. data/lib/oxc/3.2/oxc.so +0 -0
  8. data/lib/oxc/3.3/oxc.so +0 -0
  9. data/lib/oxc/3.4/oxc.so +0 -0
  10. data/lib/oxc/4.0/oxc.so +0 -0
  11. data/lib/oxc/backend.rb +41 -0
  12. data/lib/oxc/diagnosed.rb +33 -0
  13. data/lib/oxc/diagnostic.rb +86 -0
  14. data/lib/oxc/errors.rb +26 -0
  15. data/lib/oxc/minifier.rb +31 -0
  16. data/lib/oxc/minify_result.rb +25 -0
  17. data/lib/oxc/options.rb +113 -0
  18. data/lib/oxc/parse_result.rb +106 -0
  19. data/lib/oxc/result.rb +51 -0
  20. data/lib/oxc/transform_result.rb +47 -0
  21. data/lib/oxc/transformer.rb +31 -0
  22. data/lib/oxc/version.rb +5 -0
  23. data/lib/oxc.rb +52 -0
  24. data/licenses/README.md +12 -0
  25. data/licenses/oxc-MIT.txt +22 -0
  26. data/licenses/oxc-THIRD-PARTY.txt +763 -0
  27. data/oxc.gemspec +43 -0
  28. data/rust/Cargo.lock +1436 -0
  29. data/rust/Cargo.toml +32 -0
  30. data/rust/build.rs +52 -0
  31. data/rust/cbindgen.toml +24 -0
  32. data/rust/rustfmt.toml +3 -0
  33. data/rust/src/diagnostic.rs +75 -0
  34. data/rust/src/lib.rs +288 -0
  35. data/rust/src/module_record.rs +262 -0
  36. data/rust/src/options.rs +744 -0
  37. data/rust/src/parse.rs +93 -0
  38. data/rust/src/result.rs +55 -0
  39. data/rust/src/source_type.rs +26 -0
  40. data/rust/src/symbols.rs +101 -0
  41. data/rust/src/transform.rs +116 -0
  42. data/sig/oxc/backend.rbs +29 -0
  43. data/sig/oxc/diagnosed.rbs +23 -0
  44. data/sig/oxc/diagnostic.rbs +57 -0
  45. data/sig/oxc/errors.rbs +31 -0
  46. data/sig/oxc/minifier.rbs +21 -0
  47. data/sig/oxc/minify_result.rbs +11 -0
  48. data/sig/oxc/options.rbs +42 -0
  49. data/sig/oxc/parse_result.rbs +61 -0
  50. data/sig/oxc/result.rbs +32 -0
  51. data/sig/oxc/transform_result.rbs +22 -0
  52. data/sig/oxc/transformer.rbs +21 -0
  53. data/sig/oxc/types.rbs +96 -0
  54. data/sig/oxc/version.rbs +5 -0
  55. data/sig/oxc.rbs +15 -0
  56. metadata +107 -0
data/rust/src/parse.rs ADDED
@@ -0,0 +1,93 @@
1
+ use oxc::allocator::Allocator;
2
+ use oxc::ast::CommentKind;
3
+ use oxc::parser::{ParseOptions as OxcParseOptions, Parser};
4
+ use oxc::semantic::SemanticBuilder;
5
+ use serde_json::value::RawValue;
6
+
7
+ use crate::diagnostic::Diagnostic;
8
+ use crate::module_record::ModuleRecord;
9
+ use crate::options::ParseOptions;
10
+ use crate::result::{Comment, ParsePayload};
11
+ use crate::source_type::source_type_for;
12
+ use crate::symbols;
13
+
14
+ pub fn parse_source(source: &str, options: &ParseOptions) -> Result<ParsePayload, String> {
15
+ let filename = options.filename.clone().unwrap_or_default();
16
+ let source_type = source_type_for(&filename, options.lang.as_deref(), options.source_type.as_deref())?;
17
+ let include_ts_fields = options.include_ts_fields(&source_type)?;
18
+
19
+ let allocator = Allocator::default();
20
+
21
+ let parsed = Parser::new(&allocator, source, source_type)
22
+ .with_options(OxcParseOptions {
23
+ preserve_parens: options.preserve_parens,
24
+ enable_ident_hashes: options.semantic_errors || options.symbols,
25
+ ..OxcParseOptions::default()
26
+ })
27
+ .parse();
28
+
29
+ let program = parsed.program;
30
+ let mut diagnostics = parsed.diagnostics;
31
+
32
+ let module_record = options.module_record.then(|| ModuleRecord::from(&parsed.module_record));
33
+ let symbols = options.symbols.then(|| symbols::read(&program));
34
+
35
+ if options.semantic_errors {
36
+ diagnostics.extend(SemanticBuilder::new_compiler().build(&program).diagnostics);
37
+ }
38
+
39
+ let comments = if options.comments {
40
+ collect_comments(source, &program, include_ts_fields)
41
+ } else {
42
+ Vec::new()
43
+ };
44
+
45
+ let serialized = if options.ast {
46
+ let json = program.to_estree_json(include_ts_fields, options.ranges);
47
+
48
+ Some(RawValue::from_string(json).map_err(|error| format!("Failed to read the AST back: {error}"))?)
49
+ } else {
50
+ None
51
+ };
52
+
53
+ Ok(ParsePayload {
54
+ program: serialized,
55
+ module_record,
56
+ symbols,
57
+ comments,
58
+ errors: Diagnostic::from_diagnostics(&filename, source, diagnostics),
59
+ panicked: parsed.panicked,
60
+ })
61
+ }
62
+
63
+ fn collect_comments(source: &str, program: &oxc::ast::ast::Program<'_>, include_ts_fields: bool) -> Vec<Comment> {
64
+ let mut comments = program
65
+ .comments
66
+ .iter()
67
+ .map(|comment| Comment {
68
+ kind: match comment.kind {
69
+ CommentKind::Line => "Line",
70
+ CommentKind::SingleLineBlock | CommentKind::MultiLineBlock => "Block",
71
+ },
72
+ value: comment.content_span().source_text(source).to_string(),
73
+ start: comment.span.start,
74
+ end: comment.span.end,
75
+ })
76
+ .collect::<Vec<_>>();
77
+
78
+ if !include_ts_fields {
79
+ if let Some(hashbang) = &program.hashbang {
80
+ comments.insert(
81
+ 0,
82
+ Comment {
83
+ kind: "Line",
84
+ value: hashbang.value.to_string(),
85
+ start: hashbang.span.start,
86
+ end: hashbang.span.end,
87
+ },
88
+ );
89
+ }
90
+ }
91
+
92
+ comments
93
+ }
@@ -0,0 +1,55 @@
1
+ use std::collections::BTreeMap;
2
+
3
+ use serde::Serialize;
4
+ use serde_json::value::RawValue;
5
+
6
+ use crate::diagnostic::Diagnostic;
7
+ use crate::module_record::ModuleRecord;
8
+ use crate::symbols::Symbols;
9
+
10
+ #[derive(Debug, Default, Serialize)]
11
+ pub struct MinifyPayload {
12
+ pub code: String,
13
+ #[serde(skip_serializing_if = "Option::is_none")]
14
+ pub map: Option<String>,
15
+ pub legal_comments: Vec<String>,
16
+ pub errors: Vec<Diagnostic>,
17
+ pub panicked: bool,
18
+ }
19
+
20
+ #[derive(Debug, Default, Serialize)]
21
+ pub struct TransformPayload {
22
+ pub code: String,
23
+ #[serde(skip_serializing_if = "Option::is_none")]
24
+ pub map: Option<String>,
25
+ #[serde(skip_serializing_if = "Option::is_none")]
26
+ pub declaration: Option<String>,
27
+ #[serde(skip_serializing_if = "Option::is_none")]
28
+ pub declaration_map: Option<String>,
29
+ pub legal_comments: Vec<String>,
30
+ pub helpers_used: BTreeMap<String, String>,
31
+ pub errors: Vec<Diagnostic>,
32
+ pub panicked: bool,
33
+ }
34
+
35
+ #[derive(Debug, Serialize)]
36
+ pub struct Comment {
37
+ #[serde(rename = "type")]
38
+ pub kind: &'static str,
39
+ pub value: String,
40
+ pub start: u32,
41
+ pub end: u32,
42
+ }
43
+
44
+ #[derive(Debug, Serialize)]
45
+ pub struct ParsePayload {
46
+ #[serde(skip_serializing_if = "Option::is_none")]
47
+ pub program: Option<Box<RawValue>>,
48
+ #[serde(skip_serializing_if = "Option::is_none")]
49
+ pub module_record: Option<ModuleRecord>,
50
+ #[serde(skip_serializing_if = "Option::is_none")]
51
+ pub symbols: Option<Symbols>,
52
+ pub comments: Vec<Comment>,
53
+ pub errors: Vec<Diagnostic>,
54
+ pub panicked: bool,
55
+ }
@@ -0,0 +1,26 @@
1
+ use oxc::span::SourceType;
2
+
3
+ pub fn source_type_for(filename: &str, lang: Option<&str>, source_type: Option<&str>) -> Result<SourceType, String> {
4
+ let ty = match lang {
5
+ Some("js") => SourceType::unambiguous(),
6
+ Some("jsx") => SourceType::unambiguous().with_jsx(true),
7
+ Some("ts") => SourceType::unambiguous().with_typescript(true),
8
+ Some("tsx") => SourceType::unambiguous().with_typescript(true).with_jsx(true),
9
+ Some("dts") => SourceType::d_ts(),
10
+ Some(other) => return Err(format!("Unknown lang: {other}. Expected js, jsx, ts, tsx or dts.")),
11
+ None => SourceType::from_path(filename).unwrap_or_default(),
12
+ };
13
+
14
+ Ok(match source_type {
15
+ Some("script") => ty.with_script(true),
16
+ Some("module") => ty.with_module(true),
17
+ Some("commonjs") => ty.with_commonjs(true),
18
+ Some("unambiguous") => ty.with_unambiguous(true),
19
+ Some(other) => {
20
+ return Err(format!(
21
+ "Unknown source_type: {other}. Expected script, module, commonjs or unambiguous."
22
+ ));
23
+ }
24
+ None => ty,
25
+ })
26
+ }
@@ -0,0 +1,101 @@
1
+ use oxc::ast::ast::Program;
2
+ use oxc::semantic::{ReferenceId, Semantic, SemanticBuilder};
3
+ use oxc::span::GetSpan;
4
+ use serde::Serialize;
5
+
6
+ use crate::module_record::Span;
7
+
8
+ #[derive(Debug, Serialize)]
9
+ pub struct Symbols {
10
+ pub declared: Vec<Symbol>,
11
+ pub unresolved: Vec<Unresolved>,
12
+ }
13
+
14
+ #[derive(Debug, Serialize)]
15
+ pub struct Symbol {
16
+ pub name: String,
17
+ pub root: bool,
18
+ pub declaration: Span,
19
+ pub references: Vec<Reference>,
20
+ }
21
+
22
+ #[derive(Debug, Serialize)]
23
+ pub struct Unresolved {
24
+ pub name: String,
25
+ pub references: Vec<Reference>,
26
+ }
27
+
28
+ #[derive(Debug, Serialize)]
29
+ pub struct Reference {
30
+ pub start: u32,
31
+ pub end: u32,
32
+ pub read: bool,
33
+ pub write: bool,
34
+ }
35
+
36
+ pub fn read<'a>(program: &'a Program<'a>) -> Symbols {
37
+ let semantic = SemanticBuilder::new().with_build_nodes(true).build(program).semantic;
38
+
39
+ Symbols {
40
+ declared: declared(&semantic),
41
+ unresolved: unresolved(&semantic),
42
+ }
43
+ }
44
+
45
+ fn declared(semantic: &Semantic<'_>) -> Vec<Symbol> {
46
+ let scoping = semantic.scoping();
47
+
48
+ scoping
49
+ .symbol_ids()
50
+ .map(|symbol_id| {
51
+ let name = scoping.symbol_name(symbol_id).to_string();
52
+ let declaration = scoping.symbol_span(symbol_id);
53
+
54
+ Symbol {
55
+ root: scoping.symbol_scope_id(symbol_id) == scoping.root_scope_id(),
56
+ name,
57
+ declaration: Span {
58
+ start: declaration.start,
59
+ end: declaration.end,
60
+ },
61
+ references: scoping
62
+ .get_resolved_reference_ids(symbol_id)
63
+ .iter()
64
+ .map(|reference_id| reference(semantic, *reference_id))
65
+ .collect(),
66
+ }
67
+ })
68
+ .collect()
69
+ }
70
+
71
+ fn unresolved(semantic: &Semantic<'_>) -> Vec<Unresolved> {
72
+ let scoping = semantic.scoping();
73
+
74
+ let mut unresolved = scoping
75
+ .root_unresolved_references()
76
+ .iter()
77
+ .map(|(name, reference_ids)| Unresolved {
78
+ name: name.to_string(),
79
+ references: reference_ids
80
+ .iter()
81
+ .map(|reference_id| reference(semantic, *reference_id))
82
+ .collect(),
83
+ })
84
+ .collect::<Vec<_>>();
85
+
86
+ unresolved.sort_unstable_by(|left, right| left.name.cmp(&right.name));
87
+
88
+ unresolved
89
+ }
90
+
91
+ fn reference(semantic: &Semantic<'_>, reference_id: ReferenceId) -> Reference {
92
+ let found = semantic.scoping().get_reference(reference_id);
93
+ let span = semantic.nodes().kind(found.node_id()).span();
94
+
95
+ Reference {
96
+ start: span.start,
97
+ end: span.end,
98
+ read: found.is_read(),
99
+ write: found.is_write(),
100
+ }
101
+ }
@@ -0,0 +1,116 @@
1
+ use std::collections::BTreeMap;
2
+ use std::ops::ControlFlow;
3
+
4
+ use oxc::ast::ast::Program;
5
+ use oxc::codegen::{CodegenOptions, CodegenReturn};
6
+ use oxc::diagnostics::Diagnostics;
7
+ use oxc::isolated_declarations::IsolatedDeclarationsOptions;
8
+ use oxc::minifier::{CompressOptions, MangleOptions};
9
+ use oxc::span::Span;
10
+ use oxc::transformer::{TransformOptions as OxcTransformOptions, TransformerReturn};
11
+ use oxc::transformer_plugins::{InjectGlobalVariablesConfig, ReplaceGlobalDefinesConfig};
12
+ use oxc::CompilerInterface;
13
+
14
+ use crate::options::TransformOptions;
15
+
16
+ #[derive(Default)]
17
+ pub struct Compiler {
18
+ transform_options: OxcTransformOptions,
19
+ codegen_options: CodegenOptions,
20
+ compress: Option<CompressOptions>,
21
+ mangle: Option<MangleOptions>,
22
+ define: Option<ReplaceGlobalDefinesConfig>,
23
+ inject: Option<InjectGlobalVariablesConfig>,
24
+ sourcemap: bool,
25
+ isolated_declarations: Option<IsolatedDeclarationsOptions>,
26
+
27
+ pub code: String,
28
+ pub declaration: Option<String>,
29
+ pub declaration_map: Option<String>,
30
+ pub map: Option<String>,
31
+ pub legal_comments: Vec<Span>,
32
+ pub helpers_used: BTreeMap<String, String>,
33
+ pub errors: Diagnostics,
34
+ }
35
+
36
+ impl Compiler {
37
+ pub fn new(options: &TransformOptions) -> Result<Self, String> {
38
+ let minifier_options = options.to_minifier_options()?;
39
+
40
+ Ok(Self {
41
+ transform_options: options.to_transform_options()?,
42
+ codegen_options: options.to_codegen_options()?,
43
+ compress: minifier_options.as_ref().and_then(|options| options.compress.clone()),
44
+ mangle: minifier_options.as_ref().and_then(|options| options.mangle.clone()),
45
+ define: options.to_define_config()?,
46
+ inject: options.to_inject_config()?,
47
+ sourcemap: options.sourcemap,
48
+ isolated_declarations: options.to_isolated_declarations_options(),
49
+ ..Self::default()
50
+ })
51
+ }
52
+ }
53
+
54
+ impl CompilerInterface for Compiler {
55
+ fn handle_errors(&mut self, errors: Diagnostics) {
56
+ self.errors.extend(errors);
57
+ }
58
+
59
+ fn enable_sourcemap(&self) -> bool {
60
+ self.sourcemap
61
+ }
62
+
63
+ fn transform_options(&self) -> Option<&OxcTransformOptions> {
64
+ Some(&self.transform_options)
65
+ }
66
+
67
+ fn isolated_declaration_options(&self) -> Option<IsolatedDeclarationsOptions> {
68
+ self.isolated_declarations
69
+ }
70
+
71
+ fn define_options(&self) -> Option<ReplaceGlobalDefinesConfig> {
72
+ self.define.clone()
73
+ }
74
+
75
+ fn inject_options(&self) -> Option<InjectGlobalVariablesConfig> {
76
+ self.inject.clone()
77
+ }
78
+
79
+ fn compress_options(&self) -> Option<CompressOptions> {
80
+ self.compress.clone()
81
+ }
82
+
83
+ fn mangle_options(&self) -> Option<MangleOptions> {
84
+ self.mangle.clone()
85
+ }
86
+
87
+ fn codegen_options(&self) -> Option<CodegenOptions> {
88
+ Some(self.codegen_options.clone())
89
+ }
90
+
91
+ #[expect(deprecated)]
92
+ fn after_transform(
93
+ &mut self,
94
+ _program: &mut Program<'_>,
95
+ transformer_return: &mut TransformerReturn,
96
+ ) -> ControlFlow<()> {
97
+ self.helpers_used = transformer_return
98
+ .helpers_used
99
+ .drain()
100
+ .map(|(helper, source)| (helper.name().to_string(), source))
101
+ .collect();
102
+
103
+ ControlFlow::Continue(())
104
+ }
105
+
106
+ fn after_isolated_declarations(&mut self, ret: CodegenReturn<'_>) {
107
+ self.declaration = Some(ret.code);
108
+ self.declaration_map = ret.map.map(|map| map.to_json_string());
109
+ }
110
+
111
+ fn after_codegen(&mut self, ret: CodegenReturn<'_>) {
112
+ self.code = ret.code;
113
+ self.map = ret.map.map(|map| map.to_json_string());
114
+ self.legal_comments = ret.legal_comments.iter().map(|comment| comment.span).collect();
115
+ }
116
+ }
@@ -0,0 +1,29 @@
1
+ # Generated from lib/oxc/backend.rb with RBS::Inline
2
+
3
+ module Oxc
4
+ module Backend
5
+ module Unavailable
6
+ # : (String, String) -> String
7
+ def minify: (String, String) -> String
8
+
9
+ # : (String, String) -> String
10
+ def transform: (String, String) -> String
11
+
12
+ # : (String, String) -> String
13
+ def parse: (String, String) -> String
14
+
15
+ # : () -> String
16
+ def version: () -> String
17
+
18
+ # : () -> String
19
+ def oxc_version: () -> String
20
+
21
+ private
22
+
23
+ # : (Symbol?) -> bot
24
+ def unavailable: (Symbol?) -> bot
25
+ end
26
+
27
+ extend Unavailable
28
+ end
29
+ end
@@ -0,0 +1,23 @@
1
+ # Generated from lib/oxc/diagnosed.rb with RBS::Inline
2
+
3
+ module Oxc
4
+ # @rbs module-self _Diagnosed
5
+ module Diagnosed : _Diagnosed
6
+ @panicked: bool
7
+
8
+ # : () -> Array[Oxc::Diagnostic]
9
+ def errors: () -> Array[Oxc::Diagnostic]
10
+
11
+ # : () -> Array[Oxc::Diagnostic]
12
+ def warnings: () -> Array[Oxc::Diagnostic]
13
+
14
+ # : () -> bool
15
+ def errors?: () -> bool
16
+
17
+ # : () -> bool
18
+ def warnings?: () -> bool
19
+
20
+ # : () -> bool
21
+ def panicked?: () -> bool
22
+ end
23
+ end
@@ -0,0 +1,57 @@
1
+ # Generated from lib/oxc/diagnostic.rb with RBS::Inline
2
+
3
+ module Oxc
4
+ class Diagnostic
5
+ ERROR: String
6
+
7
+ WARNING: String
8
+
9
+ attr_reader severity: String
10
+
11
+ attr_reader message: String
12
+
13
+ attr_reader labels: Array[Oxc::Label]
14
+
15
+ attr_reader help: String?
16
+
17
+ attr_reader codeframe: String?
18
+
19
+ # : (Hash[String, untyped]) -> Oxc::Diagnostic
20
+ def self.from_hash: (Hash[String, untyped]) -> Oxc::Diagnostic
21
+
22
+ # : (severity: String, message: String, labels: Array[Oxc::Label], ?help: String?, ?codeframe: String?) -> void
23
+ def initialize: (severity: String, message: String, labels: Array[Oxc::Label], ?help: String?, ?codeframe: String?) -> void
24
+
25
+ # : () -> bool
26
+ def error?: () -> bool
27
+
28
+ # : () -> bool
29
+ def warning?: () -> bool
30
+
31
+ # : () -> String
32
+ def to_s: () -> String
33
+
34
+ # : () -> String
35
+ def inspect: () -> String
36
+ end
37
+
38
+ class Label
39
+ attr_reader message: String?
40
+
41
+ attr_reader start: Integer
42
+
43
+ attr_reader finish: Integer
44
+
45
+ # : (Hash[String, untyped]) -> Oxc::Label
46
+ def self.from_hash: (Hash[String, untyped]) -> Oxc::Label
47
+
48
+ # : (start: Integer, finish: Integer, ?message: String?) -> void
49
+ def initialize: (start: Integer, finish: Integer, ?message: String?) -> void
50
+
51
+ # : (String) -> String?
52
+ def slice: (String) -> String?
53
+
54
+ # : () -> String
55
+ def inspect: () -> String
56
+ end
57
+ end
@@ -0,0 +1,31 @@
1
+ # Generated from lib/oxc/errors.rb with RBS::Inline
2
+
3
+ module Oxc
4
+ class Error < StandardError
5
+ end
6
+
7
+ class OptionError < Error
8
+ end
9
+
10
+ class EncodingError < Error
11
+ end
12
+
13
+ class TransformError < Error
14
+ end
15
+
16
+ class InternalError < Error
17
+ end
18
+
19
+ class PanicError < InternalError
20
+ end
21
+
22
+ class SyntaxError < Error
23
+ attr_reader result: (Oxc::Result | Oxc::ParseResult)?
24
+
25
+ # : (String, ?(Oxc::Result | Oxc::ParseResult)?) -> void
26
+ def initialize: (String, ?(Oxc::Result | Oxc::ParseResult)?) -> void
27
+
28
+ # : () -> Array[Oxc::Diagnostic]
29
+ def diagnostics: () -> Array[Oxc::Diagnostic]
30
+ end
31
+ end
@@ -0,0 +1,21 @@
1
+ # Generated from lib/oxc/minifier.rb with RBS::Inline
2
+
3
+ module Oxc
4
+ class Minifier
5
+ attr_reader options: Hash[Symbol, untyped]
6
+
7
+ # : (?filename: String?, ?lang: String?, ?source_type: String?, ?compress: compress?, ?mangle: mangle?, ?codegen: codegen?, ?sourcemap: bool, ?strict: bool) -> void
8
+ def initialize: (?filename: String?, ?lang: String?, ?source_type: String?, ?compress: compress?, ?mangle: mangle?, ?codegen: codegen?, ?sourcemap: bool, ?strict: bool) -> void
9
+
10
+ # : (String, ?filename: String?, ?lang: String?, ?source_type: String?, ?compress: compress?, ?mangle: mangle?, ?codegen: codegen?, ?sourcemap: bool, ?strict: bool) -> Oxc::MinifyResult
11
+ def minify: (String, ?filename: String?, ?lang: String?, ?source_type: String?, ?compress: compress?, ?mangle: mangle?, ?codegen: codegen?, ?sourcemap: bool, ?strict: bool) -> Oxc::MinifyResult
12
+
13
+ alias call minify
14
+
15
+ # : (?filename: String?, ?lang: String?, ?source_type: String?, ?compress: compress?, ?mangle: mangle?, ?codegen: codegen?, ?sourcemap: bool, ?strict: bool) -> Oxc::Minifier
16
+ def with: (?filename: String?, ?lang: String?, ?source_type: String?, ?compress: compress?, ?mangle: mangle?, ?codegen: codegen?, ?sourcemap: bool, ?strict: bool) -> Oxc::Minifier
17
+
18
+ # : () -> String
19
+ def inspect: () -> String
20
+ end
21
+ end
@@ -0,0 +1,11 @@
1
+ # Generated from lib/oxc/minify_result.rb with RBS::Inline
2
+
3
+ module Oxc
4
+ class MinifyResult < Result
5
+ # : (String) -> Oxc::MinifyResult
6
+ def self.from_json: (String) -> Oxc::MinifyResult
7
+
8
+ # : (code: String, diagnostics: Array[Oxc::Diagnostic], ?map: String?, ?legal_comments: Array[String], ?panicked: bool) -> void
9
+ def initialize: (code: String, diagnostics: Array[Oxc::Diagnostic], ?map: String?, ?legal_comments: Array[String], ?panicked: bool) -> void
10
+ end
11
+ end
@@ -0,0 +1,42 @@
1
+ # Generated from lib/oxc/options.rb with RBS::Inline
2
+
3
+ module Oxc
4
+ class Options
5
+ MINIFY: Array[Symbol]
6
+
7
+ TRANSFORM: Array[Symbol]
8
+
9
+ PARSE: Array[Symbol]
10
+
11
+ KNOWN: Array[Symbol]
12
+
13
+ RUBY_ONLY: Array[Symbol]
14
+
15
+ # TODO: support mangle_props. It needs `lazy-regex` and `rustc-hash` as direct dependencies of the
16
+ # Rust crate, because `oxc_minifier::ManglePropertiesOptions` types `include` and `exclude` as
17
+ # `lazy_regex::Regex` and `reserved` as `FxHashSet<CompactStr>`.
18
+ UNSUPPORTED: Array[Symbol]
19
+
20
+ attr_reader to_h: Hash[Symbol, untyped]
21
+
22
+ # : (Hash[Symbol, untyped], ?Array[Symbol], ?String) -> String
23
+ def self.serialize: (Hash[Symbol, untyped], ?Array[Symbol], ?String) -> String
24
+
25
+ # : (Hash[Symbol, untyped], ?Array[Symbol], ?String) -> void
26
+ def initialize: (Hash[Symbol, untyped], ?Array[Symbol], ?String) -> void
27
+
28
+ # : (?untyped) -> String
29
+ def to_json: (?untyped) -> String
30
+
31
+ # : () -> String
32
+ def inspect: () -> String
33
+
34
+ private
35
+
36
+ # : (Array[Symbol], Array[Symbol], String) -> void
37
+ def validate!: (Array[Symbol], Array[Symbol], String) -> void
38
+
39
+ # : (Hash[Symbol, untyped]) -> Hash[Symbol, untyped]
40
+ def normalize: (Hash[Symbol, untyped]) -> Hash[Symbol, untyped]
41
+ end
42
+ end
@@ -0,0 +1,61 @@
1
+ # Generated from lib/oxc/parse_result.rb with RBS::Inline
2
+
3
+ module Oxc
4
+ class ParseResult
5
+ include Diagnosed
6
+
7
+ attr_reader program: Hash[String, untyped]?
8
+
9
+ attr_reader module_record: Hash[String, untyped]?
10
+
11
+ attr_reader symbols: Hash[String, untyped]?
12
+
13
+ attr_reader comments: Array[Oxc::Comment]
14
+
15
+ attr_reader diagnostics: Array[Oxc::Diagnostic]
16
+
17
+ # : (String) -> Oxc::ParseResult
18
+ def self.from_json: (String) -> Oxc::ParseResult
19
+
20
+ # : (comments: Array[Oxc::Comment], diagnostics: Array[Oxc::Diagnostic], ?program: Hash[String, untyped]?, ?module_record: Hash[String, untyped]?, ?symbols: Hash[String, untyped]?, ?panicked: bool) -> void
21
+ def initialize: (comments: Array[Oxc::Comment], diagnostics: Array[Oxc::Diagnostic], ?program: Hash[String, untyped]?, ?module_record: Hash[String, untyped]?, ?symbols: Hash[String, untyped]?, ?panicked: bool) -> void
22
+
23
+ # : () -> Oxc::ParseResult
24
+ def validate!: () -> Oxc::ParseResult
25
+
26
+ # : () -> String
27
+ def inspect: () -> String
28
+ end
29
+
30
+ class Comment
31
+ LINE: String
32
+
33
+ BLOCK: String
34
+
35
+ attr_reader type: String
36
+
37
+ attr_reader value: String
38
+
39
+ attr_reader start: Integer
40
+
41
+ attr_reader finish: Integer
42
+
43
+ # : (Hash[String, untyped]) -> Oxc::Comment
44
+ def self.from_hash: (Hash[String, untyped]) -> Oxc::Comment
45
+
46
+ # : (type: String, value: String, start: Integer, finish: Integer) -> void
47
+ def initialize: (type: String, value: String, start: Integer, finish: Integer) -> void
48
+
49
+ # : () -> bool
50
+ def line?: () -> bool
51
+
52
+ # : () -> bool
53
+ def block?: () -> bool
54
+
55
+ # : (String) -> String?
56
+ def slice: (String) -> String?
57
+
58
+ # : () -> String
59
+ def inspect: () -> String
60
+ end
61
+ end