Skip to content

Releases: hmsk/quickjs.rb

v0.14.0

09 Apr 02:17
bc3d7d7

Choose a tag to compare

New features

POLYFILL_URL

New opt-in feature flag that polyfills https://developer.mozilla.org/en-US/docs/Web/API/URL and https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams:

vm = Quickjs::VM.new(features: [::Quickjs::POLYFILL_URL])
vm.eval_code('new URL("https://example.com/path?q=1").searchParams.get("q")') #=> "1"

POLYFILL_CRYPTO

New opt-in feature flag that polyfills the https://developer.mozilla.org/en-US/docs/Web/API/Web_Crypto_API:

vm = Quickjs::VM.new(features: [::Quickjs::POLYFILL_CRYPTO])
vm.eval_code('crypto.randomUUID()')
vm.eval_code('await crypto.subtle.digest("SHA-256", new TextEncoder().encode("hello"))')

Supports crypto.getRandomValues, crypto.randomUUID, and crypto.subtle (digest, generateKey, importKey, exportKey, sign, verify, deriveKey, deriveBits).

VM#call

Call a JavaScript function by name with Ruby arguments:

vm = Quickjs::VM.new
vm.eval_code('function add(a, b) { return a + b }')
vm.call('add', 1, 2) #=> 3

Breaking changes

Remove deprecated VM#logs

VM#logs announced as deprecated in v0.13.0 has been removed. Use VM#on_log instead.

Maintenance

Update Intl polyfill packages

All @formatjs packages updated to their latest versions.

v0.13.0

06 Apr 20:27
7cba274

Choose a tag to compare

VM#on_log

Instead of collecting logs after the fact via VM#logs, you can now register a block that fires for every console.log/info/debug/warn/error call as it happens.

vm = Quickjs::VM.new
vm.on_log { |log| puts "#{log.severity}: #{log.to_s}" }

vm.eval_code('console.warn("watch out")')
# => prints: warning: watch out

Each log object exposes .severity (:info / :verbose / :warning / :error), .to_s (space-joined args), and .raw (array of Ruby values).

⚠️ VM#logs is now deprecated in favor of this API (will be omitted in v0.14.0).

POLYFILL_ENCODING

New opt-in feature flag that polyfills WHATWG Encoding (TextEncoder and TextDecoderr)

vm = Quickjs::VM.new(features: [::Quickjs::POLYFILL_ENCODING])
vm.eval_code('new TextEncoder().encode("hello")')

More for POLYFILL_FILE

Ruby interop for Blob and File

vm = Quickjs::VM.new(features: [::Quickjs::POLYFILL_FILE])

Ruby ::File objects returned from define_function blocks are surfaced as File-compatible JS proxies, supporting .name, .size, .text(), .arrayBuffer(), and .slice(). Passing such a proxy back to Ruby from JS returns the original ::File object. JS Blob / File values returned to Ruby are converted to Quickjs::Blob / Quickjs::File structs.

vm.define_function(:get_file) { File.open('report.pdf') }

vm.eval_code("get_file().name")         #=> "report.pdf"
vm.eval_code("await get_file().text()") #=> file content as String

RBS type definitions

Type signatures for the public API are now shipped with the gem and validated in CI.

v0.12.0

14 Feb 22:42
8316307

Choose a tag to compare

  • Support File API
    • The features: [::Quickjs::POLYFILL_FILE] option enables Blob and File in the QuickJS environment.

v0.11.2

10 Feb 02:19
ac56483

Choose a tag to compare

  • Stability improvements, especially for Ruby 4.0
  • More precise timeout calculation

v0.11.1

30 Jan 08:45
1880938

Choose a tag to compare

  • Deprecate Ruby 3.1, Introduce Ruby 4.0
  • Fix NPE when giving an unintentional argument to QuickJs#eval_code

v0.11.0

23 Sep 14:47
23c0775

Choose a tag to compare

Update QuickJS core to version 2025-09-13.
https://bellard.org/quickjs/Changelog

v0.10.0

03 Jun 05:57
edff0e3

Choose a tag to compare

Update QuickJS core to version 2025-04-26.
https://bellard.org/quickjs/Changelog

The highlights of this gem update are:

  • Fixes for CVEs
  • Adds column numbers in stack traces