wasmify-rails 0.4.1 → 0.5.0
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/CHANGELOG.md +10 -0
- data/LICENSE.txt +1 -2
- data/README.md +1 -17
- data/lib/active_record/connection_adapters/pglite_adapter.rb +17 -6
- data/lib/active_record/connection_adapters/pglite_shims/pg.rb +3 -0
- data/lib/generators/wasmify/install/install_generator.rb +12 -8
- data/lib/generators/wasmify/install/templates/config/environments/wasm.rb +8 -2
- data/lib/generators/wasmify/install/templates/config/wasmify.yml +8 -5
- data/lib/wasmify/rails/builder.rb +18 -1
- data/lib/wasmify/rails/shim.rb +1 -0
- data/lib/wasmify/rails/tasks.rake +2 -2
- data/lib/wasmify/rails/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 81052a8cdb9b45ed5173f1d9627ede9dd7116cc4a103d395ea877938a6cdeda2
|
|
4
|
+
data.tar.gz: a97fc6f32477822b7b97d80c466f9041ebf42442ba4f063313c0fa1d12da405f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 652f418e35f1cceec8aeb8076767063b507167426ecdbfd23b647e5485a46ef14fcbe12461dd5964adf8ff9a396ca438cd8316881fa35e77cbacea59b56ebecf
|
|
7
|
+
data.tar.gz: e3c19b352a4b2e4c1832f5893364127bc6df83c231c374f7da24e481139301778fbdb2759b831f29d915c35b09fb4c36504e028e543ca5b30622f00da2701057
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
## master
|
|
4
4
|
|
|
5
|
+
## 0.5.0
|
|
6
|
+
|
|
7
|
+
- PGlite adapter compatibility fixes.
|
|
8
|
+
|
|
9
|
+
- Default configuration updates (to support Ruby >3.3 and Rails 8.1).
|
|
10
|
+
|
|
11
|
+
## 0.4.2
|
|
12
|
+
|
|
13
|
+
- Minor fixes.
|
|
14
|
+
|
|
5
15
|
## 0.4.1
|
|
6
16
|
|
|
7
17
|
- Do not include DataUriUploads middleware in tests.
|
data/LICENSE.txt
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Copyright (c)
|
|
1
|
+
Copyright (c) 2026 Vladimir Dementyev
|
|
2
2
|
|
|
3
3
|
MIT License
|
|
4
4
|
|
|
@@ -20,4 +20,3 @@ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
|
20
20
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
21
21
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
22
22
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
23
|
-
|
data/README.md
CHANGED
|
@@ -188,27 +188,11 @@ This gem provides a variety of _adapters_ and plugins to make your Rails applica
|
|
|
188
188
|
|
|
189
189
|
- `Rack::DataUriUploads` middleware to transparently transform Data URI uploads into files.
|
|
190
190
|
|
|
191
|
-
## Known Issues
|
|
192
|
-
|
|
193
|
-
### `can't load bigdecimal.so`
|
|
194
|
-
|
|
195
|
-
Compiling `bigdecimal` as a gem (not a part of the Ruby distribution, i.e., when using recent Ruby versions) doesn't work; at the same time, modern Rails versions have `require 'bigdecimal` call on boot. Currently, we propose the following workaround:
|
|
196
|
-
|
|
197
|
-
- Add `bigdecimal` to the `ignore_gem_extensions` list in the `wasmify.yml` file.
|
|
198
|
-
- Add the following line to your `config/application.rb` file (before loading Wasm shims):
|
|
199
|
-
|
|
200
|
-
```ruby
|
|
201
|
-
$LOADED_FEATURES << $LOAD_PATH.resolve_feature_path("bigdecimal")[1]
|
|
202
|
-
```
|
|
203
|
-
|
|
204
|
-
We do not include this patch by default hoping that we can have a proper fix in the future.
|
|
205
|
-
|
|
206
191
|
## Roadmap
|
|
207
192
|
|
|
208
|
-
- PGLite support (see [this example](https://github.com/kateinoigakukun/mastodon/blob/fff2e4a626a20a616c546ddf4f91766abaf1133a/pwa/dist/pglite.rb#L1))
|
|
209
193
|
- Active Storage OPFS service
|
|
210
194
|
- Background jobs support
|
|
211
|
-
- WASI Preview 2 support (
|
|
195
|
+
- WASI Preview 2 support (see [this](https://github.com/kateinoigakukun/mastodon/tree/katei/wasmify))
|
|
212
196
|
|
|
213
197
|
## Contributing
|
|
214
198
|
|
|
@@ -13,6 +13,8 @@ module PGlite
|
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
class Result
|
|
16
|
+
attr_reader :res
|
|
17
|
+
|
|
16
18
|
def initialize(res)
|
|
17
19
|
@res = res
|
|
18
20
|
end
|
|
@@ -24,7 +26,7 @@ module PGlite
|
|
|
24
26
|
def values
|
|
25
27
|
results = []
|
|
26
28
|
columns = self.fields
|
|
27
|
-
|
|
29
|
+
res[:rows].to_a.each do |raw_row|
|
|
28
30
|
row = []
|
|
29
31
|
columns.each do |col|
|
|
30
32
|
value = raw_row[col]
|
|
@@ -36,11 +38,11 @@ module PGlite
|
|
|
36
38
|
end
|
|
37
39
|
|
|
38
40
|
def fields
|
|
39
|
-
|
|
41
|
+
res[:fields].to_a.map { |col| col[:name].to_s }
|
|
40
42
|
end
|
|
41
43
|
|
|
42
44
|
def ftype(index)
|
|
43
|
-
|
|
45
|
+
res[:fields][index][:dataTypeID]
|
|
44
46
|
end
|
|
45
47
|
|
|
46
48
|
def fmod(index)
|
|
@@ -48,7 +50,11 @@ module PGlite
|
|
|
48
50
|
end
|
|
49
51
|
|
|
50
52
|
def cmd_tuples
|
|
51
|
-
|
|
53
|
+
res[:affectedRows].to_i
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def ntuples
|
|
57
|
+
@res[:rows][:length].to_i
|
|
52
58
|
end
|
|
53
59
|
|
|
54
60
|
def clear
|
|
@@ -58,7 +64,7 @@ module PGlite
|
|
|
58
64
|
|
|
59
65
|
def each
|
|
60
66
|
columns = self.fields
|
|
61
|
-
|
|
67
|
+
res[:rows].to_a.each do |raw_row|
|
|
62
68
|
row = {}
|
|
63
69
|
columns.each do |col|
|
|
64
70
|
value = raw_row[col]
|
|
@@ -116,9 +122,10 @@ module ActiveRecord
|
|
|
116
122
|
end.to_sym
|
|
117
123
|
@last_result = nil
|
|
118
124
|
@prepared_statements_map = {}
|
|
125
|
+
@finished = false
|
|
119
126
|
end
|
|
120
127
|
|
|
121
|
-
def finished? =
|
|
128
|
+
def finished? = @finished
|
|
122
129
|
|
|
123
130
|
def set_client_encoding(encoding)
|
|
124
131
|
end
|
|
@@ -174,6 +181,10 @@ module ActiveRecord
|
|
|
174
181
|
def reset
|
|
175
182
|
@prepared_statements_map = {}
|
|
176
183
|
end
|
|
184
|
+
|
|
185
|
+
def close
|
|
186
|
+
@finished = true
|
|
187
|
+
end
|
|
177
188
|
end
|
|
178
189
|
|
|
179
190
|
class << self
|
|
@@ -10,9 +10,12 @@ module PG
|
|
|
10
10
|
|
|
11
11
|
class Error < StandardError; end
|
|
12
12
|
class ConnectionBad < Error; end
|
|
13
|
+
class FeatureNotSupported < Error; end
|
|
13
14
|
|
|
14
15
|
class Connection
|
|
15
16
|
class << self
|
|
17
|
+
def conndefaults_hash = {}
|
|
18
|
+
|
|
16
19
|
def quote_ident(str)
|
|
17
20
|
str = str.to_s
|
|
18
21
|
return '""' if str.empty?
|
|
@@ -28,14 +28,18 @@ class Wasmify::InstallGenerator < Rails::Generators::Base
|
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
def configure_gitignore
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
31
|
+
in_root do
|
|
32
|
+
next unless File.file?(".gitignore")
|
|
33
|
+
|
|
34
|
+
append_to_file ".gitignore", <<~EOF
|
|
35
|
+
# Ignore the compiled WebAssembly modules
|
|
36
|
+
*.wasm
|
|
37
|
+
# Ignore ruby.wasm build artefacts
|
|
38
|
+
build/
|
|
39
|
+
rubies/
|
|
40
|
+
dist/
|
|
41
|
+
EOF
|
|
42
|
+
end
|
|
39
43
|
end
|
|
40
44
|
|
|
41
45
|
def inject_wasmify_shim_into_environment
|
|
@@ -19,8 +19,14 @@ Rails.application.configure do
|
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
config.cache_store = :memory_store
|
|
22
|
-
|
|
23
|
-
config.
|
|
22
|
+
|
|
23
|
+
if config.respond_to?(:active_job)
|
|
24
|
+
config.active_job.queue_adapter = :inline
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
if config.respond_to?(:action_mailer)
|
|
28
|
+
config.action_mailer.delivery_method = :null
|
|
29
|
+
end
|
|
24
30
|
|
|
25
31
|
if config.respond_to?(:active_storage)
|
|
26
32
|
config.active_storage.variant_processor = :null
|
|
@@ -11,14 +11,17 @@ pack_directories:
|
|
|
11
11
|
# Usually, you want to specify the gems with native extensions that are
|
|
12
12
|
# not currently Wasm-compatible.
|
|
13
13
|
exclude_gems:
|
|
14
|
-
- bigdecimal
|
|
14
|
+
- bigdecimal # remove on Ruby 3.4+
|
|
15
15
|
- nio4r
|
|
16
16
|
- io-console
|
|
17
17
|
- psych
|
|
18
18
|
- date
|
|
19
|
+
- json
|
|
20
|
+
- prism # breaks parsing Ruby blocks/procs
|
|
21
|
+
- nokogiri
|
|
22
|
+
- racc
|
|
23
|
+
- openssl
|
|
19
24
|
|
|
20
25
|
# Skip building native extensions for the following gems (and keep their Ruby source)
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
# - date
|
|
24
|
-
#
|
|
26
|
+
ignore_gem_extensions:
|
|
27
|
+
- websocket-driver
|
|
@@ -7,12 +7,20 @@ require "ruby_wasm/cli"
|
|
|
7
7
|
|
|
8
8
|
# Patch ruby.wasm CLI to use the latest patch versions of Ruby
|
|
9
9
|
RubyWasm::CLI.singleton_class.prepend(Module.new do
|
|
10
|
-
def build_source_aliases(root)
|
|
10
|
+
def build_source_aliases(root) # for ruby_wasm 2.8.x and earlier
|
|
11
11
|
super.tap do |sources|
|
|
12
12
|
sources["3.3"][:url] = "https://cache.ruby-lang.org/pub/ruby/3.3/ruby-3.3.8.tar.gz"
|
|
13
13
|
sources["3.4"][:url] = "https://cache.ruby-lang.org/pub/ruby/3.4/ruby-3.4.3.tar.gz"
|
|
14
14
|
end
|
|
15
15
|
end
|
|
16
|
+
|
|
17
|
+
def build_config_aliases(root) # for ruby_wasm 2.9.0+
|
|
18
|
+
super.tap do |sources|
|
|
19
|
+
sources["3.3"][:src][:url] = "https://cache.ruby-lang.org/pub/ruby/3.3/ruby-3.3.11.tar.gz"
|
|
20
|
+
sources["3.4"][:src][:url] = "https://cache.ruby-lang.org/pub/ruby/3.4/ruby-3.4.8.tar.gz"
|
|
21
|
+
sources["4.0"][:src][:url] = "https://cache.ruby-lang.org/pub/ruby/4.0/ruby-4.0.2.tar.gz"
|
|
22
|
+
end
|
|
23
|
+
end
|
|
16
24
|
end)
|
|
17
25
|
|
|
18
26
|
module Wasmify
|
|
@@ -78,6 +86,15 @@ module Wasmify
|
|
|
78
86
|
end
|
|
79
87
|
end
|
|
80
88
|
|
|
89
|
+
# Version-specific patches
|
|
90
|
+
version_patches_dir = File.join(__dir__, "ruby_wasm_patches", Wasmify::Rails.config.short_ruby_version)
|
|
91
|
+
|
|
92
|
+
if File.directory?(version_patches_dir)
|
|
93
|
+
Dir.children(version_patches_dir).each do |patch|
|
|
94
|
+
args << "--patch=#{File.join(version_patches_dir, patch)}"
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
|
|
81
98
|
FileUtils.mkdir_p(output_dir)
|
|
82
99
|
RubyWasm::CLI.new(stdout: $stdout, stderr: $stderr).run(args)
|
|
83
100
|
end
|
data/lib/wasmify/rails/shim.rb
CHANGED
|
@@ -142,9 +142,9 @@ namespace :wasmify do
|
|
|
142
142
|
require "/rails/config/application"
|
|
143
143
|
puts "Initializing Rails application..."
|
|
144
144
|
Rails.application.initialize!
|
|
145
|
-
puts "Rails application initialized!\n\nLets try to make a request..."
|
|
145
|
+
puts "Rails application initialized!\n\nLets try to make a health check request..."
|
|
146
146
|
|
|
147
|
-
request = Rack::MockRequest.env_for("http://localhost:3000", {"HTTP_HOST" => "localhost"})
|
|
147
|
+
request = Rack::MockRequest.env_for("http://localhost:3000/up", {"HTTP_HOST" => "localhost"})
|
|
148
148
|
puts Rails.application.call(request)
|
|
149
149
|
RUBY
|
|
150
150
|
)
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: wasmify-rails
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.5.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Vladimir Dementyev
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-07-21 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: railties
|