klenod-plugin-css 0.0.13 → 0.0.14

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4acbda1ed646f829fcf4a2e65294664650fb5c6f9d30dfff21e5d948668028ab
4
- data.tar.gz: e1e18292969640397bb7bbdbb0447e9d7cfbca2fb213ee4236d7c1d554c2e7d3
3
+ metadata.gz: 3645cdc43457a3f585e7c94e1f0cce7d9998a8e0db1d7254c1975816448f5f32
4
+ data.tar.gz: cf0d7d162055eac97477aea5fbd880bc87e5c0bb150077f2f095e2024ca96117
5
5
  SHA512:
6
- metadata.gz: 5aa1eba5bfbb0df0a991dc17cd8f99b01e92618326f516c13213daea361fa24db803024897ae785f60f5aa86229a078f69cc9c7fde19196fbb10004e4e0d319e
7
- data.tar.gz: 5899a0fa6dc1c555c3c44b2c86a8a58799be7f7ab016ca8ce771579e10e4a72ccf21a62b4cb0759cf1c852477a10cd67852a207c39d40ff02259b1929e219d6f
6
+ metadata.gz: d52f8ee81bc9564e8c569349412f64d4d05cca2e51796cae3f4b86654781df11b67f3754d20ae712399a9dd61c55cc875a92294d804f96eb6c48672a112ca205
7
+ data.tar.gz: 19c25d7d56fdfe0ccb6cc379949d960aadd4217dc6c2771e32c88a33771dcb5b876638b4639d0eab48fe3b0c07f130e8be88f1cfb7128ea959cda8c5543d0ea2
@@ -236,13 +236,26 @@ dependencies = [
236
236
  "smallvec",
237
237
  ]
238
238
 
239
+ [[package]]
240
+ name = "cssparser"
241
+ version = "0.38.0"
242
+ source = "registry+https://github.com/rust-lang/crates.io-index"
243
+ checksum = "11119743ad110e8c1bdccd930d7f5c30c99e5fc76a7b63ec9807e84eef0c5f59"
244
+ dependencies = [
245
+ "cssparser-macros",
246
+ "dtoa-short",
247
+ "itoa",
248
+ "phf 0.14.0",
249
+ "smallvec",
250
+ ]
251
+
239
252
  [[package]]
240
253
  name = "cssparser-color"
241
254
  version = "0.5.0"
242
255
  source = "registry+https://github.com/rust-lang/crates.io-index"
243
256
  checksum = "bbaa233e1dcd9c13a5d3e3a8a2c0f5a727bac380398345dbcb31db4597edc86b"
244
257
  dependencies = [
245
- "cssparser",
258
+ "cssparser 0.37.0",
246
259
  ]
247
260
 
248
261
  [[package]]
