sass-embedded 1.69.5 → 1.69.6

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.
@@ -0,0 +1,73 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Sass
4
+ # The {Serializer} module.
5
+ module Serializer
6
+ module_function
7
+
8
+ def dump_quoted_string(string)
9
+ include_double_quote = false
10
+ include_single_quote = false
11
+ buffer = [34]
12
+ string.each_codepoint do |codepoint|
13
+ case codepoint
14
+ when 34
15
+ return dump_double_quoted_string(string) if include_single_quote
16
+
17
+ include_double_quote = true
18
+ buffer << 34
19
+ when 39
20
+ return dump_double_quoted_string(string) if include_double_quote
21
+
22
+ include_single_quote = true
23
+ buffer << 39
24
+ when 92
25
+ buffer << 92 << 92
26
+ when 9
27
+ buffer << 9
28
+ else
29
+ if codepoint < 32 || codepoint > 126
30
+ buffer << 92
31
+ buffer.concat(codepoint.to_s(16).codepoints)
32
+ buffer << 32
33
+ else
34
+ buffer << codepoint
35
+ end
36
+ end
37
+ end
38
+ if include_double_quote
39
+ buffer[0] = 39
40
+ buffer << 39
41
+ else
42
+ buffer << 34
43
+ end
44
+ buffer.pack('U*')
45
+ end
46
+
47
+ def dump_double_quoted_string(string)
48
+ buffer = [34]
49
+ string.each_codepoint do |codepoint|
50
+ case codepoint
51
+ when 34
52
+ buffer << 92 << 34
53
+ when 92
54
+ buffer << 92 << 92
55
+ when 9
56
+ buffer << 9
57
+ else
58
+ if codepoint < 32 || codepoint > 126
59
+ buffer << 92
60
+ buffer.concat(codepoint.to_s(16).codepoints)
61
+ buffer << 32
62
+ else
63
+ buffer << codepoint
64
+ end
65
+ end
66
+ end
67
+ buffer << 34
68
+ buffer.pack('U*')
69
+ end
70
+ end
71
+
72
+ private_constant :Serializer
73
+ end
@@ -13,7 +13,7 @@ module Sass
13
13
  # @param keywords [Hash<::String, Value>]
14
14
  # @param separator [::String]
15
15
  def initialize(contents = [], keywords = {}, separator = ',')
16
- super(contents, separator: separator)
16
+ super(contents, separator:)
17
17
 
18
18
  @id = 0
19
19
  @keywords_accessed = false
@@ -183,7 +183,7 @@ module Sass
183
183
  def convert_value(new_numerator_units, new_denominator_units, name = nil)
184
184
  coerce_or_convert_value(new_numerator_units, new_denominator_units,
185
185
  coerce_unitless: false,
186
- name: name)
186
+ name:)
187
187
  end
188
188
 
189
189
  # @param other [Number]
@@ -200,9 +200,9 @@ module Sass
200
200
  def convert_value_to_match(other, name = nil, other_name = nil)
201
201
  coerce_or_convert_value(other.numerator_units, other.denominator_units,
202
202
  coerce_unitless: false,
203
- name: name,
204
- other: other,
205
- other_name: other_name)
203
+ name:,
204
+ other:,
205
+ other_name:)
206
206
  end
207
207
 
208
208
  # @param new_numerator_units [Array<::String>]
@@ -221,7 +221,7 @@ module Sass
221
221
  def coerce_value(new_numerator_units, new_denominator_units, name = nil)
222
222
  coerce_or_convert_value(new_numerator_units, new_denominator_units,
223
223
  coerce_unitless: true,
224
- name: name)
224
+ name:)
225
225
  end
226
226
 
227
227
  # @param unit [::String]
@@ -244,9 +244,9 @@ module Sass
244
244
  def coerce_value_to_match(other, name = nil, other_name = nil)
245
245
  coerce_or_convert_value(other.numerator_units, other.denominator_units,
246
246
  coerce_unitless: true,
247
- name: name,
248
- other: other,
249
- other_name: other_name)
247
+ name:,
248
+ other:,
249
+ other_name:)
250
250
  end
251
251
 
252
252
  # @return [Number]
data/lib/sass/value.rb CHANGED
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative 'calculation_value'
4
- require_relative 'script_error'
5
4
 
