sass-embedded 0.14.0 → 0.15.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sass/embedded/compile_context.rb +4 -6
- data/lib/sass/embedded/render.rb +38 -3
- data/lib/sass/embedded/version.rb +1 -1
- data/lib/sass/embedded.rb +1 -3
- metadata +3 -7
- data/lib/sass/embedded/url.rb +0 -35
- data/lib/sass/file_importer.rb +0 -10
- data/lib/sass/importer.rb +0 -14
- data/lib/sass/importer_result.rb +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8b1ad905f18295ab48835d21b1e6a9c644a860154b37531eeaae2f50f16f70e9
|
4
|
+
data.tar.gz: 229fe63046318d8ce512683d11e3868e8c70d6b28897badeb74be7757ff63e7e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 20bc3d260f0ac7bd9473351b7f59a08ccd1de7720afc56c027c83025924b7c986335994a4b257344e8c8435c11b5248de2d1dd512cf5e499d85eeddd1166f260
|
7
|
+
data.tar.gz: 5cd706afea71314dc85b47d58f3d4cb9f7ecc82a0a1ed72fc8afc5f772bd98022a8026b62eb490b7c2d9c74c1045d7edb945736078e5195f8c93f858d3f6cc7f
|
@@ -145,7 +145,7 @@ module Sass
|
|
145
145
|
string: unless @source.nil?
|
146
146
|
EmbeddedProtocol::InboundMessage::CompileRequest::StringInput.new(
|
147
147
|
source: @source,
|
148
|
-
url: @url,
|
148
|
+
url: @url&.to_s,
|
149
149
|
syntax: to_proto_syntax(@syntax),
|
150
150
|
importer: @importer.nil? ? nil : to_proto_importer(@importer, @importers.length)
|
151
151
|
)
|
@@ -163,8 +163,7 @@ module Sass
|
|
163
163
|
|
164
164
|
def canonicalize_response(canonicalize_request)
|
165
165
|
importer = importer_of_id canonicalize_request.importer_id
|
166
|
-
url = importer.canonicalize
|
167
|
-
from_import: canonicalize_request.from_import
|
166
|
+
url = importer.canonicalize(canonicalize_request.url, from_import: canonicalize_request.from_import)&.to_s
|
168
167
|
|
169
168
|
EmbeddedProtocol::InboundMessage::CanonicalizeResponse.new(
|
170
169
|
id: canonicalize_request.id,
|
@@ -186,7 +185,7 @@ module Sass
|
|
186
185
|
success: EmbeddedProtocol::InboundMessage::ImportResponse::ImportSuccess.new(
|
187
186
|
contents: importer_result.contents,
|
188
187
|
syntax: to_proto_syntax(importer_result.syntax),
|
189
|
-
source_map_url: importer_result.respond_to?(:source_map_url) ? importer_result.source_map_url : nil
|
188
|
+
source_map_url: importer_result.respond_to?(:source_map_url) ? importer_result.source_map_url&.to_s : nil
|
190
189
|
)
|
191
190
|
)
|
192
191
|
rescue StandardError => e
|
@@ -198,8 +197,7 @@ module Sass
|
|
198
197
|
|
199
198
|
def file_import_response(file_import_request)
|
200
199
|
importer = importer_of_id file_import_request.importer_id
|
201
|
-
file_url = importer.find_file_url
|
202
|
-
from_import: file_import_request.from_import
|
200
|
+
file_url = importer.find_file_url(file_import_request.url, from_import: file_import_request.from_import)&.to_s
|
203
201
|
|
204
202
|
raise "file_url must be a file: URL, was \"#{file_url}\"" if !file_url.nil? && !file_url.start_with?('file:')
|
205
203
|
|
data/lib/sass/embedded/render.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
require 'base64'
|
4
4
|
require 'json'
|
5
5
|
require 'pathname'
|
6
|
-
|
6
|
+
require 'uri'
|
7
7
|
|
8
8
|
module Sass
|
9
9
|
# The {Embedded} host for using dart-sass-embedded. Each instance creates
|
@@ -309,11 +309,17 @@ module Sass
|
|
309
309
|
raise result if result.is_a? StandardError
|
310
310
|
|
311
311
|
if result&.key? :contents
|
312
|
-
@importer_results[canonical_url] =
|
312
|
+
@importer_results[canonical_url] = {
|
313
|
+
contents: result[:contents],
|
314
|
+
syntax: :scss
|
315
|
+
}
|
313
316
|
canonical_url
|
314
317
|
elsif result&.key? :file
|
315
318
|
canonical_url = Url.path_to_file_url(File.absolute_path(result[:file]))
|
316
|
-
@importer_results[canonical_url] =
|
319
|
+
@importer_results[canonical_url] = {
|
320
|
+
contents: File.read(result[:file]),
|
321
|
+
syntax: :scss
|
322
|
+
}
|
317
323
|
canonical_url
|
318
324
|
end
|
319
325
|
end
|
@@ -323,6 +329,35 @@ module Sass
|
|
323
329
|
end
|
324
330
|
end
|
325
331
|
|
332
|
+
# @deprecated
|
333
|
+
# The {Url} module.
|
334
|
+
module Url
|
335
|
+
# The {::URI::Parser} that is in consistent with RFC 2396 (URI Generic Syntax) and dart:core library.
|
336
|
+
URI_PARSER = URI::Parser.new({ RESERVED: ';/?:@&=+$,' })
|
337
|
+
|
338
|
+
FILE_SCHEME = 'file://'
|
339
|
+
|
340
|
+
private_constant :URI_PARSER, :FILE_SCHEME
|
341
|
+
|
342
|
+
module_function
|
343
|
+
|
344
|
+
def path_to_file_url(path)
|
345
|
+
if File.absolute_path? path
|
346
|
+
URI_PARSER.escape "#{FILE_SCHEME}#{Gem.win_platform? ? '/' : ''}#{path}"
|
347
|
+
else
|
348
|
+
URI_PARSER.escape path
|
349
|
+
end
|
350
|
+
end
|
351
|
+
|
352
|
+
def file_url_to_path(url)
|
353
|
+
if url.start_with? FILE_SCHEME
|
354
|
+
URI_PARSER.unescape url[(FILE_SCHEME.length + (Gem.win_platform? ? 1 : 0))..]
|
355
|
+
else
|
356
|
+
URI_PARSER.unescape url
|
357
|
+
end
|
358
|
+
end
|
359
|
+
end
|
360
|
+
|
326
361
|
private_constant :LegacyImporter
|
327
362
|
end
|
328
363
|
end
|
data/lib/sass/embedded.rb
CHANGED
@@ -4,11 +4,9 @@ require_relative 'compile_error'
|
|
4
4
|
require_relative 'compile_result'
|
5
5
|
require_relative 'embedded/channel'
|
6
6
|
require_relative 'embedded/compile_context'
|
7
|
-
require_relative 'embedded/render'
|
8
|
-
require_relative 'embedded/url'
|
7
|
+
require_relative 'embedded/render' # deprecated
|
9
8
|
require_relative 'embedded/version'
|
10
9
|
require_relative 'embedded/version_context'
|
11
|
-
require_relative 'importer_result'
|
12
10
|
require_relative 'logger'
|
13
11
|
|
14
12
|
module Sass
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sass-embedded
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.15.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- なつき
|
@@ -177,13 +177,9 @@ files:
|
|
177
177
|
- lib/sass/embedded/observer.rb
|
178
178
|
- lib/sass/embedded/protocol_error.rb
|
179
179
|
- lib/sass/embedded/render.rb
|
180
|
-
- lib/sass/embedded/url.rb
|
181
180
|
- lib/sass/embedded/version.rb
|
182
181
|
- lib/sass/embedded/version_context.rb
|
183
182
|
- lib/sass/embedded_protocol.rb
|
184
|
-
- lib/sass/file_importer.rb
|
185
|
-
- lib/sass/importer.rb
|
186
|
-
- lib/sass/importer_result.rb
|
187
183
|
- lib/sass/logger.rb
|
188
184
|
- lib/sass/logger/source_location.rb
|
189
185
|
- lib/sass/logger/source_span.rb
|
@@ -191,8 +187,8 @@ homepage: https://github.com/ntkme/sass-embedded-host-ruby
|
|
191
187
|
licenses:
|
192
188
|
- MIT
|
193
189
|
metadata:
|
194
|
-
documentation_uri: https://www.rubydoc.info/gems/sass-embedded/0.
|
195
|
-
source_code_uri: https://github.com/ntkme/sass-embedded-host-ruby/tree/v0.
|
190
|
+
documentation_uri: https://www.rubydoc.info/gems/sass-embedded/0.15.0
|
191
|
+
source_code_uri: https://github.com/ntkme/sass-embedded-host-ruby/tree/v0.15.0
|
196
192
|
funding_uri: https://github.com/sponsors/ntkme
|
197
193
|
post_install_message:
|
198
194
|
rdoc_options: []
|
data/lib/sass/embedded/url.rb
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'uri'
|
4
|
-
|
5
|
-
module Sass
|
6
|
-
class Embedded
|
7
|
-
# The {Url} module.
|
8
|
-
module Url
|
9
|
-
# The {::URI::Parser} that is in consistent with RFC 2396 (URI Generic Syntax) and dart:core library.
|
10
|
-
URI_PARSER = URI::Parser.new({ RESERVED: ';/?:@&=+$,' })
|
11
|
-
|
12
|
-
FILE_SCHEME = 'file://'
|
13
|
-
|
14
|
-
private_constant :URI_PARSER, :FILE_SCHEME
|
15
|
-
|
16
|
-
module_function
|
17
|
-
|
18
|
-
def path_to_file_url(path)
|
19
|
-
if File.absolute_path? path
|
20
|
-
URI_PARSER.escape "#{FILE_SCHEME}#{Gem.win_platform? ? File::SEPARATOR : ''}#{path}"
|
21
|
-
else
|
22
|
-
URI_PARSER.escape path
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
def file_url_to_path(url)
|
27
|
-
if url.start_with? FILE_SCHEME
|
28
|
-
URI_PARSER.unescape url[(FILE_SCHEME.length + (Gem.win_platform? ? 1 : 0))..]
|
29
|
-
else
|
30
|
-
URI_PARSER.unescape url
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
data/lib/sass/file_importer.rb
DELETED
@@ -1,10 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Sass
|
4
|
-
# The {FileImporter} interface.
|
5
|
-
class FileImporter
|
6
|
-
def find_file_url(url, from_import:) # rubocop:disable Lint/UnusedMethodArgument
|
7
|
-
raise NotImplementedError, 'FileImporter#find_file_url must be implemented'
|
8
|
-
end
|
9
|
-
end
|
10
|
-
end
|
data/lib/sass/importer.rb
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Sass
|
4
|
-
# The {Importer} interface.
|
5
|
-
class Importer
|
6
|
-
def canonicalize(url) # rubocop:disable Lint/UnusedMethodArgument
|
7
|
-
raise NotImplementedError, 'Importer#canonicalize must be implemented'
|
8
|
-
end
|
9
|
-
|
10
|
-
def load(canonical_url) # rubocop:disable Lint/UnusedMethodArgument
|
11
|
-
raise NotImplementedError, 'Importer#load must be implemented'
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
data/lib/sass/importer_result.rb
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Sass
|
4
|
-
# The {ImporterResult} of {Importer#load}.
|
5
|
-
class ImporterResult
|
6
|
-
attr_reader :contents, :syntax, :source_map_url
|
7
|
-
|
8
|
-
def initialize(contents, syntax, source_map_url = nil)
|
9
|
-
@contents = contents
|
10
|
-
@syntax = syntax
|
11
|
-
@source_map_url = source_map_url
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|