js 2.5.2 → 2.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ab2a18bea019f59904c71b83f4ef3ff3b5f3401a4ac855da7922eeae08268f0b
4
- data.tar.gz: 6abf47657bcc65f0c4f7f50c476e2995d40b965b7ffd42fb92bc101d137b0f92
3
+ metadata.gz: 81f4c9b970a32b1074724040b7cf50b1eb5b92c997ecc85195f6d3cc294da8fb
4
+ data.tar.gz: 765a9b39f1a77485834a71f6f5cb420d01225a0a8057316a8ec6b622d58578b1
5
5
  SHA512:
6
- metadata.gz: d468bafd32f8c1015b4c112e22b94ebe4a23abc08d6c0449e437ee650494efec2f0ae15aa906260167d98f18b327f85504fd4a126bb09e51325739a4676e16e2
7
- data.tar.gz: d60702d46ca45c76e5249cc9a5889672804ddf21f0a833835339d25c8249b32c74544e9fed1f5a420be577888fd1af077b92ae58bb766e1be74039cddffb602e
6
+ metadata.gz: 73305608f6fcc88d01fa044ff2eda293165721e8317a93f811aca35bae0b755e2dd0db595487d5f297f4c58bdc9b7e8c61931a77e920323d585f2ee3446f21d6
7
+ data.tar.gz: bae658a9d87eb2bb1f233dd54c5351b93f2f937253d0c6476006ae184dc80ef6b91ff35488aec1c4e66d26f8fe81515b767b9520fcef316577e2e6a5d7ef24f2
data/ext/js/depend CHANGED
@@ -14,4 +14,5 @@ bindgen/legacy/%.o: $(srcdir)/bindgen/legacy/%.c
14
14
 
15
15
  bindgen/ext.o: $(srcdir)/bindgen/ext.c
16
16
  @mkdir -p "$(@D)"
17
- $(CC) -c -o $@ $<
17
+ $(ECHO) compiling $(<)
18
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$<
data/ext/js/extconf.rb CHANGED
@@ -1,4 +1,12 @@
1
1
  require "mkmf"
2
+
3
+ MakeMakefile::RbConfig ||= RbConfig
4
+ unless MakeMakefile::RbConfig::CONFIG["platform"] =~ /wasm/
5
+ $stderr.puts "This extension is only for WebAssembly. Creating a dummy Makefile."
6
+ create_makefile("js")
7
+ return
8
+ end
9
+
2
10
  $objs = %w[js-core.o witapi-core.o]
3
11
 
4
12
  use_component_model = enable_config("component-model", false)
@@ -11,7 +19,16 @@ else
11
19
  $objs << "bindgen/legacy/rb-js-abi-host.o"
12
20
  $objs << "bindgen/legacy/rb-abi-guest.o"
13
21
  end
22
+
23
+ component_type_obj = "$(srcdir)/bindgen/ext_component_type.o"
24
+
25
+ unless $static
26
+ # When building shared library, we need to link the component type object
27
+ # to the shared library instead of the main ruby executable.
28
+ $libs << component_type_obj
29
+ end
30
+
14
31
  create_makefile("js") do |mk|
15
- mk << "EXTRA_OBJS = $(srcdir)/bindgen/ext_component_type.o\n" if use_component_model
32
+ mk << "EXTRA_OBJS = #{component_type_obj}\n" if use_component_model
16
33
  mk
17
34
  end
data/ext/js/witapi-core.c CHANGED
@@ -363,10 +363,15 @@ static inline void __wasm_call_ctors_if_needed(void) {
363
363
  __wasm_call_ctors_done = true;
364
364
  __wasm_call_ctors();
365
365
 
366
+ // Initialize VFS runtime if it's used
367
+ // NOTE: We don't use wasi-vfs for PIC build. Instead, we use
368
+ // Component Model-native wasi-virt.
369
+ # ifndef __PIC__
366
370
  __attribute__((weak)) extern void __wasi_vfs_rt_init(void);
367
371
  if (__wasi_vfs_rt_init) {
368
372
  __wasi_vfs_rt_init();
369
373
  }
374
+ # endif
370
375
  }
371
376
  }
372
377
 
data/lib/js/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module JS
2
- VERSION = "2.5.2"
2
+ VERSION = "2.6.0"
3
3
  end
data/lib/js.rb CHANGED
@@ -173,7 +173,11 @@ class JS::Object
173
173
  if sym_str.end_with?("?")
174
174
  # When a JS method is called with a ? suffix, it is treated as a predicate method,
175
175
  # and the return value is converted to a Ruby boolean value automatically.
176
- self.call(sym_str[0..-2].to_sym, *args, &block) == JS::True
176
+ result = self.call(sym_str[0..-2].to_sym, *args, &block)
177
+
178
+ # Type coerce the result to boolean type
179
+ # to match the true/false determination in JavaScript's if statement.
180
+ JS.global.Boolean(result) == JS::True
177
181
  elsif self[sym].typeof == "function"
178
182
  self.call(sym, *args, &block)
179
183
  else
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: js
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.2
4
+ version: 2.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yuta Saito
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2024-05-04 00:00:00.000000000 Z
10
+ date: 2024-05-05 00:00:00.000000000 Z
11
11
  dependencies: []
12
12
  description: JavaScript bindings for ruby.wasm. This gem provides a way to use JavaScript
13
13
  functionalities from Ruby through WebAssembly.