sass-embedded 0.11.0 → 0.13.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8d392419747bbe1cffb4c3843a60a8de343a07fc938c1ad061ce8cde4519fd4a
4
- data.tar.gz: 358c8083d14d6d27d84d6091cad64dd39e35c1076295e030b668386b4856098a
3
+ metadata.gz: 18c9d477f0de8ecd58a168476206d8284b840b10df7c1cea367cd553cce11054
4
+ data.tar.gz: 32c45918de0b8fe090c421c0cde9ef50c5499e0272a3e43bbe173485ed10d089
5
5
  SHA512:
6
- metadata.gz: 3a50de89e870d5d4fe054eb0702da7774fba5e445e65fba3efb9364d6ed140bbb07cb1dec2d06bee96d08cf79017c383a921def2487c78468c2a3fe2c3e6a54e
7
- data.tar.gz: e746cc7db807ab73557e03d342d7a5f88d81b7c581a5969d2a63dec1a63699828bc49fcfa1fa4d80ac5edb8452495b15bc8c2e5163127d4985276490c3259e98
6
+ metadata.gz: e8f4a1e589659b8e811f757bfee50f821bb5b295c43ccf77c382f6c6e028ff7c160ba310204538c5792cce2512a99a580df51703ddd738399fca61db05bbd672
7
+ data.tar.gz: 975a2d4257ec8a72c1bd4056902c748e8eda4b5c0e4d62f13c8cd01e2e76f5f55d93b849bd273621f82ad8732d171da63c79afd0e30340041f12c752cf2f9db3
@@ -20,6 +20,7 @@ module Sass
20
20
  url:,
21
21
 
22
22
  source_map:,
23
+ source_map_include_sources:,
23
24
  style:,
24
25
 
25
26
  functions:,
@@ -39,6 +40,7 @@ module Sass
39
40
  @url = url
40
41
 
41
42
  @source_map = source_map
43
+ @source_map_include_sources = source_map_include_sources
42
44
  @style = style
43
45
 
44
46
  @global_functions = functions.keys.map(&:to_s)
@@ -50,7 +52,11 @@ module Sass
50
52
 
51
53
  @alert_ascii = alert_ascii
52
54
  @alert_color = alert_color
53
- @logger = logger
55
+
56
+ %i[debug warn].each do |sym|
57
+ instance_variable_set("@#{sym}".to_sym, get_method(logger, sym))
58
+ end
59
+
54
60
  @quiet_deps = quiet_deps
55
61
  @verbose = verbose
56
62
 
@@ -72,9 +78,7 @@ module Sass
72
78
  when EmbeddedProtocol::OutboundMessage::LogEvent
73
79
  return unless message.compilation_id == id
74
80
 
75
- Thread.new do
76
- log message
77
- end
81
+ log message
78
82
  when EmbeddedProtocol::OutboundMessage::CanonicalizeRequest
79
83
  return unless message.compilation_id == id
80
84
 
@@ -111,24 +115,26 @@ module Sass
111
115
  def log(event)
112
116
  case event.type
113
117
  when :DEBUG
114
- if @logger.respond_to? :debug
115
- @logger.debug(event.message, span: Logger::SourceSpan.from_proto(event.span))
116
- else
118
+ if @debug.nil?
117
119
  Kernel.warn(event.formatted)
120
+ else
121
+ @debug.call(event.message, span: Logger::SourceSpan.from_proto(event.span))
118
122
  end
119
123
  when :DEPRECATION_WARNING
120
- if @logger.respond_to? :warn
121
- @logger.warn(event.message, deprecation: true, span: Logger::SourceSpan.from_proto(event.span),
122
- stack: event.stack_trace)
123
- else
124
+ if @warn.nil?
124
125
  Kernel.warn(event.formatted)
126
+ else
127
+ @warn.call(event.message, deprecation: true,
128
+ span: Logger::SourceSpan.from_proto(event.span),
129
+ stack: event.stack_trace)
125
130
  end
126
131
  when :WARNING
127
- if @logger.respond_to? :warn
128
- @logger.warn(event.message, deprecation: false, span: Logger::SourceSpan.from_proto(event.span),
129
- stack: event.stack_trace)
130
- else
132
+ if @warn.nil?
131
133
  Kernel.warn(event.formatted)
134
+ else
135
+ @warn.call(event.message, deprecation: false,
136
+ span: Logger::SourceSpan.from_proto(event.span),
137
+ stack: event.stack_trace)
132
138
  end
133
139
  end
134
140
  end
@@ -147,6 +153,7 @@ module Sass
147
153
  path: @path,
148
154
  style: to_proto_output_style(@style),
149
155
  source_map: @source_map,
