oxc 0.1.0-arm-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.
- checksums.yaml +7 -0
- data/LICENSE.txt +21 -0
- data/README.md +437 -0
- data/ext/oxc/extconf.rb +123 -0
- data/ext/oxc/include/oxc.h +40 -0
- data/ext/oxc/oxc.c +136 -0
- data/lib/oxc/3.2/oxc.so +0 -0
- data/lib/oxc/3.3/oxc.so +0 -0
- data/lib/oxc/3.4/oxc.so +0 -0
- data/lib/oxc/4.0/oxc.so +0 -0
- data/lib/oxc/backend.rb +41 -0
- data/lib/oxc/diagnosed.rb +33 -0
- data/lib/oxc/diagnostic.rb +86 -0
- data/lib/oxc/errors.rb +26 -0
- data/lib/oxc/minifier.rb +31 -0
- data/lib/oxc/minify_result.rb +25 -0
- data/lib/oxc/options.rb +113 -0
- data/lib/oxc/parse_result.rb +106 -0
- data/lib/oxc/result.rb +51 -0
- data/lib/oxc/transform_result.rb +47 -0
- data/lib/oxc/transformer.rb +31 -0
- data/lib/oxc/version.rb +5 -0
- data/lib/oxc.rb +52 -0
- data/licenses/README.md +12 -0
- data/licenses/oxc-MIT.txt +22 -0
- data/licenses/oxc-THIRD-PARTY.txt +763 -0
- data/oxc.gemspec +43 -0
- data/rust/Cargo.lock +1436 -0
- data/rust/Cargo.toml +32 -0
- data/rust/build.rs +52 -0
- data/rust/cbindgen.toml +24 -0
- data/rust/rustfmt.toml +3 -0
- data/rust/src/diagnostic.rs +75 -0
- data/rust/src/lib.rs +288 -0
- data/rust/src/module_record.rs +262 -0
- data/rust/src/options.rs +744 -0
- data/rust/src/parse.rs +93 -0
- data/rust/src/result.rs +55 -0
- data/rust/src/source_type.rs +26 -0
- data/rust/src/symbols.rs +101 -0
- data/rust/src/transform.rs +116 -0
- data/sig/oxc/backend.rbs +29 -0
- data/sig/oxc/diagnosed.rbs +23 -0
- data/sig/oxc/diagnostic.rbs +57 -0
- data/sig/oxc/errors.rbs +31 -0
- data/sig/oxc/minifier.rbs +21 -0
- data/sig/oxc/minify_result.rbs +11 -0
- data/sig/oxc/options.rbs +42 -0
- data/sig/oxc/parse_result.rbs +61 -0
- data/sig/oxc/result.rbs +32 -0
- data/sig/oxc/transform_result.rbs +22 -0
- data/sig/oxc/transformer.rbs +21 -0
- data/sig/oxc/types.rbs +96 -0
- data/sig/oxc/version.rbs +5 -0
- data/sig/oxc.rbs +15 -0
- metadata +107 -0
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
use std::collections::BTreeMap;
|
|
2
|
+
|
|
3
|
+
use oxc::syntax::module_record::{
|
|
4
|
+
ExportEntry, ExportExportName, ExportImportName, ExportLocalName, ImportEntry, ImportImportName,
|
|
5
|
+
ModuleRecord as OxcModuleRecord, NameSpan,
|
|
6
|
+
};
|
|
7
|
+
use serde::Serialize;
|
|
8
|
+
|
|
9
|
+
#[derive(Debug, Serialize)]
|
|
10
|
+
pub struct ModuleRecord {
|
|
11
|
+
pub has_module_syntax: bool,
|
|
12
|
+
pub static_imports: Vec<StaticImport>,
|
|
13
|
+
pub static_exports: Vec<StaticExport>,
|
|
14
|
+
pub dynamic_imports: Vec<DynamicImport>,
|
|
15
|
+
pub import_metas: Vec<Span>,
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
#[derive(Debug, Serialize)]
|
|
19
|
+
pub struct Span {
|
|
20
|
+
pub start: u32,
|
|
21
|
+
pub end: u32,
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
#[derive(Debug, Serialize)]
|
|
25
|
+
pub struct ValueSpan {
|
|
26
|
+
pub value: String,
|
|
27
|
+
pub start: u32,
|
|
28
|
+
pub end: u32,
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
#[derive(Debug, Serialize)]
|
|
32
|
+
pub struct Name {
|
|
33
|
+
pub kind: &'static str,
|
|
34
|
+
#[serde(skip_serializing_if = "Option::is_none")]
|
|
35
|
+
pub name: Option<String>,
|
|
36
|
+
#[serde(skip_serializing_if = "Option::is_none")]
|
|
37
|
+
pub start: Option<u32>,
|
|
38
|
+
#[serde(skip_serializing_if = "Option::is_none")]
|
|
39
|
+
pub end: Option<u32>,
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
#[derive(Debug, Serialize)]
|
|
43
|
+
pub struct StaticImport {
|
|
44
|
+
pub start: u32,
|
|
45
|
+
pub end: u32,
|
|
46
|
+
pub module_request: ValueSpan,
|
|
47
|
+
pub entries: Vec<StaticImportEntry>,
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
#[derive(Debug, Serialize)]
|
|
51
|
+
pub struct StaticImportEntry {
|
|
52
|
+
pub import_name: Name,
|
|
53
|
+
pub local_name: ValueSpan,
|
|
54
|
+
pub is_type: bool,
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
#[derive(Debug, Serialize)]
|
|
58
|
+
pub struct StaticExport {
|
|
59
|
+
pub start: u32,
|
|
60
|
+
pub end: u32,
|
|
61
|
+
pub entries: Vec<StaticExportEntry>,
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
#[derive(Debug, Serialize)]
|
|
65
|
+
pub struct StaticExportEntry {
|
|
66
|
+
pub start: u32,
|
|
67
|
+
pub end: u32,
|
|
68
|
+
#[serde(skip_serializing_if = "Option::is_none")]
|
|
69
|
+
pub module_request: Option<ValueSpan>,
|
|
70
|
+
pub import_name: Name,
|
|
71
|
+
pub export_name: Name,
|
|
72
|
+
pub local_name: Name,
|
|
73
|
+
pub is_type: bool,
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
#[derive(Debug, Serialize)]
|
|
77
|
+
pub struct DynamicImport {
|
|
78
|
+
pub start: u32,
|
|
79
|
+
pub end: u32,
|
|
80
|
+
pub module_request: Span,
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
impl From<&OxcModuleRecord<'_>> for ModuleRecord {
|
|
84
|
+
fn from(record: &OxcModuleRecord<'_>) -> Self {
|
|
85
|
+
let mut static_imports = record
|
|
86
|
+
.requested_modules
|
|
87
|
+
.iter()
|
|
88
|
+
.flat_map(|(name, requested)| {
|
|
89
|
+
requested
|
|
90
|
+
.iter()
|
|
91
|
+
.filter(|module| module.is_import)
|
|
92
|
+
.map(|module| StaticImport {
|
|
93
|
+
start: module.statement_span.start,
|
|
94
|
+
end: module.statement_span.end,
|
|
95
|
+
module_request: ValueSpan {
|
|
96
|
+
value: name.to_string(),
|
|
97
|
+
start: module.span.start,
|
|
98
|
+
end: module.span.end,
|
|
99
|
+
},
|
|
100
|
+
entries: record
|
|
101
|
+
.import_entries
|
|
102
|
+
.iter()
|
|
103
|
+
.filter(|entry| entry.statement_span == module.statement_span)
|
|
104
|
+
.map(StaticImportEntry::from)
|
|
105
|
+
.collect(),
|
|
106
|
+
})
|
|
107
|
+
})
|
|
108
|
+
.collect::<Vec<_>>();
|
|
109
|
+
|
|
110
|
+
static_imports.sort_unstable_by_key(|import| import.start);
|
|
111
|
+
|
|
112
|
+
let mut grouped = BTreeMap::<(u32, u32), Vec<StaticExportEntry>>::new();
|
|
113
|
+
|
|
114
|
+
for entry in record
|
|
115
|
+
.local_export_entries
|
|
116
|
+
.iter()
|
|
117
|
+
.chain(record.indirect_export_entries.iter())
|
|
118
|
+
.chain(record.star_export_entries.iter())
|
|
119
|
+
{
|
|
120
|
+
grouped
|
|
121
|
+
.entry((entry.statement_span.start, entry.statement_span.end))
|
|
122
|
+
.or_default()
|
|
123
|
+
.push(StaticExportEntry::from(entry));
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
let static_exports = grouped
|
|
127
|
+
.into_iter()
|
|
128
|
+
.map(|((start, end), entries)| StaticExport { start, end, entries })
|
|
129
|
+
.collect();
|
|
130
|
+
|
|
131
|
+
Self {
|
|
132
|
+
has_module_syntax: record.has_module_syntax,
|
|
133
|
+
static_imports,
|
|
134
|
+
static_exports,
|
|
135
|
+
dynamic_imports: record
|
|
136
|
+
.dynamic_imports
|
|
137
|
+
.iter()
|
|
138
|
+
.map(|import| DynamicImport {
|
|
139
|
+
start: import.span.start,
|
|
140
|
+
end: import.span.end,
|
|
141
|
+
module_request: Span {
|
|
142
|
+
start: import.module_request.start,
|
|
143
|
+
end: import.module_request.end,
|
|
144
|
+
},
|
|
145
|
+
})
|
|
146
|
+
.collect(),
|
|
147
|
+
import_metas: record
|
|
148
|
+
.import_metas
|
|
149
|
+
.iter()
|
|
150
|
+
.map(|span| Span {
|
|
151
|
+
start: span.start,
|
|
152
|
+
end: span.end,
|
|
153
|
+
})
|
|
154
|
+
.collect(),
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
impl From<&NameSpan<'_>> for ValueSpan {
|
|
160
|
+
fn from(name: &NameSpan<'_>) -> Self {
|
|
161
|
+
Self {
|
|
162
|
+
value: name.name.to_string(),
|
|
163
|
+
start: name.span.start,
|
|
164
|
+
end: name.span.end,
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
impl From<&ImportEntry<'_>> for StaticImportEntry {
|
|
170
|
+
fn from(entry: &ImportEntry<'_>) -> Self {
|
|
171
|
+
Self {
|
|
172
|
+
import_name: Name::from(&entry.import_name),
|
|
173
|
+
local_name: ValueSpan::from(&entry.local_name),
|
|
174
|
+
is_type: entry.is_type,
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
impl From<&ExportEntry<'_>> for StaticExportEntry {
|
|
180
|
+
fn from(entry: &ExportEntry<'_>) -> Self {
|
|
181
|
+
Self {
|
|
182
|
+
start: entry.span.start,
|
|
183
|
+
end: entry.span.end,
|
|
184
|
+
module_request: entry.module_request.as_ref().map(ValueSpan::from),
|
|
185
|
+
import_name: Name::from(&entry.import_name),
|
|
186
|
+
export_name: Name::from(&entry.export_name),
|
|
187
|
+
local_name: Name::from(&entry.local_name),
|
|
188
|
+
is_type: entry.is_type,
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
impl Name {
|
|
194
|
+
fn named(kind: &'static str, name: &NameSpan<'_>) -> Self {
|
|
195
|
+
Self {
|
|
196
|
+
kind,
|
|
197
|
+
name: Some(name.name.to_string()),
|
|
198
|
+
start: Some(name.span.start),
|
|
199
|
+
end: Some(name.span.end),
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
fn bare(kind: &'static str) -> Self {
|
|
204
|
+
Self {
|
|
205
|
+
kind,
|
|
206
|
+
name: None,
|
|
207
|
+
start: None,
|
|
208
|
+
end: None,
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
impl From<&ImportImportName<'_>> for Name {
|
|
214
|
+
fn from(import_name: &ImportImportName<'_>) -> Self {
|
|
215
|
+
match import_name {
|
|
216
|
+
ImportImportName::Name(name) => Self::named("name", name),
|
|
217
|
+
ImportImportName::NamespaceObject => Self::bare("namespace_object"),
|
|
218
|
+
ImportImportName::Default(span) => Self {
|
|
219
|
+
kind: "default",
|
|
220
|
+
name: None,
|
|
221
|
+
start: Some(span.start),
|
|
222
|
+
end: Some(span.end),
|
|
223
|
+
},
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
impl From<&ExportImportName<'_>> for Name {
|
|
229
|
+
fn from(import_name: &ExportImportName<'_>) -> Self {
|
|
230
|
+
match import_name {
|
|
231
|
+
ExportImportName::Name(name) => Self::named("name", name),
|
|
232
|
+
ExportImportName::All => Self::bare("all"),
|
|
233
|
+
ExportImportName::AllButDefault => Self::bare("all_but_default"),
|
|
234
|
+
ExportImportName::Null => Self::bare("none"),
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
impl From<&ExportExportName<'_>> for Name {
|
|
240
|
+
fn from(export_name: &ExportExportName<'_>) -> Self {
|
|
241
|
+
match export_name {
|
|
242
|
+
ExportExportName::Name(name) => Self::named("name", name),
|
|
243
|
+
ExportExportName::Default(span) => Self {
|
|
244
|
+
kind: "default",
|
|
245
|
+
name: None,
|
|
246
|
+
start: Some(span.start),
|
|
247
|
+
end: Some(span.end),
|
|
248
|
+
},
|
|
249
|
+
ExportExportName::Null => Self::bare("none"),
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
impl From<&ExportLocalName<'_>> for Name {
|
|
255
|
+
fn from(local_name: &ExportLocalName<'_>) -> Self {
|
|
256
|
+
match local_name {
|
|
257
|
+
ExportLocalName::Name(name) => Self::named("name", name),
|
|
258
|
+
ExportLocalName::Default(name) => Self::named("default", name),
|
|
259
|
+
ExportLocalName::Null => Self::bare("none"),
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
}
|