Skip to content

v0.14.0

Latest

Choose a tag to compare

@hmsk hmsk released this 09 Apr 02:17
bc3d7d7

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.