lightningcss 1.33.0.2-arm-linux-gnu → 1.33.0.3-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 +4 -4
- data/README.md +35 -8
- data/lib/lightningcss/3.2/lightningcss.so +0 -0
- data/lib/lightningcss/3.3/lightningcss.so +0 -0
- data/lib/lightningcss/3.4/lightningcss.so +0 -0
- data/lib/lightningcss/4.0/lightningcss.so +0 -0
- data/lib/lightningcss/options.rb +7 -2
- data/lib/lightningcss/result.rb +5 -2
- data/lib/lightningcss/transformer.rb +4 -4
- data/lib/lightningcss/version.rb +1 -1
- data/lib/lightningcss.rb +2 -2
- data/rust/Cargo.lock +3 -2
- data/rust/Cargo.toml +1 -0
- data/rust/src/lib.rs +75 -2
- data/rust/src/options.rs +26 -1
- data/sig/lightningcss/result.rbs +4 -2
- data/sig/lightningcss/transformer.rbs +8 -8
- data/sig/lightningcss.rbs +4 -4
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: dac4801c8da7f7a41e5a13d3829905e664318f0aef31cd69b49c9b5ac59e8c15
|
|
4
|
+
data.tar.gz: a22a9d1a6ae7643bc914c4e125770be5fcb97b894c84065c95b05ffba647df1c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 470def4585b9e36b493402701297f1f3b9bedfa1f52410a037a68550c1bd79625db08163f9d8361aa538c6f1b98053582a364cafa6e5f203de0033042a95bb41
|
|
7
|
+
data.tar.gz: 34ae4bab41f5ac9b950288f31ee84afedf1b658cf708cc5fa5731d76facd6a70cd6459132a5f68a31d847109033c3d15ccf36d9e97e11292cd0131bedbcf141e
|
data/README.md
CHANGED
|
@@ -76,6 +76,8 @@ LightningCSS.transform(".a { color: oklch(60% .2 30) }", targets: { safari: "15.
|
|
|
76
76
|
|
|
77
77
|
Prefer a `String` for a minor version above 9, since `16.10` as a `Float` is `16.1`.
|
|
78
78
|
|
|
79
|
+
The browsers it reads are `android`, `chrome`, `edge`, `firefox`, `ie`, `ios_saf` (or `ios`), `opera`, `safari`, and `samsung`. Any other name raises a `LightningCSS::OptionError`.
|
|
80
|
+
|
|
79
81
|
#### Bundling
|
|
80
82
|
|
|
81
83
|
`bundle` resolves the `@import` statements a stylesheet was written with by reading the files they name, so it takes a path on disk to the entry stylesheet.
|
|
@@ -142,6 +144,25 @@ LightningCSS.transform(".x:not(.y) { color: red }", scope: "[s]", minify: true).
|
|
|
142
144
|
#=> ".x:not(.y)[s]{color:red}"
|
|
143
145
|
```
|
|
144
146
|
|
|
147
|
+
#### Source maps
|
|
148
|
+
|
|
149
|
+
Pass `source_map: true` and the result has a `map`, a JSON string. Give a `filename` too, since that is what the map names as its source.
|
|
150
|
+
|
|
151
|
+
```ruby
|
|
152
|
+
result = LightningCSS.transform(".a { color: red }", filename: "main.css", source_map: true, minify: true)
|
|
153
|
+
|
|
154
|
+
result.map
|
|
155
|
+
#=> "{\"version\":3,\"sourceRoot\":null,\"mappings\":\"AAAA\",\"sources\":[\"main.css\"],...}"
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
For CSS that was compiled from something else, pass that step's map as `input_source_map` and the result maps back to the original sources. A map it cannot read raises a `LightningCSS::OptionError`.
|
|
159
|
+
|
|
160
|
+
```ruby
|
|
161
|
+
LightningCSS.transform(sass_output, filename: "main.css", source_map: true, input_source_map: sass_map)
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
`bundle` takes `source_map` as well, and adds every file it read to `sources` with its contents. `project_root` sets what the `sources` are relative to. A bundle reads many files, so it does not take a single `input_source_map`, and a style attribute has no source map.
|
|
165
|
+
|
|
145
166
|
#### Style attributes
|
|
146
167
|
|
|
147
168
|
A style attribute is the list of declarations an element carries inline. It has no selectors and no at-rules around it, so it is its own grammar.
|
|
@@ -278,14 +299,17 @@ It answers `call` as well, so it can be handed to anything expecting something c
|
|
|
278
299
|
|
|
279
300
|
### Options
|
|
280
301
|
|
|
281
|
-
| Option
|
|
282
|
-
|
|
283
|
-
| `filename`
|
|
284
|
-
| `minify`
|
|
285
|
-
| `error_recovery`
|
|
286
|
-
| `targets`
|
|
287
|
-
| `css_modules`
|
|
288
|
-
| `scope`
|
|
302
|
+
| Option | Type | Description |
|
|
303
|
+
|--------------------|----------------|----------------------------------------------------------------------------------------|
|
|
304
|
+
| `filename` | `String` | The name to use in errors and warnings. |
|
|
305
|
+
| `minify` | `bool` | Whether to print the result as small as it goes. |
|
|
306
|
+
| `error_recovery` | `bool` | Whether to carry on past a rule it cannot read. Off by default, so such a rule raises. |
|
|
307
|
+
| `targets` | `Hash` | The browsers being compiled for, each with the oldest version supported. |
|
|
308
|
+
| `css_modules` | `bool`, `Hash` | Whether to compile as a CSS module, and how. |
|
|
309
|
+
| `scope` | `String` | A selector fragment to narrow every rule by. |
|
|
310
|
+
| `source_map` | `bool` | Whether to generate a source map. Off by default. |
|
|
311
|
+
| `input_source_map` | `String` | A source map as JSON to chain through, such as one from Sass. Needs `source_map`. |
|
|
312
|
+
| `project_root` | `String` | What the `sources` of a source map are relative to. |
|
|
289
313
|
|
|
290
314
|
An option nobody reads is refused:
|
|
291
315
|
|
|
@@ -310,6 +334,9 @@ result.to_s
|
|
|
310
334
|
result.exports
|
|
311
335
|
#=> nil
|
|
312
336
|
|
|
337
|
+
result.map
|
|
338
|
+
#=> nil
|
|
339
|
+
|
|
313
340
|
result.warnings
|
|
314
341
|
#=> []
|
|
315
342
|
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
data/lib/lightningcss/options.rb
CHANGED
|
@@ -16,7 +16,10 @@ module LightningCSS
|
|
|
16
16
|
:error_recovery,
|
|
17
17
|
:targets,
|
|
18
18
|
:css_modules,
|
|
19
|
-
:scope
|
|
19
|
+
:scope,
|
|
20
|
+
:source_map,
|
|
21
|
+
:input_source_map,
|
|
22
|
+
:project_root
|
|
20
23
|
].freeze #: Array[Symbol]
|
|
21
24
|
|
|
22
25
|
STYLE_ATTRIBUTE = [
|
|
@@ -36,7 +39,9 @@ module LightningCSS
|
|
|
36
39
|
:error_recovery,
|
|
37
40
|
:targets,
|
|
38
41
|
:css_modules,
|
|
39
|
-
:scope
|
|
42
|
+
:scope,
|
|
43
|
+
:source_map,
|
|
44
|
+
:project_root
|
|
40
45
|
].freeze #: Array[Symbol]
|
|
41
46
|
|
|
42
47
|
attr_reader :to_h #: Hash[Symbol, untyped]
|
data/lib/lightningcss/result.rb
CHANGED
|
@@ -13,6 +13,7 @@ module LightningCSS
|
|
|
13
13
|
class Result
|
|
14
14
|
attr_reader :code #: String
|
|
15
15
|
attr_reader :exports #: Hash[String, String]?
|
|
16
|
+
attr_reader :map #: String?
|
|
16
17
|
attr_reader :warnings #: Array[LightningCSS::Warning]
|
|
17
18
|
|
|
18
19
|
#: (String) -> LightningCSS::Result
|
|
@@ -22,14 +23,16 @@ module LightningCSS
|
|
|
22
23
|
new(
|
|
23
24
|
code: parsed.fetch("code"),
|
|
24
25
|
exports: parsed["exports"],
|
|
26
|
+
map: parsed["map"],
|
|
25
27
|
warnings: parsed.fetch("warnings").map { |warning| Warning.from_hash(warning) }
|
|
26
28
|
)
|
|
27
29
|
end
|
|
28
30
|
|
|
29
|
-
#: (code: String, warnings: Array[LightningCSS::Warning], ?exports: Hash[String, String]?) -> void
|
|
30
|
-
def initialize(code:, warnings:, exports: nil)
|
|
31
|
+
#: (code: String, warnings: Array[LightningCSS::Warning], ?exports: Hash[String, String]?, ?map: String?) -> void
|
|
32
|
+
def initialize(code:, warnings:, exports: nil, map: nil)
|
|
31
33
|
@code = code
|
|
32
34
|
@exports = exports
|
|
35
|
+
@map = map
|
|
33
36
|
@warnings = warnings.freeze
|
|
34
37
|
|
|
35
38
|
freeze
|
|
@@ -14,14 +14,14 @@ module LightningCSS
|
|
|
14
14
|
class Transformer
|
|
15
15
|
attr_reader :options #: Hash[Symbol, untyped]
|
|
16
16
|
|
|
17
|
-
#: (?filename: String?, ?minify: bool, ?error_recovery: bool, ?targets: browsers?, ?css_modules: css_modules?, ?scope: String?) -> void
|
|
17
|
+
#: (?filename: String?, ?minify: bool, ?error_recovery: bool, ?targets: browsers?, ?css_modules: css_modules?, ?scope: String?, ?source_map: bool, ?input_source_map: String?, ?project_root: String?) -> void
|
|
18
18
|
def initialize(**options)
|
|
19
19
|
@options = options.transform_keys(&:to_sym).freeze
|
|
20
20
|
|
|
21
21
|
freeze
|
|
22
22
|
end
|
|
23
23
|
|
|
24
|
-
#: (String, ?filename: String?, ?minify: bool, ?error_recovery: bool, ?targets: browsers?, ?css_modules: css_modules?, ?scope: String?) -> LightningCSS::Result
|
|
24
|
+
#: (String, ?filename: String?, ?minify: bool, ?error_recovery: bool, ?targets: browsers?, ?css_modules: css_modules?, ?scope: String?, ?source_map: bool, ?input_source_map: String?, ?project_root: String?) -> LightningCSS::Result
|
|
25
25
|
def transform(code, **overrides)
|
|
26
26
|
LightningCSS.transform(code, **options, **overrides)
|
|
27
27
|
end
|
|
@@ -33,7 +33,7 @@ module LightningCSS
|
|
|
33
33
|
LightningCSS.parse(code, **options.slice(*Options::PARSE), **overrides)
|
|
34
34
|
end
|
|
35
35
|
|
|
36
|
-
#: (String, ?minify: bool, ?error_recovery: bool, ?targets: browsers?, ?css_modules: css_modules?, ?scope: String?) -> LightningCSS::Result
|
|
36
|
+
#: (String, ?minify: bool, ?error_recovery: bool, ?targets: browsers?, ?css_modules: css_modules?, ?scope: String?, ?source_map: bool, ?project_root: String?) -> LightningCSS::Result
|
|
37
37
|
def bundle(path, **overrides)
|
|
38
38
|
LightningCSS.bundle(path, **options, **overrides)
|
|
39
39
|
end
|
|
@@ -48,7 +48,7 @@ module LightningCSS
|
|
|
48
48
|
transform(code, **overrides, minify: true).code
|
|
49
49
|
end
|
|
50
50
|
|
|
51
|
-
#: (?filename: String?, ?minify: bool, ?error_recovery: bool, ?targets: browsers?, ?css_modules: css_modules?, ?scope: String?) -> LightningCSS::Transformer
|
|
51
|
+
#: (?filename: String?, ?minify: bool, ?error_recovery: bool, ?targets: browsers?, ?css_modules: css_modules?, ?scope: String?, ?source_map: bool, ?input_source_map: String?, ?project_root: String?) -> LightningCSS::Transformer
|
|
52
52
|
def with(**overrides)
|
|
53
53
|
self.class.new(**options, **overrides)
|
|
54
54
|
end
|
data/lib/lightningcss/version.rb
CHANGED
data/lib/lightningcss.rb
CHANGED
|
@@ -42,7 +42,7 @@ require_relative "lightningcss/transformer"
|
|
|
42
42
|
# set of them to reuse across many stylesheets.
|
|
43
43
|
#
|
|
44
44
|
module LightningCSS
|
|
45
|
-
#: (String, ?filename: String?, ?minify: bool, ?error_recovery: bool, ?targets: browsers?, ?css_modules: css_modules?, ?scope: String?) -> LightningCSS::Result
|
|
45
|
+
#: (String, ?filename: String?, ?minify: bool, ?error_recovery: bool, ?targets: browsers?, ?css_modules: css_modules?, ?scope: String?, ?source_map: bool, ?input_source_map: String?, ?project_root: String?) -> LightningCSS::Result
|
|
46
46
|
def self.transform(code, **options)
|
|
47
47
|
Result.from_json(Backend.transform(code.to_s, Options.serialize(options)))
|
|
48
48
|
end
|
|
@@ -54,7 +54,7 @@ module LightningCSS
|
|
|
54
54
|
ParseResult.from_json(Backend.parse(code.to_s, serialized), code.to_s)
|
|
55
55
|
end
|
|
56
56
|
|
|
57
|
-
#: (String, ?minify: bool, ?error_recovery: bool, ?targets: browsers?, ?css_modules: css_modules?, ?scope: String?) -> LightningCSS::Result
|
|
57
|
+
#: (String, ?minify: bool, ?error_recovery: bool, ?targets: browsers?, ?css_modules: css_modules?, ?scope: String?, ?source_map: bool, ?project_root: String?) -> LightningCSS::Result
|
|
58
58
|
def self.bundle(path, **options)
|
|
59
59
|
serialized = Options.serialize(options, Options::BUNDLE, "a bundle")
|
|
60
60
|
|
data/rust/Cargo.lock
CHANGED
|
@@ -536,6 +536,7 @@ version = "0.0.0"
|
|
|
536
536
|
dependencies = [
|
|
537
537
|
"cbindgen",
|
|
538
538
|
"lightningcss",
|
|
539
|
+
"parcel_sourcemap",
|
|
539
540
|
"serde",
|
|
540
541
|
"serde_json",
|
|
541
542
|
]
|
|
@@ -957,9 +958,9 @@ dependencies = [
|
|
|
957
958
|
|
|
958
959
|
[[package]]
|
|
959
960
|
name = "serde_json"
|
|
960
|
-
version = "1.0.
|
|
961
|
+
version = "1.0.154"
|
|
961
962
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
962
|
-
checksum = "
|
|
963
|
+
checksum = "e7e9cc8b1b85264074fbcc02a88680c4096b1e47df8f739dceb03bf482f04bd6"
|
|
963
964
|
dependencies = [
|
|
964
965
|
"itoa",
|
|
965
966
|
"memchr",
|
data/rust/Cargo.toml
CHANGED
|
@@ -16,6 +16,7 @@ crate-type = ["cdylib", "staticlib", "rlib"]
|
|
|
16
16
|
|
|
17
17
|
[dependencies]
|
|
18
18
|
lightningcss = { version = "=1.0.0-alpha.72", features = ["visitor", "serde"] }
|
|
19
|
+
parcel_sourcemap = { version = "2.1", features = ["json"] }
|
|
19
20
|
serde = { version = "1", features = ["derive"] }
|
|
20
21
|
serde_json = "1"
|
|
21
22
|
|
data/rust/src/lib.rs
CHANGED
|
@@ -20,6 +20,7 @@ use std::sync::{Arc, RwLock};
|
|
|
20
20
|
use lightningcss::bundler::{BundleErrorKind, Bundler, FileProvider};
|
|
21
21
|
use lightningcss::stylesheet::{MinifyOptions, ParserOptions, PrinterOptions, StyleAttribute, StyleSheet};
|
|
22
22
|
use lightningcss::visitor::Visit;
|
|
23
|
+
use parcel_sourcemap::SourceMap;
|
|
23
24
|
|
|
24
25
|
use crate::options::{Diagnostic, ParseResult, TransformOptions, TransformResult};
|
|
25
26
|
use crate::scope::Scoper;
|
|
@@ -146,8 +147,49 @@ fn parse_source<'i>(code: &'i str, options: &TransformOptions) -> Result<ParseRe
|
|
|
146
147
|
Ok(ParseResult { stylesheet, warnings })
|
|
147
148
|
}
|
|
148
149
|
|
|
150
|
+
fn read_input_source_map(options: &TransformOptions) -> Result<Option<SourceMap>, Failure> {
|
|
151
|
+
let Some(json) = &options.input_source_map else {
|
|
152
|
+
return Ok(None);
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
if !options.source_map {
|
|
156
|
+
return Err(Failure::option("input_source_map needs source_map: true"));
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
SourceMap::from_json("/", json)
|
|
160
|
+
.map(Some)
|
|
161
|
+
.map_err(|error| Failure::option(format!("Invalid input source map: {error}")))
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
fn new_source_map(options: &TransformOptions) -> Option<SourceMap> {
|
|
165
|
+
options
|
|
166
|
+
.source_map
|
|
167
|
+
.then(|| SourceMap::new(options.project_root.as_deref().unwrap_or("/")))
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
fn serialize_source_map(
|
|
171
|
+
source_map: Option<SourceMap>,
|
|
172
|
+
input_source_map: Option<SourceMap>,
|
|
173
|
+
) -> Result<Option<String>, Failure> {
|
|
174
|
+
let Some(mut source_map) = source_map else {
|
|
175
|
+
return Ok(None);
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
if let Some(mut input_source_map) = input_source_map {
|
|
179
|
+
source_map
|
|
180
|
+
.extends(&mut input_source_map)
|
|
181
|
+
.map_err(|error| Failure::option(format!("Invalid input source map: {error}")))?;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
source_map
|
|
185
|
+
.to_json(None)
|
|
186
|
+
.map(Some)
|
|
187
|
+
.map_err(|error| Failure::internal(format!("Failed to serialize source map: {error}")))
|
|
188
|
+
}
|
|
189
|
+
|
|
149
190
|
fn transform_source(code: &str, options: &TransformOptions) -> Result<TransformResult, Failure> {
|
|
150
191
|
let filename = options.filename.clone().unwrap_or_default();
|
|
192
|
+
let input_source_map = read_input_source_map(options)?;
|
|
151
193
|
let css_modules = match &options.css_modules {
|
|
152
194
|
Some(modules) => Some(modules.to_config().map_err(Failure::option)?),
|
|
153
195
|
None => None,
|
|
@@ -183,17 +225,28 @@ fn transform_source(code: &str, options: &TransformOptions) -> Result<TransformR
|
|
|
183
225
|
})
|
|
184
226
|
.map_err(|error| Failure::internal(format!("Failed to minify: {error}")))?;
|
|
185
227
|
|
|
228
|
+
let mut source_map = new_source_map(options);
|
|
229
|
+
|
|
230
|
+
if let Some(source_map) = &mut source_map {
|
|
231
|
+
source_map.add_source(&filename);
|
|
232
|
+
source_map
|
|
233
|
+
.set_source_content(0, code)
|
|
234
|
+
.map_err(|error| Failure::internal(format!("Failed to add source: {error}")))?;
|
|
235
|
+
}
|
|
236
|
+
|
|
186
237
|
let printed = stylesheet
|
|
187
238
|
.to_css(PrinterOptions {
|
|
188
239
|
minify: options.minify,
|
|
189
|
-
source_map:
|
|
190
|
-
project_root:
|
|
240
|
+
source_map: source_map.as_mut(),
|
|
241
|
+
project_root: options.project_root.as_deref(),
|
|
191
242
|
targets,
|
|
192
243
|
analyze_dependencies: None,
|
|
193
244
|
pseudo_classes: None,
|
|
194
245
|
})
|
|
195
246
|
.map_err(|error| Failure::internal(format!("Failed to print: {error}")))?;
|
|
196
247
|
|
|
248
|
+
let map = serialize_source_map(source_map, input_source_map)?;
|
|
249
|
+
|
|
197
250
|
let exports = printed.exports.map(|exports| {
|
|
198
251
|
exports
|
|
199
252
|
.into_iter()
|
|
@@ -209,6 +262,7 @@ fn transform_source(code: &str, options: &TransformOptions) -> Result<TransformR
|
|
|
209
262
|
Ok(TransformResult {
|
|
210
263
|
code: printed.code,
|
|
211
264
|
exports,
|
|
265
|
+
map,
|
|
212
266
|
warnings,
|
|
213
267
|
})
|
|
214
268
|
}
|
|
@@ -255,14 +309,31 @@ fn bundle_source(path: &str, options: &TransformOptions) -> Result<TransformResu
|
|
|
255
309
|
})
|
|
256
310
|
.map_err(|error| Failure::internal(format!("Failed to minify: {error}")))?;
|
|
257
311
|
|
|
312
|
+
let mut source_map = new_source_map(options);
|
|
313
|
+
|
|
314
|
+
if let Some(source_map) = &mut source_map {
|
|
315
|
+
for source in &stylesheet.sources {
|
|
316
|
+
let content = std::fs::read_to_string(source).map_err(|error| Failure::bundle(format!("{source}: {error}")))?;
|
|
317
|
+
let index = source_map.add_source(source);
|
|
318
|
+
|
|
319
|
+
source_map
|
|
320
|
+
.set_source_content(index as usize, &content)
|
|
321
|
+
.map_err(|error| Failure::internal(format!("Failed to add source: {error}")))?;
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
|
|
258
325
|
let printed = stylesheet
|
|
259
326
|
.to_css(PrinterOptions {
|
|
260
327
|
minify: options.minify,
|
|
328
|
+
source_map: source_map.as_mut(),
|
|
329
|
+
project_root: options.project_root.as_deref(),
|
|
261
330
|
targets,
|
|
262
331
|
..PrinterOptions::default()
|
|
263
332
|
})
|
|
264
333
|
.map_err(|error| Failure::internal(format!("Failed to print: {error}")))?;
|
|
265
334
|
|
|
335
|
+
let map = serialize_source_map(source_map, None)?;
|
|
336
|
+
|
|
266
337
|
let exports = printed.exports.map(|exports| {
|
|
267
338
|
exports
|
|
268
339
|
.into_iter()
|
|
@@ -278,6 +349,7 @@ fn bundle_source(path: &str, options: &TransformOptions) -> Result<TransformResu
|
|
|
278
349
|
Ok(TransformResult {
|
|
279
350
|
code: printed.code,
|
|
280
351
|
exports,
|
|
352
|
+
map,
|
|
281
353
|
warnings,
|
|
282
354
|
})
|
|
283
355
|
}
|
|
@@ -310,6 +382,7 @@ fn transform_attribute(code: &str, options: &TransformOptions) -> Result<Transfo
|
|
|
310
382
|
Ok(TransformResult {
|
|
311
383
|
code: printed.code,
|
|
312
384
|
exports: None,
|
|
385
|
+
map: None,
|
|
313
386
|
warnings: Vec::new(),
|
|
314
387
|
})
|
|
315
388
|
}
|
data/rust/src/options.rs
CHANGED
|
@@ -14,6 +14,9 @@ pub struct TransformOptions {
|
|
|
14
14
|
pub targets: Option<HashMap<String, Version>>,
|
|
15
15
|
pub css_modules: Option<CssModulesOptions>,
|
|
16
16
|
pub scope: Option<String>,
|
|
17
|
+
pub source_map: bool,
|
|
18
|
+
pub input_source_map: Option<String>,
|
|
19
|
+
pub project_root: Option<String>,
|
|
17
20
|
}
|
|
18
21
|
|
|
19
22
|
#[derive(Debug, Deserialize)]
|
|
@@ -102,12 +105,32 @@ impl Version {
|
|
|
102
105
|
}
|
|
103
106
|
}
|
|
104
107
|
|
|
108
|
+
const BROWSERS: [&str; 10] = [
|
|
109
|
+
"android", "chrome", "edge", "firefox", "ie", "ios", "ios_saf", "opera", "safari", "samsung",
|
|
110
|
+
];
|
|
111
|
+
|
|
105
112
|
impl TransformOptions {
|
|
106
113
|
pub fn to_targets(&self) -> Result<Targets, String> {
|
|
107
114
|
let Some(versions) = &self.targets else {
|
|
108
115
|
return Ok(Targets::default());
|
|
109
116
|
};
|
|
110
117
|
|
|
118
|
+
let mut unknown: Vec<&str> = versions
|
|
119
|
+
.keys()
|
|
120
|
+
.map(String::as_str)
|
|
121
|
+
.filter(|name| !BROWSERS.contains(name))
|
|
122
|
+
.collect();
|
|
123
|
+
|
|
124
|
+
if !unknown.is_empty() {
|
|
125
|
+
unknown.sort_unstable();
|
|
126
|
+
|
|
127
|
+
return Err(format!(
|
|
128
|
+
"Unknown browser{} in targets: {}",
|
|
129
|
+
if unknown.len() > 1 { "s" } else { "" },
|
|
130
|
+
unknown.join(", ")
|
|
131
|
+
));
|
|
132
|
+
}
|
|
133
|
+
|
|
111
134
|
let mut browsers = Browsers::default();
|
|
112
135
|
|
|
113
136
|
for (name, version) in versions {
|
|
@@ -127,7 +150,7 @@ impl TransformOptions {
|
|
|
127
150
|
"opera" => browsers.opera = encoded,
|
|
128
151
|
"safari" => browsers.safari = encoded,
|
|
129
152
|
"samsung" => browsers.samsung = encoded,
|
|
130
|
-
_ =>
|
|
153
|
+
_ => unreachable!(),
|
|
131
154
|
}
|
|
132
155
|
}
|
|
133
156
|
|
|
@@ -146,6 +169,8 @@ pub struct TransformResult {
|
|
|
146
169
|
pub code: String,
|
|
147
170
|
#[serde(skip_serializing_if = "Option::is_none")]
|
|
148
171
|
pub exports: Option<HashMap<String, String>>,
|
|
172
|
+
#[serde(skip_serializing_if = "Option::is_none")]
|
|
173
|
+
pub map: Option<String>,
|
|
149
174
|
pub warnings: Vec<Diagnostic>,
|
|
150
175
|
}
|
|
151
176
|
|
data/sig/lightningcss/result.rbs
CHANGED
|
@@ -14,13 +14,15 @@ module LightningCSS
|
|
|
14
14
|
|
|
15
15
|
attr_reader exports: Hash[String, String]?
|
|
16
16
|
|
|
17
|
+
attr_reader map: String?
|
|
18
|
+
|
|
17
19
|
attr_reader warnings: Array[LightningCSS::Warning]
|
|
18
20
|
|
|
19
21
|
# : (String) -> LightningCSS::Result
|
|
20
22
|
def self.from_json: (String) -> LightningCSS::Result
|
|
21
23
|
|
|
22
|
-
# : (code: String, warnings: Array[LightningCSS::Warning], ?exports: Hash[String, String]?) -> void
|
|
23
|
-
def initialize: (code: String, warnings: Array[LightningCSS::Warning], ?exports: Hash[String, String]?) -> void
|
|
24
|
+
# : (code: String, warnings: Array[LightningCSS::Warning], ?exports: Hash[String, String]?, ?map: String?) -> void
|
|
25
|
+
def initialize: (code: String, warnings: Array[LightningCSS::Warning], ?exports: Hash[String, String]?, ?map: String?) -> void
|
|
24
26
|
|
|
25
27
|
# : () -> bool
|
|
26
28
|
def warnings?: () -> bool
|
|
@@ -13,19 +13,19 @@ module LightningCSS
|
|
|
13
13
|
class Transformer
|
|
14
14
|
attr_reader options: Hash[Symbol, untyped]
|
|
15
15
|
|
|
16
|
-
# : (?filename: String?, ?minify: bool, ?error_recovery: bool, ?targets: browsers?, ?css_modules: css_modules?, ?scope: String?) -> void
|
|
17
|
-
def initialize: (?filename: String?, ?minify: bool, ?error_recovery: bool, ?targets: browsers?, ?css_modules: css_modules?, ?scope: String?) -> void
|
|
16
|
+
# : (?filename: String?, ?minify: bool, ?error_recovery: bool, ?targets: browsers?, ?css_modules: css_modules?, ?scope: String?, ?source_map: bool, ?input_source_map: String?, ?project_root: String?) -> void
|
|
17
|
+
def initialize: (?filename: String?, ?minify: bool, ?error_recovery: bool, ?targets: browsers?, ?css_modules: css_modules?, ?scope: String?, ?source_map: bool, ?input_source_map: String?, ?project_root: String?) -> void
|
|
18
18
|
|
|
19
|
-
# : (String, ?filename: String?, ?minify: bool, ?error_recovery: bool, ?targets: browsers?, ?css_modules: css_modules?, ?scope: String?) -> LightningCSS::Result
|
|
20
|
-
def transform: (String, ?filename: String?, ?minify: bool, ?error_recovery: bool, ?targets: browsers?, ?css_modules: css_modules?, ?scope: String?) -> LightningCSS::Result
|
|
19
|
+
# : (String, ?filename: String?, ?minify: bool, ?error_recovery: bool, ?targets: browsers?, ?css_modules: css_modules?, ?scope: String?, ?source_map: bool, ?input_source_map: String?, ?project_root: String?) -> LightningCSS::Result
|
|
20
|
+
def transform: (String, ?filename: String?, ?minify: bool, ?error_recovery: bool, ?targets: browsers?, ?css_modules: css_modules?, ?scope: String?, ?source_map: bool, ?input_source_map: String?, ?project_root: String?) -> LightningCSS::Result
|
|
21
21
|
|
|
22
22
|
alias call transform
|
|
23
23
|
|
|
24
24
|
# : (String, ?filename: String?, ?error_recovery: bool) -> LightningCSS::ParseResult
|
|
25
25
|
def parse: (String, ?filename: String?, ?error_recovery: bool) -> LightningCSS::ParseResult
|
|
26
26
|
|
|
27
|
-
# : (String, ?minify: bool, ?error_recovery: bool, ?targets: browsers?, ?css_modules: css_modules?, ?scope: String?) -> LightningCSS::Result
|
|
28
|
-
def bundle: (String, ?minify: bool, ?error_recovery: bool, ?targets: browsers?, ?css_modules: css_modules?, ?scope: String?) -> LightningCSS::Result
|
|
27
|
+
# : (String, ?minify: bool, ?error_recovery: bool, ?targets: browsers?, ?css_modules: css_modules?, ?scope: String?, ?source_map: bool, ?project_root: String?) -> LightningCSS::Result
|
|
28
|
+
def bundle: (String, ?minify: bool, ?error_recovery: bool, ?targets: browsers?, ?css_modules: css_modules?, ?scope: String?, ?source_map: bool, ?project_root: String?) -> LightningCSS::Result
|
|
29
29
|
|
|
30
30
|
# : (String, ?filename: String?, ?minify: bool, ?error_recovery: bool, ?targets: browsers?) -> LightningCSS::Result
|
|
31
31
|
def transform_style_attribute: (String, ?filename: String?, ?minify: bool, ?error_recovery: bool, ?targets: browsers?) -> LightningCSS::Result
|
|
@@ -33,8 +33,8 @@ module LightningCSS
|
|
|
33
33
|
# : (String, ?filename: String?, ?error_recovery: bool, ?targets: browsers?, ?css_modules: css_modules?, ?scope: String?) -> String
|
|
34
34
|
def minify: (String, ?filename: String?, ?error_recovery: bool, ?targets: browsers?, ?css_modules: css_modules?, ?scope: String?) -> String
|
|
35
35
|
|
|
36
|
-
# : (?filename: String?, ?minify: bool, ?error_recovery: bool, ?targets: browsers?, ?css_modules: css_modules?, ?scope: String?) -> LightningCSS::Transformer
|
|
37
|
-
def with: (?filename: String?, ?minify: bool, ?error_recovery: bool, ?targets: browsers?, ?css_modules: css_modules?, ?scope: String?) -> LightningCSS::Transformer
|
|
36
|
+
# : (?filename: String?, ?minify: bool, ?error_recovery: bool, ?targets: browsers?, ?css_modules: css_modules?, ?scope: String?, ?source_map: bool, ?input_source_map: String?, ?project_root: String?) -> LightningCSS::Transformer
|
|
37
|
+
def with: (?filename: String?, ?minify: bool, ?error_recovery: bool, ?targets: browsers?, ?css_modules: css_modules?, ?scope: String?, ?source_map: bool, ?input_source_map: String?, ?project_root: String?) -> LightningCSS::Transformer
|
|
38
38
|
|
|
39
39
|
# : () -> String
|
|
40
40
|
def inspect: () -> String
|
data/sig/lightningcss.rbs
CHANGED
|
@@ -19,14 +19,14 @@
|
|
|
19
19
|
# `LightningCSS::Options` is what the options are read by, and `LightningCSS::Transformer` holds a
|
|
20
20
|
# set of them to reuse across many stylesheets.
|
|
21
21
|
module LightningCSS
|
|
22
|
-
# : (String, ?filename: String?, ?minify: bool, ?error_recovery: bool, ?targets: browsers?, ?css_modules: css_modules?, ?scope: String?) -> LightningCSS::Result
|
|
23
|
-
def self.transform: (String, ?filename: String?, ?minify: bool, ?error_recovery: bool, ?targets: browsers?, ?css_modules: css_modules?, ?scope: String?) -> LightningCSS::Result
|
|
22
|
+
# : (String, ?filename: String?, ?minify: bool, ?error_recovery: bool, ?targets: browsers?, ?css_modules: css_modules?, ?scope: String?, ?source_map: bool, ?input_source_map: String?, ?project_root: String?) -> LightningCSS::Result
|
|
23
|
+
def self.transform: (String, ?filename: String?, ?minify: bool, ?error_recovery: bool, ?targets: browsers?, ?css_modules: css_modules?, ?scope: String?, ?source_map: bool, ?input_source_map: String?, ?project_root: String?) -> LightningCSS::Result
|
|
24
24
|
|
|
25
25
|
# : (String, ?filename: String?, ?error_recovery: bool) -> LightningCSS::ParseResult
|
|
26
26
|
def self.parse: (String, ?filename: String?, ?error_recovery: bool) -> LightningCSS::ParseResult
|
|
27
27
|
|
|
28
|
-
# : (String, ?minify: bool, ?error_recovery: bool, ?targets: browsers?, ?css_modules: css_modules?, ?scope: String?) -> LightningCSS::Result
|
|
29
|
-
def self.bundle: (String, ?minify: bool, ?error_recovery: bool, ?targets: browsers?, ?css_modules: css_modules?, ?scope: String?) -> LightningCSS::Result
|
|
28
|
+
# : (String, ?minify: bool, ?error_recovery: bool, ?targets: browsers?, ?css_modules: css_modules?, ?scope: String?, ?source_map: bool, ?project_root: String?) -> LightningCSS::Result
|
|
29
|
+
def self.bundle: (String, ?minify: bool, ?error_recovery: bool, ?targets: browsers?, ?css_modules: css_modules?, ?scope: String?, ?source_map: bool, ?project_root: String?) -> LightningCSS::Result
|
|
30
30
|
|
|
31
31
|
# : (String, ?filename: String?, ?minify: bool, ?error_recovery: bool, ?targets: browsers?) -> LightningCSS::Result
|
|
32
32
|
def self.transform_style_attribute: (String, ?filename: String?, ?minify: bool, ?error_recovery: bool, ?targets: browsers?) -> LightningCSS::Result
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: lightningcss
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.33.0.
|
|
4
|
+
version: 1.33.0.3
|
|
5
5
|
platform: arm-linux-gnu
|
|
6
6
|
authors:
|
|
7
7
|
- Marco Roth
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-11-08 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: Ruby bindings for Lightning CSS, an extremely fast CSS parser, transformer,
|
|
14
14
|
bundler, and minifier.
|