wasmify-rails 0.4.2 → 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: 49d32bee847e419e89afba2b7b2beafa25140d79490e0e57089f83f27a9c4b97
4
- data.tar.gz: b2bd1ce485952cccfc62a5f53ddecfb67b467afa4fa387a4a23b1f134e9d64f8
3
+ metadata.gz: 81052a8cdb9b45ed5173f1d9627ede9dd7116cc4a103d395ea877938a6cdeda2
4
+ data.tar.gz: a97fc6f32477822b7b97d80c466f9041ebf42442ba4f063313c0fa1d12da405f
5
5
  SHA512:
6
- metadata.gz: 711f3f3ee7ad3e45ee08ad7deff8081677bd2922409e786f69753cfa4ece084e5a8f9c3007990fa75bc6a8b501c1ad5b8d5b7e76381ca545732f8cc5dfc13329
7
- data.tar.gz: 15201d401397e80ebf5dc63df7b909cf24fee6ab6224ccba93e695bd11dce2ab7b99757085a0682086d7df026eda7b5071ffa52fd575cca86f1a6c3316d74b31
6
+ metadata.gz: 652f418e35f1cceec8aeb8076767063b507167426ecdbfd23b647e5485a46ef14fcbe12461dd5964adf8ff9a396ca438cd8316881fa35e77cbacea59b56ebecf
7
+ data.tar.gz: e3c19b352a4b2e4c1832f5893364127bc6df83c231c374f7da24e481139301778fbdb2759b831f29d915c35b09fb4c36504e028e543ca5b30622f00da2701057
data/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
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
+
5
11
  ## 0.4.2
6
12
 
7
13
  - Minor fixes.
data/README.md CHANGED
@@ -188,31 +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
- ### `3.4 fails on gem deprecations`
194
- Ruby 3.3.3 is a suggested starting point for getting to hello world, as 3.4 currently fails on upstream gem deprecation warnings, per [here](https://github.com/ruby/prism/issues/4065) and [here](https://github.com/palkan/wasmify-rails/pull/12#issuecomment-4274321590)
195
-
196
-
197
- ### `can't load bigdecimal.so`
198
-
199
- 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:
200
-
201
- - Add `bigdecimal` to the `ignore_gem_extensions` list in the `wasmify.yml` file.
202
- - Add the following line to your `config/application.rb` file (before loading Wasm shims):
203
-
204
- ```ruby
205
- $LOADED_FEATURES << $LOAD_PATH.resolve_feature_path("bigdecimal")[1]
206
- ```
207
-
208
- We do not include this patch by default hoping that we can have a proper fix in the future.
209
-
210
191
  ## Roadmap
211
192
 
212
- - PGLite support (see [this example](https://github.com/kateinoigakukun/mastodon/blob/fff2e4a626a20a616c546ddf4f91766abaf1133a/pwa/dist/pglite.rb#L1))
213
193
  - Active Storage OPFS service
214
194
  - Background jobs support
215
- - 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))
216
196
 
217
197
  ## Contributing
218
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,7 +19,10 @@ Rails.application.configure do
19
19
  end
20
20
 
21
21
  config.cache_store = :memory_store
22
- config.active_job.queue_adapter = :inline
22
+
23
+ if config.respond_to?(:active_job)
24
+ config.active_job.queue_adapter = :inline
25
+ end
23
26
 
24
27
  if config.respond_to?(:action_mailer)
25
28
  config.action_mailer.delivery_method = :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
@@ -86,6 +86,15 @@ module Wasmify
86
86
  end
87
87
  end
88
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
+
89
98
  FileUtils.mkdir_p(output_dir)
90
99
  RubyWasm::CLI.new(stdout: $stdout, stderr: $stderr).run(args)
91
100
  end
@@ -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.2"
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.2
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-07-16 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