sass-embedded 0.18.2 → 0.19.0
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/lib/sass/compile_error.rb +1 -1
- data/lib/sass/embedded/async.rb +65 -0
- data/lib/sass/embedded/channel.rb +21 -22
- data/lib/sass/embedded/compiler.rb +17 -83
- data/lib/sass/embedded/dispatcher.rb +90 -0
- data/lib/sass/embedded/{compile_context → host}/function_registry.rb +6 -4
- data/lib/sass/embedded/{compile_context → host}/importer_registry.rb +13 -9
- data/lib/sass/embedded/{compile_context → host}/logger_registry.rb +14 -9
- data/lib/sass/embedded/{compile_context → host}/value_protofier.rb +6 -4
- data/lib/sass/embedded/host.rb +135 -0
- data/lib/sass/embedded/legacy.rb +0 -2
- data/lib/sass/embedded/protofier.rb +3 -21
- data/lib/sass/embedded/structifier.rb +3 -1
- data/lib/sass/embedded/varint.rb +3 -1
- data/lib/sass/embedded/version.rb +1 -1
- data/lib/sass/embedded.rb +37 -39
- data/lib/sass/value/argument_list.rb +2 -2
- data/lib/sass/value/boolean.rb +5 -3
- data/lib/sass/value/color.rb +12 -5
- data/lib/sass/value/function.rb +5 -3
- data/lib/sass/value/fuzzy_math.rb +1 -1
- data/lib/sass/value/list.rb +5 -3
- data/lib/sass/value/map.rb +5 -3
- data/lib/sass/value/null.rb +5 -3
- data/lib/sass/value/number/unit.rb +1 -1
- data/lib/sass/value/number.rb +5 -3
- data/lib/sass/value/string.rb +6 -5
- data/lib/sass/value.rb +2 -3
- data/lib/sass.rb +8 -13
- metadata +11 -12
- data/lib/sass/embedded/compile_context.rb +0 -107
- data/lib/sass/embedded/observer.rb +0 -49
- data/lib/sass/embedded/protocol_error.rb +0 -7
- data/lib/sass/embedded/version_context.rb +0 -35
@@ -2,17 +2,10 @@
|
|
2
2
|
|
3
3
|
module Sass
|
4
4
|
class Embedded
|
5
|
-
# The {Protofier}
|
5
|
+
# The {Protofier} module.
|
6
|
+
#
|
7
|
+
# It converts Pure Ruby types and Protobuf Ruby types.
|
6
8
|
module Protofier
|
7
|
-
ONEOF_MESSAGE = EmbeddedProtocol::InboundMessage
|
8
|
-
.descriptor
|
9
|
-
.lookup_oneof('message')
|
10
|
-
.to_h do |field_descriptor|
|
11
|
-
[field_descriptor.subtype, field_descriptor.name]
|
12
|
-
end
|
13
|
-
|
14
|
-
private_constant :ONEOF_MESSAGE
|
15
|
-
|
16
9
|
module_function
|
17
10
|
|
18
11
|
def from_proto_compile_response(compile_response)
|
@@ -50,17 +43,6 @@ module Sass
|
|
50
43
|
source_location.column)
|
51
44
|
end
|
52
45
|
|
53
|
-
def from_proto_message(proto)
|
54
|
-
message = EmbeddedProtocol::OutboundMessage.decode(proto)
|
55
|
-
message.send(message.message)
|
56
|
-
end
|
57
|
-
|
58
|
-
def to_proto_message(message)
|
59
|
-
EmbeddedProtocol::InboundMessage.new(
|
60
|
-
ONEOF_MESSAGE[message.class.descriptor] => message
|
61
|
-
).to_proto
|
62
|
-
end
|
63
|
-
|
64
46
|
def to_proto_syntax(syntax)
|
65
47
|
case syntax&.to_sym
|
66
48
|
when :scss
|
data/lib/sass/embedded/varint.rb
CHANGED
data/lib/sass/embedded.rb
CHANGED
@@ -18,7 +18,6 @@ module Sass
|
|
18
18
|
#
|
19
19
|
# @return [CompileResult]
|
20
20
|
# @raise [CompileError]
|
21
|
-
# @raise [ProtocolError]
|
22
21
|
def compile(path,
|
23
22
|
load_paths: [],
|
24
23
|
|
@@ -38,23 +37,24 @@ module Sass
|
|
38
37
|
raise ArgumentError, 'path must be set' if path.nil?
|
39
38
|
|
40
39
|
Protofier.from_proto_compile_response(
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
40
|
+
Host.new(@channel).compile_request(
|
41
|
+
path: path,
|
42
|
+
source: nil,
|
43
|
+
importer: nil,
|
44
|
+
load_paths: load_paths,
|
45
|
+
syntax: nil,
|
46
|
+
url: nil,
|
47
|
+
source_map: source_map,
|
48
|
+
source_map_include_sources: source_map_include_sources,
|
49
|
+
style: style,
|
50
|
+
functions: functions,
|
51
|
+
importers: importers,
|
52
|
+
alert_color: alert_color,
|
53
|
+
alert_ascii: alert_ascii,
|
54
|
+
logger: logger,
|
55
|
+
quiet_deps: quiet_deps,
|
56
|
+
verbose: verbose
|
57
|
+
)
|
58
58
|
)
|
59
59
|
end
|
60
60
|
|
@@ -62,7 +62,6 @@ module Sass
|
|
62
62
|
#
|
63
63
|
# @return [CompileResult]
|
64
64
|
# @raise [CompileError]
|
65
|
-
# @raise [ProtocolError]
|
66
65
|
def compile_string(source,
|
67
66
|
importer: nil,
|
68
67
|
load_paths: [],
|
@@ -84,31 +83,30 @@ module Sass
|
|
84
83
|
raise ArgumentError, 'source must be set' if source.nil?
|
85
84
|
|
86
85
|
Protofier.from_proto_compile_response(
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
86
|
+
Host.new(@channel).compile_request(
|
87
|
+
path: nil,
|
88
|
+
source: source,
|
89
|
+
importer: importer,
|
90
|
+
load_paths: load_paths,
|
91
|
+
syntax: syntax,
|
92
|
+
url: url,
|
93
|
+
source_map: source_map,
|
94
|
+
source_map_include_sources: source_map_include_sources,
|
95
|
+
style: style,
|
96
|
+
functions: functions,
|
97
|
+
importers: importers,
|
98
|
+
alert_color: alert_color,
|
99
|
+
alert_ascii: alert_ascii,
|
100
|
+
logger: logger,
|
101
|
+
quiet_deps: quiet_deps,
|
102
|
+
verbose: verbose
|
103
|
+
)
|
104
104
|
)
|
105
105
|
end
|
106
106
|
|
107
107
|
# The {Embedded#info} method.
|
108
|
-
#
|
109
|
-
# @raise [ProtocolError]
|
110
108
|
def info
|
111
|
-
@info ||= "sass-embedded\t#{
|
109
|
+
@info ||= "sass-embedded\t#{Host.new(@channel).version_request.implementation_version}"
|
112
110
|
end
|
113
111
|
|
114
112
|
def close
|
@@ -1,12 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Sass
|
4
|
-
|
4
|
+
module Value
|
5
5
|
# Sass's argument list type.
|
6
6
|
#
|
7
7
|
# An argument list comes from a rest argument. It's distinct from a normal {List} in that it may contain a keyword
|
8
8
|
# map as well as the positional arguments.
|
9
|
-
class ArgumentList <
|
9
|
+
class ArgumentList < Value::List
|
10
10
|
def initialize(contents = [], keywords = {}, separator = ',')
|
11
11
|
super(contents, separator: separator)
|
12
12
|
|
data/lib/sass/value/boolean.rb
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Sass
|
4
|
-
|
4
|
+
module Value
|
5
5
|
# Sass's boolean type.
|
6
|
-
class Boolean
|
7
|
-
|
6
|
+
class Boolean
|
7
|
+
include Value
|
8
|
+
|
9
|
+
def initialize(value)
|
8
10
|
@value = value
|
9
11
|
end
|
10
12
|
|
data/lib/sass/value/color.rb
CHANGED
@@ -1,14 +1,21 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Sass
|
4
|
-
|
4
|
+
module Value
|
5
5
|
# Sass's color type.
|
6
6
|
#
|
7
7
|
# No matter what representation was originally used to create this color, all of its channels are accessible.
|
8
|
-
class Color
|
9
|
-
|
10
|
-
|
11
|
-
|
8
|
+
class Color
|
9
|
+
include Value
|
10
|
+
|
11
|
+
def initialize(red: nil,
|
12
|
+
green: nil,
|
13
|
+
blue: nil,
|
14
|
+
hue: nil,
|
15
|
+
saturation: nil,
|
16
|
+
lightness: nil,
|
17
|
+
whiteness: nil,
|
18
|
+
blackness: nil,
|
12
19
|
alpha: nil)
|
13
20
|
@alpha = alpha.nil? ? 1 : FuzzyMath.assert_between(alpha, 0, 1, 'alpha')
|
14
21
|
if red && green && blue
|
data/lib/sass/value/function.rb
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Sass
|
4
|
-
|
4
|
+
module Value
|
5
5
|
# Sass's function type.
|
6
|
-
class Function
|
7
|
-
|
6
|
+
class Function
|
7
|
+
include Value
|
8
|
+
|
9
|
+
def initialize(id_or_signature, callback = nil)
|
8
10
|
if id_or_signature.is_a? Numeric
|
9
11
|
@id = id_or_signature
|
10
12
|
else
|
data/lib/sass/value/list.rb
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Sass
|
4
|
-
|
4
|
+
module Value
|
5
5
|
# Sass's list type.
|
6
|
-
class List
|
7
|
-
|
6
|
+
class List
|
7
|
+
include Value
|
8
|
+
|
9
|
+
def initialize(contents = [], separator: ',', bracketed: false)
|
8
10
|
if separator.nil? && contents.length > 1
|
9
11
|
raise error 'A list with more than one element must have an explicit separator'
|
10
12
|
end
|
data/lib/sass/value/map.rb
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Sass
|
4
|
-
|
4
|
+
module Value
|
5
5
|
# Sass's map type.
|
6
|
-
class Map
|
7
|
-
|
6
|
+
class Map
|
7
|
+
include Value
|
8
|
+
|
9
|
+
def initialize(contents = {})
|
8
10
|
@contents = contents.freeze
|
9
11
|
end
|
10
12
|
|
data/lib/sass/value/null.rb
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Sass
|
4
|
-
|
4
|
+
module Value
|
5
5
|
# Sass's null type.
|
6
|
-
class Null
|
7
|
-
|
6
|
+
class Null
|
7
|
+
include Value
|
8
|
+
|
9
|
+
def initialize
|
8
10
|
@value = nil
|
9
11
|
end
|
10
12
|
|
data/lib/sass/value/number.rb
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Sass
|
4
|
-
|
4
|
+
module Value
|
5
5
|
# Sass's number type.
|
6
|
-
class Number
|
7
|
-
|
6
|
+
class Number
|
7
|
+
include Value
|
8
|
+
|
9
|
+
def initialize(value, numerator_units = [], denominator_units = [])
|
8
10
|
numerator_units = [numerator_units] if numerator_units.is_a?(::String)
|
9
11
|
denominator_units = [denominator_units] if denominator_units.is_a?(::String)
|
10
12
|
|
data/lib/sass/value/string.rb
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Sass
|
4
|
-
|
4
|
+
module Value
|
5
5
|
# Sass's string type.
|
6
|
-
class String
|
7
|
-
|
6
|
+
class String
|
7
|
+
include Value
|
8
|
+
|
9
|
+
def initialize(text = '', quoted: true)
|
8
10
|
@text = text.freeze
|
9
11
|
@quoted = quoted
|
10
12
|
end
|
@@ -20,8 +22,7 @@ module Sass
|
|
20
22
|
raise error('String index may not be 0', name) if index.zero?
|
21
23
|
|
22
24
|
if index.abs > text.length
|
23
|
-
raise error("Invalid index #{sass_index} for a string with #{text.length} characters",
|
24
|
-
name)
|
25
|
+
raise error("Invalid index #{sass_index} for a string with #{text.length} characters", name)
|
25
26
|
end
|
26
27
|
|
27
28
|
index.negative? ? text.length + index : index - 1
|
data/lib/sass/value.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module Sass
|
4
4
|
# The abstract base class of Sass's value types.
|
5
|
-
|
5
|
+
module Value
|
6
6
|
def to_a
|
7
7
|
[self]
|
8
8
|
end
|
@@ -32,8 +32,7 @@ module Sass
|
|
32
32
|
raise error('List index may not be 0', name) if index.zero?
|
33
33
|
|
34
34
|
if index.abs > to_a_length
|
35
|
-
raise error("Invalid index #{sass_index} for a list with #{to_a_length} elements",
|
36
|
-
name)
|
35
|
+
raise error("Invalid index #{sass_index} for a list with #{to_a_length} elements", name)
|
37
36
|
end
|
38
37
|
|
39
38
|
index.negative? ? to_a_length + index : index - 1
|
data/lib/sass.rb
CHANGED
@@ -3,22 +3,21 @@
|
|
3
3
|
require_relative 'sass/compile_error'
|
4
4
|
require_relative 'sass/compile_result'
|
5
5
|
require_relative 'sass/embedded'
|
6
|
+
require_relative 'sass/embedded/async'
|
6
7
|
require_relative 'sass/embedded/channel'
|
7
|
-
require_relative 'sass/embedded/observer'
|
8
|
-
require_relative 'sass/embedded/compile_context'
|
9
|
-
require_relative 'sass/embedded/compile_context/function_registry'
|
10
|
-
require_relative 'sass/embedded/compile_context/importer_registry'
|
11
|
-
require_relative 'sass/embedded/compile_context/logger_registry'
|
12
|
-
require_relative 'sass/embedded/compile_context/value_protofier'
|
13
8
|
require_relative 'sass/embedded/compiler'
|
14
|
-
require_relative 'sass/
|
9
|
+
require_relative 'sass/embedded/dispatcher'
|
10
|
+
require_relative 'sass/embedded/host'
|
11
|
+
require_relative 'sass/embedded/host/function_registry'
|
12
|
+
require_relative 'sass/embedded/host/importer_registry'
|
13
|
+
require_relative 'sass/embedded/host/logger_registry'
|
14
|
+
require_relative 'sass/embedded/host/value_protofier'
|
15
15
|
require_relative 'sass/embedded/legacy'
|
16
|
-
require_relative 'sass/embedded/protocol_error'
|
17
16
|
require_relative 'sass/embedded/protofier'
|
18
17
|
require_relative 'sass/embedded/structifier'
|
19
18
|
require_relative 'sass/embedded/varint'
|
20
19
|
require_relative 'sass/embedded/version'
|
21
|
-
require_relative 'sass/
|
20
|
+
require_relative 'sass/embedded_protocol'
|
22
21
|
require_relative 'sass/logger'
|
23
22
|
require_relative 'sass/logger/source_location'
|
24
23
|
require_relative 'sass/logger/source_span'
|
@@ -51,7 +50,6 @@ module Sass
|
|
51
50
|
# Sass.compile('style.scss')
|
52
51
|
# @return [CompileResult]
|
53
52
|
# @raise [CompileError]
|
54
|
-
# @raise [Embedded::ProtocolError]
|
55
53
|
def compile(path, **kwargs)
|
56
54
|
instance.compile(path, **kwargs)
|
57
55
|
end
|
@@ -66,7 +64,6 @@ module Sass
|
|
66
64
|
# Sass.compile_string('h1 { font-size: 40px; }')
|
67
65
|
# @return [CompileResult]
|
68
66
|
# @raise [CompileError]
|
69
|
-
# @raise [Embedded::ProtocolError]
|
70
67
|
def compile_string(source, **kwargs)
|
71
68
|
instance.compile_string(source, **kwargs)
|
72
69
|
end
|
@@ -74,8 +71,6 @@ module Sass
|
|
74
71
|
# The global {.info} method.
|
75
72
|
#
|
76
73
|
# This instantiates a global {Embedded} instance and calls {Embedded#info}.
|
77
|
-
#
|
78
|
-
# @raise [Embedded::ProtocolError]
|
79
74
|
def info
|
80
75
|
instance.info
|
81
76
|
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.
|
4
|
+
version: 0.19.0
|
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-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: google-protobuf
|
@@ -128,21 +128,20 @@ files:
|
|
128
128
|
- lib/sass/compile_error.rb
|
129
129
|
- lib/sass/compile_result.rb
|
130
130
|
- lib/sass/embedded.rb
|
131
|
+
- lib/sass/embedded/async.rb
|
131
132
|
- lib/sass/embedded/channel.rb
|
132
|
-
- lib/sass/embedded/compile_context.rb
|
133
|
-
- lib/sass/embedded/compile_context/function_registry.rb
|
134
|
-
- lib/sass/embedded/compile_context/importer_registry.rb
|
135
|
-
- lib/sass/embedded/compile_context/logger_registry.rb
|
136
|
-
- lib/sass/embedded/compile_context/value_protofier.rb
|
137
133
|
- lib/sass/embedded/compiler.rb
|
134
|
+
- lib/sass/embedded/dispatcher.rb
|
135
|
+
- lib/sass/embedded/host.rb
|
136
|
+
- lib/sass/embedded/host/function_registry.rb
|
137
|
+
- lib/sass/embedded/host/importer_registry.rb
|
138
|
+
- lib/sass/embedded/host/logger_registry.rb
|
139
|
+
- lib/sass/embedded/host/value_protofier.rb
|
138
140
|
- lib/sass/embedded/legacy.rb
|
139
|
-
- lib/sass/embedded/observer.rb
|
140
|
-
- lib/sass/embedded/protocol_error.rb
|
141
141
|
- lib/sass/embedded/protofier.rb
|
142
142
|
- lib/sass/embedded/structifier.rb
|
143
143
|
- lib/sass/embedded/varint.rb
|
144
144
|
- lib/sass/embedded/version.rb
|
145
|
-
- lib/sass/embedded/version_context.rb
|
146
145
|
- lib/sass/embedded_protocol.rb
|
147
146
|
- lib/sass/logger.rb
|
148
147
|
- lib/sass/logger/source_location.rb
|
@@ -164,8 +163,8 @@ homepage: https://github.com/ntkme/sass-embedded-host-ruby
|
|
164
163
|
licenses:
|
165
164
|
- MIT
|
166
165
|
metadata:
|
167
|
-
documentation_uri: https://www.rubydoc.info/gems/sass-embedded/0.
|
168
|
-
source_code_uri: https://github.com/ntkme/sass-embedded-host-ruby/tree/v0.
|
166
|
+
documentation_uri: https://www.rubydoc.info/gems/sass-embedded/0.19.0
|
167
|
+
source_code_uri: https://github.com/ntkme/sass-embedded-host-ruby/tree/v0.19.0
|
169
168
|
funding_uri: https://github.com/sponsors/ntkme
|
170
169
|
post_install_message:
|
171
170
|
rdoc_options: []
|
@@ -1,107 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Sass
|
4
|
-
class Embedded
|
5
|
-
# The {Observer} for {Embedded#compile}.
|
6
|
-
class CompileContext
|
7
|
-
include Observer
|
8
|
-
|
9
|
-
def initialize(channel,
|
10
|
-
path:,
|
11
|
-
source:,
|
12
|
-
|
13
|
-
importer:,
|
14
|
-
load_paths:,
|
15
|
-
syntax:,
|
16
|
-
url:,
|
17
|
-
|
18
|
-
source_map:,
|
19
|
-
source_map_include_sources:,
|
20
|
-
style:,
|
21
|
-
|
22
|
-
functions:,
|
23
|
-
importers:,
|
24
|
-
|
25
|
-
alert_ascii:,
|
26
|
-
alert_color:,
|
27
|
-
logger:,
|
28
|
-
quiet_deps:,
|
29
|
-
verbose:)
|
30
|
-
@function_registery = FunctionRegistry.new(functions, highlight: alert_color)
|
31
|
-
@importer_registery = ImporterRegistry.new(importers, load_paths, highlight: alert_color)
|
32
|
-
@logger_registery = LoggerRegistry.new(logger)
|
33
|
-
|
34
|
-
super(channel)
|
35
|
-
|
36
|
-
send_message EmbeddedProtocol::InboundMessage::CompileRequest.new(
|
37
|
-
id: id,
|
38
|
-
string: unless source.nil?
|
39
|
-
EmbeddedProtocol::InboundMessage::CompileRequest::StringInput.new(
|
40
|
-
source: source,
|
41
|
-
url: url&.to_s,
|
42
|
-
syntax: Protofier.to_proto_syntax(syntax),
|
43
|
-
importer: importer.nil? ? nil : @importer_registery.register(importer)
|
44
|
-
)
|
45
|
-
end,
|
46
|
-
path: path,
|
47
|
-
style: Protofier.to_proto_output_style(style),
|
48
|
-
source_map: source_map,
|
49
|
-
source_map_include_sources: source_map_include_sources,
|
50
|
-
importers: @importer_registery.importers,
|
51
|
-
global_functions: @function_registery.global_functions,
|
52
|
-
alert_ascii: alert_ascii,
|
53
|
-
alert_color: alert_color,
|
54
|
-
quiet_deps: quiet_deps,
|
55
|
-
verbose: verbose
|
56
|
-
)
|
57
|
-
end
|
58
|
-
|
59
|
-
def update(error, message)
|
60
|
-
raise error unless error.nil?
|
61
|
-
|
62
|
-
case message
|
63
|
-
when EmbeddedProtocol::OutboundMessage::CompileResponse
|
64
|
-
return unless message.id == id
|
65
|
-
|
66
|
-
Thread.new do
|
67
|
-
super(nil, message)
|
68
|
-
end
|
69
|
-
when EmbeddedProtocol::OutboundMessage::LogEvent
|
70
|
-
return unless message.compilation_id == id
|
71
|
-
|
72
|
-
@logger_registery.log message
|
73
|
-
when EmbeddedProtocol::OutboundMessage::CanonicalizeRequest
|
74
|
-
return unless message.compilation_id == id
|
75
|
-
|
76
|
-
Thread.new do
|
77
|
-
send_message @importer_registery.canonicalize message
|
78
|
-
end
|
79
|
-
when EmbeddedProtocol::OutboundMessage::ImportRequest
|
80
|
-
return unless message.compilation_id == id
|
81
|
-
|
82
|
-
Thread.new do
|
83
|
-
send_message @importer_registery.import message
|
84
|
-
end
|
85
|
-
when EmbeddedProtocol::OutboundMessage::FileImportRequest
|
86
|
-
return unless message.compilation_id == id
|
87
|
-
|
88
|
-
Thread.new do
|
89
|
-
send_message @importer_registery.file_import message
|
90
|
-
end
|
91
|
-
when EmbeddedProtocol::OutboundMessage::FunctionCallRequest
|
92
|
-
return unless message.compilation_id == id
|
93
|
-
|
94
|
-
Thread.new do
|
95
|
-
send_message @function_registery.function_call message
|
96
|
-
end
|
97
|
-
end
|
98
|
-
rescue StandardError => e
|
99
|
-
Thread.new do
|
100
|
-
super(e, nil)
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
|
-
private_constant :CompileContext
|
106
|
-
end
|
107
|
-
end
|
@@ -1,49 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Sass
|
4
|
-
class Embedded
|
5
|
-
# The {Observer} module for communicating with {Compiler}.
|
6
|
-
module Observer
|
7
|
-
def initialize(channel)
|
8
|
-
@mutex = Mutex.new
|
9
|
-
@condition_variable = ConditionVariable.new
|
10
|
-
@error = nil
|
11
|
-
@message = nil
|
12
|
-
|
13
|
-
@subscription = channel.subscribe(self)
|
14
|
-
end
|
15
|
-
|
16
|
-
def receive_message
|
17
|
-
@mutex.synchronize do
|
18
|
-
@condition_variable.wait(@mutex) if @error.nil? && @message.nil?
|
19
|
-
end
|
20
|
-
|
21
|
-
raise @error unless @error.nil?
|
22
|
-
|
23
|
-
@message
|
24
|
-
end
|
25
|
-
|
26
|
-
def update(error, message)
|
27
|
-
@subscription.unsubscribe
|
28
|
-
|
29
|
-
@mutex.synchronize do
|
30
|
-
@error = error
|
31
|
-
@message = message
|
32
|
-
@condition_variable.broadcast
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
private
|
37
|
-
|
38
|
-
def id
|
39
|
-
@subscription.id
|
40
|
-
end
|
41
|
-
|
42
|
-
def send_message(*args)
|
43
|
-
@subscription.send_message(*args)
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
private_constant :Observer
|
48
|
-
end
|
49
|
-
end
|