6
5
  module Sass
7
6
  # The abstract base class of Sass's value types.
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: 1.69.5
4
+ version: 1.69.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - なつき
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-10-26 00:00:00.000000000 Z
11
+ date: 2023-12-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: google-protobuf
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '3.23'
19
+ version: '3.25'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '3.23'
26
+ version: '3.25'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -55,32 +55,33 @@ files:
55
55
  - ext/sass/embedded_sass_pb.rb
56
56
  - ext/sass/expand-archive.ps1
57
57
  - ext/sass/package.json
58
- - ext/sass/win32_api.rb
59
58
  - lib/sass-embedded.rb
60
59
  - lib/sass/calculation_value.rb
61
60
  - lib/sass/calculation_value/calculation_operation.rb
62
61
  - lib/sass/canonicalize_context.rb
63
- - lib/sass/compile_error.rb
64
62
  - lib/sass/compile_result.rb
63
+ - lib/sass/compiler.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/host/value_protofier.rb
73
+ - lib/sass/compiler/resilient_dispatcher.rb
74
+ - lib/sass/compiler/varint.rb
65
75
  - lib/sass/elf.rb
66
76
  - lib/sass/embedded.rb
67
- - lib/sass/embedded/connection.rb
68
- - lib/sass/embedded/dispatcher.rb
69
- - lib/sass/embedded/host.rb
70
- - lib/sass/embedded/host/function_registry.rb
71
- - lib/sass/embedded/host/importer_registry.rb
72
- - lib/sass/embedded/host/logger_registry.rb
73
- - lib/sass/embedded/host/protofier.rb
74
- - lib/sass/embedded/host/structifier.rb
75
- - lib/sass/embedded/host/value_protofier.rb
76
- - lib/sass/embedded/resilient_dispatcher.rb
77
- - lib/sass/embedded/varint.rb
78
77
  - lib/sass/embedded/version.rb
79
78
  - lib/sass/embedded_protocol.rb
79
+ - lib/sass/exception.rb
80
+ - lib/sass/fork_tracker.rb
80
81
  - lib/sass/logger/silent.rb
81
82
  - lib/sass/logger/source_location.rb
82
83
  - lib/sass/logger/source_span.rb
83
- - lib/sass/script_error.rb
84
+ - lib/sass/serializer.rb
84
85
  - lib/sass/value.rb
85
86
  - lib/sass/value/argument_list.rb
86
87
  - lib/sass/value/boolean.rb
@@ -95,12 +96,12 @@ files:
95
96
  - lib/sass/value/number.rb
96
97
  - lib/sass/value/number/unit.rb
97
98
  - lib/sass/value/string.rb
98
- homepage: https://github.com/ntkme/sass-embedded-host-ruby
99
+ homepage: https://github.com/sass-contrib/sass-embedded-host-ruby
99
100
  licenses:
100
101
  - MIT
101
102
  metadata:
102
- documentation_uri: https://rubydoc.info/gems/sass-embedded/1.69.5
103
- source_code_uri: https://github.com/ntkme/sass-embedded-host-ruby/tree/v1.69.5
103
+ documentation_uri: https://rubydoc.info/gems/sass-embedded/1.69.6
104
+ source_code_uri: https://github.com/sass-contrib/sass-embedded-host-ruby/tree/v1.69.6
104
105
  funding_uri: https://github.com/sponsors/ntkme
105
106
  post_install_message:
106
107
  rdoc_options: []
@@ -110,14 +111,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
110
111
  requirements:
111
112
  - - ">="
112
113
  - !ruby/object:Gem::Version
113
- version: 3.0.0
114
+ version: 3.1.3
114
115
  required_rubygems_version: !ruby/object:Gem::Requirement
115
116
  requirements:
116
117
  - - ">="
117
118
  - !ruby/object:Gem::Version
118
119
  version: '0'
119
120
  requirements: []
120
- rubygems_version: 3.4.21
121
+ rubygems_version: 3.5.3
121
122
  signing_key:
122
123
  specification_version: 4
123
124
  summary: Use dart-sass with Ruby!
