class Sass::Embedded::Host
It communicates with {Dispatcher} and handles the host logic.
The {Host} class.
def await
def await @connection = @channel.connect(self) @async = Async.new yield @async.await ensure @connection.disconnect end
def canonicalize_request(message)
def canonicalize_request(message) send_message EmbeddedProtocol::InboundMessage.new( canonicalize_response: @importer_registry.canonicalize(message) ) end
def compile_request(path:,
def compile_request(path:, source:, importer:, load_paths:, syntax:, url:, source_map:, source_map_include_sources:, style:, functions:, importers:, alert_ascii:, alert_color:, logger:, quiet_deps:, verbose:) await do alert_color = $stderr.tty? if alert_color.nil? @function_registry = FunctionRegistry.new(functions, alert_color: alert_color) @importer_registry = ImporterRegistry.new(importers, load_paths, alert_color: alert_color) @logger_registry = LoggerRegistry.new(logger) send_message EmbeddedProtocol::InboundMessage.new( compile_request: EmbeddedProtocol::InboundMessage::CompileRequest.new( id: id, string: unless source.nil? EmbeddedProtocol::InboundMessage::CompileRequest::StringInput.new( source: source, url: url&.to_s, syntax: Protofier.to_proto_syntax(syntax), importer: (@importer_registry.register(importer) unless importer.nil?) ) end, path: (File.absolute_path(path) unless path.nil?), style: Protofier.to_proto_output_style(style), source_map: source_map, source_map_include_sources: source_map_include_sources, importers: @importer_registry.importers, global_functions: @function_registry.global_functions, alert_ascii: alert_ascii, alert_color: alert_color, quiet_deps: quiet_deps, verbose: verbose ) ) end end
def compile_response(message)
def compile_response(message) @async.resolve(message) end
def error(message)
def error(message) @async.reject(CompileError.new(message.message, nil, nil, nil)) end
def file_import_request(message)
def file_import_request(message) send_message EmbeddedProtocol::InboundMessage.new( file_import_response: @importer_registry.file_import(message) ) end
def function_call_request(message)
def function_call_request(message) send_message EmbeddedProtocol::InboundMessage.new( function_call_response: @function_registry.function_call(message) ) end
def id
def id @connection.id end
def import_request(message)
def import_request(message) send_message EmbeddedProtocol::InboundMessage.new( import_response: @importer_registry.import(message) ) end
def initialize(channel)
def initialize(channel) @channel = channel end
def log_event(message)
def log_event(message) @logger_registry.log(message) end
def send_message(message)
def send_message(message) @connection.send_message(message) end
def version_request
def version_request await do send_message EmbeddedProtocol::InboundMessage.new( version_request: EmbeddedProtocol::InboundMessage::VersionRequest.new( id: id ) ) end end
def version_response(message)
def version_response(message) @async.resolve(message) end