ruby_wasm 2.9.0 → 2.10.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.
data/Gemfile CHANGED
@@ -7,7 +7,7 @@ gemspec
7
7
  group :development do
8
8
  gem "rake"
9
9
  gem "rake-compiler"
10
- gem "rb_sys", "0.9.108"
10
+ gem "rb_sys", "0.9.124"
11
11
  gem "rdoc", "~> 7.0"
12
12
  end
13
13
 
data/README.md CHANGED
@@ -23,7 +23,7 @@ Create and save an `index.html` page with the following contents:
23
23
 
24
24
  ```html
25
25
  <html>
26
- <script src="https://cdn.jsdelivr.net/npm/@ruby/4.0-wasm-wasi@2.9.0/dist/browser.script.iife.js"></script>
26
+ <script src="https://cdn.jsdelivr.net/npm/@ruby/4.0-wasm-wasi@2.10.0/dist/browser.script.iife.js"></script>
27
27
  <script type="text/ruby">
28
28
  require "js"
29
29
 
data/docs/cheat_sheet.md CHANGED
@@ -26,10 +26,10 @@ const { vm } = await DefaultRubyVM(module);
26
26
  vm.eval(`puts "hello world"`);
27
27
  ```
28
28
 
29
- Then run the example code with `--experimental-wasi-unstable-preview1` flag to enable WASI support:
29
+ Then run the example code:
30
30
 
31
31
  ```console
32
- $ node --experimental-wasi-unstable-preview1 index.mjs
32
+ $ node index.mjs
33
33
  ```
34
34
 
35
35
  ## Browser
@@ -38,7 +38,7 @@ The easiest way to run Ruby on browser is to use `browser.script.iife.js` script
38
38
 
39
39
  ```html
40
40
  <html>
41
- <script src="https://cdn.jsdelivr.net/npm/@ruby/4.0-wasm-wasi@2.9.0/dist/browser.script.iife.js"></script>
41
+ <script src="https://cdn.jsdelivr.net/npm/@ruby/4.0-wasm-wasi@2.10.0/dist/browser.script.iife.js"></script>
42
42
  <script type="text/ruby">
43
43
  require "js"
44
44
  JS.global[:document].write "Hello, world!"
@@ -46,13 +46,24 @@ The easiest way to run Ruby on browser is to use `browser.script.iife.js` script
46
46
  </html>
47
47
  ```
48
48
 
49
+ Use `data-env` on the `browser.script.iife.js` script tag to pass environment variables when the Ruby VM starts:
50
+
51
+ ```html
52
+ <script
53
+ src="https://cdn.jsdelivr.net/npm/@ruby/4.0-wasm-wasi@2.9.3-2.9.4/dist/browser.script.iife.js"
54
+ data-env='{"RUBY_BOX":"1","RUBY_FIBER_MACHINE_STACK_SIZE":"1048576"}'
55
+ ></script>
56
+ ```
57
+
58
+ The `data-env` value must be a JSON object string whose values are strings.
59
+
49
60
  If you want to control Ruby VM from JavaScript, you can use `@ruby/wasm-wasi` package API:
50
61
 
51
62
  ```html
52
63
  <html>
53
64
  <script type="module">
54
- import { DefaultRubyVM } from "https://cdn.jsdelivr.net/npm/@ruby/wasm-wasi@2.9.0/dist/browser/+esm";
55
- const response = await fetch("https://cdn.jsdelivr.net/npm/@ruby/4.0-wasm-wasi@2.9.0/dist/ruby+stdlib.wasm");
65
+ import { DefaultRubyVM } from "https://cdn.jsdelivr.net/npm/@ruby/wasm-wasi@2.10.0/dist/browser/+esm";
66
+ const response = await fetch("https://cdn.jsdelivr.net/npm/@ruby/4.0-wasm-wasi@2.10.0/dist/ruby+stdlib.wasm");
56
67
  const module = await WebAssembly.compileStreaming(response);
57
68
  const { vm } = await DefaultRubyVM(module);
58
69
 
@@ -69,11 +80,11 @@ If you want to control Ruby VM from JavaScript, you can use `@ruby/wasm-wasi` pa
69
80
 
70
81
  ```html
71
82
  <html>
72
- <script src="https://cdn.jsdelivr.net/npm/@ruby/wasm-wasi@2.9.0/dist/browser.umd.js"></script>
83
+ <script src="https://cdn.jsdelivr.net/npm/@ruby/wasm-wasi@2.10.0/dist/browser.umd.js"></script>
73
84
  <script>
