sass-embedded 1.69.1 → 1.69.7

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.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/exe/sass +2 -2
  4. data/ext/sass/Rakefile +8 -24
  5. data/ext/sass/embedded_sass_pb.rb +1 -1
  6. data/ext/sass/package.json +1 -1
  7. data/lib/sass/calculation_value/calculation_operation.rb +2 -5
  8. data/lib/sass/calculation_value.rb +10 -4
  9. data/lib/sass/compiler/connection.rb +92 -0
  10. data/lib/sass/{embedded → compiler}/dispatcher.rb +54 -38
  11. data/lib/sass/compiler/dispatcher_manager.rb +44 -0
  12. data/lib/sass/{embedded → compiler}/host/function_registry.rb +3 -3
  13. data/lib/sass/{embedded → compiler}/host/importer_registry.rb +4 -4
  14. data/lib/sass/{embedded → compiler}/host/logger_registry.rb +1 -1
  15. data/lib/sass/compiler/host/protofier.rb +88 -0
  16. data/lib/sass/compiler/host/structifier.rb +37 -0
  17. data/lib/sass/{embedded → compiler}/host/value_protofier.rb +3 -3
  18. data/lib/sass/{embedded → compiler}/host.rb +26 -15
  19. data/lib/sass/{embedded → compiler}/varint.rb +3 -5
  20. data/lib/sass/compiler.rb +191 -0
  21. data/lib/sass/elf.rb +2 -2
  22. data/lib/sass/embedded/version.rb +2 -2
  23. data/lib/sass/embedded.rb +65 -208
  24. data/lib/sass/exception.rb +65 -0
  25. data/lib/sass/fork_tracker.rb +51 -0
  26. data/lib/sass/serializer.rb +41 -0
  27. data/lib/sass/value/argument_list.rb +2 -2
  28. data/lib/sass/value/calculation.rb +3 -1
  29. data/lib/sass/value/color.rb +6 -6
  30. data/lib/sass/value/function.rb +6 -4
  31. data/lib/sass/value/map.rb +1 -1
  32. data/lib/sass/value/number.rb +11 -11
  33. data/lib/sass/value/string.rb +5 -8
  34. data/lib/sass/value.rb +1 -9
  35. metadata +25 -23
  36. data/ext/sass/win32_api.rb +0 -133
  37. data/lib/sass/compile_error.rb +0 -31
  38. data/lib/sass/embedded/connection.rb +0 -71
  39. data/lib/sass/embedded/protofier.rb +0 -86
  40. data/lib/sass/embedded/resilient_dispatcher.rb +0 -44
  41. data/lib/sass/embedded/structifier.rb +0 -35
  42. data/lib/sass/script_error.rb +0 -10
