opal-webpack-loader 0.11.0 → 0.11.1
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/README.md +2 -1
- data/bin/opal-webpack-compile-server +0 -0
- data/bin/opal-webpack-windows-compile-server +0 -0
- data/bin/owl-compiler +0 -0
- data/bin/owl-gen-loadpath-cache +0 -0
- data/bin/owl-install +0 -0
- data/lib/opal-webpack-loader.rb +24 -20
- data/lib/opal-webpack-loader/pipe_server.rb +219 -219
- data/lib/opal-webpack-loader/version.rb +3 -3
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f1a1b24301ed05a439abf847ae77a460919a227d250432d0c769d3080d100dec
|
4
|
+
data.tar.gz: 48f48641c277ecbf2fd50a7c274bdcf94b960dc28bf5103da70555815b70112f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7ef00f2c1e57f71eadaae2a3b2edc6c47745c980a1f85921b0ca9e6e0b092e960c9c3971826ffec3ca22b42e56d45a9b36bd6d692b794b97f23c2343f043e25d
|
7
|
+
data.tar.gz: a5ebdd0518490d0eea2e78de43f1527f333b32ab778603fd24cc8052c3870aa4e5408a631c6a0a676185d7355f488c4cc605f5b8a793418a2072ed3c09174b85
|
data/README.md
CHANGED
@@ -23,7 +23,7 @@ At the [Isomorfeus Framework Project](http://isomorfeus.com)
|
|
23
23
|
opal-webpack-loader-0.7.1 compiles all of opal, a bunch of gems and over 19000SLC on a
|
24
24
|
Intel® Core™ i7-7700HQ CPU @ 2.80GHz × 8, with 8 workers in around 1850ms
|
25
25
|
- support for memcached or redis as compiler cache
|
26
|
-
- fast builds on windows too, parallel when building multiple assets with parallel
|
26
|
+
- fast builds on windows too, parallel when building multiple assets with parallel-webpack
|
27
27
|
- opal modules are packaged as es6 modules
|
28
28
|
- support for rails with webpacker
|
29
29
|
- other webpack features become available, like:
|
@@ -36,6 +36,7 @@ Intel® Core™ i7-7700HQ CPU @ 2.80GHz × 8, with 8 workers in around 1850ms
|
|
36
36
|
- everything else webpack can do, like loading stylesheets, etc.
|
37
37
|
|
38
38
|
### Requirements
|
39
|
+
- npm or yarn
|
39
40
|
- opal-webpack-loader consists of 2 parts, the npm package and the gem, both are required and must be the same version.
|
40
41
|
- webpack ^4.46
|
41
42
|
- webpack-dev-server ^3.11.0
|
File without changes
|
File without changes
|
data/bin/owl-compiler
CHANGED
File without changes
|
data/bin/owl-gen-loadpath-cache
CHANGED
File without changes
|
data/bin/owl-install
CHANGED
File without changes
|
data/lib/opal-webpack-loader.rb
CHANGED
@@ -38,27 +38,31 @@ OpalWebpackLoader.manifest_path = File.join(Dir.getwd, 'public', 'assets', 'mani
|
|
38
38
|
OpalWebpackLoader.client_asset_path = 'http://localhost:3035/assets/'
|
39
39
|
OpalWebpackLoader.use_manifest = false
|
40
40
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
41
|
+
owl_npm_version = nil
|
42
|
+
begin
|
43
|
+
yarn = if Gem.win_platform?
|
44
|
+
`where yarn`.chop.lines.last.include?('yarn')
|
45
|
+
else
|
46
|
+
`which yarn`.chop.include?('yarn')
|
47
|
+
end
|
48
|
+
owl_npm_version = `yarn run -s opal-webpack-loader-npm-version`.chop if yarn
|
47
49
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
50
|
+
unless owl_npm_version
|
51
|
+
npm = if Gem.win_platform?
|
52
|
+
`where npm`.chop.lines.last.include?('npm')
|
53
|
+
else
|
54
|
+
`which npm`.chop.include?('npm')
|
55
|
+
end
|
56
|
+
owl_npm_version = `npm exec opal-webpack-loader-npm-version`.chop if npm
|
54
57
|
end
|
58
|
+
rescue
|
59
|
+
owl_npm_version = nil
|
60
|
+
end
|
55
61
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
end
|
62
|
-
else
|
63
|
-
STDERR.puts "opal-webpack-loader: Unable to check npm package version. Please check your npm installation."
|
62
|
+
if owl_npm_version != OpalWebpackLoader::VERSION
|
63
|
+
STDERR.puts "opal-webpack-loader: Incorrect version of npm package found or npm package not installed.\n" +
|
64
|
+
"Please install the npm package for opal-webpack-loader:\n" +
|
65
|
+
"\twith npm:\tnpm install opal-webpack-loader@#{OpalWebpackLoader::VERSION}\n" +
|
66
|
+
"\tor with yarn:\tyarn add opal-webpack-loader@#{OpalWebpackLoader::VERSION}\n"
|
64
67
|
end
|
68
|
+
|
@@ -1,219 +1,219 @@
|
|
1
|
-
require 'ffi'
|
2
|
-
|
3
|
-
module OpalWebpackLoader
|
4
|
-
module WindowsyThings
|
5
|
-
extend FFI::Library
|
6
|
-
|
7
|
-
ffi_lib :kernel32, :user32
|
8
|
-
|
9
|
-
ERROR_IO_PENDING = 997
|
10
|
-
ERROR_PIPE_CONNECTED = 535
|
11
|
-
ERROR_SUCCESS = 0
|
12
|
-
|
13
|
-
FILE_FLAG_OVERLAPPED = 0x40000000
|
14
|
-
|
15
|
-
INFINITE = 0xFFFFFFFF
|
16
|
-
INVALID_HANDLE_VALUE = FFI::Pointer.new(-1).address
|
17
|
-
|
18
|
-
PIPE_ACCESS_DUPLEX = 0x00000003
|
19
|
-
PIPE_READMODE_BYTE = 0x00000000
|
20
|
-
PIPE_READMODE_MESSAGE = 0x00000002
|
21
|
-
PIPE_TYPE_BYTE = 0x00000000
|
22
|
-
PIPE_TYPE_MESSAGE = 0x00000004
|
23
|
-
PIPE_WAIT = 0x00000000
|
24
|
-
|
25
|
-
QS_ALLINPUT = 0x04FF
|
26
|
-
|
27
|
-
typedef :uintptr_t, :handle
|
28
|
-
|
29
|
-
attach_function :ConnectNamedPipe, [:handle, :pointer], :ulong
|
30
|
-
attach_function :CreateEvent, :CreateEventA, [:pointer, :ulong, :ulong, :string], :handle
|
31
|
-
attach_function :CreateNamedPipe, :CreateNamedPipeA, [:string, :ulong, :ulong, :ulong, :ulong, :ulong, :ulong, :pointer], :handle
|
32
|
-
attach_function :DisconnectNamedPipe, [:handle], :bool
|
33
|
-
attach_function :FlushFileBuffers, [:handle], :bool
|
34
|
-
attach_function :GetLastError, [], :ulong
|
35
|
-
attach_function :GetOverlappedResult, [:handle, :pointer, :pointer, :bool], :bool
|
36
|
-
attach_function :MsgWaitForMultipleObjects, [:ulong, :pointer, :ulong, :ulong, :ulong], :ulong
|
37
|
-
attach_function :ReadFile, [:handle, :buffer_out, :ulong, :pointer, :pointer], :bool
|
38
|
-
attach_function :SetEvent, [:handle], :bool
|
39
|
-
attach_function :WaitForMultipleObjects, [:ulong, :pointer, :ulong, :ulong], :ulong
|
40
|
-
attach_function :WriteFile, [:handle, :buffer_in, :ulong, :pointer, :pointer], :bool
|
41
|
-
end
|
42
|
-
|
43
|
-
class PipeServer
|
44
|
-
include OpalWebpackLoader::WindowsyThings
|
45
|
-
|
46
|
-
CONNECTING_STATE = 0
|
47
|
-
READING_STATE = 1
|
48
|
-
WRITING_STATE = 2
|
49
|
-
INSTANCES = 4
|
50
|
-
PIPE_TIMEOUT = 5000
|
51
|
-
BUFFER_SIZE = 65536
|
52
|
-
|
53
|
-
class Overlapped < FFI::Struct
|
54
|
-
layout(
|
55
|
-
:Internal, :uintptr_t,
|
56
|
-
:InternalHigh, :uintptr_t,
|
57
|
-
:Offset, :ulong,
|
58
|
-
:OffsetHigh, :ulong,
|
59
|
-
:hEvent, :uintptr_t
|
60
|
-
)
|
61
|
-
end
|
62
|
-
|
63
|
-
def initialize(pipe_name, instances = 4, &block)
|
64
|
-
@run_block = block
|
65
|
-
@full_pipe_name = "\\\\.\\pipe\\#{pipe_name}"
|
66
|
-
@instances = instances
|
67
|
-
@events = []
|
68
|
-
@events_pointer = FFI::MemoryPointer.new(:uintptr_t, @instances)
|
69
|
-
@pipes = []
|
70
|
-
end
|
71
|
-
|
72
|
-
def run
|
73
|
-
create_instances
|
74
|
-
while_loop
|
75
|
-
end
|
76
|
-
|
77
|
-
private
|
78
|
-
|
79
|
-
def create_instances
|
80
|
-
(0...@instances).each do |i|
|
81
|
-
@events[i] = CreateEvent(nil, 1, 1, nil)
|
82
|
-
raise "CreateEvent failed with #{GetLastError()}" unless @events[i]
|
83
|
-
|
84
|
-
overlap = Overlapped.new
|
85
|
-
overlap[:hEvent] = @events[i]
|
86
|
-
|
87
|
-
@pipes[i] = { overlap: overlap, instance: nil, request: FFI::Buffer.new(1, BUFFER_SIZE), bytes_read: 0, reply: FFI::Buffer.new(1, BUFFER_SIZE), bytes_to_write: 0, state: nil, pending_io: false }
|
88
|
-
@pipes[i][:instance] = CreateNamedPipe(@full_pipe_name,
|
89
|
-
PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED,
|
90
|
-
PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT,
|
91
|
-
@instances,
|
92
|
-
BUFFER_SIZE,
|
93
|
-
BUFFER_SIZE,
|
94
|
-
PIPE_TIMEOUT,
|
95
|
-
nil)
|
96
|
-
|
97
|
-
raise "CreateNamedPipe failed with #{GetLastError()}" if @pipes[i][:instance] == INVALID_HANDLE_VALUE
|
98
|
-
@pipes[i][:pending_io] = connect_to_new_client(i)
|
99
|
-
@pipes[i][:state] = @pipes[i][:pending_io] ? CONNECTING_STATE : READING_STATE
|
100
|
-
end
|
101
|
-
@events_pointer.write_array_of_ulong_long(@events)
|
102
|
-
nil
|
103
|
-
end
|
104
|
-
|
105
|
-
def while_loop
|
106
|
-
while true
|
107
|
-
i = MsgWaitForMultipleObjects(@instances, @events_pointer, 0, INFINITE, QS_ALLINPUT)
|
108
|
-
# Having this STDOUT.putc is essential, otherwise there is a tendency to block within MsgWaitForMultipleObjects ...
|
109
|
-
STDOUT.putc "."
|
110
|
-
# ... because the ruby interpreter is waiting for objects too on Windows. Thats why we wait for QS_ALLINPUT and
|
111
|
-
# with STDOUT.putc give back control to the ruby interpreter that it can handle its things.
|
112
|
-
if i < 0 || i > (@instances - 1)
|
113
|
-
STDERR.puts "Pipe index out of range. Maybe a error occured."
|
114
|
-
next
|
115
|
-
end
|
116
|
-
|
117
|
-
if @pipes[i][:pending_io]
|
118
|
-
bytes_transferred = FFI::MemoryPointer.new(:ulong)
|
119
|
-
success = GetOverlappedResult(@pipes[i][:instance], @pipes[i][:overlap], bytes_transferred, false)
|
120
|
-
|
121
|
-
case @pipes[i][:state]
|
122
|
-
when CONNECTING_STATE
|
123
|
-
raise "Error #{GetLastError()}" unless success
|
124
|
-
@pipes[i][:state] = READING_STATE
|
125
|
-
when READING_STATE
|
126
|
-
if !success || bytes_transferred.read_ulong == 0
|
127
|
-
disconnect_and_reconnect(i)
|
128
|
-
next
|
129
|
-
else
|
130
|
-
@pipes[i][:bytes_read] = bytes_transferred.read_ulong
|
131
|
-
@pipes[i][:state] = WRITING_STATE
|
132
|
-
end
|
133
|
-
when WRITING_STATE
|
134
|
-
if !success || bytes_transferred.read_ulong != @pipes[i][:bytes_to_write]
|
135
|
-
disconnect_and_reconnect(i)
|
136
|
-
next
|
137
|
-
else
|
138
|
-
@pipes[i][:state] = READING_STATE
|
139
|
-
end
|
140
|
-
else
|
141
|
-
raise "Invalid pipe state."
|
142
|
-
end
|
143
|
-
end
|
144
|
-
|
145
|
-
case @pipes[i][:state]
|
146
|
-
when READING_STATE
|
147
|
-
bytes_read = FFI::MemoryPointer.new(:ulong)
|
148
|
-
success = ReadFile(@pipes[i][:instance], @pipes[i][:request], BUFFER_SIZE, bytes_read, @pipes[i][:overlap].to_ptr)
|
149
|
-
if success && bytes_read.read_ulong != 0
|
150
|
-
@pipes[i][:pending_io] = false
|
151
|
-
@pipes[i][:state] = WRITING_STATE
|
152
|
-
next
|
153
|
-
end
|
154
|
-
|
155
|
-
err = GetLastError()
|
156
|
-
if !success && err == ERROR_IO_PENDING
|
157
|
-
@pipes[i][:pending_io] = true
|
158
|
-
next
|
159
|
-
end
|
160
|
-
|
161
|
-
disconnect_and_reconnect(i)
|
162
|
-
when WRITING_STATE
|
163
|
-
@pipes[i][:reply] = @run_block.call(@pipes[i][:request].get_string(0))
|
164
|
-
@pipes[i][:bytes_to_write] = @pipes[i][:reply].bytesize
|
165
|
-
bytes_written = FFI::MemoryPointer.new(:ulong)
|
166
|
-
success = WriteFile(@pipes[i][:instance], @pipes[i][:reply], @pipes[i][:bytes_to_write], bytes_written, @pipes[i][:overlap].to_ptr)
|
167
|
-
|
168
|
-
if success && bytes_written.read_ulong == @pipes[i][:bytes_to_write]
|
169
|
-
@pipes[i][:pending_io] = false
|
170
|
-
@pipes[i][:state] = READING_STATE
|
171
|
-
next
|
172
|
-
end
|
173
|
-
|
174
|
-
err = GetLastError()
|
175
|
-
|
176
|
-
if !success && err == ERROR_IO_PENDING
|
177
|
-
@pipes[i][:pending_io] = true
|
178
|
-
next
|
179
|
-
end
|
180
|
-
|
181
|
-
disconnect_and_reconnect(i)
|
182
|
-
else
|
183
|
-
raise "Invalid pipe state."
|
184
|
-
end
|
185
|
-
end
|
186
|
-
end
|
187
|
-
|
188
|
-
def disconnect_and_reconnect(i)
|
189
|
-
FlushFileBuffers(@pipes[i][:instance])
|
190
|
-
STDERR.puts("DisconnectNamedPipe failed with #{GetLastError()}") if !DisconnectNamedPipe(@pipes[i][:instance])
|
191
|
-
|
192
|
-
@pipes[i][:pending_io] = connect_to_new_client(i)
|
193
|
-
|
194
|
-
@pipes[i][:state] = @pipes[i][:pending_io] ? CONNECTING_STATE : READING_STATE
|
195
|
-
end
|
196
|
-
|
197
|
-
def connect_to_new_client(i)
|
198
|
-
pending_io = false
|
199
|
-
@pipes[i][:request].clear
|
200
|
-
@pipes[i][:reply].clear
|
201
|
-
connected = ConnectNamedPipe(@pipes[i][:instance], @pipes[i][:overlap].to_ptr)
|
202
|
-
last_error = GetLastError()
|
203
|
-
raise "ConnectNamedPipe failed with #{last_error} - #{connected}" if connected != 0
|
204
|
-
|
205
|
-
case last_error
|
206
|
-
when ERROR_IO_PENDING
|
207
|
-
pending_io = true
|
208
|
-
when ERROR_PIPE_CONNECTED
|
209
|
-
SetEvent(@pipes[i][:overlap][:hEvent])
|
210
|
-
when ERROR_SUCCESS
|
211
|
-
pending_io = true
|
212
|
-
else
|
213
|
-
raise "ConnectNamedPipe failed with error #{last_error}"
|
214
|
-
end
|
215
|
-
|
216
|
-
pending_io
|
217
|
-
end
|
218
|
-
end
|
219
|
-
end
|
1
|
+
require 'ffi'
|
2
|
+
|
3
|
+
module OpalWebpackLoader
|
4
|
+
module WindowsyThings
|
5
|
+
extend FFI::Library
|
6
|
+
|
7
|
+
ffi_lib :kernel32, :user32
|
8
|
+
|
9
|
+
ERROR_IO_PENDING = 997
|
10
|
+
ERROR_PIPE_CONNECTED = 535
|
11
|
+
ERROR_SUCCESS = 0
|
12
|
+
|
13
|
+
FILE_FLAG_OVERLAPPED = 0x40000000
|
14
|
+
|
15
|
+
INFINITE = 0xFFFFFFFF
|
16
|
+
INVALID_HANDLE_VALUE = FFI::Pointer.new(-1).address
|
17
|
+
|
18
|
+
PIPE_ACCESS_DUPLEX = 0x00000003
|
19
|
+
PIPE_READMODE_BYTE = 0x00000000
|
20
|
+
PIPE_READMODE_MESSAGE = 0x00000002
|
21
|
+
PIPE_TYPE_BYTE = 0x00000000
|
22
|
+
PIPE_TYPE_MESSAGE = 0x00000004
|
23
|
+
PIPE_WAIT = 0x00000000
|
24
|
+
|
25
|
+
QS_ALLINPUT = 0x04FF
|
26
|
+
|
27
|
+
typedef :uintptr_t, :handle
|
28
|
+
|
29
|
+
attach_function :ConnectNamedPipe, [:handle, :pointer], :ulong
|
30
|
+
attach_function :CreateEvent, :CreateEventA, [:pointer, :ulong, :ulong, :string], :handle
|
31
|
+
attach_function :CreateNamedPipe, :CreateNamedPipeA, [:string, :ulong, :ulong, :ulong, :ulong, :ulong, :ulong, :pointer], :handle
|
32
|
+
attach_function :DisconnectNamedPipe, [:handle], :bool
|
33
|
+
attach_function :FlushFileBuffers, [:handle], :bool
|
34
|
+
attach_function :GetLastError, [], :ulong
|
35
|
+
attach_function :GetOverlappedResult, [:handle, :pointer, :pointer, :bool], :bool
|
36
|
+
attach_function :MsgWaitForMultipleObjects, [:ulong, :pointer, :ulong, :ulong, :ulong], :ulong
|
37
|
+
attach_function :ReadFile, [:handle, :buffer_out, :ulong, :pointer, :pointer], :bool
|
38
|
+
attach_function :SetEvent, [:handle], :bool
|
39
|
+
attach_function :WaitForMultipleObjects, [:ulong, :pointer, :ulong, :ulong], :ulong
|
40
|
+
attach_function :WriteFile, [:handle, :buffer_in, :ulong, :pointer, :pointer], :bool
|
41
|
+
end
|
42
|
+
|
43
|
+
class PipeServer
|
44
|
+
include OpalWebpackLoader::WindowsyThings
|
45
|
+
|
46
|
+
CONNECTING_STATE = 0
|
47
|
+
READING_STATE = 1
|
48
|
+
WRITING_STATE = 2
|
49
|
+
INSTANCES = 4
|
50
|
+
PIPE_TIMEOUT = 5000
|
51
|
+
BUFFER_SIZE = 65536
|
52
|
+
|
53
|
+
class Overlapped < FFI::Struct
|
54
|
+
layout(
|
55
|
+
:Internal, :uintptr_t,
|
56
|
+
:InternalHigh, :uintptr_t,
|
57
|
+
:Offset, :ulong,
|
58
|
+
:OffsetHigh, :ulong,
|
59
|
+
:hEvent, :uintptr_t
|
60
|
+
)
|
61
|
+
end
|
62
|
+
|
63
|
+
def initialize(pipe_name, instances = 4, &block)
|
64
|
+
@run_block = block
|
65
|
+
@full_pipe_name = "\\\\.\\pipe\\#{pipe_name}"
|
66
|
+
@instances = instances
|
67
|
+
@events = []
|
68
|
+
@events_pointer = FFI::MemoryPointer.new(:uintptr_t, @instances)
|
69
|
+
@pipes = []
|
70
|
+
end
|
71
|
+
|
72
|
+
def run
|
73
|
+
create_instances
|
74
|
+
while_loop
|
75
|
+
end
|
76
|
+
|
77
|
+
private
|
78
|
+
|
79
|
+
def create_instances
|
80
|
+
(0...@instances).each do |i|
|
81
|
+
@events[i] = CreateEvent(nil, 1, 1, nil)
|
82
|
+
raise "CreateEvent failed with #{GetLastError()}" unless @events[i]
|
83
|
+
|
84
|
+
overlap = Overlapped.new
|
85
|
+
overlap[:hEvent] = @events[i]
|
86
|
+
|
87
|
+
@pipes[i] = { overlap: overlap, instance: nil, request: FFI::Buffer.new(1, BUFFER_SIZE), bytes_read: 0, reply: FFI::Buffer.new(1, BUFFER_SIZE), bytes_to_write: 0, state: nil, pending_io: false }
|
88
|
+
@pipes[i][:instance] = CreateNamedPipe(@full_pipe_name,
|
89
|
+
PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED,
|
90
|
+
PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT,
|
91
|
+
@instances,
|
92
|
+
BUFFER_SIZE,
|
93
|
+
BUFFER_SIZE,
|
94
|
+
PIPE_TIMEOUT,
|
95
|
+
nil)
|
96
|
+
|
97
|
+
raise "CreateNamedPipe failed with #{GetLastError()}" if @pipes[i][:instance] == INVALID_HANDLE_VALUE
|
98
|
+
@pipes[i][:pending_io] = connect_to_new_client(i)
|
99
|
+
@pipes[i][:state] = @pipes[i][:pending_io] ? CONNECTING_STATE : READING_STATE
|
100
|
+
end
|
101
|
+
@events_pointer.write_array_of_ulong_long(@events)
|
102
|
+
nil
|
103
|
+
end
|
104
|
+
|
105
|
+
def while_loop
|
106
|
+
while true
|
107
|
+
i = MsgWaitForMultipleObjects(@instances, @events_pointer, 0, INFINITE, QS_ALLINPUT)
|
108
|
+
# Having this STDOUT.putc is essential, otherwise there is a tendency to block within MsgWaitForMultipleObjects ...
|
109
|
+
STDOUT.putc "."
|
110
|
+
# ... because the ruby interpreter is waiting for objects too on Windows. Thats why we wait for QS_ALLINPUT and
|
111
|
+
# with STDOUT.putc give back control to the ruby interpreter that it can handle its things.
|
112
|
+
if i < 0 || i > (@instances - 1)
|
113
|
+
STDERR.puts "Pipe index out of range. Maybe a error occured."
|
114
|
+
next
|
115
|
+
end
|
116
|
+
|
117
|
+
if @pipes[i][:pending_io]
|
118
|
+
bytes_transferred = FFI::MemoryPointer.new(:ulong)
|
119
|
+
success = GetOverlappedResult(@pipes[i][:instance], @pipes[i][:overlap], bytes_transferred, false)
|
120
|
+
|
121
|
+
case @pipes[i][:state]
|
122
|
+
when CONNECTING_STATE
|
123
|
+
raise "Error #{GetLastError()}" unless success
|
124
|
+
@pipes[i][:state] = READING_STATE
|
125
|
+
when READING_STATE
|
126
|
+
if !success || bytes_transferred.read_ulong == 0
|
127
|
+
disconnect_and_reconnect(i)
|
128
|
+
next
|
129
|
+
else
|
130
|
+
@pipes[i][:bytes_read] = bytes_transferred.read_ulong
|
131
|
+
@pipes[i][:state] = WRITING_STATE
|
132
|
+
end
|
133
|
+
when WRITING_STATE
|
134
|
+
if !success || bytes_transferred.read_ulong != @pipes[i][:bytes_to_write]
|
135
|
+
disconnect_and_reconnect(i)
|
136
|
+
next
|
137
|
+
else
|
138
|
+
@pipes[i][:state] = READING_STATE
|
139
|
+
end
|
140
|
+
else
|
141
|
+
raise "Invalid pipe state."
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
case @pipes[i][:state]
|
146
|
+
when READING_STATE
|
147
|
+
bytes_read = FFI::MemoryPointer.new(:ulong)
|
148
|
+
success = ReadFile(@pipes[i][:instance], @pipes[i][:request], BUFFER_SIZE, bytes_read, @pipes[i][:overlap].to_ptr)
|
149
|
+
if success && bytes_read.read_ulong != 0
|
150
|
+
@pipes[i][:pending_io] = false
|
151
|
+
@pipes[i][:state] = WRITING_STATE
|
152
|
+
next
|
153
|
+
end
|
154
|
+
|
155
|
+
err = GetLastError()
|
156
|
+
if !success && err == ERROR_IO_PENDING
|
157
|
+
@pipes[i][:pending_io] = true
|
158
|
+
next
|
159
|
+
end
|
160
|
+
|
161
|
+
disconnect_and_reconnect(i)
|
162
|
+
when WRITING_STATE
|
163
|
+
@pipes[i][:reply] = @run_block.call(@pipes[i][:request].get_string(0))
|
164
|
+
@pipes[i][:bytes_to_write] = @pipes[i][:reply].bytesize
|
165
|
+
bytes_written = FFI::MemoryPointer.new(:ulong)
|
166
|
+
success = WriteFile(@pipes[i][:instance], @pipes[i][:reply], @pipes[i][:bytes_to_write], bytes_written, @pipes[i][:overlap].to_ptr)
|
167
|
+
|
168
|
+
if success && bytes_written.read_ulong == @pipes[i][:bytes_to_write]
|
169
|
+
@pipes[i][:pending_io] = false
|
170
|
+
@pipes[i][:state] = READING_STATE
|
171
|
+
next
|
172
|
+
end
|
173
|
+
|
174
|
+
err = GetLastError()
|
175
|
+
|
176
|
+
if !success && err == ERROR_IO_PENDING
|
177
|
+
@pipes[i][:pending_io] = true
|
178
|
+
next
|
179
|
+
end
|
180
|
+
|
181
|
+
disconnect_and_reconnect(i)
|
182
|
+
else
|
183
|
+
raise "Invalid pipe state."
|
184
|
+
end
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
def disconnect_and_reconnect(i)
|
189
|
+
FlushFileBuffers(@pipes[i][:instance])
|
190
|
+
STDERR.puts("DisconnectNamedPipe failed with #{GetLastError()}") if !DisconnectNamedPipe(@pipes[i][:instance])
|
191
|
+
|
192
|
+
@pipes[i][:pending_io] = connect_to_new_client(i)
|
193
|
+
|
194
|
+
@pipes[i][:state] = @pipes[i][:pending_io] ? CONNECTING_STATE : READING_STATE
|
195
|
+
end
|
196
|
+
|
197
|
+
def connect_to_new_client(i)
|
198
|
+
pending_io = false
|
199
|
+
@pipes[i][:request].clear
|
200
|
+
@pipes[i][:reply].clear
|
201
|
+
connected = ConnectNamedPipe(@pipes[i][:instance], @pipes[i][:overlap].to_ptr)
|
202
|
+
last_error = GetLastError()
|
203
|
+
raise "ConnectNamedPipe failed with #{last_error} - #{connected}" if connected != 0
|
204
|
+
|
205
|
+
case last_error
|
206
|
+
when ERROR_IO_PENDING
|
207
|
+
pending_io = true
|
208
|
+
when ERROR_PIPE_CONNECTED
|
209
|
+
SetEvent(@pipes[i][:overlap][:hEvent])
|
210
|
+
when ERROR_SUCCESS
|
211
|
+
pending_io = true
|
212
|
+
else
|
213
|
+
raise "ConnectNamedPipe failed with error #{last_error}"
|
214
|
+
end
|
215
|
+
|
216
|
+
pending_io
|
217
|
+
end
|
218
|
+
end
|
219
|
+
end
|
@@ -1,3 +1,3 @@
|
|
1
|
-
module OpalWebpackLoader
|
2
|
-
VERSION="0.11.
|
3
|
-
end
|
1
|
+
module OpalWebpackLoader
|
2
|
+
VERSION="0.11.1"
|
3
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opal-webpack-loader
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.11.
|
4
|
+
version: 0.11.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Biedermann
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-05-
|
11
|
+
date: 2021-05-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: opal
|
@@ -257,7 +257,7 @@ licenses:
|
|
257
257
|
- MIT
|
258
258
|
metadata:
|
259
259
|
github_repo: ssh://github.com/isomorfeus/gems
|
260
|
-
post_install_message:
|
260
|
+
post_install_message:
|
261
261
|
rdoc_options: []
|
262
262
|
require_paths:
|
263
263
|
- lib
|
@@ -273,7 +273,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
273
273
|
version: '0'
|
274
274
|
requirements: []
|
275
275
|
rubygems_version: 3.2.15
|
276
|
-
signing_key:
|
276
|
+
signing_key:
|
277
277
|
specification_version: 4
|
278
278
|
summary: Bundle assets with webpack, resolve and compile opal ruby files and import
|
279
279
|
them in the bundle.
|