sass-embedded 0.8.1 → 0.8.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 +4 -4
- data/ext/sass/extconf.rb +171 -169
- data/lib/sass/embedded/compile.rb +255 -0
- data/lib/sass/embedded/compiler.rb +17 -0
- data/lib/sass/embedded/error.rb +29 -0
- data/lib/sass/embedded/info.rb +38 -0
- data/lib/sass/embedded/observer.rb +42 -0
- data/lib/sass/embedded/platform.rb +55 -0
- data/lib/sass/embedded/protocol.rb +3 -0
- data/lib/sass/embedded/result.rb +34 -0
- data/lib/sass/embedded/struct.rb +22 -0
- data/lib/sass/embedded/transport.rb +131 -0
- data/lib/sass/embedded/util.rb +33 -0
- data/lib/sass/{version.rb → embedded/version.rb} +3 -1
- data/lib/sass/embedded.rb +15 -0
- data/lib/sass.rb +8 -23
- metadata +15 -14
- data/lib/sass/compile.rb +0 -249
- data/lib/sass/compiler.rb +0 -13
- data/lib/sass/error.rb +0 -27
- data/lib/sass/info.rb +0 -33
- data/lib/sass/observer.rb +0 -40
- data/lib/sass/platform.rb +0 -53
- data/lib/sass/result.rb +0 -30
- data/lib/sass/struct.rb +0 -20
- data/lib/sass/transport.rb +0 -127
- data/lib/sass/util.rb +0 -31
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 36a036051c7abed208ad60c033464cc8ebba1c7b16e0aaf4d32e7e88e7480dbe
|
4
|
+
data.tar.gz: d90c2b2f3c0a66c1de05cdb30fa66bb0b42b8d29ecaa84be53a36dc42fc886b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9ea57f9e2d75135b81cc2dcdc7dd37cf1db7b185512f90b2e40a5c03d05994409d85023b61feccdc0a346443863fac2c4439c439d975adfd2404319747d1f8fc
|
7
|
+
data.tar.gz: 90d91290a68af79837a17dd4cd73645524e4d9e377b5e30f232df2c2a2dde1dba4f4c2a7520b66fda1e225f409804abc3b2de0df8c8998be094827982114472c
|
data/ext/sass/extconf.rb
CHANGED
@@ -1,221 +1,223 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
require '
|
4
|
+
require 'fileutils'
|
5
5
|
require 'json'
|
6
|
+
require 'mkmf'
|
6
7
|
require 'open-uri'
|
7
|
-
|
8
|
-
require_relative '../../lib/sass/platform'
|
9
|
-
require_relative '../../lib/sass/compiler'
|
8
|
+
require_relative '../../lib/sass/embedded/compiler'
|
9
|
+
require_relative '../../lib/sass/embedded/platform'
|
10
10
|
|
11
11
|
module Sass
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
12
|
+
class Embedded
|
13
|
+
# The dependency downloader. This downloads all the dependencies during gem
|
14
|
+
# installation. The companion Makefile then unpacks all downloaded
|
15
|
+
# dependencies. By default it downloads the release of each dependency
|
16
|
+
# from GitHub releases.
|
17
|
+
#
|
18
|
+
# It is possible to specify an alternative source or version of each
|
19
|
+
# dependency. Local sources can be used for offline installation.
|
20
|
+
#
|
21
|
+
# @example
|
22
|
+
# gem install sass-embedded -- \
|
23
|
+
# --with-protoc=file:///path/to/protoc-*.zip \
|
24
|
+
# --with-sass-embedded=file:///path/to/sass_embedded-*.(tar.gz|zip) \
|
25
|
+
# --with-sass-embedded-protocol=file:///path/to/embedded_sass.proto
|
26
|
+
# @example
|
27
|
+
# bundle config build.sass-embedded \
|
28
|
+
# --with-protoc=file:///path/to/protoc-*.zip \
|
29
|
+
# --with-sass-embedded=file:///path/to/sass_embedded-*.(tar.gz|zip) \
|
30
|
+
# --with-sass-embedded-protocol=file:///path/to/embedded_sass.proto
|
31
|
+
class Extconf
|
32
|
+
def initialize
|
33
|
+
fetch_with_config('protoc', false) { default_protoc }
|
34
|
+
fetch_with_config('sass-embedded', false) { default_sass_embedded }
|
35
|
+
fetch_with_config('sass-embedded-protocol', false) { default_sass_embedded_protocol }
|
36
|
+
end
|
36
37
|
|
37
|
-
|
38
|
+
private
|
38
39
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
40
|
+
def fetch_with_config(config, default)
|
41
|
+
val = with_config(config, default)
|
42
|
+
case val
|
43
|
+
when true
|
44
|
+
if block_given?
|
45
|
+
fetch yield
|
46
|
+
else
|
47
|
+
fetch default
|
48
|
+
end
|
49
|
+
when false
|
50
|
+
nil
|
45
51
|
else
|
46
|
-
fetch
|
52
|
+
fetch val
|
47
53
|
end
|
48
|
-
when false
|
49
|
-
nil
|
50
|
-
else
|
51
|
-
fetch val
|
52
54
|
end
|
53
|
-
end
|
54
55
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
56
|
+
def fetch(uri_s)
|
57
|
+
uri = URI.parse(uri_s)
|
58
|
+
path = File.absolute_path(File.basename(uri.path), __dir__)
|
59
|
+
if uri.is_a?(URI::File) || uri.instance_of?(URI::Generic)
|
60
|
+
FileUtils.copy_file uri.path, path
|
61
|
+
elsif uri.respond_to? :open
|
62
|
+
puts "curl -fsSLo #{path} -- #{uri}"
|
63
|
+
uri.open do |source|
|
64
|
+
File.open(path, 'wb') do |destination|
|
65
|
+
destination.write source.read
|
66
|
+
end
|
65
67
|
end
|
68
|
+
else
|
69
|
+
raise
|
66
70
|
end
|
67
|
-
|
71
|
+
rescue StandardError
|
72
|
+
warn "ERROR: Error fetching #{uri_s}:"
|
68
73
|
raise
|
69
74
|
end
|
70
|
-
rescue StandardError
|
71
|
-
warn "ERROR: Error fetching #{uri_s}:"
|
72
|
-
raise
|
73
|
-
end
|
74
75
|
|
75
|
-
|
76
|
-
|
76
|
+
def resolve_tag_name(repo, *requirements, gh_release: true)
|
77
|
+
requirements = Gem::Requirement.create(*requirements)
|
77
78
|
|
78
|
-
|
79
|
-
|
80
|
-
|
79
|
+
satisfied = lambda { |version|
|
80
|
+
Gem::Version.correct?(version) && requirements.satisfied_by?(Gem::Version.new(version))
|
81
|
+
}
|
81
82
|
|
82
|
-
|
83
|
-
|
83
|
+
headers = {}
|
84
|
+
headers['Authorization'] = "token #{ENV['GITHUB_TOKEN']}" if ENV['GITHUB_TOKEN']
|
84
85
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
86
|
+
begin
|
87
|
+
if gh_release
|
88
|
+
releases_uri = "https://github.com/#{repo}/releases"
|
89
|
+
uri = "#{releases_uri}/latest"
|
90
|
+
tag_name = URI.parse(uri).open do |file|
|
91
|
+
return nil if file.base_uri == releases_uri
|
91
92
|
|
92
|
-
|
93
|
-
|
94
|
-
|
93
|
+
latest = File.basename file.base_uri.to_s
|
94
|
+
latest if satisfied.call latest
|
95
|
+
end
|
95
96
|
|
96
|
-
|
97
|
+
return tag_name unless tag_name.nil?
|
97
98
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
99
|
+
uri = "https://api.github.com/repos/#{repo}/releases?per_page=100"
|
100
|
+
tag_name = URI.parse(uri).open(headers) do |file|
|
101
|
+
JSON.parse(file.read).map { |release| release['tag_name'] }
|
102
|
+
end
|
103
|
+
.find(satisfied)&.peek
|
104
|
+
else
|
105
|
+
uri = "https://api.github.com/repos/#{repo}/tags?per_page=100"
|
106
|
+
tag_name = URI.parse(uri).open(headers) do |file|
|
107
|
+
JSON.parse(file.read).map { |tag| tag['name'] }
|
108
|
+
end
|
109
|
+
.find(satisfied)&.peek
|
107
110
|
end
|
108
|
-
|
111
|
+
|
112
|
+
return tag_name unless tag_name.nil?
|
113
|
+
rescue OpenURI::HTTPError => e
|
114
|
+
warn "WARNING: Error fetching #{uri}: #{e}"
|
109
115
|
end
|
110
116
|
|
111
|
-
|
112
|
-
|
113
|
-
|
117
|
+
requirements.requirements
|
118
|
+
.map { |requirement| requirement.last.to_s.gsub('.pre.', '-') }
|
119
|
+
.find(satisfied)&.peek
|
114
120
|
end
|
115
121
|
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
122
|
+
def default_sass_embedded
|
123
|
+
repo = 'sass/dart-sass-embedded'
|
124
|
+
|
125
|
+
tag_name = resolve_tag_name(repo, Compiler::REQUIREMENTS)
|
120
126
|
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
'macos'
|
129
|
-
when 'linux'
|
130
|
-
'linux'
|
131
|
-
when 'windows'
|
132
|
-
'windows'
|
133
|
-
else
|
134
|
-
raise "Unsupported OS: #{Platform::OS}"
|
135
|
-
end
|
136
|
-
|
137
|
-
arch = case Platform::ARCH
|
138
|
-
when 'x86_64'
|
139
|
-
'x64'
|
140
|
-
when 'i386'
|
141
|
-
'ia32'
|
142
|
-
when 'aarch64'
|
143
|
-
raise "Unsupported Arch: #{Platform::ARCH}" unless Platform::OS == 'darwin'
|
144
|
-
|
145
|
-
'x64'
|
127
|
+
os = case Platform::OS
|
128
|
+
when 'darwin'
|
129
|
+
'macos'
|
130
|
+
when 'linux'
|
131
|
+
'linux'
|
132
|
+
when 'windows'
|
133
|
+
'windows'
|
146
134
|
else
|
147
|
-
raise "Unsupported
|
135
|
+
raise "Unsupported OS: #{Platform::OS}"
|
148
136
|
end
|
149
137
|
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
138
|
+
arch = case Platform::ARCH
|
139
|
+
when 'x86_64'
|
140
|
+
'x64'
|
141
|
+
when 'i386'
|
142
|
+
'ia32'
|
143
|
+
when 'aarch64'
|
144
|
+
raise "Unsupported Arch: #{Platform::ARCH}" unless Platform::OS == 'darwin'
|
156
145
|
|
157
|
-
|
158
|
-
|
146
|
+
'x64'
|
147
|
+
else
|
148
|
+
raise "Unsupported Arch: #{Platform::ARCH}"
|
149
|
+
end
|
159
150
|
|
160
|
-
|
161
|
-
|
151
|
+
ext = case os
|
152
|
+
when 'windows'
|
153
|
+
'zip'
|
154
|
+
else
|
155
|
+
'tar.gz'
|
156
|
+
end
|
162
157
|
|
163
|
-
|
158
|
+
"https://github.com/#{repo}/releases/download/#{tag_name}/sass_embedded-#{tag_name}-#{os}-#{arch}.#{ext}"
|
159
|
+
end
|
164
160
|
|
165
|
-
|
161
|
+
def default_protoc
|
162
|
+
repo = 'protocolbuffers/protobuf'
|
166
163
|
|
167
|
-
|
168
|
-
when 'darwin'
|
169
|
-
'osx'
|
170
|
-
when 'linux'
|
171
|
-
'linux'
|
172
|
-
when 'windows'
|
173
|
-
'win'
|
174
|
-
else
|
175
|
-
raise "Unsupported OS: #{Platform::OS}"
|
176
|
-
end
|
164
|
+
spec = Gem::Dependency.new('google-protobuf').to_spec
|
177
165
|
|
178
|
-
|
179
|
-
|
180
|
-
|
166
|
+
tag_name = "v#{spec.version}"
|
167
|
+
|
168
|
+
os = case Platform::OS
|
169
|
+
when 'darwin'
|
170
|
+
'osx'
|
171
|
+
when 'linux'
|
172
|
+
'linux'
|
173
|
+
when 'windows'
|
174
|
+
'win'
|
175
|
+
else
|
176
|
+
raise "Unsupported OS: #{Platform::OS}"
|
177
|
+
end
|
178
|
+
|
179
|
+
arch = case Platform::ARCH
|
180
|
+
when 'aarch64'
|
181
|
+
if Platform::OS == 'darwin'
|
182
|
+
'x86_64'
|
183
|
+
else
|
184
|
+
'aarch_64'
|
185
|
+
end
|
186
|
+
when 'sparcv9'
|
187
|
+
's390'
|
188
|
+
when 'i386'
|
189
|
+
'x86_32'
|
190
|
+
when 'x86_64'
|
181
191
|
'x86_64'
|
192
|
+
when 'powerpc64'
|
193
|
+
'ppcle_64'
|
182
194
|
else
|
183
|
-
|
195
|
+
raise "Unsupported Arch: #{Platform::ARCH}"
|
184
196
|
end
|
185
|
-
when 'sparcv9'
|
186
|
-
's390'
|
187
|
-
when 'i386'
|
188
|
-
'x86_32'
|
189
|
-
when 'x86_64'
|
190
|
-
'x86_64'
|
191
|
-
when 'powerpc64'
|
192
|
-
'ppcle_64'
|
193
|
-
else
|
194
|
-
raise "Unsupported Arch: #{Platform::ARCH}"
|
195
|
-
end
|
196
197
|
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
198
|
+
os_arch = case os
|
199
|
+
when 'win'
|
200
|
+
os + arch.split('_').last
|
201
|
+
else
|
202
|
+
"#{os}-#{arch}"
|
203
|
+
end
|
203
204
|
|
204
|
-
|
205
|
+
ext = 'zip'
|
205
206
|
|
206
|
-
|
207
|
-
|
207
|
+
"https://github.com/#{repo}/releases/download/#{tag_name}/protoc-#{tag_name[1..]}-#{os_arch}.#{ext}"
|
208
|
+
end
|
208
209
|
|
209
|
-
|
210
|
-
|
210
|
+
def default_sass_embedded_protocol
|
211
|
+
repo = 'sass/embedded-protocol'
|
211
212
|
|
212
|
-
|
213
|
-
|
214
|
-
|
213
|
+
tag_name = IO.popen([Compiler::DART_SASS_EMBEDDED, '--version']) do |file|
|
214
|
+
JSON.parse(file.read)['protocolVersion']
|
215
|
+
end
|
215
216
|
|
216
|
-
|
217
|
+
"https://raw.githubusercontent.com/#{repo}/#{tag_name}/embedded_sass.proto"
|
218
|
+
end
|
217
219
|
end
|
218
220
|
end
|
219
221
|
end
|
220
222
|
|
221
|
-
Sass::Extconf.new
|
223
|
+
Sass::Embedded::Extconf.new
|
@@ -0,0 +1,255 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'observer'
|
4
|
+
require_relative 'protocol'
|
5
|
+
require_relative 'util'
|
6
|
+
|
7
|
+
module Sass
|
8
|
+
class Embedded
|
9
|
+
# The {Observer} for {Embedded#render}.
|
10
|
+
class CompileContext
|
11
|
+
include Observer
|
12
|
+
|
13
|
+
def initialize(transport, id,
|
14
|
+
data:,
|
15
|
+
file:,
|
16
|
+
indented_syntax:,
|
17
|
+
include_paths:,
|
18
|
+
output_style:,
|
19
|
+
source_map:,
|
20
|
+
out_file:,
|
21
|
+
functions:,
|
22
|
+
importer:)
|
23
|
+
raise ArgumentError, 'either data or file must be set' if file.nil? && data.nil?
|
24
|
+
|
25
|
+
@id = id
|
26
|
+
@data = data
|
27
|
+
@file = file
|
28
|
+
@indented_syntax = indented_syntax
|
29
|
+
@include_paths = include_paths
|
30
|
+
@output_style = output_style
|
31
|
+
@source_map = source_map
|
32
|
+
@out_file = out_file
|
33
|
+
@global_functions = functions.keys
|
34
|
+
@functions = functions.transform_keys do |key|
|
35
|
+
key.to_s.split('(')[0].chomp
|
36
|
+
end
|
37
|
+
@importer = importer
|
38
|
+
@import_responses = {}
|
39
|
+
|
40
|
+
super(transport)
|
41
|
+
|
42
|
+
send_message compile_request
|
43
|
+
end
|
44
|
+
|
45
|
+
def update(error, message)
|
46
|
+
raise error unless error.nil?
|
47
|
+
|
48
|
+
case message
|
49
|
+
when EmbeddedProtocol::OutboundMessage::CompileResponse
|
50
|
+
return unless message.id == @id
|
51
|
+
|
52
|
+
Thread.new do
|
53
|
+
super(nil, message)
|
54
|
+
end
|
55
|
+
when EmbeddedProtocol::OutboundMessage::LogEvent
|
56
|
+
return unless message.compilation_id == @id && $stderr.tty?
|
57
|
+
|
58
|
+
warn message.formatted
|
59
|
+
when EmbeddedProtocol::OutboundMessage::CanonicalizeRequest
|
60
|
+
return unless message.compilation_id == @id
|
61
|
+
|
62
|
+
Thread.new do
|
63
|
+
send_message canonicalize_response message
|
64
|
+
end
|
65
|
+
when EmbeddedProtocol::OutboundMessage::ImportRequest
|
66
|
+
return unless message.compilation_id == @id
|
67
|
+
|
68
|
+
Thread.new do
|
69
|
+
send_message import_response message
|
70
|
+
end
|
71
|
+
when EmbeddedProtocol::OutboundMessage::FileImportRequest
|
72
|
+
raise NotImplementedError, 'FileImportRequest is not implemented'
|
73
|
+
when EmbeddedProtocol::OutboundMessage::FunctionCallRequest
|
74
|
+
return unless message.compilation_id == @id
|
75
|
+
|
76
|
+
Thread.new do
|
77
|
+
send_message function_call_response message
|
78
|
+
end
|
79
|
+
end
|
80
|
+
rescue StandardError => e
|
81
|
+
Thread.new do
|
82
|
+
super(e, nil)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
private
|
87
|
+
|
88
|
+
def compile_request
|
89
|
+
EmbeddedProtocol::InboundMessage::CompileRequest.new(
|
90
|
+
id: @id,
|
91
|
+
string: string,
|
92
|
+
path: path,
|
93
|
+
style: style,
|
94
|
+
source_map: source_map,
|
95
|
+
importers: importers,
|
96
|
+
global_functions: global_functions,
|
97
|
+
alert_color: $stderr.tty?,
|
98
|
+
alert_ascii: Platform::OS == 'windows'
|
99
|
+
)
|
100
|
+
end
|
101
|
+
|
102
|
+
def canonicalize_response(canonicalize_request)
|
103
|
+
url = Util.file_uri_from_path(File.absolute_path(canonicalize_request.url, (@file.nil? ? 'stdin' : @file)))
|
104
|
+
|
105
|
+
begin
|
106
|
+
result = @importer[canonicalize_request.importer_id].call canonicalize_request.url, @file
|
107
|
+
raise result if result.is_a? StandardError
|
108
|
+
rescue StandardError => e
|
109
|
+
return EmbeddedProtocol::InboundMessage::CanonicalizeResponse.new(
|
110
|
+
id: canonicalize_request.id,
|
111
|
+
error: e.message
|
112
|
+
)
|
113
|
+
end
|
114
|
+
|
115
|
+
if result&.key? :contents
|
116
|
+
@import_responses[url] = EmbeddedProtocol::InboundMessage::ImportResponse.new(
|
117
|
+
id: canonicalize_request.id,
|
118
|
+
success: EmbeddedProtocol::InboundMessage::ImportResponse::ImportSuccess.new(
|
119
|
+
contents: result[:contents],
|
120
|
+
syntax: EmbeddedProtocol::Syntax::SCSS,
|
121
|
+
source_map_url: nil
|
122
|
+
)
|
123
|
+
)
|
124
|
+
EmbeddedProtocol::InboundMessage::CanonicalizeResponse.new(
|
125
|
+
id: canonicalize_request.id,
|
126
|
+
url: url
|
127
|
+
)
|
128
|
+
elsif result&.key? :file
|
129
|
+
canonicalized_url = Util.file_uri_from_path(File.absolute_path(result[:file]))
|
130
|
+
|
131
|
+
# TODO: FileImportRequest is not supported yet.
|
132
|
+
# Workaround by reading contents and return it when server asks
|
133
|
+
@import_responses[canonicalized_url] = EmbeddedProtocol::InboundMessage::ImportResponse.new(
|
134
|
+
id: canonicalize_request.id,
|
135
|
+
success: EmbeddedProtocol::InboundMessage::ImportResponse::ImportSuccess.new(
|
136
|
+
contents: File.read(result[:file]),
|
137
|
+
syntax: EmbeddedProtocol::Syntax::SCSS,
|
138
|
+
source_map_url: nil
|
139
|
+
)
|
140
|
+
)
|
141
|
+
|
142
|
+
EmbeddedProtocol::InboundMessage::CanonicalizeResponse.new(
|
143
|
+
id: canonicalize_request.id,
|
144
|
+
url: canonicalized_url
|
145
|
+
)
|
146
|
+
else
|
147
|
+
EmbeddedProtocol::InboundMessage::CanonicalizeResponse.new(
|
148
|
+
id: canonicalize_request.id
|
149
|
+
)
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
def import_response(import_request)
|
154
|
+
url = import_request.url
|
155
|
+
|
156
|
+
if @import_responses.key? url
|
157
|
+
@import_responses[url].id = import_request.id
|
158
|
+
else
|
159
|
+
@import_responses[url] = EmbeddedProtocol::InboundMessage::ImportResponse.new(
|
160
|
+
id: import_request.id,
|
161
|
+
error: "Failed to import: #{url}"
|
162
|
+
)
|
163
|
+
end
|
164
|
+
|
165
|
+
@import_responses[url]
|
166
|
+
end
|
167
|
+
|
168
|
+
def function_call_response(function_call_request)
|
169
|
+
# TODO: convert argument_list to **kwargs
|
170
|
+
EmbeddedProtocol::InboundMessage::FunctionCallResponse.new(
|
171
|
+
id: function_call_request.id,
|
172
|
+
success: @functions[function_call_request.name].call(*function_call_request.arguments),
|
173
|
+
accessed_argument_lists: function_call_request.arguments
|
174
|
+
.filter { |argument| argument.value == :argument_list }
|
175
|
+
.map { |argument| argument.argument_list.id }
|
176
|
+
)
|
177
|
+
rescue StandardError => e
|
178
|
+
EmbeddedProtocol::InboundMessage::FunctionCallResponse.new(
|
179
|
+
id: function_call_request.id,
|
180
|
+
error: e.message
|
181
|
+
)
|
182
|
+
end
|
183
|
+
|
184
|
+
def syntax
|
185
|
+
if @indented_syntax == true
|
186
|
+
EmbeddedProtocol::Syntax::INDENTED
|
187
|
+
else
|
188
|
+
EmbeddedProtocol::Syntax::SCSS
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
def url
|
193
|
+
return if @file.nil?
|
194
|
+
|
195
|
+
Util.file_uri_from_path File.absolute_path @file
|
196
|
+
end
|
197
|
+
|
198
|
+
def string
|
199
|
+
return if @data.nil?
|
200
|
+
|
201
|
+
EmbeddedProtocol::InboundMessage::CompileRequest::StringInput.new(
|
202
|
+
source: @data,
|
203
|
+
url: url,
|
204
|
+
syntax: syntax
|
205
|
+
)
|
206
|
+
end
|
207
|
+
|
208
|
+
def path
|
209
|
+
@file if @data.nil?
|
210
|
+
end
|
211
|
+
|
212
|
+
def style
|
213
|
+
case @output_style&.to_sym
|
214
|
+
when :expanded
|
215
|
+
EmbeddedProtocol::OutputStyle::EXPANDED
|
216
|
+
when :compressed
|
217
|
+
EmbeddedProtocol::OutputStyle::COMPRESSED
|
218
|
+
else
|
219
|
+
raise ArgumentError, 'output_style must be one of :expanded, :compressed'
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
223
|
+
def source_map
|
224
|
+
@source_map.is_a?(String) || (@source_map == true && !@out_file.nil?)
|
225
|
+
end
|
226
|
+
|
227
|
+
attr_reader :global_functions
|
228
|
+
|
229
|
+
# Order
|
230
|
+
# 1. Loading a file relative to the file in which the @use or @import appeared.
|
231
|
+
# 2. Each custom importer.
|
232
|
+
# 3. Loading a file relative to the current working directory.
|
233
|
+
# 4. Each load path in includePaths
|
234
|
+
# 5. Each load path specified in the SASS_PATH environment variable, which should
|
235
|
+
# be semicolon-separated on Windows and colon-separated elsewhere.
|
236
|
+
def importers
|
237
|
+
custom_importers = @importer.map.with_index do |_, id|
|
238
|
+
EmbeddedProtocol::InboundMessage::CompileRequest::Importer.new(
|
239
|
+
importer_id: id
|
240
|
+
)
|
241
|
+
end
|
242
|
+
|
243
|
+
include_path_importers = @include_paths
|
244
|
+
.concat(Embedded.include_paths)
|
245
|
+
.map do |include_path|
|
246
|
+
EmbeddedProtocol::InboundMessage::CompileRequest::Importer.new(
|
247
|
+
path: File.absolute_path(include_path)
|
248
|
+
)
|
249
|
+
end
|
250
|
+
|
251
|
+
custom_importers.concat include_path_importers
|
252
|
+
end
|
253
|
+
end
|
254
|
+
end
|
255
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'platform'
|
4
|
+
|
5
|
+
module Sass
|
6
|
+
class Embedded
|
7
|
+
module Compiler
|
8
|
+
DART_SASS_EMBEDDED = File.absolute_path(
|
9
|
+
"../../../ext/sass/sass_embedded/dart-sass-embedded#{Platform::OS == 'windows' ? '.bat' : ''}", __dir__
|
10
|
+
)
|
11
|
+
|
12
|
+
PROTOCOL_ERROR_ID = 4_294_967_295
|
13
|
+
|
14
|
+
REQUIREMENTS = '~> 1.0.0-beta.11'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|