mayu-css 0.0.2-arm64-darwin → 0.1.0-arm64-darwin

Sign up to get free protection for your applications and to get access to all the features.
Binary file
Binary file
Binary file
Binary file
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Mayu
4
4
  module CSS
5
- VERSION = "0.0.2"
5
+ VERSION = "0.1.0"
6
6
  end
7
7
  end
data/lib/mayu/css.rb CHANGED
@@ -13,10 +13,103 @@ end
13
13
  module Mayu
14
14
  module CSS
15
15
  class Error < StandardError; end
16
+ class ParseError < Error; end
16
17
 
17
- class TransformResult
18
- def dependencies = JSON.parse(serialized_dependencies, symbolize_names: true)
19
- def exports = JSON.parse(serialized_exports, symbolize_names: true)
18
+ ImportDependency = Data.define(:url, :placeholder, :supports, :media, :loc)
19
+ UrlDependency = Data.define(:url, :placeholder, :loc)
20
+
21
+ Export = Data.define(:name, :composes, :referenced?)
22
+
23
+ ComposeLocal = Data.define(:name)
24
+ ComposeDependency = Data.define(:name, :specifier)
25
+
26
+ Loc = Data.define(:file_path, :start, :end) do
27
+ def self.from_ext(data) =
28
+ new(
29
+ file_path: data[:filePath],
30
+ start: Pos.from_ext(data[:start]),
31
+ end: Pos.from_ext(data[:end]),
32
+ )
33
+ end
34
+
35
+ Pos = Data.define(:line, :column) do
36
+ def self.from_ext(data) =
37
+ new(data[:line], data[:column])
20
38
  end
39
+
40
+ TransformResult = Data.define(:classes, :elements, :code, :source_map, :dependencies, :exports) do
41
+ def self.from_ext(data) =
42
+ new(
43
+ classes: data.classes.transform_keys(&:to_sym),
44
+ elements: data.elements.transform_keys(&:to_sym),
45
+ code: data.code,
46
+ source_map: data.source_map,
47
+ dependencies:
48
+ data.serialized_dependencies
49
+ .then { JSON.parse(_1, symbolize_names: true) }
50
+ .map do |dep|
51
+ case dep
52
+ in { type: "import", url:, placeholder:, supports:, media:, loc: }
53
+ ImportDependency[url:, placeholder:, supports:, media:, loc: Loc.from_ext(loc) ]
54
+ in { type: "url", url:, placeholder:, loc: }
55
+ UrlDependency[url:, placeholder:, loc: Loc.from_ext(loc)]
56
+ end
57
+ end,
58
+ exports:
59
+ data.serialized_exports
60
+ .then { JSON.parse(_1, symbolize_names: true) }
61
+ .transform_keys(&:to_s)
62
+ .transform_values do |export|
63
+ export => { name:, composes:, isReferenced: }
64
+
65
+ Export[
66
+ name:,
67
+ referenced?: isReferenced,
68
+ composes: composes.map do |compose|
69
+ case compose
70
+ in { type: "local", name: }
71
+ ComposeLocal[name:]
72
+ in { type: "dependency", name:, specifier: }
73
+ ComposeDependency[name:, specifier:]
74
+ end
75
+ end
76
+ ]
77
+ end
78
+ )
79
+
80
+ def replace_dependencies
81
+ dependencies.reduce(code) do |code, dependency|
82
+ code.gsub(dependency.placeholder, (yield dependency))
83
+ end
84
+ end
85
+
86
+ def code_with_source_map
87
+ <<~CSS
88
+ #{code}
89
+ /*# sourceMappingURL=#{source_map} */
90
+ CSS
91
+ end
92
+ end
93
+
94
+ SerializeResult = Data.define(:rules, :sources, :source_map_urls, :license_comments) do
95
+ def self.from_ext(data)
96
+ JSON.parse(data, symbolize_names: true) => {
97
+ rules:,
98
+ sources:,
99
+ sourceMapUrls: source_map_urls,
100
+ licenseComments: license_comments,
101
+ }
102
+ new(rules:, sources:, source_map_urls:, license_comments:)
103
+ end
104
+ end
105
+
106
+ def self.transform(file, code, minify: true) =
107
+ TransformResult.from_ext(ext_transform(file, code, minify))
108
+
109
+ def self.minify(file, code) =
110
+ ext_minify(file, code)
111
+
112
+ def self.serialize(file, code) =
113
+ SerializeResult.from_ext(ext_serialize(file, code))
21
114
  end
22
115
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mayu-css
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.1.0
5
5
  platform: arm64-darwin
6
6
  authors:
7
7
  - Andreas Alin
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-02-08 00:00:00.000000000 Z
11
+ date: 2024-01-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake-compiler
@@ -16,42 +16,56 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 1.2.1
19
+ version: 1.2.5
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 1.2.1
26
+ version: 1.2.5
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rb_sys
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 0.9.58
33
+ version: 0.9.86
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 0.9.58
40
+ version: 0.9.86
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '13.0'
47
+ version: '13.1'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '13.0'
54
+ version: '13.1'
55
+ - !ruby/object:Gem::Dependency
56
+ name: minitest
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '5.20'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '5.20'
55
69
  description:
56
70
  email:
57
71
  - andreas.alin@gmail.com
@@ -63,8 +77,10 @@ files:
63
77
  - Cargo.toml
64
78
  - README.md
65
79
  - lib/mayu/css.rb
80
+ - lib/mayu/css/3.0/ext.bundle
66
81
  - lib/mayu/css/3.1/ext.bundle
67
82
  - lib/mayu/css/3.2/ext.bundle
83
+ - lib/mayu/css/3.3/ext.bundle
68
84
  - lib/mayu/css/version.rb
69
85
  homepage: https://github.com/mayu-live/mayu-css
70
86
  licenses:
@@ -79,10 +95,10 @@ required_ruby_version: !ruby/object:Gem::Requirement
79
95
  requirements:
80
96
  - - ">="
81
97
  - !ruby/object:Gem::Version
82
- version: '3.1'
98
+ version: '3.0'
83
99
  - - "<"
84
100
  - !ruby/object:Gem::Version
85
- version: 3.3.dev
101
+ version: 3.4.dev
86
102
  required_rubygems_version: !ruby/object:Gem::Requirement
87
103
  requirements:
88
104
  - - ">="