sass-embedded 0.19.7 → 1.0.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: a45cb1a6cf846dde82321dc1b98ec60c2ff835c2421e9b46291ec3f2c8c6ab92
4
- data.tar.gz: b879612efdf38864699c2ac75b3d3342035882860fa311ee4938067c96a5b92c
3
+ metadata.gz: 67fbb8f12d410a5a32da08234aa6568c38f12813f14dc0623c83c26457a0ea89
4
+ data.tar.gz: e643ceae6abd2803a219dad01e8429964492c4c3e690c959ec49e63ba0ce9d10
5
5
  SHA512:
6
- metadata.gz: 6e13d63c13ef66008c4c971d45b8e865f5c4cdc4e5a72e239691c5bb1a9e6b61928cd413f46a08da9a14161ed42c054f810fe7288a19bae9ef52b5b6248f9c21
7
- data.tar.gz: 849bf9f6fdc5471881337f92f2cb3ced649b59ba7b7f07fbf78bda974f432d1bc5c93547bccf70827acf721c0585f4e61e92c0ab6aa43cc56bdc5656c234a69a
6
+ metadata.gz: 6489e76fd276fd9bf60f53bd51ad0b8be787c64c035a81401f037dc523b9820a5948f5feae19f16745fe3a3dc728599c64360fb1a49a68bc160f4fee540f929b
7
+ data.tar.gz: a5aefa5a6de1ba7c50251da6ab08f42f6d21311e020dcfc793acead9ceb2fd0662b298fae04d2c74459a3e79555155ad53f4d71cd28f71fea5afc678c87189ba
data/ext/sass/Makefile CHANGED
@@ -6,18 +6,18 @@ endif
6
6
  EXTCONF = ruby -- extconf.rb
7
7
 
8
8
  .PHONY: all
9
- all: sass_embedded embedded_sass_pb.rb
9
+ all: embedded_sass_pb.rb sass_embedded
10
10
 
11
11
  .PHONY: install
12
- install:
12
+ install: clean
13
+
14
+ .PHONY: uninstall
15
+ uninstall:
16
+ $(RM) embedded_sass_pb.rb sass_embedded
13
17
 
14
18
  .PHONY: clean
15
19
  clean:
16
- $(RM) embedded_sass_pb.rb protoc sass_embedded
17
-
18
- .PHONY: distclean
19
- distclean: clean
20
- $(RM) embedded_sass.proto protoc-*.zip sass_embedded-*.tar.gz
20
+ $(RM) embedded_sass.proto protoc protoc-* sass_embedded-*
21
21
 
22
22
  ifeq ($(OS),Windows_NT)
23
23
  sass_embedded-*.zip:
data/ext/sass/extconf.rb CHANGED
@@ -106,15 +106,15 @@ module Sass
106
106
 
107
107
  def fetch(uri_s)
108
108
  uri = URI.parse(uri_s)
109
- path = File.absolute_path(File.basename(uri.path), __dir__)
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
- source = uri_parser.unescape(uri.path)
112
- puts "cp -- #{source} #{path}"
113
- FileUtils.copy_file(source, path)
112
+ puts "cp -- #{path} #{dest}"
113
+ FileUtils.copy_file(path, dest)
114
114
  elsif uri.respond_to? :open
115
- puts "curl -fsSLo #{path} -- #{uri}"
115
+ puts "curl -fsSLo #{dest} -- #{uri}"
116
116
  uri.open do |stream|
117
- File.binwrite(path, stream.read)
117
+ File.binwrite(dest, stream.read)
118
118
  end
119
119
  else
120
120
  raise
@@ -123,10 +123,6 @@ module Sass
123
123
  raise "Failed to fetch #{uri_s}"
124
124
  end
125
125
 
126
- def uri_parser
127
- @uri_parser ||= URI::Parser.new({ RESERVED: ';/?:@&=+$,' })
128
- end
129
-
130
126
  def default_sass_embedded
131
127
  repo = 'sass/dart-sass-embedded'
132
128
 
@@ -214,7 +210,7 @@ module Sass
214
210
 
215
211
  ext = 'zip'
216
212
 
217
- "https://github.com/#{repo}/releases/download/#{tag_name}/protoc-#{tag_name[1..]}-#{os_arch}.#{ext}"
213
+ "https://github.com/#{repo}/releases/download/#{tag_name}/protoc-#{tag_name.delete_prefix('v')}-#{os_arch}.#{ext}"
218
214
  end
219
215
 
220
216
  def default_sass_embedded_protocol
@@ -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
- .filter do |argument|
52
+ .select do |argument|
53
53
  argument.is_a?(Sass::Value::ArgumentList) && argument.instance_eval do
54
54
  @keywords_accessed
55
55
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Sass
4
4
  class Embedded
5
- VERSION = '0.19.7'
5
+ VERSION = '1.0.2'
6
6
  end
7
7
  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.19.7
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - なつき
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-02-25 00:00:00.000000000 Z
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.19.7
167
- source_code_uri: https://github.com/ntkme/sass-embedded-host-ruby/tree/v0.19.7
165
+ documentation_uri: https://www.rubydoc.info/gems/sass-embedded/1.0.2
166
+ source_code_uri: https://github.com/ntkme/sass-embedded-host-ruby/tree/v1.0.2
168
167
  funding_uri: https://github.com/sponsors/ntkme
169
168
  post_install_message:
170
169
  rdoc_options: []
@@ -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