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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b859c871ac4b531df1f3f12b7c8ca66a2b2b8b60fa9d237f3b74689c1c82e425
4
- data.tar.gz: 686abb224ce48236b480b02a3195b1c66ba458f48fc349754a9ee43a388e9a11
3
+ metadata.gz: 81052a8cdb9b45ed5173f1d9627ede9dd7116cc4a103d395ea877938a6cdeda2
4
+ data.tar.gz: a97fc6f32477822b7b97d80c466f9041ebf42442ba4f063313c0fa1d12da405f
5
5
  SHA512:
6
- metadata.gz: a02fa2dbd49b7de55b33dfbc51b2b267154310ec5f962757e67ccd0832dd24fb1621119959d94bedb8e80ba3e31a4784bcab7bf12ecb894ab8737c865d091ae4
7
- data.tar.gz: 74dc5979250f81b0d2d0485ea670df41f44c6bc8079a6aace56448b16046f61820ade9032bdf605026af40fa7d75998fe76e3b79c4fac7e8cc031cf86b44ab3a
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) 2024 Vladimir Dementyev
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 (also [this](https://github.com/kateinoigakukun/mastodon/tree/katei/wasmify))
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
- @res[:rows].to_a.each do |raw_row|
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
- @res[:fields].to_a.map { |col| col[:name].to_s }
41
+ res[:fields].to_a.map { |col| col[:name].to_s }
40
42
  end
41
43
 
42
44
  def ftype(index)
43
- @res[:fields][index][:dataTypeID]
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
- @res[:affectedRows].to_i
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
- @res[:rows].to_a.each do |raw_row|
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? = true
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
- append_to_file ".gitignore", <<~EOF
32
- # Ignore the compiled WebAssembly modules
33
- *.wasm
34
- # Ignore ruby.wasm build artefacts
35
- build/
36
- rubies/
37
- dist/
38
- EOF
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
- config.active_job.queue_adapter = :inline
23
- config.action_mailer.delivery_method = :null
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
- # ignore_gem_extensions:
22
- # - bigdecimal
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
@@ -13,6 +13,7 @@ end
13
13
  return unless on_wasm?
14
14
 
15
15
  # Setup Bundler
16
+ require "rubygems"
16
17
  require "/bundle/setup"
17
18
  require "bundler"
18
19
 
@@ -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
  )
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Wasmify
4
4
  module Rails # :nodoc:
5
- VERSION = "0.4.1"
5
+ VERSION = "0.5.0"
6
6
  end
7
7
  end
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.1
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-03-19 00:00:00.000000000 Z
11
+ date: 2026-07-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties