sass-embedded 1.6.2 → 1.83.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -3
- data/exe/sass +13 -0
- data/ext/sass/Rakefile +352 -76
- data/ext/sass/embedded_sass_pb.rb +61 -0
- data/ext/sass/expand-archive.ps1 +1 -0
- data/ext/sass/package.json +1 -1
- data/lib/sass/calculation_value/calculation_operation.rb +49 -0
- data/lib/sass/calculation_value.rb +22 -0
- data/lib/sass/canonicalize_context.rb +25 -0
- data/lib/sass/compile_result.rb +3 -2
- data/lib/sass/compiler/channel.rb +68 -0
- data/lib/sass/compiler/connection.rb +89 -0
- data/lib/sass/compiler/dispatcher.rb +116 -0
- data/lib/sass/{embedded → compiler}/host/function_registry.rb +31 -34
- data/lib/sass/compiler/host/importer_registry.rb +141 -0
- data/lib/sass/compiler/host/logger_registry.rb +80 -0
- data/lib/sass/compiler/host/protofier.rb +360 -0
- data/lib/sass/compiler/host/structifier.rb +37 -0
- data/lib/sass/compiler/host.rb +226 -0
- data/lib/sass/{embedded → compiler}/varint.rb +9 -5
- data/lib/sass/compiler.rb +212 -0
- data/lib/sass/elf.rb +222 -0
- data/lib/sass/embedded/version.rb +2 -2
- data/lib/sass/embedded.rb +76 -204
- data/lib/sass/embedded_protocol.rb +10 -0
- data/lib/sass/exception.rb +74 -0
- data/lib/sass/fork_tracker.rb +51 -0
- data/lib/sass/logger/silent.rb +5 -3
- data/lib/sass/logger/source_location.rb +6 -5
- data/lib/sass/logger/source_span.rb +8 -7
- data/lib/sass/node_package_importer.rb +17 -0
- data/lib/sass/serializer.rb +30 -0
- data/lib/sass/value/argument_list.rb +13 -6
- data/lib/sass/value/boolean.rb +1 -1
- data/lib/sass/value/calculation.rb +90 -0
- data/lib/sass/value/color/channel.rb +79 -0
- data/lib/sass/value/color/conversions.rb +473 -0
- data/lib/sass/value/color/gamut_map_method/clip.rb +45 -0
- data/lib/sass/value/color/gamut_map_method/local_minde.rb +94 -0
- data/lib/sass/value/color/gamut_map_method.rb +45 -0
- data/lib/sass/value/color/interpolation_method.rb +51 -0
- data/lib/sass/value/color/space/a98_rgb.rb +57 -0
- data/lib/sass/value/color/space/display_p3.rb +57 -0
- data/lib/sass/value/color/space/hsl.rb +65 -0
- data/lib/sass/value/color/space/hwb.rb +70 -0
- data/lib/sass/value/color/space/lab.rb +77 -0
- data/lib/sass/value/color/space/lch.rb +53 -0
- data/lib/sass/value/color/space/lms.rb +129 -0
- data/lib/sass/value/color/space/oklab.rb +66 -0
- data/lib/sass/value/color/space/oklch.rb +54 -0
- data/lib/sass/value/color/space/prophoto_rgb.rb +59 -0
- data/lib/sass/value/color/space/rec2020.rb +69 -0
- data/lib/sass/value/color/space/rgb.rb +52 -0
- data/lib/sass/value/color/space/srgb.rb +140 -0
- data/lib/sass/value/color/space/srgb_linear.rb +72 -0
- data/lib/sass/value/color/space/utils.rb +86 -0
- data/lib/sass/value/color/space/xyz_d50.rb +100 -0
- data/lib/sass/value/color/space/xyz_d65.rb +57 -0
- data/lib/sass/value/color/space.rb +198 -0
- data/lib/sass/value/color.rb +538 -163
- data/lib/sass/value/function.rb +11 -16
- data/lib/sass/value/fuzzy_math.rb +24 -21
- data/lib/sass/value/list.rb +7 -7
- data/lib/sass/value/map.rb +6 -6
- data/lib/sass/value/mixin.rb +34 -0
- data/lib/sass/value/null.rb +1 -1
- data/lib/sass/value/number/unit.rb +7 -6
- data/lib/sass/value/number.rb +34 -26
- data/lib/sass/value/string.rb +9 -3
- data/lib/sass/value.rb +20 -16
- metadata +67 -103
- data/ext/sass/unzip.vbs +0 -13
- data/lib/sass/compile_error.rb +0 -28
- data/lib/sass/embedded/async.rb +0 -65
- data/lib/sass/embedded/channel.rb +0 -61
- data/lib/sass/embedded/compiler.rb +0 -60
- data/lib/sass/embedded/dispatcher.rb +0 -90
- data/lib/sass/embedded/host/importer_registry.rb +0 -107
- data/lib/sass/embedded/host/logger_registry.rb +0 -50
- data/lib/sass/embedded/host/value_protofier.rb +0 -241
- data/lib/sass/embedded/host.rb +0 -139
- data/lib/sass/embedded/protofier.rb +0 -78
- data/lib/sass/embedded/structifier.rb +0 -36
- data/lib/sass/script_error.rb +0 -6
metadata
CHANGED
@@ -1,168 +1,133 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sass-embedded
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.83.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- なつき
|
8
|
-
|
9
|
-
bindir: bin
|
8
|
+
bindir: exe
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2025-01-04 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: google-protobuf
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '3.19'
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '3.19'
|
27
12
|
- !ruby/object:Gem::Dependency
|
28
13
|
name: rake
|
29
14
|
requirement: !ruby/object:Gem::Requirement
|
30
15
|
requirements:
|
31
16
|
- - ">="
|
32
17
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
18
|
+
version: '13'
|
34
19
|
type: :runtime
|
35
20
|
prerelease: false
|
36
21
|
version_requirements: !ruby/object:Gem::Requirement
|
37
22
|
requirements:
|
38
23
|
- - ">="
|
39
24
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: rspec
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: 3.11.0
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: 3.11.0
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: rubocop
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: 1.30.0
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: 1.30.0
|
25
|
+
version: '13'
|
69
26
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - "~>"
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: 1.14.0
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - "~>"
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: 1.14.0
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: rubocop-rake
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - "~>"
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: 0.6.0
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - "~>"
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: 0.6.0
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: rubocop-rspec
|
27
|
+
name: google-protobuf
|
99
28
|
requirement: !ruby/object:Gem::Requirement
|
100
29
|
requirements:
|
101
30
|
- - "~>"
|
102
31
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
104
|
-
type: :
|
32
|
+
version: '4.29'
|
33
|
+
type: :runtime
|
105
34
|
prerelease: false
|
106
35
|
version_requirements: !ruby/object:Gem::Requirement
|
107
36
|
requirements:
|
108
37
|
- - "~>"
|
109
38
|
- !ruby/object:Gem::Version
|
110
|
-
version:
|
39
|
+
version: '4.29'
|
111
40
|
description: A Ruby library that will communicate with Embedded Dart Sass using the
|
112
41
|
Embedded Sass protocol.
|
113
42
|
email:
|
114
43
|
- i@ntk.me
|
115
|
-
executables:
|
44
|
+
executables:
|
45
|
+
- sass
|
116
46
|
extensions:
|
117
47
|
- ext/sass/Rakefile
|
118
48
|
extra_rdoc_files: []
|
119
49
|
files:
|
120
50
|
- LICENSE
|
121
51
|
- README.md
|
52
|
+
- exe/sass
|
122
53
|
- ext/sass/Rakefile
|
54
|
+
- ext/sass/embedded_sass_pb.rb
|
55
|
+
- ext/sass/expand-archive.ps1
|
123
56
|
- ext/sass/package.json
|
124
|
-
- ext/sass/unzip.vbs
|
125
57
|
- lib/sass-embedded.rb
|
126
|
-
- lib/sass/
|
58
|
+
- lib/sass/calculation_value.rb
|
59
|
+
- lib/sass/calculation_value/calculation_operation.rb
|
60
|
+
- lib/sass/canonicalize_context.rb
|
127
61
|
- lib/sass/compile_result.rb
|
62
|
+
- lib/sass/compiler.rb
|
63
|
+
- lib/sass/compiler/channel.rb
|
64
|
+
- lib/sass/compiler/connection.rb
|
65
|
+
- lib/sass/compiler/dispatcher.rb
|
66
|
+
- lib/sass/compiler/host.rb
|
67
|
+
- lib/sass/compiler/host/function_registry.rb
|
68
|
+
- lib/sass/compiler/host/importer_registry.rb
|
69
|
+
- lib/sass/compiler/host/logger_registry.rb
|
70
|
+
- lib/sass/compiler/host/protofier.rb
|
71
|
+
- lib/sass/compiler/host/structifier.rb
|
72
|
+
- lib/sass/compiler/varint.rb
|
73
|
+
- lib/sass/elf.rb
|
128
74
|
- lib/sass/embedded.rb
|
129
|
-
- lib/sass/embedded/async.rb
|
130
|
-
- lib/sass/embedded/channel.rb
|
131
|
-
- lib/sass/embedded/compiler.rb
|
132
|
-
- lib/sass/embedded/dispatcher.rb
|
133
|
-
- lib/sass/embedded/host.rb
|
134
|
-
- lib/sass/embedded/host/function_registry.rb
|
135
|
-
- lib/sass/embedded/host/importer_registry.rb
|
136
|
-
- lib/sass/embedded/host/logger_registry.rb
|
137
|
-
- lib/sass/embedded/host/value_protofier.rb
|
138
|
-
- lib/sass/embedded/protofier.rb
|
139
|
-
- lib/sass/embedded/structifier.rb
|
140
|
-
- lib/sass/embedded/varint.rb
|
141
75
|
- lib/sass/embedded/version.rb
|
76
|
+
- lib/sass/embedded_protocol.rb
|
77
|
+
- lib/sass/exception.rb
|
78
|
+
- lib/sass/fork_tracker.rb
|
142
79
|
- lib/sass/logger/silent.rb
|
143
80
|
- lib/sass/logger/source_location.rb
|
144
81
|
- lib/sass/logger/source_span.rb
|
145
|
-
- lib/sass/
|
82
|
+
- lib/sass/node_package_importer.rb
|
83
|
+
- lib/sass/serializer.rb
|
146
84
|
- lib/sass/value.rb
|
147
85
|
- lib/sass/value/argument_list.rb
|
148
86
|
- lib/sass/value/boolean.rb
|
87
|
+
- lib/sass/value/calculation.rb
|
149
88
|
- lib/sass/value/color.rb
|
89
|
+
- lib/sass/value/color/channel.rb
|
90
|
+
- lib/sass/value/color/conversions.rb
|
91
|
+
- lib/sass/value/color/gamut_map_method.rb
|
92
|
+
- lib/sass/value/color/gamut_map_method/clip.rb
|
93
|
+
- lib/sass/value/color/gamut_map_method/local_minde.rb
|
94
|
+
- lib/sass/value/color/interpolation_method.rb
|
95
|
+
- lib/sass/value/color/space.rb
|
96
|
+
- lib/sass/value/color/space/a98_rgb.rb
|
97
|
+
- lib/sass/value/color/space/display_p3.rb
|
98
|
+
- lib/sass/value/color/space/hsl.rb
|
99
|
+
- lib/sass/value/color/space/hwb.rb
|
100
|
+
- lib/sass/value/color/space/lab.rb
|
101
|
+
- lib/sass/value/color/space/lch.rb
|
102
|
+
- lib/sass/value/color/space/lms.rb
|
103
|
+
- lib/sass/value/color/space/oklab.rb
|
104
|
+
- lib/sass/value/color/space/oklch.rb
|
105
|
+
- lib/sass/value/color/space/prophoto_rgb.rb
|
106
|
+
- lib/sass/value/color/space/rec2020.rb
|
107
|
+
- lib/sass/value/color/space/rgb.rb
|
108
|
+
- lib/sass/value/color/space/srgb.rb
|
109
|
+
- lib/sass/value/color/space/srgb_linear.rb
|
110
|
+
- lib/sass/value/color/space/utils.rb
|
111
|
+
- lib/sass/value/color/space/xyz_d50.rb
|
112
|
+
- lib/sass/value/color/space/xyz_d65.rb
|
150
113
|
- lib/sass/value/function.rb
|
151
114
|
- lib/sass/value/fuzzy_math.rb
|
152
115
|
- lib/sass/value/list.rb
|
153
116
|
- lib/sass/value/map.rb
|
117
|
+
- lib/sass/value/mixin.rb
|
154
118
|
- lib/sass/value/null.rb
|
155
119
|
- lib/sass/value/number.rb
|
156
120
|
- lib/sass/value/number/unit.rb
|
157
121
|
- lib/sass/value/string.rb
|
158
|
-
homepage: https://github.com/
|
122
|
+
homepage: https://github.com/sass-contrib/sass-embedded-host-ruby
|
159
123
|
licenses:
|
160
124
|
- MIT
|
161
125
|
metadata:
|
162
|
-
|
163
|
-
|
126
|
+
bug_tracker_uri: https://github.com/sass-contrib/sass-embedded-host-ruby/issues
|
127
|
+
documentation_uri: https://rubydoc.info/gems/sass-embedded/1.83.1
|
128
|
+
source_code_uri: https://github.com/sass-contrib/sass-embedded-host-ruby/tree/v1.83.1
|
164
129
|
funding_uri: https://github.com/sponsors/ntkme
|
165
|
-
|
130
|
+
rubygems_mfa_required: 'true'
|
166
131
|
rdoc_options: []
|
167
132
|
require_paths:
|
168
133
|
- lib
|
@@ -170,15 +135,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
170
135
|
requirements:
|
171
136
|
- - ">="
|
172
137
|
- !ruby/object:Gem::Version
|
173
|
-
version:
|
138
|
+
version: '3.1'
|
174
139
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
175
140
|
requirements:
|
176
141
|
- - ">="
|
177
142
|
- !ruby/object:Gem::Version
|
178
143
|
version: '0'
|
179
144
|
requirements: []
|
180
|
-
rubygems_version: 3.
|
181
|
-
signing_key:
|
145
|
+
rubygems_version: 3.6.2
|
182
146
|
specification_version: 4
|
183
147
|
summary: Use dart-sass with Ruby!
|
184
148
|
test_files: []
|
data/ext/sass/unzip.vbs
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
path = WScript.Arguments.item(0)
|
2
|
-
destinationPath = WScript.Arguments.item(1)
|
3
|
-
|
4
|
-
Set fileSystemObject = WScript.CreateObject("Scripting.FileSystemObject")
|
5
|
-
If NOT fileSystemObject.FolderExists(destinationPath) Then
|
6
|
-
fileSystemObject.CreateFolder(destinationPath)
|
7
|
-
End If
|
8
|
-
|
9
|
-
Set application = WScript.CreateObject("Shell.Application")
|
10
|
-
Set pathNameSpace = application.NameSpace(fileSystemObject.GetAbsolutePathName(path))
|
11
|
-
Set destinationPathNameSpace = application.NameSpace(fileSystemObject.GetAbsolutePathName(destinationPath))
|
12
|
-
|
13
|
-
destinationPathNameSpace.CopyHere pathNameSpace.items, 4 + 16
|
data/lib/sass/compile_error.rb
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Sass
|
4
|
-
# An exception thrown because a Sass compilation failed.
|
5
|
-
class CompileError < StandardError
|
6
|
-
# @return [String, nil]
|
7
|
-
attr_accessor :sass_stack
|
8
|
-
|
9
|
-
# @return [Logger::SourceSpan, nil]
|
10
|
-
attr_accessor :span
|
11
|
-
|
12
|
-
def initialize(message, full_message, sass_stack, span)
|
13
|
-
super(message)
|
14
|
-
@full_message = full_message == '' ? nil : full_message.dup
|
15
|
-
@sass_stack = sass_stack == '' ? nil : sass_stack
|
16
|
-
@span = span
|
17
|
-
end
|
18
|
-
|
19
|
-
# @return [String]
|
20
|
-
def full_message(*args, **kwargs)
|
21
|
-
if @full_message.nil?
|
22
|
-
super(*args, **kwargs)
|
23
|
-
else
|
24
|
-
@full_message
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
data/lib/sass/embedded/async.rb
DELETED
@@ -1,65 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Sass
|
4
|
-
class Embedded
|
5
|
-
# The {Async} class.
|
6
|
-
#
|
7
|
-
# It awaits until the promise is resolved or rejected.
|
8
|
-
class Async
|
9
|
-
module State
|
10
|
-
PENDING = 0
|
11
|
-
FULFILLED = 1
|
12
|
-
REJECTED = 2
|
13
|
-
end
|
14
|
-
|
15
|
-
private_constant :State
|
16
|
-
|
17
|
-
def initialize
|
18
|
-
@error = nil
|
19
|
-
@result = nil
|
20
|
-
@state = State::PENDING
|
21
|
-
|
22
|
-
@condition_variable = ConditionVariable.new
|
23
|
-
@mutex = Mutex.new
|
24
|
-
|
25
|
-
begin
|
26
|
-
yield if block_given?
|
27
|
-
rescue StandardError => e
|
28
|
-
reject e
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
def resolve(value)
|
33
|
-
@mutex.synchronize do
|
34
|
-
return unless @state == State::PENDING
|
35
|
-
|
36
|
-
@state = State::FULFILLED
|
37
|
-
@result = value
|
38
|
-
@condition_variable.broadcast
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
def reject(reason)
|
43
|
-
@mutex.synchronize do
|
44
|
-
return unless @state == State::PENDING
|
45
|
-
|
46
|
-
@state = State::REJECTED
|
47
|
-
@error = reason
|
48
|
-
@condition_variable.broadcast
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
def await
|
53
|
-
@mutex.synchronize do
|
54
|
-
@condition_variable.wait(@mutex) if @state == State::PENDING
|
55
|
-
|
56
|
-
raise @error if @state == State::REJECTED
|
57
|
-
|
58
|
-
@result
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
private_constant :Async
|
64
|
-
end
|
65
|
-
end
|
@@ -1,61 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Sass
|
4
|
-
class Embedded
|
5
|
-
# The {Channel} class.
|
6
|
-
#
|
7
|
-
# It establishes connection between {Host} and {Dispatcher}.
|
8
|
-
class Channel
|
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(observer)
|
27
|
-
@mutex.synchronize do
|
28
|
-
begin
|
29
|
-
id = @dispatcher.subscribe(observer)
|
30
|
-
rescue EOFError
|
31
|
-
@dispatcher = Dispatcher.new
|
32
|
-
id = @dispatcher.subscribe(observer)
|
33
|
-
end
|
34
|
-
Connection.new(@dispatcher, id)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
# The {Connection} between {Host} to {Dispatcher}.
|
39
|
-
class Connection
|
40
|
-
attr_reader :id
|
41
|
-
|
42
|
-
def initialize(dispatcher, id)
|
43
|
-
@dispatcher = dispatcher
|
44
|
-
@id = id
|
45
|
-
end
|
46
|
-
|
47
|
-
def disconnect
|
48
|
-
@dispatcher.unsubscribe(id)
|
49
|
-
end
|
50
|
-
|
51
|
-
def send_message(message)
|
52
|
-
@dispatcher.send_message(message)
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
private_constant :Connection
|
57
|
-
end
|
58
|
-
|
59
|
-
private_constant :Channel
|
60
|
-
end
|
61
|
-
end
|
@@ -1,60 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'open3'
|
4
|
-
|
5
|
-
module Sass
|
6
|
-
class Embedded
|
7
|
-
# The {Compiler} class.
|
8
|
-
#
|
9
|
-
# It runs the `dart-sass-embedded` process.
|
10
|
-
class Compiler
|
11
|
-
def initialize
|
12
|
-
@stdin, @stdout, @stderr, @wait_thread = Open3.popen3(PATH, chdir: __dir__)
|
13
|
-
@stdin.binmode
|
14
|
-
@stdout.binmode
|
15
|
-
@stdin_mutex = Mutex.new
|
16
|
-
@stdout_mutex = Mutex.new
|
17
|
-
|
18
|
-
Thread.new do
|
19
|
-
loop do
|
20
|
-
warn(@stderr.readline, uplevel: 1)
|
21
|
-
rescue IOError, Errno::EBADF
|
22
|
-
break
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
def close
|
28
|
-
@stdin_mutex.synchronize do
|
29
|
-
@stdin.close unless @stdin.closed?
|
30
|
-
@stdout.close unless @stdout.closed?
|
31
|
-
@stderr.close unless @stderr.closed?
|
32
|
-
end
|
33
|
-
|
34
|
-
@wait_thread.value
|
35
|
-
end
|
36
|
-
|
37
|
-
def closed?
|
38
|
-
@stdin_mutex.synchronize do
|
39
|
-
@stdin.closed?
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
def write(payload)
|
44
|
-
@stdin_mutex.synchronize do
|
45
|
-
Varint.write(@stdin, payload.length)
|
46
|
-
@stdin.write(payload)
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
def read
|
51
|
-
@stdout_mutex.synchronize do
|
52
|
-
length = Varint.read(@stdout)
|
53
|
-
@stdout.read(length)
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
private_constant :Compiler
|
59
|
-
end
|
60
|
-
end
|
@@ -1,90 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Sass
|
4
|
-
class Embedded
|
5
|
-
# The {Dispatcher} class.
|
6
|
-
#
|
7
|
-
# It dispatches messages between mutliple instances of {Host} and a single {Compiler}.
|
8
|
-
class Dispatcher
|
9
|
-
PROTOCOL_ERROR_ID = 0xffffffff
|
10
|
-
|
11
|
-
def initialize
|
12
|
-
@compiler = Compiler.new
|
13
|
-
@observers = {}
|
14
|
-
@id = 0
|
15
|
-
@mutex = Mutex.new
|
16
|
-
|
17
|
-
Thread.new do
|
18
|
-
loop do
|
19
|
-
receive_message EmbeddedProtocol::OutboundMessage.decode @compiler.read
|
20
|
-
rescue IOError, Errno::EBADF => e
|
21
|
-
@mutex.synchronize do
|
22
|
-
@id = PROTOCOL_ERROR_ID
|
23
|
-
@observers.values
|
24
|
-
end.each do |observer|
|
25
|
-
observer.error e
|
26
|
-
end
|
27
|
-
break
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
def subscribe(observer)
|
33
|
-
@mutex.synchronize do
|
34
|
-
raise EOFError if @id == PROTOCOL_ERROR_ID
|
35
|
-
|
36
|
-
id = @id
|
37
|
-
@id = id.next
|
38
|
-
@observers[id] = observer
|
39
|
-
id
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
def unsubscribe(id)
|
44
|
-
@mutex.synchronize do
|
45
|
-
@observers.delete(id)
|
46
|
-
|
47
|
-
close if @id == PROTOCOL_ERROR_ID && @observers.empty?
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
def close
|
52
|
-
@compiler.close
|
53
|
-
end
|
54
|
-
|
55
|
-
def closed?
|
56
|
-
@compiler.closed?
|
57
|
-
end
|
58
|
-
|
59
|
-
def send_message(inbound_message)
|
60
|
-
@compiler.write(inbound_message.to_proto)
|
61
|
-
end
|
62
|
-
|
63
|
-
private
|
64
|
-
|
65
|
-
def receive_message(outbound_message)
|
66
|
-
oneof = outbound_message.message
|
67
|
-
message = outbound_message.public_send(oneof)
|
68
|
-
case oneof
|
69
|
-
when :error
|
70
|
-
@mutex.synchronize do
|
71
|
-
@id = PROTOCOL_ERROR_ID
|
72
|
-
message.id == PROTOCOL_ERROR_ID ? @observers.values : [@observers[message.id]]
|
73
|
-
end.each do |observer|
|
74
|
-
observer.public_send(oneof, message)
|
75
|
-
end
|
76
|
-
when :compile_response, :version_response
|
77
|
-
@mutex.synchronize { @observers[message.id] }.public_send(oneof, message)
|
78
|
-
when :log_event, :canonicalize_request, :import_request, :file_import_request, :function_call_request
|
79
|
-
Thread.new(@mutex.synchronize { @observers[message.compilation_id] }) do |observer|
|
80
|
-
observer.public_send(oneof, message)
|
81
|
-
end
|
82
|
-
else
|
83
|
-
raise ArgumentError, "Unknown OutboundMessage.message #{message}"
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
private_constant :Dispatcher
|
89
|
-
end
|
90
|
-
end
|
@@ -1,107 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Sass
|
4
|
-
class Embedded
|
5
|
-
class Host
|
6
|
-
# The {ImporterRegistry} class.
|
7
|
-
#
|
8
|
-
# It stores importers and handles import requests.
|
9
|
-
class ImporterRegistry
|
10
|
-
attr_reader :importers
|
11
|
-
|
12
|
-
def initialize(importers, load_paths, alert_color:)
|
13
|
-
@id = 0
|
14
|
-
@importers_by_id = {}
|
15
|
-
@importers = importers
|
16
|
-
.map { |importer| register(importer) }
|
17
|
-
.concat(
|
18
|
-
load_paths.map do |load_path|
|
19
|
-
EmbeddedProtocol::InboundMessage::CompileRequest::Importer.new(
|
20
|
-
path: File.absolute_path(load_path)
|
21
|
-
)
|
22
|
-
end
|
23
|
-
)
|
24
|
-
|
25
|
-
@highlight = alert_color
|
26
|
-
end
|
27
|
-
|
28
|
-
def register(importer)
|
29
|
-
importer = Structifier.to_struct(importer)
|
30
|
-
|
31
|
-
is_importer = importer.respond_to?(:canonicalize) && importer.respond_to?(:load)
|
32
|
-
is_file_importer = importer.respond_to?(:find_file_url)
|
33
|
-
|
34
|
-
raise ArgumentError, 'importer must be an Importer or a FileImporter' if is_importer == is_file_importer
|
35
|
-
|
36
|
-
proto = if is_importer
|
37
|
-
EmbeddedProtocol::InboundMessage::CompileRequest::Importer.new(
|
38
|
-
importer_id: @id
|
39
|
-
)
|
40
|
-
else
|
41
|
-
EmbeddedProtocol::InboundMessage::CompileRequest::Importer.new(
|
42
|
-
file_importer_id: @id
|
43
|
-
)
|
44
|
-
end
|
45
|
-
@importers_by_id[@id] = importer
|
46
|
-
@id = @id.next
|
47
|
-
proto
|
48
|
-
end
|
49
|
-
|
50
|
-
def canonicalize(canonicalize_request)
|
51
|
-
importer = @importers_by_id[canonicalize_request.importer_id]
|
52
|
-
url = importer.canonicalize(canonicalize_request.url, from_import: canonicalize_request.from_import)&.to_s
|
53
|
-
|
54
|
-
EmbeddedProtocol::InboundMessage::CanonicalizeResponse.new(
|
55
|
-
id: canonicalize_request.id,
|
56
|
-
url: url
|
57
|
-
)
|
58
|
-
rescue StandardError => e
|
59
|
-
EmbeddedProtocol::InboundMessage::CanonicalizeResponse.new(
|
60
|
-
id: canonicalize_request.id,
|
61
|
-
error: e.full_message(highlight: @highlight, order: :top)
|
62
|
-
)
|
63
|
-
end
|
64
|
-
|
65
|
-
def import(import_request)
|
66
|
-
importer = @importers_by_id[import_request.importer_id]
|
67
|
-
importer_result = Structifier.to_struct importer.load(import_request.url)
|
68
|
-
|
69
|
-
EmbeddedProtocol::InboundMessage::ImportResponse.new(
|
70
|
-
id: import_request.id,
|
71
|
-
success: EmbeddedProtocol::InboundMessage::ImportResponse::ImportSuccess.new(
|
72
|
-
contents: importer_result.contents,
|
73
|
-
syntax: Protofier.to_proto_syntax(importer_result.syntax),
|
74
|
-
source_map_url: (importer_result.source_map_url&.to_s if importer_result.respond_to?(:source_map_url))
|
75
|
-
)
|
76
|
-
)
|
77
|
-
rescue StandardError => e
|
78
|
-
EmbeddedProtocol::InboundMessage::ImportResponse.new(
|
79
|
-
id: import_request.id,
|
80
|
-
error: e.full_message(highlight: @highlight, order: :top)
|
81
|
-
)
|
82
|
-
end
|
83
|
-
|
84
|
-
def file_import(file_import_request)
|
85
|
-
importer = @importers_by_id[file_import_request.importer_id]
|
86
|
-
file_url = importer.find_file_url(file_import_request.url, from_import: file_import_request.from_import)&.to_s
|
87
|
-
|
88
|
-
if !file_url.nil? && !file_url.start_with?('file:')
|
89
|
-
raise "file_url must be a file: URL, was #{file_url.inspect}"
|
90
|
-
end
|
91
|
-
|
92
|
-
EmbeddedProtocol::InboundMessage::FileImportResponse.new(
|
93
|
-
id: file_import_request.id,
|
94
|
-
file_url: file_url
|
95
|
-
)
|
96
|
-
rescue StandardError => e
|
97
|
-
EmbeddedProtocol::InboundMessage::FileImportResponse.new(
|
98
|
-
id: file_import_request.id,
|
99
|
-
error: e.full_message(highlight: @highlight, order: :top)
|
100
|
-
)
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
private_constant :ImporterRegistry
|
105
|
-
end
|
106
|
-
end
|
107
|
-
end
|