@@ -1,133 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'fiddle'
4
-
5
- # @!visibility private
6
- module SassConfig
7
- # @see https://learn.microsoft.com/en-us/windows/win32/api/
8
- module Win32API
9
- Kernel32 = Fiddle.dlopen('Kernel32.dll')
10
-
11
- # @see https://learn.microsoft.com/en-us/windows/win32/sysinfo/image-file-machine-constants
12
- module ImageFileMachineConstants
13
- IMAGE_FILE_MACHINE_I386 = 0x014c
14
- IMAGE_FILE_MACHINE_ARMNT = 0x01c4
15
- IMAGE_FILE_MACHINE_AMD64 = 0x8664
16
- IMAGE_FILE_MACHINE_ARM64 = 0xaa64
17
- end
18
-
19
- private_constant :ImageFileMachineConstants
20
-
21
- # @see https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/ne-processthreadsapi-machine_attributes
22
- module MachineAttributes
23
- USER_ENABLED = 0x00000001
24
- KERNEL_ENABLED = 0x00000002
25
- WOW64_CONTAINER = 0x00000004
26
- end
27
-
28
- private_constant :MachineAttributes
29
-
30
- # Specifies the ways in which an architecture of code can run on a host operating system.
31
- class MachineTypeAttributes
32
- def initialize(machine_type_attributes)
33
- @machine_type_attributes = machine_type_attributes
34
- end
35
-
36
- # The specified architecture of code can run in user mode.
37
- def user_enabled?
38
- @machine_type_attributes & MachineAttributes::USER_ENABLED == MachineAttributes::USER_ENABLED
39
- end
40
-
41
- # The specified architecture of code can run in kernel mode.
42
- def kernel_enabled?
43
- @machine_type_attributes & MachineAttributes::KERNEL_ENABLED == MachineAttributes::KERNEL_ENABLED
44
- end
45
-
46
- # The specified architecture of code runs on WOW64.
47
- def wow64_container?
48
- @machine_type_attributes & MachineAttributes::WOW64_CONTAINER == MachineAttributes::WOW64_CONTAINER
49
- end
50
- end
51
-
52
- private_constant :MachineTypeAttributes
53
-
54
- class << self
55
- def x86?
56
- get_machine_type_attributes(ImageFileMachineConstants::IMAGE_FILE_MACHINE_I386).user_enabled?
57
- end
58
-
59
- def arm?
60
- get_machine_type_attributes(ImageFileMachineConstants::IMAGE_FILE_MACHINE_ARMNT).user_enabled?
61
- end
62
-
63
- def x64?
64
- get_machine_type_attributes(ImageFileMachineConstants::IMAGE_FILE_MACHINE_AMD64).user_enabled?
65
- end
66
-
67
- def arm64?
68
- get_machine_type_attributes(ImageFileMachineConstants::IMAGE_FILE_MACHINE_ARM64).user_enabled?
69
- end
70
-
71
- private
72
-
73
- begin
74
- # @see https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-getmachinetypeattributes
75
- GetMachineTypeAttributes = Fiddle::Function.new(
76
- Kernel32['GetMachineTypeAttributes'],
77
- [-Fiddle::TYPE_SHORT, Fiddle::TYPE_VOIDP],
78
- Fiddle::TYPE_LONG
79
- )
80
-
81
- def get_machine_type_attributes(machine)
82
- p_machine_type_attributes = Fiddle::Pointer.malloc(Fiddle::SIZEOF_INT, Fiddle::RUBY_FREE)
83
- raise Fiddle.win32_last_error unless GetMachineTypeAttributes.call(machine, p_machine_type_attributes).zero?
84
-
85
- MachineTypeAttributes.new(p_machine_type_attributes.to_str.unpack1('i'))
86
- end
87
- rescue Fiddle::DLError
88
- # @see https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-getcurrentprocess
89
- GetCurrentProcess = Fiddle::Function.new(
90
- Kernel32['GetCurrentProcess'],
91
- [],
92
- Fiddle::TYPE_VOIDP
93
- )
94
-
95
- # @see https://learn.microsoft.com/en-us/windows/win32/api/wow64apiset/nf-wow64apiset-iswow64process2
96
- IsWow64Process2 = Fiddle::Function.new(
97
- Kernel32['IsWow64Process2'],
98
- [Fiddle::TYPE_VOIDP, Fiddle::TYPE_VOIDP, Fiddle::TYPE_VOIDP],
99
- Fiddle::TYPE_CHAR
100
- )
101
-
102
- # @see https://learn.microsoft.com/en-us/windows/win32/api/wow64apiset/nf-wow64apiset-iswow64guestmachinesupported
103
- IsWow64GuestMachineSupported = Fiddle::Function.new(
104
- Kernel32['IsWow64GuestMachineSupported'],
105
- [-Fiddle::TYPE_SHORT, Fiddle::TYPE_VOIDP],
106
- Fiddle::TYPE_LONG
107
- )
108
-
109
- def get_machine_type_attributes(machine)
110
- h_process = GetCurrentProcess.call
111
- p_process_machine = Fiddle::Pointer.malloc(Fiddle::SIZEOF_SHORT, Fiddle::RUBY_FREE)
112
- p_native_machine = Fiddle::Pointer.malloc(Fiddle::SIZEOF_SHORT, Fiddle::RUBY_FREE)
113
- raise Fiddle.win32_last_error if IsWow64Process2.call(h_process, p_process_machine, p_native_machine).zero?
114
-
115
- if p_native_machine.to_str.unpack1('S!') == machine
116
- return MachineTypeAttributes.new(MachineAttributes::USER_ENABLED | MachineAttributes::KERNEL_ENABLED)
117
- end
118
-
119
- p_machine_is_supported = Fiddle::Pointer.malloc(Fiddle::SIZEOF_CHAR, Fiddle::RUBY_FREE)
120
- raise Fiddle.win32_last_error unless IsWow64GuestMachineSupported.call(machine, p_machine_is_supported).zero?
121
-
122
- if p_machine_is_supported.to_str.unpack1('c').zero?
123
- MachineTypeAttributes.new(0)
124
- else
125
- MachineTypeAttributes.new(MachineAttributes::USER_ENABLED | MachineAttributes::WOW64_CONTAINER)
126
- end
127
- end
128
- end
129
- end
130
- end
131
-
132
- private_constant :Win32API
133
- end
@@ -1,31 +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_reader :sass_stack
8
-
9
- # @return [Logger::SourceSpan, nil]
10
- attr_reader :span
11
-
12
- # @return [Array<String>]
13
- attr_reader :loaded_urls
14
-
15
- # @!visibility private
16
- def initialize(message, full_message, sass_stack, span, loaded_urls)
17
- super(message)
18
- @full_message = full_message
19
- @sass_stack = sass_stack
20
- @span = span
21
- @loaded_urls = loaded_urls
22
- end
23
-
24
- # @return [String]
25
- def full_message(...)
26
- return super(...) if @full_message.nil?
27
-
28
- @full_message = +@full_message
29
- end
30
- end
31
- end
@@ -1,71 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'open3'
4
-
5
- require_relative '../../../ext/sass/cli'
6
-
7
- module Sass
8
- class Embedded
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
- @stdin.binmode
25
-
26
- Thread.new do
27
- stdout.binmode
28
- loop do
29
- length = Varint.read(stdout)
30
- id = Varint.read(stdout)
31
- proto = stdout.read(length - Varint.length(id))
32
- dispatcher.receive_proto(id, proto)
33
- rescue IOError, Errno::EBADF, Errno::EPROTO => e
34
- dispatcher.error(e)
35
- break
36
- end
37
- stdout.close
38
- end
39
-
40
- Thread.new do
41
- loop do
42
- warn(stderr.readline, uplevel: 1)
43
- rescue IOError, Errno::EBADF
44
- break
45
- end
46
- stderr.close
47
- end
48
- end
49
-
50
- def close
51
- @stdin.close
52
- @wait_thread.join
53
- end
54
-
55
- def closed?
56
- @stdin.closed? && !@wait_thread.alive?
57
- end
58
-
59
- def write(id, proto)
60
- buffer = []
61
- Varint.write(buffer, Varint.length(id) + proto.length)
62
- Varint.write(buffer, id)
63
- @mutex.synchronize do
64
- @stdin.write(buffer.pack('C*'), proto)
65
- end
66
- end
67
- end
68
-
69
- private_constant :Connection
70
- end
71
- end
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Sass
4
- # An exception thrown by Sass Script.
5
- class ScriptError < StandardError
6
- def initialize(message, name = nil)
7
- super(name.nil? ? message : "$#{name}: #{message}")
8
- end
9
- end
10
- end