sass-embedded 1.74.1-riscv64-linux-android
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +20 -0
- data/README.md +48 -0
- data/exe/sass +21 -0
- data/ext/sass/cli.rb +12 -0
- data/ext/sass/dart-sass/sass +20 -0
- data/ext/sass/dart-sass/src/LICENSE +1687 -0
- data/ext/sass/dart-sass/src/dart +0 -0
- data/ext/sass/dart-sass/src/sass.snapshot +0 -0
- data/ext/sass/embedded_sass_pb.rb +63 -0
- data/lib/sass/calculation_value/calculation_operation.rb +49 -0
- data/lib/sass/calculation_value.rb +22 -0
- data/lib/sass/canonicalize_context.rb +21 -0
- data/lib/sass/compile_result.rb +24 -0
- data/lib/sass/compiler/channel.rb +68 -0
- data/lib/sass/compiler/connection.rb +92 -0
- data/lib/sass/compiler/dispatcher.rb +115 -0
- data/lib/sass/compiler/host/function_registry.rb +87 -0
- data/lib/sass/compiler/host/importer_registry.rb +137 -0
- data/lib/sass/compiler/host/logger_registry.rb +55 -0
- data/lib/sass/compiler/host/protofier.rb +390 -0
- data/lib/sass/compiler/host/structifier.rb +37 -0
- data/lib/sass/compiler/host.rb +226 -0
- data/lib/sass/compiler/varint.rb +39 -0
- data/lib/sass/compiler.rb +212 -0
- data/lib/sass/elf.rb +276 -0
- data/lib/sass/embedded/version.rb +7 -0
- data/lib/sass/embedded.rb +107 -0
- data/lib/sass/embedded_protocol.rb +10 -0
- data/lib/sass/exception.rb +69 -0
- data/lib/sass/fork_tracker.rb +51 -0
- data/lib/sass/logger/silent.rb +28 -0
- data/lib/sass/logger/source_location.rb +22 -0
- data/lib/sass/logger/source_span.rb +28 -0
- data/lib/sass/node_package_importer.rb +17 -0
- data/lib/sass/serializer.rb +36 -0
- data/lib/sass/value/argument_list.rb +37 -0
- data/lib/sass/value/boolean.rb +52 -0
- data/lib/sass/value/calculation.rb +90 -0
- data/lib/sass/value/color.rb +253 -0
- data/lib/sass/value/function.rb +51 -0
- data/lib/sass/value/fuzzy_math.rb +80 -0
- data/lib/sass/value/list.rb +79 -0
- data/lib/sass/value/map.rb +71 -0
- data/lib/sass/value/mixin.rb +36 -0
- data/lib/sass/value/null.rb +48 -0
- data/lib/sass/value/number/unit.rb +186 -0
- data/lib/sass/value/number.rb +366 -0
- data/lib/sass/value/string.rb +61 -0
- data/lib/sass/value.rb +136 -0
- data/lib/sass-embedded.rb +4 -0
- metadata +120 -0
Binary file
|
Binary file
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
3
|
+
# source: embedded_sass.proto
|
4
|
+
|
5
|
+
require 'google/protobuf'
|
6
|
+
|
7
|
+
|
8
|
+
descriptor_data = "\n\x13\x65mbedded_sass.proto\x12\x16sass.embedded_protocol\"\xaa\x10\n\x0eInboundMessage\x12P\n\x0f\x63ompile_request\x18\x02 \x01(\x0b\x32\x35.sass.embedded_protocol.InboundMessage.CompileRequestH\x00\x12\\\n\x15\x63\x61nonicalize_response\x18\x03 \x01(\x0b\x32;.sass.embedded_protocol.InboundMessage.CanonicalizeResponseH\x00\x12P\n\x0fimport_response\x18\x04 \x01(\x0b\x32\x35.sass.embedded_protocol.InboundMessage.ImportResponseH\x00\x12Y\n\x14\x66ile_import_response\x18\x05 \x01(\x0b\x32\x39.sass.embedded_protocol.InboundMessage.FileImportResponseH\x00\x12]\n\x16\x66unction_call_response\x18\x06 \x01(\x0b\x32;.sass.embedded_protocol.InboundMessage.FunctionCallResponseH\x00\x12P\n\x0fversion_request\x18\x07 \x01(\x0b\x32\x35.sass.embedded_protocol.InboundMessage.VersionRequestH\x00\x1a\x1c\n\x0eVersionRequest\x12\n\n\x02id\x18\x01 \x01(\r\x1a\x98\x07\n\x0e\x43ompileRequest\x12S\n\x06string\x18\x02 \x01(\x0b\x32\x41.sass.embedded_protocol.InboundMessage.CompileRequest.StringInputH\x00\x12\x0e\n\x04path\x18\x03 \x01(\tH\x00\x12\x32\n\x05style\x18\x04 \x01(\x0e\x32#.sass.embedded_protocol.OutputStyle\x12\x12\n\nsource_map\x18\x05 \x01(\x08\x12Q\n\timporters\x18\x06 \x03(\x0b\x32>.sass.embedded_protocol.InboundMessage.CompileRequest.Importer\x12\x18\n\x10global_functions\x18\x07 \x03(\t\x12\x13\n\x0b\x61lert_color\x18\x08 \x01(\x08\x12\x13\n\x0b\x61lert_ascii\x18\t \x01(\x08\x12\x0f\n\x07verbose\x18\n \x01(\x08\x12\x12\n\nquiet_deps\x18\x0b \x01(\x08\x12\"\n\x1asource_map_include_sources\x18\x0c \x01(\x08\x12\x0f\n\x07\x63harset\x18\r \x01(\x08\x12\x0e\n\x06silent\x18\x0e \x01(\x08\x12\x19\n\x11\x66\x61tal_deprecation\x18\x0f \x03(\t\x12\x1b\n\x13silence_deprecation\x18\x10 \x03(\t\x12\x1a\n\x12\x66uture_deprecation\x18\x11 \x03(\t\x1a\xac\x01\n\x0bStringInput\x12\x0e\n\x06source\x18\x01 \x01(\t\x12\x0b\n\x03url\x18\x02 \x01(\t\x12.\n\x06syntax\x18\x03 \x01(\x0e\x32\x1e.sass.embedded_protocol.Syntax\x12P\n\x08importer\x18\x04 \x01(\x0b\x32>.sass.embedded_protocol.InboundMessage.CompileRequest.Importer\x1a\xc5\x01\n\x08Importer\x12\x0e\n\x04path\x18\x01 \x01(\tH\x00\x12\x15\n\x0bimporter_id\x18\x02 \x01(\rH\x00\x12\x1a\n\x10\x66ile_importer_id\x18\x03 \x01(\rH\x00\x12L\n\x15node_package_importer\x18\x05 \x01(\x0b\x32+.sass.embedded_protocol.NodePackageImporterH\x00\x12\x1c\n\x14non_canonical_scheme\x18\x04 \x03(\tB\n\n\x08importerB\x07\n\x05inputJ\x04\x08\x01\x10\x02\x1aL\n\x14\x43\x61nonicalizeResponse\x12\n\n\x02id\x18\x01 \x01(\r\x12\r\n\x03url\x18\x02 \x01(\tH\x00\x12\x0f\n\x05\x65rror\x18\x03 \x01(\tH\x00\x42\x08\n\x06result\x1a\x93\x02\n\x0eImportResponse\x12\n\n\x02id\x18\x01 \x01(\r\x12V\n\x07success\x18\x02 \x01(\x0b\x32\x43.sass.embedded_protocol.InboundMessage.ImportResponse.ImportSuccessH\x00\x12\x0f\n\x05\x65rror\x18\x03 \x01(\tH\x00\x1a\x81\x01\n\rImportSuccess\x12\x10\n\x08\x63ontents\x18\x01 \x01(\t\x12.\n\x06syntax\x18\x02 \x01(\x0e\x32\x1e.sass.embedded_protocol.Syntax\x12\x1b\n\x0esource_map_url\x18\x03 \x01(\tH\x00\x88\x01\x01\x42\x11\n\x0f_source_map_urlB\x08\n\x06result\x1aO\n\x12\x46ileImportResponse\x12\n\n\x02id\x18\x01 \x01(\r\x12\x12\n\x08\x66ile_url\x18\x02 \x01(\tH\x00\x12\x0f\n\x05\x65rror\x18\x03 \x01(\tH\x00\x42\x08\n\x06result\x1a\x90\x01\n\x14\x46unctionCallResponse\x12\n\n\x02id\x18\x01 \x01(\r\x12\x30\n\x07success\x18\x02 \x01(\x0b\x32\x1d.sass.embedded_protocol.ValueH\x00\x12\x0f\n\x05\x65rror\x18\x03 \x01(\tH\x00\x12\x1f\n\x17\x61\x63\x63\x65ssed_argument_lists\x18\x04 \x03(\rB\x08\n\x06resultB\t\n\x07message\"\xcb\x0f\n\x0fOutboundMessage\x12\x36\n\x05\x65rror\x18\x01 \x01(\x0b\x32%.sass.embedded_protocol.ProtocolErrorH\x00\x12S\n\x10\x63ompile_response\x18\x02 \x01(\x0b\x32\x37.sass.embedded_protocol.OutboundMessage.CompileResponseH\x00\x12\x45\n\tlog_event\x18\x03 \x01(\x0b\x32\x30.sass.embedded_protocol.OutboundMessage.LogEventH\x00\x12[\n\x14\x63\x61nonicalize_request\x18\x04 \x01(\x0b\x32;.sass.embedded_protocol.OutboundMessage.CanonicalizeRequestH\x00\x12O\n\x0eimport_request\x18\x05 \x01(\x0b\x32\x35.sass.embedded_protocol.OutboundMessage.ImportRequestH\x00\x12X\n\x13\x66ile_import_request\x18\x06 \x01(\x0b\x32\x39.sass.embedded_protocol.OutboundMessage.FileImportRequestH\x00\x12\\\n\x15\x66unction_call_request\x18\x07 \x01(\x0b\x32;.sass.embedded_protocol.OutboundMessage.FunctionCallRequestH\x00\x12S\n\x10version_response\x18\x08 \x01(\x0b\x32\x37.sass.embedded_protocol.OutboundMessage.VersionResponseH\x00\x1a\x8e\x01\n\x0fVersionResponse\x12\n\n\x02id\x18\x05 \x01(\r\x12\x18\n\x10protocol_version\x18\x01 \x01(\t\x12\x18\n\x10\x63ompiler_version\x18\x02 \x01(\t\x12\x1e\n\x16implementation_version\x18\x03 \x01(\t\x12\x1b\n\x13implementation_name\x18\x04 \x01(\t\x1a\xa2\x03\n\x0f\x43ompileResponse\x12Y\n\x07success\x18\x02 \x01(\x0b\x32\x46.sass.embedded_protocol.OutboundMessage.CompileResponse.CompileSuccessH\x00\x12Y\n\x07\x66\x61ilure\x18\x03 \x01(\x0b\x32\x46.sass.embedded_protocol.OutboundMessage.CompileResponse.CompileFailureH\x00\x12\x13\n\x0bloaded_urls\x18\x04 \x03(\t\x1a\x37\n\x0e\x43ompileSuccess\x12\x0b\n\x03\x63ss\x18\x01 \x01(\t\x12\x12\n\nsource_map\x18\x02 \x01(\tJ\x04\x08\x03\x10\x04\x1a{\n\x0e\x43ompileFailure\x12\x0f\n\x07message\x18\x01 \x01(\t\x12\x30\n\x04span\x18\x02 \x01(\x0b\x32\".sass.embedded_protocol.SourceSpan\x12\x13\n\x0bstack_trace\x18\x03 \x01(\t\x12\x11\n\tformatted\x18\x04 \x01(\tB\x08\n\x06resultJ\x04\x08\x01\x10\x02\x1a\xf1\x01\n\x08LogEvent\x12\x32\n\x04type\x18\x02 \x01(\x0e\x32$.sass.embedded_protocol.LogEventType\x12\x0f\n\x07message\x18\x03 \x01(\t\x12\x35\n\x04span\x18\x04 \x01(\x0b\x32\".sass.embedded_protocol.SourceSpanH\x00\x88\x01\x01\x12\x13\n\x0bstack_trace\x18\x05 \x01(\t\x12\x11\n\tformatted\x18\x06 \x01(\t\x12\x1d\n\x10\x64\x65precation_type\x18\x07 \x01(\tH\x01\x88\x01\x01\x42\x07\n\x05_spanB\x13\n\x11_deprecation_typeJ\x04\x08\x01\x10\x02\x1a\x8e\x01\n\x13\x43\x61nonicalizeRequest\x12\n\n\x02id\x18\x01 \x01(\r\x12\x13\n\x0bimporter_id\x18\x03 \x01(\r\x12\x0b\n\x03url\x18\x04 \x01(\t\x12\x13\n\x0b\x66rom_import\x18\x05 \x01(\x08\x12\x1b\n\x0e\x63ontaining_url\x18\x06 \x01(\tH\x00\x88\x01\x01\x42\x11\n\x0f_containing_urlJ\x04\x08\x02\x10\x03\x1a\x43\n\rImportRequest\x12\n\n\x02id\x18\x01 \x01(\r\x12\x13\n\x0bimporter_id\x18\x03 \x01(\r\x12\x0b\n\x03url\x18\x04 \x01(\tJ\x04\x08\x02\x10\x03\x1a\x8c\x01\n\x11\x46ileImportRequest\x12\n\n\x02id\x18\x01 \x01(\r\x12\x13\n\x0bimporter_id\x18\x03 \x01(\r\x12\x0b\n\x03url\x18\x04 \x01(\t\x12\x13\n\x0b\x66rom_import\x18\x05 \x01(\x08\x12\x1b\n\x0e\x63ontaining_url\x18\x06 \x01(\tH\x00\x88\x01\x01\x42\x11\n\x0f_containing_urlJ\x04\x08\x02\x10\x03\x1a\x8e\x01\n\x13\x46unctionCallRequest\x12\n\n\x02id\x18\x01 \x01(\r\x12\x0e\n\x04name\x18\x03 \x01(\tH\x00\x12\x15\n\x0b\x66unction_id\x18\x04 \x01(\rH\x00\x12\x30\n\targuments\x18\x05 \x03(\x0b\x32\x1d.sass.embedded_protocol.ValueB\x0c\n\nidentifierJ\x04\x08\x02\x10\x03\x42\t\n\x07message\"e\n\rProtocolError\x12\x37\n\x04type\x18\x01 \x01(\x0e\x32).sass.embedded_protocol.ProtocolErrorType\x12\n\n\x02id\x18\x02 \x01(\r\x12\x0f\n\x07message\x18\x03 \x01(\t\"\x87\x02\n\nSourceSpan\x12\x0c\n\x04text\x18\x01 \x01(\t\x12@\n\x05start\x18\x02 \x01(\x0b\x32\x31.sass.embedded_protocol.SourceSpan.SourceLocation\x12\x43\n\x03\x65nd\x18\x03 \x01(\x0b\x32\x31.sass.embedded_protocol.SourceSpan.SourceLocationH\x00\x88\x01\x01\x12\x0b\n\x03url\x18\x04 \x01(\t\x12\x0f\n\x07\x63ontext\x18\x05 \x01(\t\x1a>\n\x0eSourceLocation\x12\x0e\n\x06offset\x18\x01 \x01(\r\x12\x0c\n\x04line\x18\x02 \x01(\r\x12\x0e\n\x06\x63olumn\x18\x03 \x01(\rB\x06\n\x04_end\"\xb8\x13\n\x05Value\x12\x36\n\x06string\x18\x01 \x01(\x0b\x32$.sass.embedded_protocol.Value.StringH\x00\x12\x36\n\x06number\x18\x02 \x01(\x0b\x32$.sass.embedded_protocol.Value.NumberH\x00\x12;\n\trgb_color\x18\x03 \x01(\x0b\x32&.sass.embedded_protocol.Value.RgbColorH\x00\x12;\n\thsl_color\x18\x04 \x01(\x0b\x32&.sass.embedded_protocol.Value.HslColorH\x00\x12\x32\n\x04list\x18\x05 \x01(\x0b\x32\".sass.embedded_protocol.Value.ListH\x00\x12\x30\n\x03map\x18\x06 \x01(\x0b\x32!.sass.embedded_protocol.Value.MapH\x00\x12;\n\tsingleton\x18\x07 \x01(\x0e\x32&.sass.embedded_protocol.SingletonValueH\x00\x12K\n\x11\x63ompiler_function\x18\x08 \x01(\x0b\x32..sass.embedded_protocol.Value.CompilerFunctionH\x00\x12\x43\n\rhost_function\x18\t \x01(\x0b\x32*.sass.embedded_protocol.Value.HostFunctionH\x00\x12\x43\n\rargument_list\x18\n \x01(\x0b\x32*.sass.embedded_protocol.Value.ArgumentListH\x00\x12;\n\thwb_color\x18\x0b \x01(\x0b\x32&.sass.embedded_protocol.Value.HwbColorH\x00\x12@\n\x0b\x63\x61lculation\x18\x0c \x01(\x0b\x32).sass.embedded_protocol.Value.CalculationH\x00\x12\x45\n\x0e\x63ompiler_mixin\x18\r \x01(\x0b\x32+.sass.embedded_protocol.Value.CompilerMixinH\x00\x1a&\n\x06String\x12\x0c\n\x04text\x18\x01 \x01(\t\x12\x0e\n\x06quoted\x18\x02 \x01(\x08\x1a\x41\n\x06Number\x12\r\n\x05value\x18\x01 \x01(\x01\x12\x12\n\nnumerators\x18\x02 \x03(\t\x12\x14\n\x0c\x64\x65nominators\x18\x03 \x03(\t\x1a\x43\n\x08RgbColor\x12\x0b\n\x03red\x18\x01 \x01(\r\x12\r\n\x05green\x18\x02 \x01(\r\x12\x0c\n\x04\x62lue\x18\x03 \x01(\r\x12\r\n\x05\x61lpha\x18\x04 \x01(\x01\x1aM\n\x08HslColor\x12\x0b\n\x03hue\x18\x01 \x01(\x01\x12\x12\n\nsaturation\x18\x02 \x01(\x01\x12\x11\n\tlightness\x18\x03 \x01(\x01\x12\r\n\x05\x61lpha\x18\x04 \x01(\x01\x1aL\n\x08HwbColor\x12\x0b\n\x03hue\x18\x01 \x01(\x01\x12\x11\n\twhiteness\x18\x02 \x01(\x01\x12\x11\n\tblackness\x18\x03 \x01(\x01\x12\r\n\x05\x61lpha\x18\x04 \x01(\x01\x1a\x87\x01\n\x04List\x12\x38\n\tseparator\x18\x01 \x01(\x0e\x32%.sass.embedded_protocol.ListSeparator\x12\x14\n\x0chas_brackets\x18\x02 \x01(\x08\x12/\n\x08\x63ontents\x18\x03 \x03(\x0b\x32\x1d.sass.embedded_protocol.Value\x1a\xa2\x01\n\x03Map\x12\x38\n\x07\x65ntries\x18\x01 \x03(\x0b\x32\'.sass.embedded_protocol.Value.Map.Entry\x1a\x61\n\x05\x45ntry\x12*\n\x03key\x18\x01 \x01(\x0b\x32\x1d.sass.embedded_protocol.Value\x12,\n\x05value\x18\x02 \x01(\x0b\x32\x1d.sass.embedded_protocol.Value\x1a\x1e\n\x10\x43ompilerFunction\x12\n\n\x02id\x18\x01 \x01(\r\x1a-\n\x0cHostFunction\x12\n\n\x02id\x18\x01 \x01(\r\x12\x11\n\tsignature\x18\x02 \x01(\t\x1a\x1b\n\rCompilerMixin\x12\n\n\x02id\x18\x01 \x01(\r\x1a\xa1\x02\n\x0c\x41rgumentList\x12\n\n\x02id\x18\x01 \x01(\r\x12\x38\n\tseparator\x18\x02 \x01(\x0e\x32%.sass.embedded_protocol.ListSeparator\x12/\n\x08\x63ontents\x18\x03 \x03(\x0b\x32\x1d.sass.embedded_protocol.Value\x12J\n\x08keywords\x18\x04 \x03(\x0b\x32\x38.sass.embedded_protocol.Value.ArgumentList.KeywordsEntry\x1aN\n\rKeywordsEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12,\n\x05value\x18\x02 \x01(\x0b\x32\x1d.sass.embedded_protocol.Value:\x02\x38\x01\x1a\xef\x04\n\x0b\x43\x61lculation\x12\x0c\n\x04name\x18\x01 \x01(\t\x12M\n\targuments\x18\x02 \x03(\x0b\x32:.sass.embedded_protocol.Value.Calculation.CalculationValue\x1a\x95\x02\n\x10\x43\x61lculationValue\x12\x36\n\x06number\x18\x01 \x01(\x0b\x32$.sass.embedded_protocol.Value.NumberH\x00\x12\x10\n\x06string\x18\x02 \x01(\tH\x00\x12\x17\n\rinterpolation\x18\x03 \x01(\tH\x00\x12S\n\toperation\x18\x04 \x01(\x0b\x32>.sass.embedded_protocol.Value.Calculation.CalculationOperationH\x00\x12@\n\x0b\x63\x61lculation\x18\x05 \x01(\x0b\x32).sass.embedded_protocol.Value.CalculationH\x00\x42\x07\n\x05value\x1a\xea\x01\n\x14\x43\x61lculationOperation\x12=\n\x08operator\x18\x01 \x01(\x0e\x32+.sass.embedded_protocol.CalculationOperator\x12H\n\x04left\x18\x02 \x01(\x0b\x32:.sass.embedded_protocol.Value.Calculation.CalculationValue\x12I\n\x05right\x18\x03 \x01(\x0b\x32:.sass.embedded_protocol.Value.Calculation.CalculationValueB\x07\n\x05value\"4\n\x13NodePackageImporter\x12\x1d\n\x15\x65ntry_point_directory\x18\x01 \x01(\t*+\n\x0bOutputStyle\x12\x0c\n\x08\x45XPANDED\x10\x00\x12\x0e\n\nCOMPRESSED\x10\x01*)\n\x06Syntax\x12\x08\n\x04SCSS\x10\x00\x12\x0c\n\x08INDENTED\x10\x01\x12\x07\n\x03\x43SS\x10\x02*?\n\x0cLogEventType\x12\x0b\n\x07WARNING\x10\x00\x12\x17\n\x13\x44\x45PRECATION_WARNING\x10\x01\x12\t\n\x05\x44\x45\x42UG\x10\x02*8\n\x11ProtocolErrorType\x12\t\n\x05PARSE\x10\x00\x12\n\n\x06PARAMS\x10\x01\x12\x0c\n\x08INTERNAL\x10\x02*?\n\rListSeparator\x12\t\n\x05\x43OMMA\x10\x00\x12\t\n\x05SPACE\x10\x01\x12\t\n\x05SLASH\x10\x02\x12\r\n\tUNDECIDED\x10\x03*/\n\x0eSingletonValue\x12\x08\n\x04TRUE\x10\x00\x12\t\n\x05\x46\x41LSE\x10\x01\x12\x08\n\x04NULL\x10\x02*A\n\x13\x43\x61lculationOperator\x12\x08\n\x04PLUS\x10\x00\x12\t\n\x05MINUS\x10\x01\x12\t\n\x05TIMES\x10\x02\x12\n\n\x06\x44IVIDE\x10\x03\x42#\n\x1f\x63om.sass_lang.embedded_protocolP\x01\x62\x06proto3"
|
9
|
+
|
10
|
+
pool = Google::Protobuf::DescriptorPool.generated_pool
|
11
|
+
pool.add_serialized_file(descriptor_data)
|
12
|
+
|
13
|
+
module Sass
|
14
|
+
module EmbeddedProtocol
|
15
|
+
InboundMessage = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("sass.embedded_protocol.InboundMessage").msgclass
|
16
|
+
InboundMessage::VersionRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("sass.embedded_protocol.InboundMessage.VersionRequest").msgclass
|
17
|
+
InboundMessage::CompileRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("sass.embedded_protocol.InboundMessage.CompileRequest").msgclass
|
18
|
+
InboundMessage::CompileRequest::StringInput = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("sass.embedded_protocol.InboundMessage.CompileRequest.StringInput").msgclass
|
19
|
+
InboundMessage::CompileRequest::Importer = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("sass.embedded_protocol.InboundMessage.CompileRequest.Importer").msgclass
|
20
|
+
InboundMessage::CanonicalizeResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("sass.embedded_protocol.InboundMessage.CanonicalizeResponse").msgclass
|
21
|
+
InboundMessage::ImportResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("sass.embedded_protocol.InboundMessage.ImportResponse").msgclass
|
22
|
+
InboundMessage::ImportResponse::ImportSuccess = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("sass.embedded_protocol.InboundMessage.ImportResponse.ImportSuccess").msgclass
|
23
|
+
InboundMessage::FileImportResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("sass.embedded_protocol.InboundMessage.FileImportResponse").msgclass
|
24
|
+
InboundMessage::FunctionCallResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("sass.embedded_protocol.InboundMessage.FunctionCallResponse").msgclass
|
25
|
+
OutboundMessage = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("sass.embedded_protocol.OutboundMessage").msgclass
|
26
|
+
OutboundMessage::VersionResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("sass.embedded_protocol.OutboundMessage.VersionResponse").msgclass
|
27
|
+
OutboundMessage::CompileResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("sass.embedded_protocol.OutboundMessage.CompileResponse").msgclass
|
28
|
+
OutboundMessage::CompileResponse::CompileSuccess = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("sass.embedded_protocol.OutboundMessage.CompileResponse.CompileSuccess").msgclass
|
29
|
+
OutboundMessage::CompileResponse::CompileFailure = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("sass.embedded_protocol.OutboundMessage.CompileResponse.CompileFailure").msgclass
|
30
|
+
OutboundMessage::LogEvent = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("sass.embedded_protocol.OutboundMessage.LogEvent").msgclass
|
31
|
+
OutboundMessage::CanonicalizeRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("sass.embedded_protocol.OutboundMessage.CanonicalizeRequest").msgclass
|
32
|
+
OutboundMessage::ImportRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("sass.embedded_protocol.OutboundMessage.ImportRequest").msgclass
|
33
|
+
OutboundMessage::FileImportRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("sass.embedded_protocol.OutboundMessage.FileImportRequest").msgclass
|
34
|
+
OutboundMessage::FunctionCallRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("sass.embedded_protocol.OutboundMessage.FunctionCallRequest").msgclass
|
35
|
+
ProtocolError = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("sass.embedded_protocol.ProtocolError").msgclass
|
36
|
+
SourceSpan = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("sass.embedded_protocol.SourceSpan").msgclass
|
37
|
+
SourceSpan::SourceLocation = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("sass.embedded_protocol.SourceSpan.SourceLocation").msgclass
|
38
|
+
Value = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("sass.embedded_protocol.Value").msgclass
|
39
|
+
Value::String = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("sass.embedded_protocol.Value.String").msgclass
|
40
|
+
Value::Number = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("sass.embedded_protocol.Value.Number").msgclass
|
41
|
+
Value::RgbColor = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("sass.embedded_protocol.Value.RgbColor").msgclass
|
42
|
+
Value::HslColor = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("sass.embedded_protocol.Value.HslColor").msgclass
|
43
|
+
Value::HwbColor = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("sass.embedded_protocol.Value.HwbColor").msgclass
|
44
|
+
Value::List = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("sass.embedded_protocol.Value.List").msgclass
|
45
|
+
Value::Map = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("sass.embedded_protocol.Value.Map").msgclass
|
46
|
+
Value::Map::Entry = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("sass.embedded_protocol.Value.Map.Entry").msgclass
|
47
|
+
Value::CompilerFunction = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("sass.embedded_protocol.Value.CompilerFunction").msgclass
|
48
|
+
Value::HostFunction = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("sass.embedded_protocol.Value.HostFunction").msgclass
|
49
|
+
Value::CompilerMixin = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("sass.embedded_protocol.Value.CompilerMixin").msgclass
|
50
|
+
Value::ArgumentList = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("sass.embedded_protocol.Value.ArgumentList").msgclass
|
51
|
+
Value::Calculation = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("sass.embedded_protocol.Value.Calculation").msgclass
|
52
|
+
Value::Calculation::CalculationValue = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("sass.embedded_protocol.Value.Calculation.CalculationValue").msgclass
|
53
|
+
Value::Calculation::CalculationOperation = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("sass.embedded_protocol.Value.Calculation.CalculationOperation").msgclass
|
54
|
+
NodePackageImporter = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("sass.embedded_protocol.NodePackageImporter").msgclass
|
55
|
+
OutputStyle = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("sass.embedded_protocol.OutputStyle").enummodule
|
56
|
+
Syntax = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("sass.embedded_protocol.Syntax").enummodule
|
57
|
+
LogEventType = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("sass.embedded_protocol.LogEventType").enummodule
|
58
|
+
ProtocolErrorType = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("sass.embedded_protocol.ProtocolErrorType").enummodule
|
59
|
+
ListSeparator = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("sass.embedded_protocol.ListSeparator").enummodule
|
60
|
+
SingletonValue = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("sass.embedded_protocol.SingletonValue").enummodule
|
61
|
+
CalculationOperator = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("sass.embedded_protocol.CalculationOperator").enummodule
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Sass
|
4
|
+
module CalculationValue
|
5
|
+
# A binary operation that can appear in a SassCalculation.
|
6
|
+
#
|
7
|
+
# @see https://sass-lang.com/documentation/js-api/classes/calculationoperation/
|
8
|
+
class CalculationOperation
|
9
|
+
include CalculationValue
|
10
|
+
|
11
|
+
OPERATORS = %w[+ - * /].freeze
|
12
|
+
|
13
|
+
private_constant :OPERATORS
|
14
|
+
|
15
|
+
# @param operator [::String]
|
16
|
+
# @param left [CalculationValue]
|
17
|
+
# @param right [CalculationValue]
|
18
|
+
def initialize(operator, left, right)
|
19
|
+
raise Sass::ScriptError, "Invalid operator: #{operator}" unless OPERATORS.include?(operator)
|
20
|
+
|
21
|
+
@operator = operator.freeze
|
22
|
+
@left = assert_calculation_value(left, 'left')
|
23
|
+
@right = assert_calculation_value(right, 'right')
|
24
|
+
end
|
25
|
+
|
26
|
+
# @return [::String]
|
27
|
+
attr_reader :operator
|
28
|
+
|
29
|
+
# @return [CalculationValue]
|
30
|
+
attr_reader :left
|
31
|
+
|
32
|
+
# @return [CalculationValue]
|
33
|
+
attr_reader :right
|
34
|
+
|
35
|
+
# @return [::Boolean]
|
36
|
+
def ==(other)
|
37
|
+
other.is_a?(Sass::CalculationValue::CalculationOperation) &&
|
38
|
+
other.operator == operator &&
|
39
|
+
other.left == left &&
|
40
|
+
other.right == right
|
41
|
+
end
|
42
|
+
|
43
|
+
# @return [Integer]
|
44
|
+
def hash
|
45
|
+
@hash ||= [operator, left, right].hash
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Sass
|
4
|
+
# The type of values that can be arguments to a SassCalculation.
|
5
|
+
#
|
6
|
+
# @see https://sass-lang.com/documentation/js-api/types/calculationvalue/
|
7
|
+
module CalculationValue
|
8
|
+
private
|
9
|
+
|
10
|
+
def assert_calculation_value(value, name = nil)
|
11
|
+
if !value.is_a?(Sass::CalculationValue) || (value.is_a?(Sass::Value::String) && value.quoted?)
|
12
|
+
raise Sass::ScriptError.new(
|
13
|
+
"#{value} must be one of SassNumber, unquoted SassString, SassCalculation, CalculationOperation", name
|
14
|
+
)
|
15
|
+
end
|
16
|
+
|
17
|
+
value
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
require_relative 'calculation_value/calculation_operation'
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Sass
|
4
|
+
# Contextual information passed to `canonicalize` and `find_file_url`.
|
5
|
+
# Not all importers will need this information to resolve loads, but some may find it useful.
|
6
|
+
#
|
7
|
+
# @see https://sass-lang.com/documentation/js-api/interfaces/canonicalizecontext/
|
8
|
+
class CanonicalizeContext
|
9
|
+
# @return [String, nil]
|
10
|
+
attr_reader :containing_url
|
11
|
+
|
12
|
+
# @return [Boolean]
|
13
|
+
attr_reader :from_import
|
14
|
+
|
15
|
+
# @!visibility private
|
16
|
+
def initialize(canonicalize_request)
|
17
|
+
@containing_url = canonicalize_request.containing_url == '' ? nil : canonicalize_request.containing_url
|
18
|
+
@from_import = canonicalize_request.from_import
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Sass
|
4
|
+
# The result of compiling Sass to CSS. Returned by {Sass.compile} and {Sass.compile_string}.
|
5
|
+
#
|
6
|
+
# @see https://sass-lang.com/documentation/js-api/interfaces/compileresult/
|
7
|
+
class CompileResult
|
8
|
+
# @return [String]
|
9
|
+
attr_reader :css
|
10
|
+
|
11
|
+
# @return [String, nil]
|
12
|
+
attr_reader :source_map
|
13
|
+
|
14
|
+
# @return [Array<String>]
|
15
|
+
attr_reader :loaded_urls
|
16
|
+
|
17
|
+
# @!visibility private
|
18
|
+
def initialize(css, source_map, loaded_urls)
|
19
|
+
@css = css
|
20
|
+
@source_map = source_map
|
21
|
+
@loaded_urls = loaded_urls
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Sass
|
4
|
+
class Compiler
|
5
|
+
# The {Channel} class.
|
6
|
+
#
|
7
|
+
# It manages the lifecycle of {Dispatcher}.
|
8
|
+
class Channel
|
9
|
+
def initialize(dispatcher_class)
|
10
|
+
@dispatcher_class = dispatcher_class
|
11
|
+
@dispatcher = @dispatcher_class.new
|
12
|
+
@mutex = Mutex.new
|
13
|
+
end
|
14
|
+
|
15
|
+
def close
|
16
|
+
@mutex.synchronize do
|
17
|
+
unless @dispatcher.nil?
|
18
|
+
@dispatcher.close
|
19
|
+
@dispatcher = nil
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def closed?
|
25
|
+
@mutex.synchronize do
|
26
|
+
@dispatcher.nil?
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def stream(host)
|
31
|
+
@mutex.synchronize do
|
32
|
+
raise IOError, 'closed compiler' if @dispatcher.nil?
|
33
|
+
|
34
|
+
Stream.new(@dispatcher, host)
|
35
|
+
rescue Errno::EBUSY
|
36
|
+
@dispatcher = @dispatcher_class.new
|
37
|
+
Stream.new(@dispatcher, host)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
# The {Stream} between {Dispatcher} and {Host}.
|
42
|
+
class Stream
|
43
|
+
attr_reader :id
|
44
|
+
|
45
|
+
def initialize(dispatcher, host)
|
46
|
+
@dispatcher = dispatcher
|
47
|
+
@id = @dispatcher.subscribe(host)
|
48
|
+
end
|
49
|
+
|
50
|
+
def close
|
51
|
+
@dispatcher.unsubscribe(@id)
|
52
|
+
end
|
53
|
+
|
54
|
+
def error(...)
|
55
|
+
@dispatcher.error(...)
|
56
|
+
end
|
57
|
+
|
58
|
+
def send_proto(...)
|
59
|
+
@dispatcher.send_proto(...)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
private_constant :Stream
|
64
|
+
end
|
65
|
+
|
66
|
+
private_constant :Channel
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'open3'
|
4
|
+
|
5
|
+
require_relative '../../../ext/sass/cli'
|
6
|
+
|
7
|
+
module Sass
|
8
|
+
class Compiler
|
9
|
+
# The stdio based {Connection} between the {Dispatcher} and the compiler.
|
10
|
+
#
|
11
|
+
# It runs the `sass --embedded` command.
|
12
|
+
class Connection
|
13
|
+
def initialize(dispatcher)
|
14
|
+
@mutex = Mutex.new
|
15
|
+
@stdin, @stdout, @stderr, @wait_thread = begin
|
16
|
+
Open3.popen3(*CLI::COMMAND, '--embedded', chdir: __dir__)
|
17
|
+
rescue Errno::ENOENT
|
18
|
+
require_relative '../elf'
|
19
|
+
|
20
|
+
raise if ELF::INTERPRETER.nil?
|
21
|
+
|
22
|
+
Open3.popen3(ELF::INTERPRETER, *CLI::COMMAND, '--embedded', chdir: __dir__)
|
23
|
+
end
|
24
|
+
|
25
|
+
@stdin.binmode
|
26
|
+
|
27
|
+
Thread.new do
|
28
|
+
Thread.current.name = "sass-embedded-process-stdout-poller-#{@wait_thread.pid}"
|
29
|
+
|
30
|
+
# # https://dart.dev/tools/dart-devtools
|
31
|
+
# if 'dart' == File.basename(CLI::COMMAND.first, '.exe') && CLI::COMMAND.include?('--observe')
|
32
|
+
# Kernel.warn(@stdout.readline, uplevel: 0)
|
33
|
+
# Kernel.warn(@stdout.readline, uplevel: 0)
|
34
|
+
# end
|
35
|
+
|
36
|
+
@stdout.binmode
|
37
|
+
|
38
|
+
loop do
|
39
|
+
length = Varint.read(@stdout)
|
40
|
+
id = Varint.read(@stdout)
|
41
|
+
proto = @stdout.read(length - Varint.length(id))
|
42
|
+
dispatcher.receive_proto(id, proto)
|
43
|
+
end
|
44
|
+
rescue IOError, Errno::EBADF, Errno::EPROTO => e
|
45
|
+
dispatcher.error(e)
|
46
|
+
@mutex.synchronize do
|
47
|
+
@stdout.close
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
Thread.new do
|
52
|
+
Thread.current.name = "sass-embedded-process-stderr-poller-#{@wait_thread.pid}"
|
53
|
+
loop do
|
54
|
+
Kernel.warn(@stderr.readline, uplevel: 0)
|
55
|
+
end
|
56
|
+
rescue IOError, Errno::EBADF
|
57
|
+
@mutex.synchronize do
|
58
|
+
@stderr.close
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
@wait_thread.name = "sass-embedded-process-waiter-#{@wait_thread.pid}"
|
63
|
+
end
|
64
|
+
|
65
|
+
def close
|
66
|
+
@mutex.synchronize do
|
67
|
+
@stdin.close
|
68
|
+
@wait_thread.join
|
69
|
+
@stdout.close
|
70
|
+
@stderr.close
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def closed?
|
75
|
+
@mutex.synchronize do
|
76
|
+
@stdin.closed? && !@wait_thread.alive?
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def write(id, proto)
|
81
|
+
buffer = []
|
82
|
+
Varint.write(buffer, Varint.length(id) + proto.length)
|
83
|
+
Varint.write(buffer, id)
|
84
|
+
@mutex.synchronize do
|
85
|
+
@stdin.write(buffer.pack('C*'), proto)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
private_constant :Connection
|
91
|
+
end
|
92
|
+
end
|
@@ -0,0 +1,115 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Sass
|
4
|
+
class Compiler
|
5
|
+
# The {Dispatcher} class.
|
6
|
+
#
|
7
|
+
# It dispatches messages between multiple instances of {Host} and a single {Connection} to the compiler.
|
8
|
+
class Dispatcher
|
9
|
+
def initialize
|
10
|
+
@id = 1
|
11
|
+
@observers = {}.compare_by_identity
|
12
|
+
@mutex = Mutex.new
|
13
|
+
@connection = Connection.new(self)
|
14
|
+
ForkTracker.add(self)
|
15
|
+
end
|
16
|
+
|
17
|
+
def subscribe(observer)
|
18
|
+
@mutex.synchronize do
|
19
|
+
raise Errno::EBUSY if _closed?
|
20
|
+
|
21
|
+
id = @id
|
22
|
+
@id = id.next
|
23
|
+
@observers[id] = observer
|
24
|
+
id
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def unsubscribe(id)
|
29
|
+
@mutex.synchronize do
|
30
|
+
@observers.delete(id)
|
31
|
+
|
32
|
+
return unless @observers.empty?
|
33
|
+
|
34
|
+
if _closed?
|
35
|
+
Thread.new do
|
36
|
+
close
|
37
|
+
end
|
38
|
+
else
|
39
|
+
_idle
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def close
|
45
|
+
@mutex.synchronize do
|
46
|
+
_close
|
47
|
+
end
|
48
|
+
@connection.close
|
49
|
+
ForkTracker.delete(self)
|
50
|
+
end
|
51
|
+
|
52
|
+
def closed?
|
53
|
+
@connection.closed?
|
54
|
+
end
|
55
|
+
|
56
|
+
def error(error)
|
57
|
+
observers = @mutex.synchronize do
|
58
|
+
_close
|
59
|
+
@observers.values
|
60
|
+
end
|
61
|
+
|
62
|
+
if observers.empty?
|
63
|
+
close
|
64
|
+
else
|
65
|
+
observers.each do |observer|
|
66
|
+
observer.error(error)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def receive_proto(id, proto)
|
72
|
+
case id
|
73
|
+
when 1...0xffffffff
|
74
|
+
@mutex.synchronize { @observers[id] }&.receive_proto(proto)
|
75
|
+
when 0
|
76
|
+
outbound_message = EmbeddedProtocol::OutboundMessage.decode(proto)
|
77
|
+
oneof = outbound_message.message
|
78
|
+
message = outbound_message.public_send(oneof)
|
79
|
+
@mutex.synchronize { @observers[message.id] }&.public_send(oneof, message)
|
80
|
+
when 0xffffffff
|
81
|
+
outbound_message = EmbeddedProtocol::OutboundMessage.decode(proto)
|
82
|
+
oneof = outbound_message.message
|
83
|
+
message = outbound_message.public_send(oneof)
|
84
|
+
raise Errno::EPROTO, message.message
|
85
|
+
else
|
86
|
+
raise Errno::EPROTO
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def send_proto(...)
|
91
|
+
@connection.write(...)
|
92
|
+
end
|
93
|
+
|
94
|
+
private
|
95
|
+
|
96
|
+
def _close
|
97
|
+
@id = 0xffffffff
|
98
|
+
end
|
99
|
+
|
100
|
+
def _closed?
|
101
|
+
@id == 0xffffffff
|
102
|
+
end
|
103
|
+
|
104
|
+
def _idle
|
105
|
+
@id = 1
|
106
|
+
end
|
107
|
+
|
108
|
+
def _idle?
|
109
|
+
@id == 1
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
private_constant :Dispatcher
|
114
|
+
end
|
115
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Sass
|
4
|
+
class Compiler
|
5
|
+
class Host
|
6
|
+
# The {FunctionRegistry} class.
|
7
|
+
#
|
8
|
+
# It stores sass custom functions and handles function calls.
|
9
|
+
class FunctionRegistry
|
10
|
+
attr_reader :global_functions
|
11
|
+
|
12
|
+
def initialize(functions, alert_color:)
|
13
|
+
functions = functions.transform_keys(&:to_s)
|
14
|
+
|
15
|
+
@global_functions = functions.keys
|
16
|
+
@functions_by_name = functions.transform_keys do |signature|
|
17
|
+
index = signature.index('(')
|
18
|
+
if index
|
19
|
+
signature.slice(0, index)
|
20
|
+
else
|
21
|
+
signature
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
@id = 0
|
26
|
+
@functions_by_id = {}.compare_by_identity
|
27
|
+
@ids_by_function = {}.compare_by_identity
|
28
|
+
|
29
|
+
@highlight = alert_color
|
30
|
+
end
|
31
|
+
|
32
|
+
def register(function)
|
33
|
+
@ids_by_function.fetch(function) do |fn|
|
34
|
+
id = @id
|
35
|
+
@id = id.next
|
36
|
+
|
37
|
+
@functions_by_id[id] = fn
|
38
|
+
@ids_by_function[fn] = id
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def function_call(function_call_request)
|
43
|
+
oneof = function_call_request.identifier
|
44
|
+
identifier = function_call_request.public_send(oneof)
|
45
|
+
function = case oneof
|
46
|
+
when :name
|
47
|
+
@functions_by_name[identifier]
|
48
|
+
when :function_id
|
49
|
+
@functions_by_id[identifier]
|
50
|
+
else
|
51
|
+
raise ArgumentError, "Unknown FunctionCallRequest.identifier #{identifier}"
|
52
|
+
end
|
53
|
+
|
54
|
+
arguments = function_call_request.arguments.map do |argument|
|
55
|
+
protofier.from_proto(argument)
|
56
|
+
end
|
57
|
+
|
58
|
+
success = protofier.to_proto(function.call(arguments))
|
59
|
+
accessed_argument_lists = arguments.filter_map do |argument|
|
60
|
+
if argument.is_a?(Sass::Value::ArgumentList) && argument.instance_eval { @keywords_accessed }
|
61
|
+
argument.instance_eval { @id }
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
EmbeddedProtocol::InboundMessage::FunctionCallResponse.new(
|
66
|
+
id: function_call_request.id,
|
67
|
+
success:,
|
68
|
+
accessed_argument_lists:
|
69
|
+
)
|
70
|
+
rescue StandardError => e
|
71
|
+
EmbeddedProtocol::InboundMessage::FunctionCallResponse.new(
|
72
|
+
id: function_call_request.id,
|
73
|
+
error: e.full_message(highlight: @highlight, order: :top)
|
74
|
+
)
|
75
|
+
end
|
76
|
+
|
77
|
+
private
|
78
|
+
|
79
|
+
def protofier
|
80
|
+
@protofier ||= Protofier.new(self)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
private_constant :FunctionRegistry
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|