lightningcss 1.33.0 → 1.33.0.2
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 +153 -5
- data/ext/lightningcss/include/lightningcss.h +2 -0
- data/ext/lightningcss/lightningcss.c +9 -2
- data/lib/lightningcss/backend.rb +5 -0
- data/lib/lightningcss/errors.rb +22 -1
- data/lib/lightningcss/location.rb +21 -0
- data/lib/lightningcss/node.rb +220 -0
- data/lib/lightningcss/options.rb +5 -0
- data/lib/lightningcss/parse_result.rb +52 -0
- data/lib/lightningcss/result.rb +4 -4
- data/lib/lightningcss/transformer.rb +5 -0
- data/lib/lightningcss/version.rb +1 -1
- data/lib/lightningcss/visitor.rb +37 -0
- data/lib/lightningcss/warning.rb +60 -0
- data/lib/lightningcss.rb +18 -0
- data/rust/Cargo.lock +32 -0
- data/rust/Cargo.toml +1 -1
- data/rust/src/lib.rs +71 -37
- data/rust/src/options.rs +119 -6
- data/rust/src/scope.rs +2 -1
- data/sig/lightningcss/backend.rbs +3 -0
- data/sig/lightningcss/errors.rbs +9 -0
- data/sig/lightningcss/location.rbs +26 -0
- data/sig/lightningcss/node.rbs +104 -0
- data/sig/lightningcss/options.rbs +2 -0
- data/sig/lightningcss/parse_result.rbs +30 -0
- data/sig/lightningcss/result.rbs +3 -3
- data/sig/lightningcss/transformer.rbs +3 -0
- data/sig/lightningcss/types.rbs +12 -10
- data/sig/lightningcss/visitor.rbs +24 -0
- data/sig/lightningcss/warning.rbs +36 -0
- data/sig/lightningcss.rbs +8 -0
- metadata +11 -1
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
# Generated from lib/lightningcss/node.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module LightningCSS
|
|
4
|
+
# One object in the AST Lightning CSS parsed a stylesheet to.
|
|
5
|
+
#
|
|
6
|
+
# root = LightningCSS.parse(".a { color: red }").root
|
|
7
|
+
#
|
|
8
|
+
# root.type #=> "stylesheet"
|
|
9
|
+
# root.every("declaration") #=> every declaration in the stylesheet
|
|
10
|
+
# root.rules.first.value.location #=> {"source_index" => 0, "line" => 0, "column" => 1}
|
|
11
|
+
#
|
|
12
|
+
# Every object in the tree is a node, so reads chain all the way down. Most say what they are
|
|
13
|
+
# with their own `type`. The stylesheet, a declaration block, and a declaration do not, so a node
|
|
14
|
+
# names those from where it sits.
|
|
15
|
+
class Node
|
|
16
|
+
include Enumerable[LightningCSS::Node]
|
|
17
|
+
|
|
18
|
+
POSITION: Array[String]
|
|
19
|
+
|
|
20
|
+
DECLARATIONS: Array[String]
|
|
21
|
+
|
|
22
|
+
attr_reader parent: LightningCSS::Node?
|
|
23
|
+
|
|
24
|
+
attr_reader field: String?
|
|
25
|
+
|
|
26
|
+
# : (Hash[String, untyped], ?LightningCSS::Node?, ?String?) -> void
|
|
27
|
+
def initialize: (Hash[String, untyped], ?LightningCSS::Node?, ?String?) -> void
|
|
28
|
+
|
|
29
|
+
# : () -> String?
|
|
30
|
+
def type: () -> String?
|
|
31
|
+
|
|
32
|
+
# : () -> String?
|
|
33
|
+
def underscored_type: () -> String?
|
|
34
|
+
|
|
35
|
+
# : () -> bool
|
|
36
|
+
def rule?: () -> bool
|
|
37
|
+
|
|
38
|
+
# : () -> Hash[String, Integer]?
|
|
39
|
+
def location: () -> Hash[String, Integer]?
|
|
40
|
+
|
|
41
|
+
# : (String) -> untyped
|
|
42
|
+
def []: (String) -> untyped
|
|
43
|
+
|
|
44
|
+
# : () -> Array[String]
|
|
45
|
+
def keys: () -> Array[String]
|
|
46
|
+
|
|
47
|
+
# : () -> Hash[String, untyped]
|
|
48
|
+
def to_h: () -> Hash[String, untyped]
|
|
49
|
+
|
|
50
|
+
# : (?untyped) -> String
|
|
51
|
+
def to_json: (?untyped) -> String
|
|
52
|
+
|
|
53
|
+
# : (Array[Symbol]?) -> Hash[Symbol, untyped]
|
|
54
|
+
def deconstruct_keys: (Array[Symbol]?) -> Hash[Symbol, untyped]
|
|
55
|
+
|
|
56
|
+
# : () -> Array[LightningCSS::Node]
|
|
57
|
+
def child_nodes: () -> Array[LightningCSS::Node]
|
|
58
|
+
|
|
59
|
+
# : () { (LightningCSS::Node) -> void } -> void
|
|
60
|
+
# : () -> Enumerator[LightningCSS::Node, void]
|
|
61
|
+
def each: () { (LightningCSS::Node) -> void } -> void
|
|
62
|
+
| () -> Enumerator[LightningCSS::Node, void]
|
|
63
|
+
|
|
64
|
+
# : () -> Array[LightningCSS::Node]
|
|
65
|
+
def ancestors: () -> Array[LightningCSS::Node]
|
|
66
|
+
|
|
67
|
+
# : (String) -> Array[LightningCSS::Node]
|
|
68
|
+
def every: (String) -> Array[LightningCSS::Node]
|
|
69
|
+
|
|
70
|
+
# : () -> Hash[String, untyped]
|
|
71
|
+
def fields: () -> Hash[String, untyped]
|
|
72
|
+
|
|
73
|
+
# : () -> String
|
|
74
|
+
def inspect: () -> String
|
|
75
|
+
|
|
76
|
+
# : (Symbol, *untyped) -> untyped
|
|
77
|
+
def method_missing: (Symbol, *untyped) -> untyped
|
|
78
|
+
|
|
79
|
+
# : (Symbol, ?bool) -> bool
|
|
80
|
+
def respond_to_missing?: (Symbol, ?bool) -> bool
|
|
81
|
+
|
|
82
|
+
attr_reader attributes: Hash[String, untyped]
|
|
83
|
+
|
|
84
|
+
private
|
|
85
|
+
|
|
86
|
+
# : () -> String?
|
|
87
|
+
def inferred_type: () -> String?
|
|
88
|
+
|
|
89
|
+
# : (untyped, String) -> Array[LightningCSS::Node]
|
|
90
|
+
def nodes_in: (untyped, String) -> Array[LightningCSS::Node]
|
|
91
|
+
|
|
92
|
+
# : (String, untyped) -> String
|
|
93
|
+
def described_field: (String, untyped) -> String
|
|
94
|
+
|
|
95
|
+
# : (Array[untyped]) -> String
|
|
96
|
+
def counted: (Array[untyped]) -> String
|
|
97
|
+
|
|
98
|
+
# : (String) -> String?
|
|
99
|
+
def field_for: (String) -> String?
|
|
100
|
+
|
|
101
|
+
# : (untyped, String) -> untyped
|
|
102
|
+
def wrap: (untyped, String) -> untyped
|
|
103
|
+
end
|
|
104
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Generated from lib/lightningcss/parse_result.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module LightningCSS
|
|
4
|
+
# What a stylesheet parsed to.
|
|
5
|
+
#
|
|
6
|
+
# `stylesheet` is the AST exactly as Lightning CSS serializes it, and `root` is the same tree as a
|
|
7
|
+
# `LightningCSS::Node` to walk. `warnings` are the ones a transform would have reported.
|
|
8
|
+
class ParseResult
|
|
9
|
+
attr_reader source: String?
|
|
10
|
+
|
|
11
|
+
attr_reader stylesheet: Hash[String, untyped]
|
|
12
|
+
|
|
13
|
+
attr_reader warnings: Array[LightningCSS::Warning]
|
|
14
|
+
|
|
15
|
+
# : (String, ?String?) -> LightningCSS::ParseResult
|
|
16
|
+
def self.from_json: (String, ?String?) -> LightningCSS::ParseResult
|
|
17
|
+
|
|
18
|
+
# : (stylesheet: Hash[String, untyped], warnings: Array[LightningCSS::Warning], ?source: String?) -> void
|
|
19
|
+
def initialize: (stylesheet: Hash[String, untyped], warnings: Array[LightningCSS::Warning], ?source: String?) -> void
|
|
20
|
+
|
|
21
|
+
# : () -> LightningCSS::Node
|
|
22
|
+
def root: () -> LightningCSS::Node
|
|
23
|
+
|
|
24
|
+
# : () -> bool
|
|
25
|
+
def warnings?: () -> bool
|
|
26
|
+
|
|
27
|
+
# : () -> String
|
|
28
|
+
def inspect: () -> String
|
|
29
|
+
end
|
|
30
|
+
end
|
data/sig/lightningcss/result.rbs
CHANGED
|
@@ -14,13 +14,13 @@ module LightningCSS
|
|
|
14
14
|
|
|
15
15
|
attr_reader exports: Hash[String, String]?
|
|
16
16
|
|
|
17
|
-
attr_reader warnings: Array[
|
|
17
|
+
attr_reader warnings: Array[LightningCSS::Warning]
|
|
18
18
|
|
|
19
19
|
# : (String) -> LightningCSS::Result
|
|
20
20
|
def self.from_json: (String) -> LightningCSS::Result
|
|
21
21
|
|
|
22
|
-
# : (code: String, warnings: Array[
|
|
23
|
-
def initialize: (code: String, warnings: Array[
|
|
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
24
|
|
|
25
25
|
# : () -> bool
|
|
26
26
|
def warnings?: () -> bool
|
|
@@ -21,6 +21,9 @@ module LightningCSS
|
|
|
21
21
|
|
|
22
22
|
alias call transform
|
|
23
23
|
|
|
24
|
+
# : (String, ?filename: String?, ?error_recovery: bool) -> LightningCSS::ParseResult
|
|
25
|
+
def parse: (String, ?filename: String?, ?error_recovery: bool) -> LightningCSS::ParseResult
|
|
26
|
+
|
|
24
27
|
# : (String, ?minify: bool, ?error_recovery: bool, ?targets: browsers?, ?css_modules: css_modules?, ?scope: String?) -> LightningCSS::Result
|
|
25
28
|
def bundle: (String, ?minify: bool, ?error_recovery: bool, ?targets: browsers?, ?css_modules: css_modules?, ?scope: String?) -> LightningCSS::Result
|
|
26
29
|
|
data/sig/lightningcss/types.rbs
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
# Note: This file is hand written, `rbs-inline` does not generate this file.
|
|
2
2
|
|
|
3
3
|
module LightningCSS
|
|
4
|
+
type version = Integer | Float | String
|
|
5
|
+
|
|
4
6
|
type browsers = {
|
|
5
|
-
?android:
|
|
6
|
-
?chrome:
|
|
7
|
-
?edge:
|
|
8
|
-
?firefox:
|
|
9
|
-
?ie:
|
|
10
|
-
?ios:
|
|
11
|
-
?ios_saf:
|
|
12
|
-
?opera:
|
|
13
|
-
?safari:
|
|
14
|
-
?samsung:
|
|
7
|
+
?android: version,
|
|
8
|
+
?chrome: version,
|
|
9
|
+
?edge: version,
|
|
10
|
+
?firefox: version,
|
|
11
|
+
?ie: version,
|
|
12
|
+
?ios: version,
|
|
13
|
+
?ios_saf: version,
|
|
14
|
+
?opera: version,
|
|
15
|
+
?safari: version,
|
|
16
|
+
?samsung: version
|
|
15
17
|
}
|
|
16
18
|
|
|
17
19
|
type css_modules = bool | {
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Generated from lib/lightningcss/visitor.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module LightningCSS
|
|
4
|
+
# Walks an AST, answering each node with the method named after it and walking through anything
|
|
5
|
+
# nothing answers.
|
|
6
|
+
#
|
|
7
|
+
# class Colors < LightningCSS::Visitor
|
|
8
|
+
# def visit_declaration(node)
|
|
9
|
+
# puts node.value.type if node.property == "color"
|
|
10
|
+
# end
|
|
11
|
+
# end
|
|
12
|
+
#
|
|
13
|
+
# Colors.new.visit(LightningCSS.parse(".a { color: red }"))
|
|
14
|
+
#
|
|
15
|
+
# A rule is answered as one, as in `visit_style_rule` or `visit_media_rule`, since `style`,
|
|
16
|
+
# `nesting`, and `namespace` are also what a selector is made of.
|
|
17
|
+
class Visitor
|
|
18
|
+
# : (LightningCSS::Node | LightningCSS::ParseResult) -> void
|
|
19
|
+
def visit: (LightningCSS::Node | LightningCSS::ParseResult) -> void
|
|
20
|
+
|
|
21
|
+
# : (LightningCSS::Node) -> void
|
|
22
|
+
def visit_children: (LightningCSS::Node) -> void
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Generated from lib/lightningcss/warning.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module LightningCSS
|
|
4
|
+
class Warning
|
|
5
|
+
attr_reader message: String
|
|
6
|
+
|
|
7
|
+
attr_reader type: String?
|
|
8
|
+
|
|
9
|
+
attr_reader location: LightningCSS::Location?
|
|
10
|
+
|
|
11
|
+
# : (Hash[String, untyped]) -> LightningCSS::Warning
|
|
12
|
+
def self.from_hash: (Hash[String, untyped]) -> LightningCSS::Warning
|
|
13
|
+
|
|
14
|
+
# : (message: String, ?type: String?, ?location: LightningCSS::Location?) -> void
|
|
15
|
+
def initialize: (message: String, ?type: String?, ?location: LightningCSS::Location?) -> void
|
|
16
|
+
|
|
17
|
+
# : () -> Hash[Symbol, untyped]
|
|
18
|
+
def to_h: () -> Hash[Symbol, untyped]
|
|
19
|
+
|
|
20
|
+
# : () -> String
|
|
21
|
+
def to_s: () -> String
|
|
22
|
+
|
|
23
|
+
alias to_str to_s
|
|
24
|
+
|
|
25
|
+
# : (untyped) -> bool
|
|
26
|
+
def ==: (untyped) -> bool
|
|
27
|
+
|
|
28
|
+
alias eql? ==
|
|
29
|
+
|
|
30
|
+
# : () -> Integer
|
|
31
|
+
def hash: () -> Integer
|
|
32
|
+
|
|
33
|
+
# : () -> String
|
|
34
|
+
def inspect: () -> String
|
|
35
|
+
end
|
|
36
|
+
end
|
data/sig/lightningcss.rbs
CHANGED
|
@@ -11,12 +11,20 @@
|
|
|
11
11
|
# LightningCSS.transform(".title { color: red }", scope: "[data-scope-abc]").code
|
|
12
12
|
# #=> ".title[data-scope-abc]{color:red}"
|
|
13
13
|
#
|
|
14
|
+
# `parse` returns the AST instead, to walk with `LightningCSS::Node` and `LightningCSS::Visitor`:
|
|
15
|
+
#
|
|
16
|
+
# LightningCSS.parse(".a { color: red }").root.every("declaration").first.property
|
|
17
|
+
# #=> "color"
|
|
18
|
+
#
|
|
14
19
|
# `LightningCSS::Options` is what the options are read by, and `LightningCSS::Transformer` holds a
|
|
15
20
|
# set of them to reuse across many stylesheets.
|
|
16
21
|
module LightningCSS
|
|
17
22
|
# : (String, ?filename: String?, ?minify: bool, ?error_recovery: bool, ?targets: browsers?, ?css_modules: css_modules?, ?scope: String?) -> LightningCSS::Result
|
|
18
23
|
def self.transform: (String, ?filename: String?, ?minify: bool, ?error_recovery: bool, ?targets: browsers?, ?css_modules: css_modules?, ?scope: String?) -> LightningCSS::Result
|
|
19
24
|
|
|
25
|
+
# : (String, ?filename: String?, ?error_recovery: bool) -> LightningCSS::ParseResult
|
|
26
|
+
def self.parse: (String, ?filename: String?, ?error_recovery: bool) -> LightningCSS::ParseResult
|
|
27
|
+
|
|
20
28
|
# : (String, ?minify: bool, ?error_recovery: bool, ?targets: browsers?, ?css_modules: css_modules?, ?scope: String?) -> LightningCSS::Result
|
|
21
29
|
def self.bundle: (String, ?minify: bool, ?error_recovery: bool, ?targets: browsers?, ?css_modules: css_modules?, ?scope: String?) -> LightningCSS::Result
|
|
22
30
|
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Marco Roth
|
|
@@ -26,10 +26,15 @@ files:
|
|
|
26
26
|
- lib/lightningcss.rb
|
|
27
27
|
- lib/lightningcss/backend.rb
|
|
28
28
|
- lib/lightningcss/errors.rb
|
|
29
|
+
- lib/lightningcss/location.rb
|
|
30
|
+
- lib/lightningcss/node.rb
|
|
29
31
|
- lib/lightningcss/options.rb
|
|
32
|
+
- lib/lightningcss/parse_result.rb
|
|
30
33
|
- lib/lightningcss/result.rb
|
|
31
34
|
- lib/lightningcss/transformer.rb
|
|
32
35
|
- lib/lightningcss/version.rb
|
|
36
|
+
- lib/lightningcss/visitor.rb
|
|
37
|
+
- lib/lightningcss/warning.rb
|
|
33
38
|
- licenses/README.md
|
|
34
39
|
- licenses/lightningcss-MPL-2.0.txt
|
|
35
40
|
- lightningcss.gemspec
|
|
@@ -44,11 +49,16 @@ files:
|
|
|
44
49
|
- sig/lightningcss.rbs
|
|
45
50
|
- sig/lightningcss/backend.rbs
|
|
46
51
|
- sig/lightningcss/errors.rbs
|
|
52
|
+
- sig/lightningcss/location.rbs
|
|
53
|
+
- sig/lightningcss/node.rbs
|
|
47
54
|
- sig/lightningcss/options.rbs
|
|
55
|
+
- sig/lightningcss/parse_result.rbs
|
|
48
56
|
- sig/lightningcss/result.rbs
|
|
49
57
|
- sig/lightningcss/transformer.rbs
|
|
50
58
|
- sig/lightningcss/types.rbs
|
|
51
59
|
- sig/lightningcss/version.rbs
|
|
60
|
+
- sig/lightningcss/visitor.rbs
|
|
61
|
+
- sig/lightningcss/warning.rbs
|
|
52
62
|
homepage: https://github.com/marcoroth/lightningcss-ruby
|
|
53
63
|
licenses:
|
|
54
64
|
- MIT
|