nanoc-dart-sass 1.0.3 → 2.0.0

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: 3b3ec8688e0eacf5312456127b9f9137d7ee17fdc3b2788c8eb44d2a18a48d39
4
- data.tar.gz: dfc61b8856486c27210a20b79fa70da2852a88f4eeb5a5e804b2b3411e8d7653
3
+ metadata.gz: a840ef7c17c7990a2284598a2c33f76f7ab9e8dc36a2b80b5f92fed04d372e76
4
+ data.tar.gz: c3af25569e9f23519cf53bad2cdd5f01bfbb328d3e6f732447f6f5fa68eee76b
5
5
  SHA512:
6
- metadata.gz: 054bdb5a6ba1c907c2c8fc06f56efde60a173df8b0aa328b3654df7b7a8e42017b0cc123bcf09317aa6e93ef1754ef65a83e659122ea1794950f8d63c87ef9f8
7
- data.tar.gz: ba2afccd8953791279521d4444053df10e94ad69e9b16f787519b621e69fdf9e5f9b71bb72a861cb57165ccb9b8e4bf918724bef1805362fd3be2c1c6c2c32dc
6
+ metadata.gz: 794c4037f669e64e01c4bcae49c3a83b790d13d8598d39f99e5e128127735adea09cb9d384f8973aec4ab58e70af7990d7369f7f048772b97b3d0b46bcb8f310
7
+ data.tar.gz: 94a5d55959ba24ea46254632bfa1ed2c1e3b7424f69084ae628f0be68afe66cab37e0e92e59f0abced939710bd34af8bec880cf2ce09b514bde6f86f483c74d3
data/NEWS.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # nanoc-dart-sass news
2
2
 