74
85
  const main = async () => {
75
86
  const { DefaultRubyVM } = window["ruby-wasm-wasi"];
76
- const response = await fetch("https://cdn.jsdelivr.net/npm/@ruby/4.0-wasm-wasi@2.9.0/dist/ruby+stdlib.wasm");
87
+ const response = await fetch("https://cdn.jsdelivr.net/npm/@ruby/4.0-wasm-wasi@2.10.0/dist/ruby+stdlib.wasm");
77
88
  const module = await WebAssembly.compileStreaming(response);
78
89
  const { vm } = await DefaultRubyVM(module);
79
90
 
@@ -128,7 +139,7 @@ end
128
139
 
129
140
  ```html
130
141
  <html>
131
- <script src="https://cdn.jsdelivr.net/npm/@ruby/4.0-wasm-wasi@2.9.0/dist/browser.script.iife.js"></script>
142
+ <script src="https://cdn.jsdelivr.net/npm/@ruby/4.0-wasm-wasi@2.10.0/dist/browser.script.iife.js"></script>
132
143
  <script type="text/ruby" data-eval="async">
133
144
  require "js"
134
145
 
@@ -143,8 +154,8 @@ Or using `@ruby/wasm-wasi` package API `RubyVM#evalAsync`:
143
154
  ```html
144
155
  <html>
145
156
  <script type="module">
146
- import { DefaultRubyVM } from "https://cdn.jsdelivr.net/npm/@ruby/wasm-wasi@2.9.0/dist/browser/+esm";
147
- const response = await fetch("https://cdn.jsdelivr.net/npm/@ruby/4.0-wasm-wasi@2.9.0/dist/ruby+stdlib.wasm");
157
+ import { DefaultRubyVM } from "https://cdn.jsdelivr.net/npm/@ruby/wasm-wasi@2.10.0/dist/browser/+esm";
158
+ const response = await fetch("https://cdn.jsdelivr.net/npm/@ruby/4.0-wasm-wasi@2.10.0/dist/ruby+stdlib.wasm");
148
159
  const module = await WebAssembly.compileStreaming(response);
149
160
  const { vm } = await DefaultRubyVM(module);
150
161
 
@@ -12,9 +12,8 @@ crate-type = ["cdylib"]
12
12
  [dependencies]
13
13
  magnus = { version = "0.8", features = ["bytes"] }
14
14
  bytes = "1"
15
- wizer = "6.0.0"
16
- wasi-vfs-cli = { git = "https://github.com/kateinoigakukun/wasi-vfs/", tag = "v0.5.3-p1" }
17
15
  structopt = "0.3.26"
18
16
  wit-component = "0.216.0"
19
17
  wasm-compose = "0.219.1"
20
18
  wasi-virt = { git = "https://github.com/bytecodealliance/wasi-virt", rev = "dadd131d8cf8ed1ed4265e96350f5f166e27a339", default-features = false }
19
+ wasi-vfs-cli = { git = "https://github.com/kateinoigakukun/wasi-vfs/", tag = "v0.6.2" }
@@ -1,37 +1,19 @@
1
1
  use std::{collections::HashMap, env, path::PathBuf, time::SystemTime};
2
2
 
3
3
  use magnus::{
4
- eval, function, method,
4
+ function, method,
5
5
  prelude::*,
6
6
  value::{self, InnerValue},
7
- wrap, Error, ExceptionClass, RModule, Ruby,
7
+ wrap, Error, RModule, Ruby,
8
8
  };
9
9
  use structopt::StructOpt;
10
- use wizer::Wizer;
11
10
  use wasi_virt;
12
11
 
13
12
  static RUBY_WASM: value::Lazy<RModule> =
14
13
  value::Lazy::new(|ruby| ruby.define_module("RubyWasmExt").unwrap());
15
14
 
16
- fn preinit(core_module: bytes::Bytes) -> Result<bytes::Bytes, Error> {
17
- let rbwasm_error = eval("RubyWasmExt::Error")?;
18
- let rbwasm_error = ExceptionClass::from_value(rbwasm_error).unwrap();
19
- let mut wizer = Wizer::new();
20
- wizer
21
- .wasm_bulk_memory(true)
22
- .inherit_stdio(true)
23
- .inherit_env(true)
24
- .allow_wasi(true)
25
- .map_err(|e| Error::new(rbwasm_error, format!("failed to create wizer: {}", e)))?;
26
-
27
- wizer
28
- .run(&core_module)
29
- .map_err(|e| Error::new(rbwasm_error, format!("failed to run wizer: {}", e)))
30
- .map(|output| output.into())
31
- }
32
-
33
15
  struct WasiVfsInner {
34
- map_dirs: Vec<(PathBuf, PathBuf)>,
16
+ map_dirs: Vec<(String, PathBuf)>,
35
17
  }
36
18
 
37
19
  #[wrap(class = "RubyWasmExt::WasiVfs")]
@@ -284,8 +266,6 @@ fn init(ruby: &Ruby) -> Result<(), Error> {
284
266
  let module = RUBY_WASM.get_inner_with(ruby);
285
267
  module.define_error("Error", ruby.exception_standard_error())?;
286
268
 
287
- module.define_singleton_method("preinitialize", function!(preinit, 1))?;
288
-
289
269
  let wasi_vfs = module.define_class("WasiVfs", ruby.class_object())?;
290
270
  wasi_vfs.define_singleton_method("new", function!(WasiVfs::new, 0))?;
291
271
  wasi_vfs.define_singleton_method("run_cli", function!(WasiVfs::run_cli, 1))?;
@@ -2,7 +2,7 @@ require_relative "./product"
2
2
 
3
3
  module RubyWasm
4
4
  class WasiVfsProduct < BuildProduct
5
- WASI_VFS_VERSION = "0.5.0"
5
+ WASI_VFS_VERSION = "0.6.2"
6
6
 
7
7
  def initialize(build_dir)
8
8
  @build_dir = build_dir
data/lib/ruby_wasm/cli.rb CHANGED
@@ -45,7 +45,6 @@ module RubyWasm
45
45
  # @type var options: cli_options
46
46
  options = {
47
47
  save_temps: false,
48
- optimize: false,
49
48
  remake: false,
50
49
  reconfigure: false,
51
50
  clean: false,
@@ -84,10 +83,6 @@ module RubyWasm
84
83
  "Build profile. full or minimal"
85
84
  ) { |profile| options[:profile] = profile }
86
85
 
87
- opts.on("--optimize", "Optimize the output") do
88
- options[:optimize] = true
89
- end
90
-
91
86
  opts.on("--remake", "Re-execute make for Ruby") do
92
87
  options[:remake] = true
93
88
  end
@@ -220,11 +215,13 @@ module RubyWasm
220
215
  {
221
216
  name: "local",
222
217
  src: {
218
+ name: "local",
223
219
  type: "local",
224
220
  path: src_name,
225
221
  patches: patches
226
222
  },
227
- all_default_exts: RubyWasm::Packager::ALL_DEFAULT_EXTS
223
+ all_default_exts: RubyWasm::Packager::ALL_DEFAULT_EXTS,
224
+ wasi_sdk_version: aliases.fetch("head").fetch(:wasi_sdk_version)
228
225
  }
229
226
  )
230
227
  end
@@ -68,7 +68,6 @@ class RubyWasm::Packager
68
68
  wasm_bytes = wasi_virt.compose(wasm_bytes)
69
69
  end
70
70
 
71
- wasm_bytes = RubyWasmExt.preinitialize(wasm_bytes) if options[:optimize]
72
71
  wasm_bytes
73
72
  end
74
73
 
@@ -1,3 +1,3 @@
1
1
  module RubyWasm
2
- VERSION = "2.9.0"
2
+ VERSION = "2.10.0"
3
3
  end
data/package-lock.json CHANGED
@@ -3586,7 +3586,7 @@
3586
3586
  },
3587
3587
  "packages/npm-packages/ruby-3.2-wasm-wasi": {
3588
3588
  "name": "@ruby/3.2-wasm-wasi",
3589
- "version": "2.9.0",
3589
+ "version": "2.10.0",
3590
3590
  "license": "MIT",
3591
3591
  "dependencies": {
3592
3592
  "@ruby/wasm-wasi": "^2.0.0"
@@ -3594,7 +3594,7 @@
3594
3594
  },
3595
3595
  "packages/npm-packages/ruby-3.3-wasm-wasi": {
3596
3596
  "name": "@ruby/3.3-wasm-wasi",
3597
- "version": "2.9.0",
3597
+ "version": "2.10.0",
3598
3598
  "license": "MIT",
3599
3599
  "dependencies": {
3600
3600
  "@ruby/wasm-wasi": "^2.0.0"
@@ -3602,7 +3602,7 @@
3602
3602
  },
3603
3603
  "packages/npm-packages/ruby-3.4-wasm-wasi": {
3604
3604
  "name": "@ruby/3.4-wasm-wasi",
3605
- "version": "2.9.0",
3605
+ "version": "2.10.0",
3606
3606
  "license": "MIT",
3607
3607
  "dependencies": {
3608
3608
  "@ruby/wasm-wasi": "^2.0.0"
@@ -3610,7 +3610,7 @@
3610
3610
  },
3611
3611
  "packages/npm-packages/ruby-4.0-wasm-wasi": {
3612
3612
  "name": "@ruby/4.0-wasm-wasi",
3613
- "version": "2.9.0",
3613
+ "version": "2.10.0",
3614
3614
  "license": "MIT",
3615
3615
  "dependencies": {
3616
3616
  "@ruby/wasm-wasi": "^2.0.0"
@@ -3618,12 +3618,12 @@
3618
3618
  },
3619
3619
  "packages/npm-packages/ruby-head-wasm-emscripten": {
3620
3620
  "name": "@ruby/head-wasm-emscripten",
3621
- "version": "2.9.0",
3621
+ "version": "2.10.0",
3622
3622
  "license": "MIT"
3623
3623
  },
3624
3624
  "packages/npm-packages/ruby-head-wasm-wasi": {
3625
3625
  "name": "@ruby/head-wasm-wasi",
3626
- "version": "2.9.0",
3626
+ "version": "2.10.0",
3627
3627
  "license": "MIT",
3628
3628
  "dependencies": {
3629
3629
  "@ruby/wasm-wasi": "^2.0.0"
@@ -3631,7 +3631,7 @@
3631
3631
  },
3632
3632
  "packages/npm-packages/ruby-head-wasm-wasip2": {
3633
3633
  "name": "@ruby/head-wasm-wasip2",
3634
- "version": "2.9.0",
3634
+ "version": "2.10.0",
3635
3635
  "license": "MIT",
3636
3636
  "dependencies": {
3637
3637
  "@bytecodealliance/preview2-shim": "^0.17.2",
@@ -3648,7 +3648,7 @@
3648
3648
  },
3649
3649
  "packages/npm-packages/ruby-wasm-wasi": {
3650
3650
  "name": "@ruby/wasm-wasi",
3651
- "version": "2.9.0",
3651
+ "version": "2.10.0",
3652
3652
  "license": "MIT",
3653
3653
  "dependencies": {
3654
3654
  "@bjorn3/browser_wasi_shim": "^0.4.2",
@@ -62,6 +62,9 @@ def build_ruby(pkg, base_dir, pkg_dir, binaryen, clean: false)
62
62
  # Share ./build and ./rubies in the same workspace
63
63
  "RUBY_WASM_ROOT" => base_dir
64
64
  }
65
+ # We vendor a freshly built js gem in package workspaces. Bundler checksum
66
+ # validation against rubygems.org can fail for the same version.
67
+ env["BUNDLE_DISABLE_CHECKSUM_VALIDATION"] = "true" if pkg[:gemfile]
65
68
  cwd = base_dir
66
69
  if gemfile_path = pkg[:gemfile]
67
70
  cwd = File.dirname(gemfile_path)
@@ -94,8 +97,10 @@ def build_ruby(pkg, base_dir, pkg_dir, binaryen, clean: false)
94
97
  Dir.chdir(cwd) do
95
98
  # uninstall js gem to re-install just-built js gem
96
99
  sh "gem", "uninstall", "js", "-v", js_gem_version, "--force"
97
- # install gems including js gem
98
- sh "bundle", "install"
100
+ # install gems including js gem. Bundler may compare checksums with
101
+ # rubygems.org for the same version and reject our just-built local gem.
102
+ # Disable checksum validation only for this install command.
103
+ sh({ "BUNDLE_DISABLE_CHECKSUM_VALIDATION" => "true" }, "bundle", "install")
99
104
 
100
105
  sh env,
101
106
  "bundle", "exec",
@@ -5,7 +5,6 @@ module RubyWasm
5
5
  save_temps: bool,
6
6
  output: String,
7
7
 
8
- optimize: bool,
9
8
  remake: bool,
10
9
  reconfigure: bool,
11
10
  clean: bool,
@@ -1,8 +1,6 @@
1
1
  module RubyWasmExt
2
2
  type bytes = String
3
3
 
4
- def self.preinitialize: (bytes module_bytes) -> bytes
5
-
6
4
  class WasiVfs
7
5
  def initialize: () -> void
8
6
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_wasm
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.9.0
4
+ version: 2.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yuta Saito
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2026-03-29 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: logger
@@ -118,7 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
118
118
  - !ruby/object:Gem::Version
119
119
  version: '0'
120
120
  requirements: []
121
- rubygems_version: 3.6.2
121
+ rubygems_version: 3.6.9
122
122
  specification_version: 4
123
123
  summary: Ruby to WebAssembly toolkit
124
124
  test_files: []