@@ -1,71 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'open3'
4
-
5
- module Sass
6
- class Embedded
7
- # The stdio based {Connection} between the {Dispatcher} and the compiler.
8
- #
9
- # It runs the `sass --embedded` command.
10
- class Connection
11
- def initialize
12
- @stdin, @stdout, @stderr, @wait_thread = begin
13
- Open3.popen3(*CLI::COMMAND, '--embedded', chdir: __dir__)
14
- rescue Errno::ENOENT
15
- require_relative '../elf'
16
-
17
- raise if ELF::INTERPRETER.nil?
18
-
19
- Open3.popen3(ELF::INTERPRETER, *CLI::COMMAND, '--embedded', chdir: __dir__)
20
- end
21
-
22
- @stdin.binmode
23
- @stdout.binmode
24
- @stdin_mutex = Mutex.new
25
- @stdout_mutex = Mutex.new
26
-
27
- Thread.new do
28
- loop do
29
- warn(@stderr.readline, uplevel: 1)
30
- rescue IOError, Errno::EBADF
31
- break
32
- end
33
- end
34
- end
35
-
36
- def close
37
- @stdin_mutex.synchronize do
38
- @stdin.close
39
- @wait_thread.join
40
- @stdout.close
41
- @stderr.close
42
- end
43
- end
44
-
45
- def closed?
46
- @stdin_mutex.synchronize do
47
- @stdin.closed?
48
- end
49
- end
50
-
51
- def write(id, proto)
52
- @stdin_mutex.synchronize do
53
- Varint.write(@stdin, Varint.length(id) + proto.length)
54
- Varint.write(@stdin, id)
55
- @stdin.write(proto)
56
- end
57
- end
58
-
59
- def read
60
- @stdout_mutex.synchronize do
61
- length = Varint.read(@stdout)
62
- id = Varint.read(@stdout)
63
- proto = @stdout.read(length - Varint.length(id))
64
- return id, proto
65
- end
66
- end
67
- end
68
-
69
- private_constant :Connection
70
- end
71
- end
@@ -1,86 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Sass
4
- class Embedded
5
- # The {Protofier} module.
6
- #
7
- # It converts Pure Ruby types and Protobuf Ruby types.
8
- module Protofier
9
- module_function
10
-
11
- def from_proto_canonicalize_context(canonicalize_request)
12
- CanonicalizeContext.new(
13
- canonicalize_request.containing_url == '' ? nil : canonicalize_request.containing_url,
14
- canonicalize_request.from_import
15
- )
16
- end
17
-
18
- def from_proto_compile_response(compile_response)
19
- oneof = compile_response.result
20
- result = compile_response.public_send(oneof)
21
- case oneof
22
- when :failure
23
- raise CompileError.new(
24
- result.message,
25
- result.formatted == '' ? nil : result.formatted,
26
- result.stack_trace == '' ? nil : result.stack_trace,
27
- from_proto_source_span(result.span),
28
- compile_response.loaded_urls
29
- )
30
- when :success
31
- CompileResult.new(
32
- result.css,
33
- result.source_map == '' ? nil : result.source_map,
34
- compile_response.loaded_urls
35
- )
36
- else
37
- raise ArgumentError, "Unknown CompileResponse.result #{result}"
38
- end
39
- end
40
-
41
- def from_proto_source_span(source_span)
42
- return if source_span.nil?
43
-
44
- Logger::SourceSpan.new(from_proto_source_location(source_span.start),
45
- from_proto_source_location(source_span.end),
46
- source_span.text,
47
- source_span.url == '' ? nil : source_span.url,
48
- source_span.context == '' ? nil : source_span.context)
49
- end
50
-
51
- def from_proto_source_location(source_location)
52
- return if source_location.nil?
53
-
54
- Logger::SourceLocation.new(source_location.offset,
55
- source_location.line,
56
- source_location.column)
57
- end
58
-
59
- def to_proto_syntax(syntax)
60
- case syntax&.to_sym
61
- when :scss
62
- EmbeddedProtocol::Syntax::SCSS
63
- when :indented
64
- EmbeddedProtocol::Syntax::INDENTED
65
- when :css
66
- EmbeddedProtocol::Syntax::CSS
67
- else
68
- raise ArgumentError, 'syntax must be one of :scss, :indented, :css'
69
- end
70
- end
71
-
72
- def to_proto_output_style(style)
73
- case style&.to_sym
74
- when :expanded
75
- EmbeddedProtocol::OutputStyle::EXPANDED
76
- when :compressed
77
- EmbeddedProtocol::OutputStyle::COMPRESSED
78
- else
79
- raise ArgumentError, 'style must be one of :expanded, :compressed'
80
- end
81
- end
82
- end
83
-
84
- private_constant :Protofier
85
- end
86
- end
@@ -1,44 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Sass
4
- class Embedded
5
- # The {ResilientDispatcher} class.
6
- #
7
- # It recovers from failures and continues to function.
8
- class ResilientDispatcher
9
- def initialize
10
- @dispatcher = Dispatcher.new
11
- @mutex = Mutex.new
12
- end
13
-
14
- def close(...)
15
- @mutex.synchronize do
16
- @dispatcher.close(...)
17
- end
18
- end
19
-
20
- def closed?(...)
21
- @mutex.synchronize do
22
- @dispatcher.closed?(...)
23
- end
24
- end
25
-
26
- def connect(...)
27
- @dispatcher.connect(...)
28
- rescue Errno::EBUSY
29
- @mutex.synchronize do
30
- @dispatcher.connect(...)
31
- rescue Errno::EBUSY
32
- @dispatcher = Dispatcher.new
33
- @dispatcher.connect(...)
34
- end
35
- end
36
-
37
- def error(...)
38
- @dispatcher.error(...)
39
- end
40
- end
41
-
42
- private_constant :ResilientDispatcher
43
- end
44
- end
@@ -1,35 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Sass
4
- class Embedded
5
- # The {Structifier} module.
6
- #
7
- # It converts {::Hash} to {Struct}-like objects.
8
- module Structifier
9
- module_function
10
-
11
- def to_struct(obj, *symbols)
12
- return obj unless obj.is_a? Hash
13
-
14
- struct = Object.new
15
- symbols.each do |key|
16
- next unless obj.key?(key)
17
-
18
- value = obj[key]
19
- if value.respond_to? :call
20
- struct.define_singleton_method key do |*args, **kwargs|
21
- value.call(*args, **kwargs)
22
- end
23
- else
24
- struct.define_singleton_method key do
25
- value
26
- end
27
- end
28
- end
29
- struct
30
- end
31
- end
32
-
33
- private_constant :Structifier
34
- end
35
- end
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Sass
4
- # An exception thrown by Sass Script.
5
- class ScriptError < StandardError
6
- def initialize(message, name = nil)
7
- super(name.nil? ? message : "$#{name}: #{message}")
8
- end
9
- end
10
- end