156
+ source_map_include_sources: @source_map_include_sources,
150
157
  importers: to_proto_importers(@importers, @load_paths),
151
158
  global_functions: @global_functions,
152
159
  alert_ascii: @alert_ascii,
@@ -155,7 +162,9 @@ module Sass
155
162
  end
156
163
 
157
164
  def canonicalize_response(canonicalize_request)
158
- url = importer_with_id(canonicalize_request.importer_id).canonicalize canonicalize_request.url
165
+ importer = importer_with_id(canonicalize_request.importer_id)
166
+ url = get_method(importer, :canonicalize).call canonicalize_request.url,
167
+ from_import: canonicalize_request.from_import
159
168
 
160
169
  EmbeddedProtocol::InboundMessage::CanonicalizeResponse.new(
161
170
  id: canonicalize_request.id,
@@ -169,14 +178,15 @@ module Sass
169
178
  end
170
179
 
171
180
  def import_response(import_request)
172
- importer_result = importer_with_id(import_request.importer_id).load import_request.url
181
+ importer = importer_with_id(import_request.importer_id)
182
+ importer_result = get_method(importer, :load).call import_request.url
173
183
 
174
184
  EmbeddedProtocol::InboundMessage::ImportResponse.new(
175
185
  id: import_request.id,
176
186
  success: EmbeddedProtocol::InboundMessage::ImportResponse::ImportSuccess.new(
177
- contents: importer_result.contents,
178
- syntax: to_proto_syntax(importer_result.syntax),
179
- source_map_url: importer_result.source_map_url
187
+ contents: get_attr(importer_result, :contents),
188
+ syntax: to_proto_syntax(get_attr(importer_result, :syntax)),
189
+ source_map_url: get_attr(importer_result, :source_map_url)
180
190
  )
181
191
  )
182
192
  rescue StandardError => e
@@ -188,8 +198,10 @@ module Sass
188
198
 
189
199
  def file_import_response(file_import_request)
190
200
  file_importer = importer_with_id(file_import_request.importer_id)
191
- file_url = file_importer.find_file_url file_import_request.url,
192
- from_import: file_import_request.from_import
201
+ file_url = get_method(file_importer, :find_file_url).call file_import_request.url,
202
+ from_import: file_import_request.from_import
203
+
204
+ raise "file_url must be a file: URL, was \"#{file_url}\"" if !file_url.nil? && !file_url.start_with?('file:')
193
205
 
194
206
  EmbeddedProtocol::InboundMessage::FileImportResponse.new(
195
207
  id: file_import_request.id,
@@ -237,16 +249,19 @@ module Sass
237
249
  when :compressed
238
250
  EmbeddedProtocol::OutputStyle::COMPRESSED
239
251
  else
240
- raise ArgumentError, 'output_style must be one of :expanded, :compressed'
252
+ raise ArgumentError, 'style must be one of :expanded, :compressed'
241
253
  end
242
254
  end
243
255
 
244
256
  def to_proto_importer(importer, id)
245
- if importer.respond_to?(:canonicalize) && importer.respond_to?(:load)
257
+ is_importer = get_method(importer, :canonicalize) && get_method(importer, :load)
258
+ is_file_importer = get_method(importer, :find_file_url)
259
+
260
+ if is_importer && !is_file_importer
246
261
  EmbeddedProtocol::InboundMessage::CompileRequest::Importer.new(
247
262
  importer_id: id
248
263
  )
249
- elsif importer.respond_to?(:find_file_url)
264
+ elsif is_file_importer && !is_importer
250
265
  EmbeddedProtocol::InboundMessage::CompileRequest::Importer.new(
251
266
  file_importer_id: id
252
267
  )
@@ -276,6 +291,32 @@ module Sass
276
291
  @importers[id]
277
292
  end
278
293
  end
294
+
295
+ def get_method(obj, sym)
296
+ sym = sym.to_sym
297
+ if obj.respond_to? sym
298
+ obj.method(sym)
299
+ elsif obj.respond_to? :[]
300
+ if obj[sym].respond_to? :call
301
+ obj[sym]
302
+ elsif obj[sym.to_s].respond_to? :call
303
+ obj[sym.to_s]
304
+ end
305
+ end
306
+ end
307
+
308
+ def get_attr(obj, sym)
309
+ sym = sym.to_sym
310
+ if obj.respond_to? sym
311
+ obj.method(sym).call
312
+ elsif obj.respond_to? :[]
313
+ if obj[sym]
314
+ obj[sym]
315
+ elsif obj[sym.to_s]
316
+ obj[sym.to_s]
317
+ end
318
+ end
319
+ end
279
320
  end
280
321
  end
281
322
  end
@@ -3,7 +3,7 @@
3
3
  module Sass
4
4
  class Embedded
5
5
  class Compiler
6
- REQUIREMENTS = '~> 1.0.0-beta.16'
6
+ REQUIREMENTS = '~> 1.49.7'
7
7
  end
8
8
  end
9
9
  end
@@ -66,6 +66,7 @@ module Sass
66
66
  syntax: indented_syntax ? :indented : :scss,
67
67
  url: (Url.path_to_file_url(File.absolute_path(file)) unless file.nil?),
68
68
  source_map: source_map_option,
69
+ source_map_include_sources: source_map_contents,
69
70
  style: output_style,
70
71
  functions: functions,
71
72
  importers: importer.map do |legacy_importer|
@@ -74,6 +75,7 @@ module Sass
74
75
  else
75
76
  compile(file, load_paths: load_paths,
76
77
  source_map: source_map_option,
78
+ source_map_include_sources: source_map_contents,
77
79
  style: output_style,
78
80
  functions: functions,
79
81
  importers: importer.map do |legacy_importer|
@@ -98,11 +100,9 @@ module Sass
98
100
  end
99
101
 
100
102
  map, source_map = post_process_map(map: compile_result.source_map,
101
- data: data,
102
103
  file: file,
103
104
  out_file: out_file,
104
105
  source_map: source_map,
105
- source_map_contents: source_map_contents,
106
106
  source_map_root: source_map_root)
107
107
 
108
108
  css = post_process_css(css: compile_result.css,
@@ -172,11 +172,9 @@ module Sass
172
172
 
173
173
  # @deprecated
174
174
  def post_process_map(map:,
175
- data:,
176
175
  file:,
177
176
  out_file:,
178
177
  source_map:,
179
- source_map_contents:,
180
178
  source_map_root:)
181
179
  return if map.nil? || map.empty?
182
180
 
@@ -201,26 +199,11 @@ module Sass
201
199
  map_data['file'] = 'stdin.css'
202
200
  end
203
201
 
204
- map_data['sourcesContent'] = [] if source_map_contents
205
-
206
- file = File.absolute_path(file) unless file.nil?
207
-
208
202
  map_data['sources'].map! do |source|
209
203
  if source.start_with? 'file://'
210
204
  path = Url.file_url_to_path(source)
211
- content = if path == file && !data.nil?
212
- data
213
- else
214
- begin
215
- File.read(path)
216
- rescue StandardError
217
- nil
218
- end
219
- end
220
- map_data['sourcesContent'].push(content) if source_map_contents
221
205
  relative_path(source_map_dir, path)
222
206
  else
223
- map_data['sourcesContent'].push(nil) if source_map_contents
224
207
  source
225
208
  end
226
209
  end
@@ -317,7 +300,7 @@ module Sass
317
300
  @importer_results = {}
318
301
  end
319
302
 
320
- def canonicalize(url)
303
+ def canonicalize(url, **_kwargs)
321
304
  path = Url.file_url_to_path(url)
322
305
  canonical_url = Url.path_to_file_url(File.absolute_path(path, (@file.nil? ? 'stdin' : @file)))
323
306
 
@@ -6,24 +6,26 @@ module Sass
6
6
  class Embedded
7
7
  # The {Url} module.
8
8
  module Url
9
- # The {::URI::Parser} that is in consistent with Dart Uri.
9
+ # The {::URI::Parser} that is in consistent with RFC 2396 (URI Generic Syntax) and dart:core library.
10
10
  URI_PARSER = URI::Parser.new({ RESERVED: ';/?:@&=+$,' })
11
11
 
12
- private_constant :URI_PARSER
12
+ FILE_SCHEME = 'file://'
13
+
14
+ private_constant :URI_PARSER, :FILE_SCHEME
13
15
 
14
16
  module_function
15
17
 
16
18
  def path_to_file_url(path)
17
19
  if File.absolute_path? path
18
- "file://#{Platform::OS == 'windows' ? File::SEPARATOR : ''}#{URI_PARSER.escape(path)}"
20
+ URI_PARSER.escape "#{FILE_SCHEME}#{Platform::OS == 'windows' ? File::SEPARATOR : ''}#{path}"
19
21
  else
20
- URI_PARSER.escape(path)
22
+ URI_PARSER.escape path
21
23
  end
22
24
  end
23
25
 
24
26
  def file_url_to_path(url)
25
- if url.start_with? 'file://'
26
- URI_PARSER.unescape url[(Platform::OS == 'windows' ? 8 : 7)..]
27
+ if url.start_with? FILE_SCHEME
28
+ URI_PARSER.unescape url[(FILE_SCHEME.length + (Platform::OS == 'windows' ? 1 : 0))..]
27
29
  else
28
30
  URI_PARSER.unescape url
29
31
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Sass
4
4
  class Embedded
5
- VERSION = '0.11.0'
5
+ VERSION = '0.13.2'
6
6
  end
7
7
  end
data/lib/sass/embedded.rb CHANGED
@@ -34,6 +34,7 @@ module Sass
34
34
  load_paths: [],
35
35
 
36
36
  source_map: false,
37
+ source_map_include_sources: false,
37
38
  style: :expanded,
38
39
 
39
40
  functions: {},
@@ -55,6 +56,7 @@ module Sass
55
56
  syntax: nil,
56
57
  url: nil,
57
58
  source_map: source_map,
59
+ source_map_include_sources: source_map_include_sources,
58
60
  style: style,
59
61
  functions: functions,
60
62
  importers: importers,
@@ -81,6 +83,7 @@ module Sass
81
83
  url: nil,
82
84
 
83
85
  source_map: false,
86
+ source_map_include_sources: false,
84
87
  style: :expanded,
85
88
 
86
89
  functions: {},
@@ -101,6 +104,7 @@ module Sass
101
104
  syntax: syntax,
102
105
  url: url,
103
106
  source_map: source_map,
107
+ source_map_include_sources: source_map_include_sources,
104
108
  style: style,
105
109
  functions: functions,
106
110
  importers: importers,
@@ -119,7 +123,7 @@ module Sass
119
123
  #
120
124
  # @raise [ProtocolError]
121
125
  def info
122
- @info ||= VersionContext.new(@channel).receive_message
126
+ @info ||= "sass-embedded\t#{VersionContext.new(@channel).receive_message.implementation_version}"
123
127
  end
124
128
 
125
129
  def close
data/lib/sass/logger.rb CHANGED
@@ -3,18 +3,22 @@
3
3
  module Sass
4
4
  # The {Logger} module.
5
5
  module Logger
6
- # The instance of a slient {Logger}.
7
- def self.slient
8
- @slient ||= Slient.new
6
+ module_function
7
+
8
+ # The instance of a silent {Logger}.
9
+ def silent
10
+ Silent
9
11
  end
10
12
 
11
- # The slient {Logger}.
12
- class Slient
13
+ # The silent {Logger}.
14
+ module Silent
15
+ module_function
16
+
13
17
  def warn(message, deprecation: false, span: nil, stack: nil); end
14
18
 
15
19
  def debug(message, span: nil); end
16
20
  end
17
21
 
18
- private_constant :Slient
22
+ private_constant :Silent
19
23
  end
20
24
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sass-embedded
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.0
4
+ version: 0.13.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - なつき
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-01-18 00:00:00.000000000 Z
11
+ date: 2022-02-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: google-protobuf
@@ -66,20 +66,34 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: 13.0.6
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 3.10.0
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 3.10.0
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: rubocop
71
85
  requirement: !ruby/object:Gem::Requirement
72
86
  requirements:
73
87
  - - "~>"
74
88
  - !ruby/object:Gem::Version
75
- version: 1.24.0
89
+ version: 1.25.0
76
90
  type: :development
77
91
  prerelease: false
78
92
  version_requirements: !ruby/object:Gem::Requirement
79
93
  requirements:
80
94
  - - "~>"
81
95
  - !ruby/object:Gem::Version
82
- version: 1.24.0
96
+ version: 1.25.0
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: rubocop-minitest
85
99
  requirement: !ruby/object:Gem::Requirement
@@ -122,6 +136,20 @@ dependencies:
122
136
  - - "~>"
123
137
  - !ruby/object:Gem::Version
124
138
  version: 0.6.0
139
+ - !ruby/object:Gem::Dependency
140
+ name: rubocop-rspec
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: 2.8.0
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: 2.8.0
125
153
  description: A Ruby library that will communicate with Embedded Dart Sass using the
126
154
  Embedded Sass protocol.
127
155
  email:
@@ -164,8 +192,8 @@ homepage: https://github.com/ntkme/sass-embedded-host-ruby
164
192
  licenses:
165
193
  - MIT
166
194
  metadata:
167
- documentation_uri: https://www.rubydoc.info/gems/sass-embedded/0.11.0
168
- source_code_uri: https://github.com/ntkme/sass-embedded-host-ruby/tree/v0.11.0
195
+ documentation_uri: https://www.rubydoc.info/gems/sass-embedded/0.13.2
196
+ source_code_uri: https://github.com/ntkme/sass-embedded-host-ruby/tree/v0.13.2
169
197
  funding_uri: https://github.com/sponsors/ntkme
170
198
  post_install_message:
171
199
  rdoc_options: []