sass-embedded 0.19.6 → 1.0.1
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 +4 -4
- data/ext/sass/extconf.rb +9 -8
- data/lib/sass/embedded/channel.rb +1 -1
- data/lib/sass/embedded/compiler.rb +3 -3
- data/lib/sass/embedded/host/function_registry.rb +1 -1
- data/lib/sass/embedded/version.rb +1 -1
- data/lib/sass.rb +0 -1
- metadata +4 -5
- data/lib/sass/embedded/legacy.rb +0 -406
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5f5ecc805dbe549bd19b1e5777bd16500bcd71fc56def8fe364f542c7bb731e0
|
4
|
+
data.tar.gz: 14c15309ebc1aff54a5b9df78cbd5a66e7321c22e4229357724945aa2a0d3647
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e4d372b8b307ff60d2f21c6b6bf1674833587c0945ff13e6435dae761fb4bfa0e75233f5dfe88aa47d97b7d4cea483ffdc55e71df92ae9d472d29a94c4eb4f21
|
7
|
+
data.tar.gz: 4ecd5d19ca66c2697e0a2cdbfccbb550ab0cb414829d542e71b7f28c77122973f5dc508e2aec3c214aaad777c674cc72a1a8a0b5b90b256728ef20623e16df53
|
data/ext/sass/extconf.rb
CHANGED
@@ -106,20 +106,21 @@ module Sass
|
|
106
106
|
|
107
107
|
def fetch(uri_s)
|
108
108
|
uri = URI.parse(uri_s)
|
109
|
-
path =
|
109
|
+
path = URI::DEFAULT_PARSER.unescape(uri.path)
|
110
|
+
dest = File.absolute_path(File.basename(path), __dir__)
|
110
111
|
if uri.is_a?(URI::File) || uri.instance_of?(URI::Generic)
|
111
|
-
|
112
|
+
puts "cp -- #{path} #{dest}"
|
113
|
+
FileUtils.copy_file(path, dest)
|
112
114
|
elsif uri.respond_to? :open
|
113
|
-
puts "curl -fsSLo #{
|
114
|
-
uri.open do |
|
115
|
-
File.binwrite(
|
115
|
+
puts "curl -fsSLo #{dest} -- #{uri}"
|
116
|
+
uri.open do |stream|
|
117
|
+
File.binwrite(dest, stream.read)
|
116
118
|
end
|
117
119
|
else
|
118
120
|
raise
|
119
121
|
end
|
120
122
|
rescue StandardError
|
121
|
-
|
122
|
-
raise
|
123
|
+
raise "Failed to fetch #{uri_s}"
|
123
124
|
end
|
124
125
|
|
125
126
|
def default_sass_embedded
|
@@ -209,7 +210,7 @@ module Sass
|
|
209
210
|
|
210
211
|
ext = 'zip'
|
211
212
|
|
212
|
-
"https://github.com/#{repo}/releases/download/#{tag_name}/protoc-#{tag_name
|
213
|
+
"https://github.com/#{repo}/releases/download/#{tag_name}/protoc-#{tag_name.delete_prefix('v')}-#{os_arch}.#{ext}"
|
213
214
|
end
|
214
215
|
|
215
216
|
def default_sass_embedded_protocol
|
@@ -13,11 +13,11 @@ module Sass
|
|
13
13
|
)
|
14
14
|
|
15
15
|
def initialize
|
16
|
+
@stdin, @stdout, @stderr, @wait_thread = Open3.popen3(PATH)
|
17
|
+
@stdin.binmode
|
18
|
+
@stdout.binmode
|
16
19
|
@stdin_mutex = Mutex.new
|
17
20
|
@stdout_mutex = Mutex.new
|
18
|
-
@stdin, @stdout, @stderr, @wait_thread = Open3.popen3(PATH)
|
19
|
-
|
20
|
-
[@stdin, @stdout].each(&:binmode)
|
21
21
|
|
22
22
|
Thread.new do
|
23
23
|
loop do
|
@@ -49,7 +49,7 @@ module Sass
|
|
49
49
|
|
50
50
|
success = value_protofier.to_proto(get(function_call_request).call(arguments))
|
51
51
|
accessed_argument_lists = arguments
|
52
|
-
.
|
52
|
+
.select do |argument|
|
53
53
|
argument.is_a?(Sass::Value::ArgumentList) && argument.instance_eval do
|
54
54
|
@keywords_accessed
|
55
55
|
end
|
data/lib/sass.rb
CHANGED
@@ -12,7 +12,6 @@ require_relative 'sass/embedded/host/function_registry'
|
|
12
12
|
require_relative 'sass/embedded/host/importer_registry'
|
13
13
|
require_relative 'sass/embedded/host/logger_registry'
|
14
14
|
require_relative 'sass/embedded/host/value_protofier'
|
15
|
-
require_relative 'sass/embedded/legacy'
|
16
15
|
require_relative 'sass/embedded/protofier'
|
17
16
|
require_relative 'sass/embedded/structifier'
|
18
17
|
require_relative 'sass/embedded/varint'
|
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.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- なつき
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-02-
|
11
|
+
date: 2022-02-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: google-protobuf
|
@@ -137,7 +137,6 @@ files:
|
|
137
137
|
- lib/sass/embedded/host/importer_registry.rb
|
138
138
|
- lib/sass/embedded/host/logger_registry.rb
|
139
139
|
- lib/sass/embedded/host/value_protofier.rb
|
140
|
-
- lib/sass/embedded/legacy.rb
|
141
140
|
- lib/sass/embedded/protofier.rb
|
142
141
|
- lib/sass/embedded/structifier.rb
|
143
142
|
- lib/sass/embedded/varint.rb
|
@@ -163,8 +162,8 @@ homepage: https://github.com/ntkme/sass-embedded-host-ruby
|
|
163
162
|
licenses:
|
164
163
|
- MIT
|
165
164
|
metadata:
|
166
|
-
documentation_uri: https://www.rubydoc.info/gems/sass-embedded/0.
|
167
|
-
source_code_uri: https://github.com/ntkme/sass-embedded-host-ruby/tree/
|
165
|
+
documentation_uri: https://www.rubydoc.info/gems/sass-embedded/1.0.1
|
166
|
+
source_code_uri: https://github.com/ntkme/sass-embedded-host-ruby/tree/v1.0.1
|
168
167
|
funding_uri: https://github.com/sponsors/ntkme
|
169
168
|
post_install_message:
|
170
169
|
rdoc_options: []
|
data/lib/sass/embedded/legacy.rb
DELETED
@@ -1,406 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# The Sass module.
|
4
|
-
#
|
5
|
-
# This communicates with Embedded Dart Sass using the Embedded Sass protocol.
|
6
|
-
module Sass
|
7
|
-
class << self
|
8
|
-
# @deprecated
|
9
|
-
# The global {.include_paths} for Sass files. This is meant for plugins and
|
10
|
-
# libraries to register the paths to their Sass stylesheets to that they may
|
11
|
-
# be included via `@import` or `@use`. This include path is used by every
|
12
|
-
# instance of {Sass::Embedded}. They are lower-precedence than any include
|
13
|
-
# paths passed in via the `include_paths` option.
|
14
|
-
#
|
15
|
-
# If the `SASS_PATH` environment variable is set,
|
16
|
-
# the initial value of `include_paths` will be initialized based on that.
|
17
|
-
# The variable should be a colon-separated list of path names
|
18
|
-
# (semicolon-separated on Windows).
|
19
|
-
#
|
20
|
-
# @example
|
21
|
-
# Sass.include_paths << File.dirname(__FILE__) + '/sass'
|
22
|
-
# @return [Array]
|
23
|
-
def include_paths
|
24
|
-
Embedded.include_paths
|
25
|
-
end
|
26
|
-
|
27
|
-
# @deprecated
|
28
|
-
# The global {.render} method. This instantiates a global {Embedded} instance
|
29
|
-
# and calls {Embedded#render}.
|
30
|
-
#
|
31
|
-
# See {Embedded#render} for supported options.
|
32
|
-
#
|
33
|
-
# @example
|
34
|
-
# Sass.render(data: 'h1 { font-size: 40px; }')
|
35
|
-
# @example
|
36
|
-
# Sass.render(file: 'style.css')
|
37
|
-
# @return [Result]
|
38
|
-
# @raise [RenderError]
|
39
|
-
def render(**kwargs)
|
40
|
-
instance.render(**kwargs)
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
# The {Embedded} host for using dart-sass-embedded. Each instance creates
|
45
|
-
# its own {Channel}.
|
46
|
-
#
|
47
|
-
# @example
|
48
|
-
# embedded = Sass::Embedded.new
|
49
|
-
# result = embedded.compile_string('h1 { font-size: 40px; }')
|
50
|
-
# result = embedded.compile('style.scss')
|
51
|
-
# embedded.close
|
52
|
-
class Embedded
|
53
|
-
# @deprecated
|
54
|
-
def self.include_paths
|
55
|
-
@include_paths ||= if ENV['SASS_PATH']
|
56
|
-
ENV['SASS_PATH'].split(File::PATH_SEPARATOR)
|
57
|
-
else
|
58
|
-
[]
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
# @deprecated
|
63
|
-
# The {Embedded#render} method.
|
64
|
-
#
|
65
|
-
# See {file:README.md#options} for supported options.
|
66
|
-
#
|
67
|
-
# @return [RenderResult]
|
68
|
-
# @raise [RenderError]
|
69
|
-
def render(data: nil,
|
70
|
-
file: nil,
|
71
|
-
indented_syntax: false,
|
72
|
-
include_paths: [],
|
73
|
-
output_style: :expanded,
|
74
|
-
indent_type: :space,
|
75
|
-
indent_width: 2,
|
76
|
-
linefeed: :lf,
|
77
|
-
source_map: false,
|
78
|
-
out_file: nil,
|
79
|
-
omit_source_map_url: false,
|
80
|
-
source_map_contents: false,
|
81
|
-
source_map_embed: false,
|
82
|
-
source_map_root: '',
|
83
|
-
functions: {},
|
84
|
-
importer: [])
|
85
|
-
raise ArgumentError, 'either data or file must be set' if file.nil? && data.nil?
|
86
|
-
|
87
|
-
start = now
|
88
|
-
|
89
|
-
indent_type = parse_indent_type(indent_type)
|
90
|
-
indent_width = parse_indent_width(indent_width)
|
91
|
-
linefeed = parse_linefeed(linefeed)
|
92
|
-
|
93
|
-
load_paths = include_paths + Embedded.include_paths
|
94
|
-
|
95
|
-
source_map_option = source_map.is_a?(String) || (source_map == true && !out_file.nil?)
|
96
|
-
|
97
|
-
begin
|
98
|
-
compile_result = if data
|
99
|
-
compile_string(data, load_paths: load_paths,
|
100
|
-
syntax: indented_syntax ? :indented : :scss,
|
101
|
-
url: (Url.path_to_file_url(File.absolute_path(file)) unless file.nil?),
|
102
|
-
source_map: source_map_option,
|
103
|
-
source_map_include_sources: source_map_contents,
|
104
|
-
style: output_style,
|
105
|
-
functions: functions,
|
106
|
-
importers: importer.map do |legacy_importer|
|
107
|
-
LegacyImporter.new(legacy_importer, file)
|
108
|
-
end)
|
109
|
-
else
|
110
|
-
compile(file, load_paths: load_paths,
|
111
|
-
source_map: source_map_option,
|
112
|
-
source_map_include_sources: source_map_contents,
|
113
|
-
style: output_style,
|
114
|
-
functions: functions,
|
115
|
-
importers: importer.map do |legacy_importer|
|
116
|
-
LegacyImporter.new(legacy_importer, file)
|
117
|
-
end)
|
118
|
-
end
|
119
|
-
rescue CompileError => e
|
120
|
-
raise RenderError.new(
|
121
|
-
e.message,
|
122
|
-
e.full_message,
|
123
|
-
if e.span.nil?
|
124
|
-
nil
|
125
|
-
elsif e.span.url.nil?
|
126
|
-
'stdin'
|
127
|
-
else
|
128
|
-
Url.file_url_to_path(e.span.url)
|
129
|
-
end,
|
130
|
-
e.span.start.line + 1,
|
131
|
-
e.span.start.column + 1,
|
132
|
-
1
|
133
|
-
)
|
134
|
-
end
|
135
|
-
|
136
|
-
map, source_map = post_process_map(map: compile_result.source_map,
|
137
|
-
file: file,
|
138
|
-
out_file: out_file,
|
139
|
-
source_map: source_map,
|
140
|
-
source_map_root: source_map_root)
|
141
|
-
|
142
|
-
css = post_process_css(css: compile_result.css,
|
143
|
-
indent_type: indent_type,
|
144
|
-
indent_width: indent_width,
|
145
|
-
linefeed: linefeed,
|
146
|
-
map: map,
|
147
|
-
out_file: out_file,
|
148
|
-
omit_source_map_url: omit_source_map_url,
|
149
|
-
source_map: source_map,
|
150
|
-
source_map_embed: source_map_embed)
|
151
|
-
|
152
|
-
finish = now
|
153
|
-
|
154
|
-
stats = RenderResultStats.new(file.nil? ? 'data' : file, start, finish, finish - start)
|
155
|
-
|
156
|
-
RenderResult.new(css, map, stats)
|
157
|
-
end
|
158
|
-
|
159
|
-
# @deprecated
|
160
|
-
# The {RenderResult} of {Embedded#render}.
|
161
|
-
class RenderResult
|
162
|
-
attr_reader :css, :map, :stats
|
163
|
-
|
164
|
-
def initialize(css, map, stats)
|
165
|
-
@css = css
|
166
|
-
@map = map
|
167
|
-
@stats = stats
|
168
|
-
end
|
169
|
-
end
|
170
|
-
|
171
|
-
# @deprecated
|
172
|
-
# The {RenderResultStats} of {Embedded#render}.
|
173
|
-
class RenderResultStats
|
174
|
-
attr_reader :entry, :start, :end, :duration
|
175
|
-
|
176
|
-
def initialize(entry, start, finish, duration)
|
177
|
-
@entry = entry
|
178
|
-
@start = start
|
179
|
-
@end = finish
|
180
|
-
@duration = duration
|
181
|
-
end
|
182
|
-
end
|
183
|
-
|
184
|
-
# @deprecated
|
185
|
-
# The {RenderError} raised by {Embedded#render}.
|
186
|
-
class RenderError < StandardError
|
187
|
-
attr_reader :formatted, :file, :line, :column, :status
|
188
|
-
|
189
|
-
def initialize(message, formatted, file, line, column, status)
|
190
|
-
super(message)
|
191
|
-
@formatted = formatted
|
192
|
-
@file = file
|
193
|
-
@line = line
|
194
|
-
@column = column
|
195
|
-
@status = status
|
196
|
-
end
|
197
|
-
|
198
|
-
def backtrace
|
199
|
-
return nil if super.nil?
|
200
|
-
|
201
|
-
["#{@file}:#{@line}:#{@column}"] + super
|
202
|
-
end
|
203
|
-
end
|
204
|
-
|
205
|
-
private
|
206
|
-
|
207
|
-
# @deprecated
|
208
|
-
def post_process_map(map:,
|
209
|
-
file:,
|
210
|
-
out_file:,
|
211
|
-
source_map:,
|
212
|
-
source_map_root:)
|
213
|
-
return if map.nil? || map.empty?
|
214
|
-
|
215
|
-
require 'json'
|
216
|
-
|
217
|
-
map_data = JSON.parse(map)
|
218
|
-
|
219
|
-
map_data['sourceRoot'] = source_map_root
|
220
|
-
|
221
|
-
source_map_path = if source_map.is_a? String
|
222
|
-
source_map
|
223
|
-
else
|
224
|
-
"#{out_file}.map"
|
225
|
-
end
|
226
|
-
|
227
|
-
source_map_dir = File.dirname(source_map_path)
|
228
|
-
|
229
|
-
if out_file
|
230
|
-
map_data['file'] = relative_path(source_map_dir, out_file)
|
231
|
-
elsif file
|
232
|
-
ext = File.extname(file)
|
233
|
-
map_data['file'] = "#{file[0..(ext.empty? ? -1 : -ext.length - 1)]}.css"
|
234
|
-
else
|
235
|
-
map_data['file'] = 'stdin.css'
|
236
|
-
end
|
237
|
-
|
238
|
-
map_data['sources'].map! do |source|
|
239
|
-
if source.start_with? 'file://'
|
240
|
-
path = Url.file_url_to_path(source)
|
241
|
-
relative_path(source_map_dir, path)
|
242
|
-
else
|
243
|
-
source
|
244
|
-
end
|
245
|
-
end
|
246
|
-
|
247
|
-
[-JSON.generate(map_data), source_map_path]
|
248
|
-
end
|
249
|
-
|
250
|
-
# @deprecated
|
251
|
-
def post_process_css(css:,
|
252
|
-
indent_type:,
|
253
|
-
indent_width:,
|
254
|
-
linefeed:,
|
255
|
-
map:,
|
256
|
-
omit_source_map_url:,
|
257
|
-
out_file:,
|
258
|
-
source_map:,
|
259
|
-
source_map_embed:)
|
260
|
-
css = +css
|
261
|
-
if indent_width != 2 || indent_type.to_sym != :space
|
262
|
-
indent = indent_type * indent_width
|
263
|
-
css.gsub!(/^ +/) do |space|
|
264
|
-
indent * (space.length / 2)
|
265
|
-
end
|
266
|
-
end
|
267
|
-
css.gsub!("\n", linefeed) if linefeed != "\n"
|
268
|
-
|
269
|
-
unless map.nil? || omit_source_map_url == true
|
270
|
-
url = if source_map_embed
|
271
|
-
require 'base64'
|
272
|
-
|
273
|
-
"data:application/json;base64,#{Base64.strict_encode64(map)}"
|
274
|
-
elsif out_file
|
275
|
-
relative_path(File.dirname(out_file), source_map)
|
276
|
-
else
|
277
|
-
source_map
|
278
|
-
end
|
279
|
-
css += "#{linefeed}#{linefeed}/*# sourceMappingURL=#{url} */"
|
280
|
-
end
|
281
|
-
|
282
|
-
-css
|
283
|
-
end
|
284
|
-
|
285
|
-
# @deprecated
|
286
|
-
def parse_indent_type(indent_type)
|
287
|
-
case indent_type.to_sym
|
288
|
-
when :space
|
289
|
-
' '
|
290
|
-
when :tab
|
291
|
-
"\t"
|
292
|
-
else
|
293
|
-
raise ArgumentError, 'indent_type must be one of :space, :tab'
|
294
|
-
end
|
295
|
-
end
|
296
|
-
|
297
|
-
# @deprecated
|
298
|
-
def parse_indent_width(indent_width)
|
299
|
-
raise ArgumentError, 'indent_width must be an integer' unless indent_width.is_a? Integer
|
300
|
-
raise RangeError, 'indent_width must be in between 0 and 10 (inclusive)' unless indent_width.between? 0, 10
|
301
|
-
|
302
|
-
indent_width
|
303
|
-
end
|
304
|
-
|
305
|
-
# @deprecated
|
306
|
-
def parse_linefeed(linefeed)
|
307
|
-
case linefeed.to_sym
|
308
|
-
when :lf
|
309
|
-
"\n"
|
310
|
-
when :lfcr
|
311
|
-
"\n\r"
|
312
|
-
when :cr
|
313
|
-
"\r"
|
314
|
-
when :crlf
|
315
|
-
"\r\n"
|
316
|
-
else
|
317
|
-
raise ArgumentError, 'linefeed must be one of :lf, :lfcr, :cr, :crlf'
|
318
|
-
end
|
319
|
-
end
|
320
|
-
|
321
|
-
# @deprecated
|
322
|
-
def now
|
323
|
-
(Time.now.to_f * 1000).to_i
|
324
|
-
end
|
325
|
-
|
326
|
-
# @deprecated
|
327
|
-
def relative_path(from, to)
|
328
|
-
require 'pathname'
|
329
|
-
|
330
|
-
Pathname.new(File.absolute_path(to)).relative_path_from(Pathname.new(File.absolute_path(from))).to_s
|
331
|
-
end
|
332
|
-
|
333
|
-
# @deprecated
|
334
|
-
# The {LegacyImporter} for {Embedded#render}.
|
335
|
-
class LegacyImporter
|
336
|
-
def initialize(importer, file)
|
337
|
-
super()
|
338
|
-
@file = file
|
339
|
-
@importer = importer
|
340
|
-
@importer_results = {}
|
341
|
-
end
|
342
|
-
|
343
|
-
def canonicalize(url, **_kwargs)
|
344
|
-
path = Url.file_url_to_path(url)
|
345
|
-
canonical_url = Url.path_to_file_url(File.absolute_path(path, (@file.nil? ? 'stdin' : @file)))
|
346
|
-
|
347
|
-
result = @importer.call canonical_url, @file
|
348
|
-
|
349
|
-
raise result if result.is_a? StandardError
|
350
|
-
|
351
|
-
if result&.key? :contents
|
352
|
-
@importer_results[canonical_url] = {
|
353
|
-
contents: result[:contents],
|
354
|
-
syntax: :scss
|
355
|
-
}
|
356
|
-
canonical_url
|
357
|
-
elsif result&.key? :file
|
358
|
-
canonical_url = Url.path_to_file_url(File.absolute_path(result[:file]))
|
359
|
-
@importer_results[canonical_url] = {
|
360
|
-
contents: File.read(result[:file]),
|
361
|
-
syntax: :scss
|
362
|
-
}
|
363
|
-
canonical_url
|
364
|
-
end
|
365
|
-
end
|
366
|
-
|
367
|
-
def load(canonical_url)
|
368
|
-
@importer_results[canonical_url]
|
369
|
-
end
|
370
|
-
end
|
371
|
-
|
372
|
-
# @deprecated
|
373
|
-
# The {Url} module.
|
374
|
-
module Url
|
375
|
-
FILE_SCHEME = 'file://'
|
376
|
-
|
377
|
-
private_constant :FILE_SCHEME
|
378
|
-
|
379
|
-
module_function
|
380
|
-
|
381
|
-
def path_to_file_url(path)
|
382
|
-
if File.absolute_path? path
|
383
|
-
Url.uri_parser.escape "#{FILE_SCHEME}#{Gem.win_platform? ? '/' : ''}#{path}"
|
384
|
-
else
|
385
|
-
Url.uri_parser.escape path
|
386
|
-
end
|
387
|
-
end
|
388
|
-
|
389
|
-
def file_url_to_path(url)
|
390
|
-
if url.start_with? FILE_SCHEME
|
391
|
-
Url.uri_parser.unescape url[(FILE_SCHEME.length + (Gem.win_platform? ? 1 : 0))..]
|
392
|
-
else
|
393
|
-
Url.uri_parser.unescape url
|
394
|
-
end
|
395
|
-
end
|
396
|
-
|
397
|
-
def uri_parser
|
398
|
-
require 'uri'
|
399
|
-
|
400
|
-
@uri_parser ||= URI::Parser.new({ RESERVED: ';/?:@&=+$,' })
|
401
|
-
end
|
402
|
-
end
|
403
|
-
|
404
|
-
private_constant :LegacyImporter
|
405
|
-
end
|
406
|
-
end
|