@@ -494,7 +507,7 @@ dependencies = [
494
507
  "ahash 0.8.12",
495
508
  "bitflags",
496
509
  "const-str",
497
- "cssparser",
510
+ "cssparser 0.37.0",
498
511
  "cssparser-color",
499
512
  "dashmap",
500
513
  "data-encoding",
@@ -587,7 +600,7 @@ name = "native"
587
600
  version = "0.0.1"
588
601
  dependencies = [
589
602
  "base64",
590
- "cssparser",
603
+ "cssparser 0.38.0",
591
604
  "lightningcss",
592
605
  "magnus",
593
606
  "parcel_sourcemap",
@@ -624,7 +637,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
624
637
  checksum = "d05f71e01edca03d245ab0a9f7ce13a974ceb79baaae8faf2ba0b11de6b90913"
625
638
  dependencies = [
626
639
  "bitflags",
627
- "cssparser",
640
+ "cssparser 0.37.0",
628
641
  "log",
629
642
  "phf 0.11.3",
630
643
  "phf_codegen",
@@ -689,11 +702,22 @@ version = "0.13.1"
689
702
  source = "registry+https://github.com/rust-lang/crates.io-index"
690
703
  checksum = "c1562dc717473dbaa4c1f85a36410e03c047b2e7df7f45ee938fbef64ae7fadf"
691
704
  dependencies = [
692
- "phf_macros",
705
+ "phf_macros 0.13.1",
693
706
  "phf_shared 0.13.1",
694
707
  "serde",
695
708
  ]
696
709
 
710
+ [[package]]
711
+ name = "phf"
712
+ version = "0.14.0"
713
+ source = "registry+https://github.com/rust-lang/crates.io-index"
714
+ checksum = "010378780309880b08997fae13be7834dba947d36393bd372f2b1556deb2a2f6"
715
+ dependencies = [
716
+ "phf_macros 0.14.0",
717
+ "phf_shared 0.14.0",
718
+ "serde",
719
+ ]
720
+
697
721
  [[package]]
698
722
  name = "phf_codegen"
699
723
  version = "0.11.3"
@@ -724,6 +748,16 @@ dependencies = [
724
748
  "phf_shared 0.13.1",
725
749
  ]
726
750
 
751
+ [[package]]
752
+ name = "phf_generator"
753
+ version = "0.14.0"
754
+ source = "registry+https://github.com/rust-lang/crates.io-index"
755
+ checksum = "aeb62e0959d5a1bebc965f4d15d9e2b7cea002b6b0f5ba8cde6cc26738467100"
756
+ dependencies = [
757
+ "fastrand",
758
+ "phf_shared 0.14.0",
759
+ ]
760
+
727
761
  [[package]]
728
762
  name = "phf_macros"
729
763
  version = "0.13.1"
@@ -737,6 +771,19 @@ dependencies = [
737
771
  "syn 2.0.119",
738
772
  ]
739
773
 
774
+ [[package]]
775
+ name = "phf_macros"
776
+ version = "0.14.0"
777
+ source = "registry+https://github.com/rust-lang/crates.io-index"
778
+ checksum = "5fa8d0ca26d424d27630da600c6624696e7dec8bf7b3b492b383c5dc49e5e085"
779
+ dependencies = [
780
+ "phf_generator 0.14.0",
781
+ "phf_shared 0.14.0",
782
+ "proc-macro2",
783
+ "quote",
784
+ "syn 2.0.119",
785
+ ]
786
+
740
787
  [[package]]
741
788
  name = "phf_shared"
742
789
  version = "0.11.3"
@@ -755,6 +802,15 @@ dependencies = [
755
802
  "siphasher",
756
803
  ]
757
804
 
805
+ [[package]]
806
+ name = "phf_shared"
807
+ version = "0.14.0"
808
+ source = "registry+https://github.com/rust-lang/crates.io-index"
809
+ checksum = "c6fd9027e2d9319be6349febd1db4e8d02aa544921200c9b777720ac34a3aa89"
810
+ dependencies = [
811
+ "siphasher",
812
+ ]
813
+
758
814
  [[package]]
759
815
  name = "pin-project-lite"
760
816
  version = "0.2.17"
@@ -9,7 +9,7 @@ crate-type = ["cdylib"]
9
9
 
10
10
  [dependencies]
11
11
  base64 = "0.23.1"
12
- cssparser = "0.37.0"
12
+ cssparser = "0.38.0"
13
13
  lightningcss = { version = "1.0.0-alpha.70", features = ["serde", "visitor", "sourcemap"] }
14
14
  magnus = "0.8.2"
15
15
  parcel_sourcemap = { version = "2.1.1", features = ["json"] }
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "klenod/plugin/css/errors"
3
4
  require "klenod/plugin/css/transformer"
4
5
  require "uri"
5
6
 
@@ -202,6 +203,8 @@ module Klenod
202
203
  end
203
204
 
204
205
  def transform_css(module_id, code, transform_names:, context:)
206
+ # The filename also names the source in the emitted source map, so
207
+ # it stays the plain path. The error report uses module_id instead.
205
208
  Transformer.transform(
206
209
  module_id.path,
207
210
  code,
@@ -212,6 +215,10 @@ module Klenod
212
215
  local_css_variables: @local_css_variables && transform_names,
213
216
  variable_pattern: @variable_pattern
214
217
  )
218
+ rescue ParseError => error
219
+ # The native extension raises with only a message. Re-raise with the
220
+ # source so the report carries an excerpt like every other format.
221
+ raise ParseError.new(error, source: code, module_id: module_id)
215
222
  end
216
223
 
217
224
  def minify_enabled?(context)
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "klenod/build/source_error"
4
+
5
+ module Klenod
6
+ module Build
7
+ module Plugins
8
+ module CSSPlugin
9
+ # The native extension looks this class up by name and raises it with
10
+ # only a message, so it has to tolerate being constructed that way. The
11
+ # plugin catches that bare error and re-raises it with the source and
12
+ # module attached, which is what fills in the excerpt.
13
+ class ParseError < Klenod::Build::SourceError
14
+ # "Unexpected token Colon at app:/styles.css:11:5"
15
+ LOCATION = /\A(?<message>.*)\s+at\s+(?<file>.+):(?<line>\d+):(?<column>\d+)\s*\z/m
16
+
17
+ def initialize(error, source: nil, module_id: nil)
18
+ super
19
+ end
20
+
21
+ def kind
22
+ "CSS parse error"
23
+ end
24
+
25
+ private
26
+
27
+ def location(error)
28
+ found = LOCATION.match(message_for(error))
29
+ return nil unless found
30
+
31
+ Location.new(
32
+ # lightningcss reports a zero-based line and a one-based column.
33
+ line: found[:line].to_i + 1,
34
+ column: found[:column].to_i,
35
+ detail: found[:message]
36
+ )
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -2,6 +2,8 @@
2
2
 
3
3
  require "json"
4
4
 
5
+ require "klenod/plugin/css/errors"
6
+
5
7
  begin
6
8
  require "klenod/plugin/css/native"
7
9
  rescue LoadError
@@ -13,7 +15,6 @@ module Klenod
13
15
  module Plugins
14
16
  module CSSPlugin
15
17
  class Error < StandardError; end
16
- class ParseError < Error; end
17
18
 
18
19
  ImportDependency = Data.define(:url, :placeholder, :supports, :media, :loc)
19
20
  UrlDependency = Data.define(:url, :placeholder, :loc)
@@ -4,7 +4,7 @@ module Klenod
4
4
  module Build
5
5
  module Plugins
6
6
  module CSSPlugin
7
- VERSION = "0.0.13"
7
+ VERSION = "0.0.14"
8
8
  end
9
9
  end
10
10
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: klenod-plugin-css
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.13
4
+ version: 0.0.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrés Alin
@@ -15,14 +15,14 @@ dependencies:
15
15
  requirements:
16
16
  - - '='
17
17
  - !ruby/object:Gem::Version
18
- version: 0.0.13
18
+ version: 0.0.14
19
19
  type: :runtime
20
20
  prerelease: false
21
21
  version_requirements: !ruby/object:Gem::Requirement
22
22
  requirements:
23
23
  - - '='
24
24
  - !ruby/object:Gem::Version
25
- version: 0.0.13
25
+ version: 0.0.14
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: rb_sys
28
28
  requirement: !ruby/object:Gem::Requirement
@@ -66,6 +66,7 @@ files:
66
66
  - ext/native/src/lib.rs
67
67
  - lib/klenod/build/plugins/css_plugin.rb
68
68
  - lib/klenod/plugin/css.rb
69
+ - lib/klenod/plugin/css/errors.rb
69
70
  - lib/klenod/plugin/css/transformer.rb
70
71
  - lib/klenod/plugin/css/version.rb
71
72
  homepage: https://github.com/aalin/klenod