3
+ ## 2.0.0 (2025-12-31)
4
+
5
+ Features:
6
+
7
+ - Added support for `source_map` option [ntkme] (#1749, #1775)
8
+
9
+ Changes:
10
+
11
+ - Changed the importer to be in line with the spec [ntkme] (#1755)
12
+
13
+ ## 1.0.4 (2024-11-04)
14
+
15
+ Fixes:
16
+
17
+ - Fixed imports on Windows, by stripping drive identifier (#1703, #1716)
18
+
3
19
  ## 1.0.3 (2024-04-19)
4
20
 
5
21
  Enhancements:
@@ -18,30 +18,37 @@ module Nanoc
18
18
 
19
19
  result = Sass.compile_string(
20
20
  content,
21
- importer: NanocImporter.new(@items, item),
21
+ source_map_include_sources: true,
22
22
  **params,
23
- syntax: syntax,
23
+ importers: [NanocImporter.new(@items)].concat(params.fetch(:importers, [])),
24
+ syntax:,
25
+ url: Addressable::URI.new({ scheme: 'nanoc', path: item.identifier.to_s }).to_s,
24
26
  )
25
- result.css
27
+
28
+ if result.source_map
29
+ "#{result.css}\n/*# sourceMappingURL=data:application/json;base64,#{[result.source_map].pack('m0')} */"
30
+ else
31
+ result.css
32
+ end
26
33
  end
27
34
 
28
35
  class NanocImporter
29
- def initialize(items, source_item)
36
+ def initialize(items)
30
37
  @items = items
31
- @source_item = source_item
32
38
  end
33
39
 
34
- def canonicalize(url, *, **)
35
- # Construct proper URL with `nanoc:` prefix if needed
36
- if url.start_with?('nanoc:')
37
- url
38
- else
39
- "nanoc:#{url}"
40
- end
40
+ def canonicalize(url, context)
41
+ uri = Addressable::URI.parse(url)
42
+ uri = Addressable::URI.parse(context.containing_url).join(uri) unless context.containing_url.nil?
43
+ return unless uri.scheme == 'nanoc'
44
+
45
+ resolved = resolve_path(uri.path, context.from_import)
46
+ Addressable::URI.new({ scheme: 'nanoc', path: resolved }).to_s unless resolved.nil?
41
47
  end
42
48
 
43
49
  def load(url)
44
- item = find_item_for_url(url)
50
+ uri = Addressable::URI.parse(url)
51
+ item = @items[uri.path]
45
52
 
46
53
  {
47
54
  contents: item.raw_content,
@@ -51,62 +58,72 @@ module Nanoc
51
58
 
52
59
  private
53
60
 
54
- def find_item_for_url(url)
55
- pat = url.sub(/\Ananoc:/, '')
61
+ # https://github.com/sass-contrib/sassc-embedded-shim-ruby/blob/594632bb896fb765462253b16ea0451f5f93316d/lib/sassc/embedded.rb#L228
62
+ def resolve_path(path, from_import)
63
+ ext = File.extname(path)
64
+ if ext == '.*'
65
+ if from_import
66
+ result = exactly_one(try_path_with_ext("#{without_ext(path)}.import") + try_path_with_ext("#{path}.import"))
67
+ return result unless result.nil?
68
+ end
56
69
 
57
- is_extension_given = !pat.match?(%r{(/|^)[^.]+$})
70
+ result = exactly_one(try_path_with_ext(without_ext(path)) + try_path_with_ext(path))
71
+ return result unless result.nil?
58
72
 
59
- # Convert to absolute pattern
60
- pat =
61
- if pat.start_with?('/')
62
- pat
63
- else
64
- dirname = File.dirname(@source_item.identifier.to_s)
65
- File.expand_path(pat, dirname)
66
- end
73
+ return try_path_as_dir(path, from_import)
74
+ end
67
75
 
68
- items = collect_items(pat, is_extension_given)
76
+ if ['.sass', '.scss', '.css'].include?(ext)
77
+ if from_import
78
+ result = exactly_one(try_path("#{without_ext(path)}.import#{ext}"))
79
+ return result unless result.nil?
80
+ end
81
+ return exactly_one(try_path(path))
82
+ end
69
83
 
70
- # Get the single matching item, or error if there isn’t exactly one
71
- items = items.compact
72
- case items.size
73
- when 0
74
- raise "Could not find an item matching pattern `#{pat}`"
75
- when 1
76
- items.first
77
- else
78
- raise "It is not clear which item to import. Multiple items match `#{pat}`: #{items.map { _1.identifier.to_s }.sort.join(', ')}"
84
+ if from_import
85
+ result = exactly_one(try_path_with_ext("#{path}.import"))
86
+ return result unless result.nil?
79
87
  end
80
- end
81
88
 
82
- # Given a pattern, return a collection of items that match this pattern.
83
- # This goes beyond what Nanoc patterns typically support by e.g.
84
- # supporting partials and index imports.
85
- def collect_items(pat, is_extension_given)
86
- items = []
89
+ result = exactly_one(try_path_with_ext(path))
90
+ return result unless result.nil?
87
91
 
88
- # Try as a regular path
89
- items.concat(try_pat(pat, is_extension_given))
92
+ try_path_as_dir(path, from_import)
93
+ end
90
94
 
91
- # Try as a partial
92
- partial_pat = File.join(File.dirname(pat), "_#{File.basename(pat)}")
93
- items.concat(try_pat(partial_pat, is_extension_given))
95
+ def try_path_with_ext(path)
96
+ result = try_path("#{path}.sass") + try_path("#{path}.scss")
97
+ result.empty? ? try_path("#{path}.css") : result
98
+ end
99
+
100
+ def try_path(path)
101
+ partial = File.join(File.dirname(path), "_#{File.basename(path)}")
102
+ result = []
103
+ result.concat(@items.find_all(partial).map(&:identifier).map(&:to_s))
104
+ result.concat(@items.find_all(path).map(&:identifier).map(&:to_s))
105
+ result
106
+ end
94
107
 
95
- # Try as index
96
- unless is_extension_given
97
- items.concat(@items.find_all(File.join(pat, '/index.*')))
98
- items.concat(@items.find_all(File.join(pat, '/_index.*')))
108
+ def try_path_as_dir(path, from_import)
109
+ if from_import
110
+ result = exactly_one(try_path_with_ext(File.join(path, 'index.import')))
111
+ return result unless result.nil?
99
112
  end
100
113
 
101
- items
114
+ exactly_one(try_path_with_ext(File.join(path, 'index')))
102
115
  end
103
116
 
104
- def try_pat(pat, is_extension_given)
105
- if is_extension_given
106
- @items.find_all(pat)
107
- else
108
- @items.find_all("#{pat}.*")
109
- end
117
+ def exactly_one(paths)
118
+ return if paths.empty?
119
+ return paths.first if paths.one?
120
+
121
+ raise "It's not clear which file to import. Found:\n#{paths.map { |path| " #{path}" }.join("\n")}"
122
+ end
123
+
124
+ def without_ext(path)
125
+ ext = File.extname(path)
126
+ path.delete_suffix(ext)
110
127
  end
111
128
  end
112
129
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Nanoc
4
4
  module DartSass
5
- VERSION = '1.0.3'
5
+ VERSION = '2.0.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nanoc-dart-sass
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Denis Defreyne
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2024-04-19 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: nanoc-core
@@ -16,28 +15,28 @@ dependencies:
16
15
  requirements:
17
16
  - - "~>"
18
17
  - !ruby/object:Gem::Version
19
- version: '4.12'
18
+ version: '4.14'
20
19
  type: :runtime
21
20
  prerelease: false
22
21
  version_requirements: !ruby/object:Gem::Requirement
23
22
  requirements:
24
23
  - - "~>"
25
24
  - !ruby/object:Gem::Version
26
- version: '4.12'
25
+ version: '4.14'
27
26
  - !ruby/object:Gem::Dependency
28
27
  name: sass-embedded
29
28
  requirement: !ruby/object:Gem::Requirement
30
29
  requirements:
31
30
  - - "~>"
32
31
  - !ruby/object:Gem::Version
33
- version: '1.56'
32
+ version: '1.80'
34
33
  type: :runtime
35
34
  prerelease: false
36
35
  version_requirements: !ruby/object:Gem::Requirement
37
36
  requirements:
38
37
  - - "~>"
39
38
  - !ruby/object:Gem::Version
40
- version: '1.56'
39
+ version: '1.80'
41
40
  description: Provides a :dart_sass filter for Nanoc
42
41
  email: denis+rubygems@denis.ws
43
42
  executables: []
@@ -56,8 +55,7 @@ licenses:
56
55
  - MIT
57
56
  metadata:
58
57
  rubygems_mfa_required: 'true'
59
- source_code_uri: https://github.com/nanoc/nanoc/tree/nanoc-dart-sass-v1.0.3/nanoc-dart-sass
60
- post_install_message:
58
+ source_code_uri: https://github.com/nanoc/nanoc/tree/nanoc-dart-sass-v2.0.0/nanoc-dart-sass
61
59
  rdoc_options: []
62
60
  require_paths:
63
61
  - lib
@@ -65,15 +63,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
65
63
  requirements:
66
64
  - - ">="
67
65
  - !ruby/object:Gem::Version
68
- version: '2.7'
66
+ version: '3.2'
69
67
  required_rubygems_version: !ruby/object:Gem::Requirement
70
68
  requirements:
71
69
  - - ">="
72
70
  - !ruby/object:Gem::Version
73
71
  version: '0'
74
72
  requirements: []
75
- rubygems_version: 3.5.9
76
- signing_key:
73
+ rubygems_version: 4.0.3
77
74
  specification_version: 4
78
75
  summary: Dart Sass filter for Nanoc
79
76
  test_files: []